X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_main%2FBilling.pm;h=29f7e8e5413cbfc1a5c5b59f44cbaf8839a4c995;hb=7a486dea647f735a9a1d0381443218ad6affe6e1;hp=815fe57d980f01b8d5f69afe7efb82a9b2ea1266;hpb=291043d63ad76932471fa4704258009963b6dfb4;p=freeside.git diff --git a/FS/FS/cust_main/Billing.pm b/FS/FS/cust_main/Billing.pm index 815fe57d9..29f7e8e54 100644 --- a/FS/FS/cust_main/Billing.pm +++ b/FS/FS/cust_main/Billing.pm @@ -106,7 +106,7 @@ options of those methods are also available. sub bill_and_collect { my( $self, %options ) = @_; - my $log = FS::Log->new('bill_and_collect'); + my $log = FS::Log->new('FS::cust_main::Billing::bill_and_collect'); my %logopt = (object => $self); $log->debug('start', %logopt); @@ -379,7 +379,10 @@ sub bill { return '' if $self->payby eq 'COMP'; local($DEBUG) = $FS::cust_main::DEBUG if $FS::cust_main::DEBUG > $DEBUG; + my $log = FS::Log->new('FS::cust_main::Billing::bill'); + my %logopt = (object => $self); + $log->debug('start', %logopt); warn "$me bill customer ". $self->custnum. "\n" if $DEBUG; @@ -408,11 +411,13 @@ sub bill { local $FS::UID::AutoCommit = 0; my $dbh = dbh; + $log->debug('acquiring lock', %logopt); warn "$me acquiring lock on customer ". $self->custnum. "\n" if $DEBUG; $self->select_for_update; #mutex + $log->debug('running pre-bill events', %logopt); warn "$me running pre-bill events for customer ". $self->custnum. "\n" if $DEBUG; @@ -428,6 +433,7 @@ sub bill { return $error; } + $log->debug('done running pre-bill events', %logopt); warn "$me done running pre-bill events for customer ". $self->custnum. "\n" if $DEBUG; @@ -458,6 +464,7 @@ sub bill { next if $options{'no_prepaid'} && $part_pkg->is_prepaid; + $log->debug('bill package '. $cust_pkg->pkgnum, %logopt); warn " bill package ". $cust_pkg->pkgnum. "\n" if $DEBUG; #? to avoid use of uninitialized value errors... ? @@ -749,6 +756,7 @@ sub bill { ? ( $previous_bill->billing_balance + $previous_bill->charged ) : 0; + $log->debug('creating the new invoice', %logopt); warn "creating the new invoice\n" if $DEBUG; #create the new invoice my $cust_bill = new FS::cust_bill ( { @@ -1082,6 +1090,16 @@ sub _make_lines { my %setup_param = ( 'discounts' => \@setup_discounts ); my $setup_billed_currency = ''; my $setup_billed_amount = 0; + # Conditions for setting setup date and charging the setup fee: + # - this is not a recurring-only billing run + # - and the package is not currently being canceled + # - and, unless we're specifically told otherwise via 'resetup': + # - it doesn't already HAVE a setup date + # - or a start date in the future + # - and it's not suspended + # + # The last condition used to check the "disable_setup_suspended" option but + # that's obsolete. We now never set the setup date on a suspended package. if ( ! $options{recurring_only} and ! $options{cancel} and ( $options{'resetup'} @@ -1089,11 +1107,7 @@ sub _make_lines { && ( ! $cust_pkg->start_date || $cust_pkg->start_date <= $cmp_time ) - && ( ! $conf->exists('disable_setup_suspended_pkgs') - || ( $conf->exists('disable_setup_suspended_pkgs') && - ! $cust_pkg->getfield('susp') - ) - ) + && ( ! $cust_pkg->getfield('susp') ) ) ) )