X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_pay.pm;h=30333e0c4e27d593355c847374db0c5a78eb44da;hb=4e35589e637aa3a3615a780d4086085c5ecb1782;hp=85bd4dbdfd6d1b62df4e9d6ba3fde1c2a9c11080;hpb=a7ea8cde763b396d0f4ce48168c689d038263786;p=freeside.git diff --git a/FS/FS/cust_pay.pm b/FS/FS/cust_pay.pm index 85bd4dbdf..30333e0c4 100644 --- a/FS/FS/cust_pay.pm +++ b/FS/FS/cust_pay.pm @@ -192,8 +192,14 @@ sub insert { if ( $conf->exists('payment_receipt_email') && grep { $_ !~ /^(POST|FAX)$/ } $cust_main->invoicing_list ) { + + $cust_bill ||= ($cust_main->cust_bill)[-1]; #rather inefficient though? + my $error; - if ( exists($options{ 'manual' }) && $options{ 'manual' } ) { + if ( ( exists($options{'manual'}) && $options{'manual'} ) + || ! $conf->exists('invoice_html_statement') + || ! $cust_bill + ) { my $receipt_template = new Text::Template ( TYPE => 'ARRAY', @@ -226,21 +232,20 @@ sub insert { 'balance' => $cust_main->balance, } ) ], ); - }else{ - unless($cust_bill){ - $cust_bill = ($cust_main->cust_bill)[-1]; - } - if ($cust_bill) { - my $queue = new FS::queue { - 'paynum' => $self->paynum, - 'job' => 'FS::cust_bill::queueable_send', - }; - $error = $queue->insert( - 'invnum' => $cust_bill->invnum, - 'template' => 'statement', - ); - } + + } else { + + my $queue = new FS::queue { + 'paynum' => $self->paynum, + 'job' => 'FS::cust_bill::queueable_email', + }; + $error = $queue->insert( + 'invnum' => $cust_bill->invnum, + 'template' => 'statement', + ); + } + if ( $error ) { warn "can't send payment receipt/statement: $error"; }