From ffe2da5352a459c39f8e9bd999e96a03c86324fb Mon Sep 17 00:00:00 2001 From: Ivan Kohler Date: Wed, 15 May 2013 02:39:26 -0700 Subject: [PATCH] queue all email receipts, RT#22731, RT#23023 --- FS/FS/cust_pay.pm | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/FS/FS/cust_pay.pm b/FS/FS/cust_pay.pm index 86fcf9b4d..f6954a4bc 100644 --- a/FS/FS/cust_pay.pm +++ b/FS/FS/cust_pay.pm @@ -9,7 +9,6 @@ use vars qw( $DEBUG $me $conf @encrypted_fields use Date::Format; use Business::CreditCard; use Text::Template; -use FS::Misc qw( send_email ); use FS::Record qw( dbh qsearch qsearchs ); use FS::CurrentUser; use FS::payby; @@ -593,11 +592,18 @@ sub send_receipt { { my $msgnum = $conf->config('payment_receipt_msgnum', $cust_main->agentnum); if ( $msgnum ) { - my $msg_template = FS::msg_template->by_key($msgnum); - $error = $msg_template->send( - 'cust_main' => $cust_main, - 'object' => $self, - 'from_config' => 'payment_receipt_from', + + my $queue = new FS::queue { + 'job' => 'FS::Misc::process_send_email', + 'paynum' => $self->paynum, + 'custnum' => $cust_main->custnum, + }; + $error = $queue->insert( + FS::msg_template->by_key($msgnum)->prepare( + 'cust_main' => $cust_main, + 'object' => $self, + 'from_config' => 'payment_receipt_from', + ) ); } elsif ( $conf->exists('payment_receipt_email') ) { @@ -636,7 +642,12 @@ sub send_receipt { #setup date, other things? } - $error = send_email( + my $queue = new FS::queue { + 'job' => 'FS::Misc::process_send_generated_email', + 'paynum' => $self->paynum, + 'custnum' => $cust_main->custnum, + }; + $error = $queue->insert( 'from' => $conf->config('invoice_from', $cust_main->agentnum), #invoice_from??? well as good as any 'to' => \@invoicing_list, @@ -653,8 +664,9 @@ sub send_receipt { } elsif ( ! $cust_main->invoice_noemail ) { #not manual my $queue = new FS::queue { - 'paynum' => $self->paynum, - 'job' => 'FS::cust_bill::queueable_email', + 'job' => 'FS::cust_bill::queueable_email', + 'paynum' => $self->paynum, + 'custnum' => $cust_main->custnum, }; $error = $queue->insert( @@ -666,7 +678,7 @@ sub send_receipt { } - warn "send_receipt: $error\n" if $error; + warn "send_receipt: $error\n" if $error; } =item cust_bill_pay -- 2.11.0