diff options
| -rw-r--r-- | FS/FS/cust_main/Billing.pm | 33 | ||||
| -rw-r--r-- | FS/FS/part_pkg/prorate_Mixin.pm | 1 | 
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; | 
