X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpart_pkg%2Fbulk.pm;h=beee06913a95ade3a1ec824e10d6613ffcd6d5de;hb=db4098505d7936ff06df667e72626a4e04eba6d5;hp=a346b90967ce0da9917d8e0e58e1696deabc6fc9;hpb=0a51b87d75f8c93de863f729ef1ca568ca227e32;p=freeside.git diff --git a/FS/FS/part_pkg/bulk.pm b/FS/FS/part_pkg/bulk.pm index a346b9096..beee06913 100644 --- a/FS/FS/part_pkg/bulk.pm +++ b/FS/FS/part_pkg/bulk.pm @@ -7,35 +7,30 @@ use FS::part_pkg::flat; @ISA = qw(FS::part_pkg::flat); -$DEBUG = 1; +$DEBUG = 0; $me = '[FS::part_pkg::bulk]'; %info = ( 'name' => 'Bulk billing based on number of active services', + 'inherit_fields' => [ 'global_Mixin' ], 'fields' => { - 'setup_fee' => { 'name' => 'Setup fee for the entire bulk package', - 'default' => 0, - }, - 'recur_fee' => { 'name' => 'Recurring fee for the entire bulk package', - 'default' => 0, - }, 'svc_setup_fee' => { 'name' => 'Setup fee for each new service', 'default' => 0, }, 'svc_recur_fee' => { 'name' => 'Recurring fee for each service', 'default' => 0, }, - 'unused_credit' => { 'name' => 'Credit the customer for the unused portion'. - ' of service at cancellation', - 'type' => 'checkbox', - }, 'summarize_svcs'=> { 'name' => 'Show a count of services on the invoice, '. 'instead of a detailed list', 'type' => 'checkbox', }, + 'no_prorate' => { 'name' => 'Don\'t prorate recurring fees on services '. + 'active for a partial month', + 'type' => 'checkbox', + }, }, - 'fieldorder' => [ 'setup_fee', 'recur_fee', 'svc_setup_fee', 'svc_recur_fee', - 'unused_credit', 'summarize_svcs' ], + 'fieldorder' => [ 'svc_setup_fee', 'svc_recur_fee', + 'summarize_svcs', 'no_prorate' ], 'weight' => 50, ); @@ -50,7 +45,7 @@ sub calc_recur { my $last_bill = $cust_pkg->last_bill; - return sprintf("%.2f", $self->base_recur($cust_pkg) ) + return sprintf("%.2f", $self->base_recur($cust_pkg, $sdate) ) unless $$sdate > $last_bill; my $total_svc_charge = 0; @@ -86,9 +81,15 @@ sub calc_recur { my $svc_end = $h_cust_svc->date_deleted; $svc_end = ( !$svc_end || $svc_end > $$sdate ) ? $$sdate : $svc_end; - my $recur_charge = - $self->option('svc_recur_fee') * ( $svc_end - $svc_start ) + my $recur_charge; + if ( $self->option('no_prorate',1) ) { + $recur_charge = $self->option('svc_recur_fee'); + } + else { + $recur_charge = $self->option('svc_recur_fee') + * ( $svc_end - $svc_start ) / ( $$sdate - $last_bill ); + } $svc_details .= $money_char. sprintf('%.2f', $recur_charge ). ' ('. time2str('%x', $svc_start). @@ -112,7 +113,7 @@ sub calc_recur { } } - sprintf('%.2f', $self->base_recur($cust_pkg) + $total_svc_charge ); + sprintf('%.2f', $self->base_recur($cust_pkg, $sdate) + $total_svc_charge ); } sub can_discount { 0; }