X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_pay.pm;h=3f6b8e8cf0c691ae4f2c9a0cbe238f72626817f6;hb=5ebcddd3d2cb95a02eaba0a8fc301b9c0d7e3e73;hp=285ab3f3ce72044308f051df07b550ed9c9d47d6;hpb=0bc6f2a95309807cc9372a6be3a36d5e8b3485d8;p=freeside.git diff --git a/FS/FS/cust_pay.pm b/FS/FS/cust_pay.pm index 285ab3f3c..3f6b8e8cf 100644 --- a/FS/FS/cust_pay.pm +++ b/FS/FS/cust_pay.pm @@ -227,6 +227,8 @@ sub insert { local $FS::UID::AutoCommit = 0; my $dbh = dbh; + my $conf = new FS::Conf; + my $cust_bill; if ( $self->invnum ) { $cust_bill = qsearchs('cust_bill', { 'invnum' => $self->invnum } ) @@ -379,6 +381,8 @@ sub insert { $dbh->commit or die $dbh->errstr if $oldAutoCommit; + $self->{'processing_fee'} = $options{'processing-fee'}; + #payment receipt my $trigger = $conf->config('payment_receipt-trigger', $self->cust_main->agentnum) || 'cust_pay'; @@ -652,6 +656,8 @@ sub send_receipt { return '' unless $conf->config_bool('payment_receipt', $cust_main->agentnum); + return '' if ($conf->config_bool('allow_payment_receipt_noemail', $cust_main->agentnum) && $cust_main->paymentreceipt_noemail); + my @invoicing_list = $cust_main->invoicing_list_emailonly; return '' unless @invoicing_list; @@ -664,11 +670,12 @@ sub send_receipt { || ! $cust_bill ) { + $error = $self->send_message_receipt( 'cust_main' => $cust_main, 'cust_bill' => $opt->{cust_bill}, 'cust_pkg' => $opt->{cust_pkg}, - 'invoicing_list' => @invoicing_list, + 'invoicing_list' => \@invoicing_list, 'msgnum' => $conf->config('payment_receipt_msgnum', $cust_main->agentnum) ); @@ -705,9 +712,6 @@ sub send_receipt { $error = $queue->insert(%opt); } - - - } warn "send_receipt: $error\n" if $error; @@ -716,7 +720,13 @@ sub send_receipt { =item send_message_receipt sends out a message receipt. -send_message_receipt($cust_main, $msgnum); +$error = $self->send_message_receipt( + 'cust_main' => $cust_main, + 'cust_bill' => $opt->{cust_bill}, + 'cust_pkg' => $opt->{cust_pkg}, + 'invoicing_list' => \@invoicing_list, + 'msgnum' => $conf->config('payment_receipt_msgnum', $cust_main->agentnum) + ); =cut @@ -725,7 +735,7 @@ sub send_message_receipt { my $cust_main = $opt{'cust_main'}; my $cust_bill = $opt{'cust_bill'}; my $cust_pkg = $opt{'cust_pkg'}; - my @invoicing_list = $opt{'invoicing_list'}; + my @invoicing_list = ref($opt{'invoicing_list'}) ? @{ $opt{'invoicing_list'} } : ( $opt{'invoicing_list'} ); my $msgnum = $opt{'msgnum'}; my $error = ''; @@ -733,6 +743,13 @@ sub send_message_receipt { my %substitutions = (); $substitutions{invnum} = $cust_bill->invnum if $cust_bill; + $substitutions{'processing_fee'} = $self->{'processing_fee'}; + + + my $msg_template = qsearchs('msg_template',{ msgnum => $msgnum}); + unless ($msg_template) { + return "send_receipt could not load msg_template"; + } my $queue = new FS::queue { 'job' => 'FS::Misc::process_send_email', @@ -754,8 +771,7 @@ sub send_message_receipt { TYPE => 'ARRAY', SOURCE => [ map "$_\n", $conf->config('payment_receipt_email') ], ) or do { - warn "can't create payment receipt template: $Text::Template::ERROR"; - return ''; + return "can't create payment receipt template: $Text::Template::ERROR"; }; my $payby = $self->payby; @@ -800,8 +816,7 @@ sub send_message_receipt { 'body' => [ $receipt_template->fill_in( HASH => \%fill_in ) ], ); } else { - warn "payment_receipt is on, but no payment_receipt_msgnum\n"; - $error = "payment_receipt is on, but no payment_receipt_msgnum"; + $error = "payment_receipt is on, but no payment_receipt_msgnum\n"; } return $error;