summaryrefslogtreecommitdiff
path: root/FS/FS/cust_refund.pm
diff options
context:
space:
mode:
authorJonathan Prykop <jonathan@freeside.biz>2015-10-23 20:24:40 -0500
committerJonathan Prykop <jonathan@freeside.biz>2015-10-23 20:24:40 -0500
commitacfdb8bec93849e35ae5c4abc276d6ca8006f717 (patch)
tree2352be75383b347dd05892e661642384d84e31e6 /FS/FS/cust_refund.pm
parentbeb4c90e57b8063677a556a1a0bf10395ca49d4e (diff)
RT#38432: OFM - Send refund receipt
Diffstat (limited to 'FS/FS/cust_refund.pm')
-rw-r--r--FS/FS/cust_refund.pm53
1 files changed, 53 insertions, 0 deletions
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