diff options
-rw-r--r-- | FS/FS/Conf.pm | 7 | ||||
-rw-r--r-- | FS/FS/cust_main.pm | 12 |
2 files changed, 17 insertions, 2 deletions
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index df9d9066e..faed4ea12 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -2068,6 +2068,13 @@ worry that config_items is freeside-specific and icky. }, { + 'key' => 'postal_invoice-recurring_only', + 'section' => 'billing', + 'description' => 'The postal invoice fee is omitted on invoices without recurring charges when this is set', + 'type' => 'checkbox', + }, + + { 'key' => 'batch-enable', 'section' => 'deprecated', #make sure batch-enable_payby is set for #everyone before removing diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index 2f28df3e2..a1130f44d 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -2229,7 +2229,13 @@ sub bill { if ( $setup != 0 || $recur != 0 ) { - unless ($postal_charge) { + # Only create a postal charge if: + # - this package has a recurring fee OR postal charges are enabled for non-recurring fees + # - AND there isn't already a postal charge for this invoice. + if ( (!$postal_charge) && + ( !$conf->exists('postal_invoice-recurring_only') || + $recur > 0 ) + ) { $postal_charge = 1; # try only once my $postal_pkg = $self->charge_postal_fee(); if ( $postal_pkg && !ref( $postal_pkg ) ) { @@ -2237,7 +2243,9 @@ sub bill { return "can't charge postal invoice fee for customer ". $self->custnum. ": $postal_pkg"; } - push @cust_pkgs, $postal_pkg if $postal_pkg; + if ( $postal_pkg ) { + push @cust_pkgs, $postal_pkg; + } } warn " charges (setup=$setup, recur=$recur); adding line items\n" |