X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpart_pkg%2Fprorate.pm;h=09561cf51f9046950592965e9ff08d509e4485c0;hb=e6820a61a43c840ef08a11bdda41507dac2a9ff7;hp=45bbf01533ec23f08f256c612679911014e04a8d;hpb=5e05724a635a22776f1b973f5d7e77989da4e048;p=freeside.git diff --git a/FS/FS/part_pkg/prorate.pm b/FS/FS/part_pkg/prorate.pm index 45bbf0153..09561cf51 100644 --- a/FS/FS/part_pkg/prorate.pm +++ b/FS/FS/part_pkg/prorate.pm @@ -10,6 +10,7 @@ use FS::part_pkg::flat; %info = ( 'name' => 'First partial month pro-rated, then flat-rate (selectable billing day)', + 'shortname' => 'Prorate (Nth of month billing)', 'fields' => { 'setup_fee' => { 'name' => 'Setup fee for this package', 'default' => 0, @@ -85,7 +86,7 @@ use FS::part_pkg::flat; }, }, 'fieldorder' => [ 'setup_fee', 'recur_fee', 'unused_credit', 'cutoff_day', - 'seconds', 'upbyte', 'downbytes', 'totalbytes', + 'seconds', 'upbytes', 'downbytes', 'totalbytes', 'recharge_amount', 'recharge_seconds', 'recharge_upbytes', 'recharge_downbytes', 'recharge_totalbytes', 'usage_rollover', 'recharge_reset', 'externalid', ], @@ -94,7 +95,7 @@ use FS::part_pkg::flat; ); sub calc_recur { - my($self, $cust_pkg, $sdate ) = @_; + my($self, $cust_pkg, $sdate, $details, $param ) = @_; my $cutoff_day = $self->option('cutoff_day', 1) || 1; my $mnow = $$sdate; my ($sec,$min,$hour,$mday,$mon,$year) = (localtime($mnow) )[0,1,2,3,4,5]; @@ -116,7 +117,12 @@ sub calc_recur { $$sdate = $mstart; my $permonth = $self->option('recur_fee') / $self->freq; - $permonth * ( ( $self->freq - 1 ) + ($mend-$mnow) / ($mend-$mstart) ); + my $months = ( ( $self->freq - 1 ) + ($mend-$mnow) / ($mend-$mstart) ); + + $param->{'months'} = $months; + my $discount = $self->calc_discount( $cust_pkg, $sdate, $details, $param); + + sprintf('%.2f', $permonth * $months - $discount); } 1;