add cust_pay insert noemail flag, RT#23357, github #32
authorIvan Kohler <ivan@freeside.biz>
Mon, 3 Nov 2014 01:11:59 +0000 (17:11 -0800)
committerIvan Kohler <ivan@freeside.biz>
Mon, 3 Nov 2014 01:11:59 +0000 (17:11 -0800)
FS/FS/cust_pay.pm

index 80a1e3e..87fad02 100644 (file)
@@ -190,7 +190,13 @@ If the additional field discount_term is defined then a prepayment discount
 is taken for that length of time.  It is an error for the customer to owe
 after this payment is made.
 
 is taken for that length of time.  It is an error for the customer to owe
 after this payment is made.
 
-A hash of optional arguments may be passed.  Currently "manual" is supported.
+A hash of optional arguments may be passed.  The following arguments are
+supported:
+
+=over 4
+
+=item manual
+
 If true, a payment receipt is sent instead of a statement when
 'payment_receipt_email' configuration option is set.
 
 If true, a payment receipt is sent instead of a statement when
 'payment_receipt_email' configuration option is set.
 
@@ -203,6 +209,13 @@ payment is created directly from the web interface, from a user-initiated
 realtime payment, or from a third-party payment via self-service.  It should
 be I<false> when creating a payment from a billing event or from a batch.
 
 realtime payment, or from a third-party payment via self-service.  It should
 be I<false> when creating a payment from a billing event or from a batch.
 
+=item noemail
+
+Don't send an email receipt.  (Note: does not currently work when
+payment_receipt-trigger is set to something other than default / cust_bill)
+
+=back
+
 =cut
 
 sub insert {
 =cut
 
 sub insert {
@@ -379,6 +392,7 @@ sub insert {
   if ( $trigger eq 'cust_pay' ) {
     my $error = $self->send_receipt(
       'manual'    => $options{'manual'},
   if ( $trigger eq 'cust_pay' ) {
     my $error = $self->send_receipt(
       'manual'    => $options{'manual'},
+      'noemail'   => $options{'noemail'},
       'cust_bill' => $cust_bill,
       'cust_main' => $cust_main,
     );
       'cust_bill' => $cust_bill,
       'cust_main' => $cust_main,
     );
@@ -581,6 +595,12 @@ will be assumed.
 
 Customer (FS::cust_main) object (for efficiency).
 
 
 Customer (FS::cust_main) object (for efficiency).
 
+=item noemail
+
+Don't send an email receipt.
+
+=cut
+
 =back
 
 =cut
 =back
 
 =cut
@@ -687,7 +707,8 @@ sub send_receipt {
 
     }
 
 
     }
 
-  } elsif ( ! $cust_main->invoice_noemail ) { #not manual
+  #not manual and no noemail flag (here or on the customer)
+  } elsif ( ! $opt->{'noemail'} && ! $cust_main->invoice_noemail ) {
 
     my $queue = new FS::queue {
        'job'     => 'FS::cust_bill::queueable_email',
 
     my $queue = new FS::queue {
        'job'     => 'FS::cust_bill::queueable_email',