From e88bf2f5af9cdb6091e6ceacec606868a9067934 Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 19 Jan 2011 19:12:25 +0000 Subject: [PATCH] add cust_bill-no_recipients-error config, RT#11276 --- FS/FS/Conf.pm | 7 +++++++ FS/FS/cust_bill.pm | 10 ++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index ad44f9f48..fe81887b9 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -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 => "DEPRECATED", type => "text" }, { key => "apachemachine", section => "deprecated", description => "DEPRECATED", type => "text" }, { key => "apachemachines", section => "deprecated", description => "DEPRECATED", type => "text" }, diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm index 6581578f5..f07834297 100644 --- a/FS/FS/cust_bill.pm +++ b/FS/FS/cust_bill.pm @@ -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); -- 2.11.0