add cust_bill-no_recipients-error config, RT#11276
authorivan <ivan>
Wed, 19 Jan 2011 19:12:25 +0000 (19:12 +0000)
committerivan <ivan>
Wed, 19 Jan 2011 19:12:25 +0000 (19:12 +0000)
FS/FS/Conf.pm
FS/FS/cust_bill.pm

index ad44f9f..fe81887 100644 (file)
@@ -4263,6 +4263,13 @@ and customer address. Include units.',
     'agentonly'   => 1,
   },
 
+  {
+    'key'         => 'cust_bill-no_recipients-error',
+    'section'     => 'invoicing',
+    'description' => 'For customers with no invoice recipients, throw a job queue error rather than the default behavior of emailing the invoice to the invoice_from address.'.
+    'type'        => 'checkbox',
+  },
+
   { key => "apacheroot", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
   { key => "apachemachine", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
   { key => "apachemachines", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
index 6581578..f078342 100644 (file)
@@ -1241,8 +1241,14 @@ sub email {
   my @invoicing_list = grep { $_ !~ /^(POST|FAX)$/ } 
                             $self->cust_main->invoicing_list;
 
-  #better to notify this person than silence
-  @invoicing_list = ($invoice_from) unless @invoicing_list;
+  if ( ! @invoicing_list ) { #no recipients
+    if ( $conf->exists('cust_bill-no_recipients-error') ) {
+      die 'No recipients for customer #'. $self->custnum;
+    } else {
+      #default: better to notify this person than silence
+      @invoicing_list = ($invoice_from);
+    }
+  }
 
   my $subject = $self->email_subject($template);