backported option for no postal fee on one-time charges
authormark <mark>
Fri, 12 Jun 2009 10:20:30 +0000 (10:20 +0000)
committermark <mark>
Fri, 12 Jun 2009 10:20:30 +0000 (10:20 +0000)
FS/FS/Conf.pm
FS/FS/cust_main.pm

index df9d906..faed4ea 100644 (file)
@@ -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
index 2f28df3..a1130f4 100644 (file)
@@ -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"