diff options
Diffstat (limited to 'FS')
-rw-r--r-- | FS/FS/Conf.pm | 7 | ||||
-rw-r--r-- | FS/FS/Report/Tax.pm | 4 | ||||
-rw-r--r-- | FS/FS/cust_refund.pm | 53 | ||||
-rw-r--r-- | FS/FS/msg_template.pm | 12 |
4 files changed, 74 insertions, 2 deletions
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index a1b0e7cde..594c0e076 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -1675,6 +1675,13 @@ and customer address. Include units.', }, { + 'key' => 'refund_receipt_msgnum', + 'section' => 'notification', + 'description' => 'Template to use for manual refund receipts.', + %msg_template_options, + }, + + { 'key' => 'trigger_export_insert_on_payment', 'section' => 'billing', 'description' => 'Enable exports on payment application.', diff --git a/FS/FS/Report/Tax.pm b/FS/FS/Report/Tax.pm index a892a6b87..93fc64435 100644 --- a/FS/FS/Report/Tax.pm +++ b/FS/FS/Report/Tax.pm @@ -237,7 +237,7 @@ sub report_internal { LEFT JOIN ($sales_credit) AS sales_credit USING (billpkgnum) LEFT JOIN ($exempt_credit) AS exempt_credit USING (billpkgnum, taxnum) $join_cust_pkg $where AND $nottax - $group + $group_all "; # also include the exempt-sales credit amount, for the credit report @@ -256,7 +256,7 @@ sub report_internal { LEFT JOIN ($exempt_credit) AS exempt_credit USING (taxnum) JOIN cust_bill_pkg USING (billpkgnum) $join_cust_pkg $where AND $nottax - $group + $group_all "; # taxable sales diff --git a/FS/FS/cust_refund.pm b/FS/FS/cust_refund.pm index e3fc910ec..efbdceeb0 100644 --- a/FS/FS/cust_refund.pm +++ b/FS/FS/cust_refund.pm @@ -370,6 +370,59 @@ sub unapplied { sprintf("%.2f", $amount ); } +=item send_receipt HASHREF | OPTION => VALUE ... + +Sends a payment receipt for this payment. + +refund_receipt_msgnum must be configured. + +Available options: + +=over 4 + +=item cust_main + +Customer (FS::cust_main) object (for efficiency). + +=cut + +=back + +=cut + +sub send_receipt { + my $self = shift; + my $opt = ref($_[0]) ? shift : { @_ }; + + my $cust_main = $opt->{'cust_main'} || $self->cust_main; + + my $conf = new FS::Conf; + + my $msgnum = $conf->config('refund_receipt_msgnum', $cust_main->agentnum); + return "No refund_receipt_msgnum configured" unless $msgnum; + + my $msg_template = qsearchs('msg_template',{ msgnum => $msgnum}); + return "Could not load template" + unless $msg_template; + + my $cust_msg = $msg_template->prepare( + 'cust_main' => $cust_main, + 'object' => $self, + 'msgtype' => 'receipt', + ); + return 'Error preparing message' unless $cust_msg; + my $error = $cust_msg->insert; + return $error if $error; + + my $queue = new FS::queue { + 'job' => 'FS::cust_msg::process_send', + 'custnum' => $cust_main->custnum, + }; + $error = $queue->insert( $cust_msg->custmsgnum ); + + return $error; +} + =back =head1 CLASS METHODS diff --git a/FS/FS/msg_template.pm b/FS/FS/msg_template.pm index 1d357b1a3..01a656366 100644 --- a/FS/FS/msg_template.pm +++ b/FS/FS/msg_template.pm @@ -614,6 +614,18 @@ sub substitutions { $cust_pay->paymask : $cust_pay->decrypt($cust_pay->payinfo) } ], ], + # for refund receipts + 'cust_refund' => [ + 'refundnum', + [ refund => sub { sprintf("%.2f", shift->refund) } ], + [ payby => sub { FS::payby->shortname(shift->payby) } ], + [ date => sub { time2str("%a %B %o, %Y", shift->_date) } ], + [ payinfo => sub { + my $cust_refund = shift; + ($cust_refund->payby eq 'CARD' || $cust_refund->payby eq 'CHEK') ? + $cust_refund->paymask : $cust_refund->decrypt($cust_refund->payinfo) + } ], + ], # for payment decline messages # try to support all cust_pay fields # 'error' is a special case, it contains the raw error from the gateway |