summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
authormark <mark>2011-05-09 20:31:10 +0000
committermark <mark>2011-05-09 20:31:10 +0000
commit27cfd639aa367ad8d878c71a9516bd913099d528 (patch)
treeda817e012bae223eca02286ca56f95b6863c86c6 /FS
parentc0e4e71f6e2888fe83c6b288a84dcc4a4897c848 (diff)
bill recurring packages up to current date, #12569
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/cust_main/Billing.pm33
-rw-r--r--FS/FS/part_pkg/prorate_Mixin.pm1
2 files changed, 22 insertions, 12 deletions
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;