},
{
+ '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
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 ) ) {
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"