From: mark Date: Mon, 9 May 2011 20:31:10 +0000 (+0000) Subject: bill recurring packages up to current date, #12569 X-Git-Tag: freeside_2_3_0~279 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=27cfd639aa367ad8d878c71a9516bd913099d528 bill recurring packages up to current date, #12569 --- diff --git a/FS/FS/cust_main/Billing.pm b/FS/FS/cust_main/Billing.pm index 4c8d40f27..f6a608053 100644 --- a/FS/FS/cust_main/Billing.pm +++ b/FS/FS/cust_main/Billing.pm @@ -416,18 +416,27 @@ sub bill { my $pass = ($cust_pkg->no_auto || $part_pkg->no_auto) ? 'no_auto' : ''; - my $error = - $self->_make_lines( 'part_pkg' => $part_pkg, - 'cust_pkg' => $cust_pkg, - 'precommit_hooks' => \@precommit_hooks, - 'line_items' => $cust_bill_pkg{$pass}, - 'setup' => $total_setup{$pass}, - 'recur' => $total_recur{$pass}, - 'tax_matrix' => $taxlisthash{$pass}, - 'time' => $time, - 'real_pkgpart' => $real_pkgpart, - 'options' => \%options, - ); + my $next_bill = $cust_pkg->getfield('bill') || 0; + my $error; + while ( $next_bill <= $time ) { + $error = + $self->_make_lines( 'part_pkg' => $part_pkg, + 'cust_pkg' => $cust_pkg, + 'precommit_hooks' => \@precommit_hooks, + 'line_items' => $cust_bill_pkg{$pass}, + 'setup' => $total_setup{$pass}, + 'recur' => $total_recur{$pass}, + 'tax_matrix' => $taxlisthash{$pass}, + 'time' => $time, + 'real_pkgpart' => $real_pkgpart, + 'options' => \%options, + ); + # Stop if anything goes wrong, or if we're not incrementing + # the bill date. + last if $error; + last if ($cust_pkg->getfield('bill') || 0) == $next_bill; + $next_bill = $cust_pkg->getfield('bill') || 0; + } if ($error) { $dbh->rollback if $oldAutoCommit && !$options{no_commit}; return $error; diff --git a/FS/FS/part_pkg/prorate_Mixin.pm b/FS/FS/part_pkg/prorate_Mixin.pm index 29409fa76..6d0c2dad4 100644 --- a/FS/FS/part_pkg/prorate_Mixin.pm +++ b/FS/FS/part_pkg/prorate_Mixin.pm @@ -50,6 +50,7 @@ day arrives. sub calc_prorate { my ($self, $cust_pkg, $sdate, $details, $param, $cutoff_day) = @_; die "no cutoff_day" unless $cutoff_day; + die "can't prorate non-monthly package\n" if $self->freq =~ /\D/; my $charge = $self->base_recur($cust_pkg, $sdate) || 0;