X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_main%2FBilling.pm;h=71d5c9b81f565d9794aae74e8e3ab3b88656fcd9;hb=f81eebbe27a6acc0ae4284fa04b5525a41ae4570;hp=51b49e4f0a1c9ec97f4ef5923c82ea088429efd3;hpb=60c34bd328a404008313d4ab78d25152ebdb9226;p=freeside.git diff --git a/FS/FS/cust_main/Billing.pm b/FS/FS/cust_main/Billing.pm index 51b49e4f0..71d5c9b81 100644 --- a/FS/FS/cust_main/Billing.pm +++ b/FS/FS/cust_main/Billing.pm @@ -1,6 +1,7 @@ package FS::cust_main::Billing; use strict; +use feature 'state'; use vars qw( $conf $DEBUG $me ); use Carp; use Data::Dumper; @@ -170,11 +171,8 @@ sub bill_and_collect { # In a batch tax environment, do not run collection if any pending # invoices were created. Collection will run after the next tax batch. - my $tax = FS::TaxEngine->new; - if ( $tax->info->{batch} and - qsearch('cust_bill', { custnum => $self->custnum, pending => 'Y' }) - ) - { + state $is_batch_tax = FS::TaxEngine->new->info->{batch} ? 1 : 0; + if ( $is_batch_tax && $self->pending_invoice_count ) { warn "skipped collection for custnum ".$self->custnum. " due to pending invoices\n" if $DEBUG; } elsif ( $conf->exists('cancelled_cust-noevents') @@ -1052,10 +1050,8 @@ sub _make_lines { } } - if ($cust_pkg->waive_setup && $part_pkg->plan eq "prorate") { - $lineitems++; - $setup = 0 if $part_pkg->prorate_setup($cust_pkg, $time); - } + $lineitems++ + if $cust_pkg->waive_setup && $part_pkg->can('prorate_setup') && $part_pkg->prorate_setup($cust_pkg, $time); if ( $cust_pkg->get('setup') ) { # don't change it