X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=FS%2FFS%2Fpart_pkg%2Frecur_Common.pm;h=7233cc67feba810c9201ee0e69088b66a0851b81;hb=226617fbfba28e74fb8175f6ce77a09302809128;hp=48e9307c41fbb3de23b6d585c6a9218015f31a64;hpb=5fdd19665fb7c0ad425a99d3dbf9ad7e27fbf44a;p=freeside.git diff --git a/FS/FS/part_pkg/recur_Common.pm b/FS/FS/part_pkg/recur_Common.pm index 48e9307c4..7233cc67f 100644 --- a/FS/FS/part_pkg/recur_Common.pm +++ b/FS/FS/part_pkg/recur_Common.pm @@ -1,7 +1,7 @@ package FS::part_pkg::recur_Common; +use base qw( FS::part_pkg::flat ); use strict; -use base qw( FS::part_pkg::flat ); use vars qw( %info %recur_method ); use Tie::IxHash; use Time::Local; @@ -22,8 +22,19 @@ sub base_recur { sub calc_setup { # moved from all descendant packages which just had $self->option('setup_fee') my($self, $cust_pkg, $sdate, $details, $param) = @_; + return 0 if $self->prorate_setup($cust_pkg, $sdate); - $self->option('setup_fee'); + + my $charge = $self->option('setup_fee'); + + my $discount = 0; + if ( $charge > 0 ) { + $param->{'setup_charge'} = $charge; + $discount = $self->calc_discount($cust_pkg, $sdate, $details, $param); + delete $param->{'setup_charge'}; + } + + sprintf('%.2f', $charge - $discount); } sub cutoff_day { @@ -49,7 +60,7 @@ sub calc_recur_Common { my $recur_method = $self->option('recur_method', 1) || 'anniversary'; my $cutoff_day = $self->cutoff_day($cust_pkg); - $charges = $self->base_recur; + $charges = $self->base_recur($cust_pkg); $charges += $param->{'override_charges'} if $param->{'override_charges'}; if ( $recur_method eq 'prorate' ) {