X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpart_pkg%2Frecur_Common.pm;h=4ed83a46b21caae3f7c29fb0d919be28b97f8d43;hb=29d80a8582103ead0b5910391cabc45cb85fa836;hp=7233cc67feba810c9201ee0e69088b66a0851b81;hpb=0aa75d8f76fd378816c1761307c39a68dd689974;p=freeside.git diff --git a/FS/FS/part_pkg/recur_Common.pm b/FS/FS/part_pkg/recur_Common.pm index 7233cc67f..4ed83a46b 100644 --- a/FS/FS/part_pkg/recur_Common.pm +++ b/FS/FS/part_pkg/recur_Common.pm @@ -34,18 +34,20 @@ sub calc_setup { delete $param->{'setup_charge'}; } - sprintf('%.2f', $charge - $discount); + sprintf('%.2f', ($cust_pkg->quantity || 1) * ($charge - $discount) ); } sub cutoff_day { # prorate/subscription only; we don't support sync_bill_date here - my $self = shift; - my $cust_pkg = shift; + my( $self, $cust_pkg ) = @_; my $recur_method = $self->option('recur_method',1) || 'anniversary'; - if ( $recur_method eq 'prorate' or $recur_method eq 'subscription' ) { - return $self->option('cutoff_day',1) || 1; - } else { - return 0; + my $cust_main = $cust_pkg->cust_main; + + if ( $cust_main->force_prorate_day and $cust_main->prorate_day ) { + return ( $cust_main->prorate_day ); + } elsif ($recur_method eq 'prorate' || $recur_method eq 'subscription') { + + return split(/\s*,\s*/, $self->option('cutoff_day', 1) || '1'); } } @@ -58,26 +60,26 @@ sub calc_recur_Common { if ( $param->{'increment_next_bill'} ) { my $recur_method = $self->option('recur_method', 1) || 'anniversary'; - my $cutoff_day = $self->cutoff_day($cust_pkg); + my @cutoff_day = $self->cutoff_day($cust_pkg); - $charges = $self->base_recur($cust_pkg); + $charges = $self->base_recur($cust_pkg, $sdate, $details, $param); $charges += $param->{'override_charges'} if $param->{'override_charges'}; if ( $recur_method eq 'prorate' ) { - $charges = $self->calc_prorate(@_, $cutoff_day); + $charges = $self->calc_prorate(@_, @cutoff_day); $charges += $param->{'override_charges'} if $param->{'override_charges'}; } elsif ( $recur_method eq 'subscription' ) { my ($day, $mon, $year) = ( localtime($$sdate) )[ 3..5 ]; - if ( $day < $cutoff_day ) { + if ( $day < $cutoff_day[0] ) { if ( $mon == 0 ) { $mon=11; $year--; } else { $mon--; } } - $$sdate = timelocal(0, 0, 0, $cutoff_day, $mon, $year); + $$sdate = timelocal(0, 0, 0, $cutoff_day[0], $mon, $year); }#$recur_method