From 4dc5a3df393ecc08e34f820c22340146c2f386c8 Mon Sep 17 00:00:00 2001 From: jeff Date: Mon, 15 Jun 2009 20:43:57 +0000 Subject: [PATCH] check for need for postal fee before charging the customer, not after --- FS/FS/cust_main.pm | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index 124cbccca..1bbf92d17 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -2429,18 +2429,18 @@ sub bill { return ''; } - my $postal_pkg = $self->charge_postal_fee(); - if ( $postal_pkg && !ref( $postal_pkg ) ) { - $dbh->rollback if $oldAutoCommit; - return "can't charge postal invoice fee for customer ". - $self->custnum. ": $postal_pkg"; - } - if ( $postal_pkg && - ( scalar( grep { $_->recur && $_->recur > 0 } @cust_bill_pkg) || + if ( scalar( grep { $_->recur && $_->recur > 0 } @cust_bill_pkg) || !$conf->exists('postal_invoice-recurring_only') - ) ) { + + my $postal_pkg = $self->charge_postal_fee(); + if ( $postal_pkg && !ref( $postal_pkg ) ) { + $dbh->rollback if $oldAutoCommit; + return "can't charge postal invoice fee for customer ". + $self->custnum. ": $postal_pkg"; + } + foreach my $part_pkg ( $postal_pkg->part_pkg->self_and_bill_linked ) { my $error = $self->_make_lines( 'part_pkg' => $part_pkg, -- 2.11.0