[freeside-commits] branch FREESIDE_3_BRANCH updated. 6b7a7b26239e9bdb02931242c321afd6e2fd9b39

Christopher Burger burgerc at freeside.biz
Mon May 7 05:57:25 PDT 2018


The branch, FREESIDE_3_BRANCH has been updated
       via  6b7a7b26239e9bdb02931242c321afd6e2fd9b39 (commit)
       via  cad17f4aca6b4c673cb72ac7af69d9a83f406e91 (commit)
      from  7e8873251e1709dee38c5cecb6b6f8fd466183f0 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 6b7a7b26239e9bdb02931242c321afd6e2fd9b39
Author: Christopher Burger <burgerc at freeside.biz>
Date:   Mon May 7 08:56:32 2018 -0400

    RT# 78131 - update just for V3 backport

diff --git a/FS/FS/cust_pay.pm b/FS/FS/cust_pay.pm
index f3c0b197f..7739203c4 100644
--- a/FS/FS/cust_pay.pm
+++ b/FS/FS/cust_pay.pm
@@ -752,31 +752,21 @@ sub send_receipt {
       my %substitutions = ();
       $substitutions{invnum} = $opt->{cust_bill}->invnum if $opt->{cust_bill};
 
-      my $msg_template = qsearchs('msg_template',{ msgnum => $msgnum});
-      unless ($msg_template) {
-        warn "send_receipt could not load msg_template";
-        return;
-      }
+      my $queue = new FS::queue {
+        'job'     => 'FS::Misc::process_send_email',
+        'paynum'  => $self->paynum,
+        'custnum' => $cust_main->custnum,
+      };
 
-      my $cust_msg = $msg_template->prepare(
+      $error = $queue->insert(
+        FS::msg_template->by_key($msgnum)->prepare(
           'cust_main'     => $cust_main,
           'object'        => $self,
           'from_config'   => 'payment_receipt_from',
           'substitutions' => \%substitutions,
-          'msgtype'       => 'receipt',
+        ),
+        'msgtype' => 'receipt', # override msg_template's default
       );
-      $error = $cust_msg ? $cust_msg->insert : 'error preparing msg_template';
-      if ($error) {
-        warn "send_receipt: $error";
-        return;
-      }
-
-      my $queue = new FS::queue {
-        'job'     => 'FS::cust_msg::process_send',
-        'paynum'  => $self->paynum,
-        'custnum' => $cust_main->custnum,
-      };
-      $error = $queue->insert( $cust_msg->custmsgnum );
 
     }
     else {

commit cad17f4aca6b4c673cb72ac7af69d9a83f406e91
Author: Christopher Burger <burgerc at freeside.biz>
Date:   Thu May 3 15:40:42 2018 -0400

    RT# 78131 - added ability to use message template for auto payment receipt and fixed NaN error when selecting nothing for config items with type select.

diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index 8574807e5..c58ca33f4 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -1836,6 +1836,13 @@ and customer address. Include units.',
     'description' => 'Template to use for manual payment receipts.',
     %msg_template_options,
   },
+
+  {
+    'key'         => 'payment_receipt_msgnum_auto',
+    'section'     => 'notification',
+    'description' => 'Automatic payments will cause a post-payment to use a message template for automatic payment receipts rather than a post payment statement.',
+    %msg_template_options,
+  },
   
   {
     'key'         => 'payment_receipt_from',
diff --git a/FS/FS/cust_pay.pm b/FS/FS/cust_pay.pm
index bd59161cd..f3c0b197f 100644
--- a/FS/FS/cust_pay.pm
+++ b/FS/FS/cust_pay.pm
@@ -745,27 +745,65 @@ sub send_receipt {
 
   } elsif ( ! $cust_main->invoice_noemail ) { #not manual
 
-    my $queue = new FS::queue {
-       'job'     => 'FS::cust_bill::queueable_email',
-       'paynum'  => $self->paynum,
-       'custnum' => $cust_main->custnum,
-    };
+    # check to see if they want to send specific message template as receipt for auto payments
+    my $msgnum = $conf->config('payment_receipt_msgnum_auto', $cust_main->agentnum);
+    if ( $msgnum ) {
 
-    my %opt = (
-      'invnum'      => $cust_bill->invnum,
-      'no_coupon'   => 1,
-    );
+      my %substitutions = ();
+      $substitutions{invnum} = $opt->{cust_bill}->invnum if $opt->{cust_bill};
 
-    if ( my $mode = $conf->config('payment_receipt_statement_mode') ) {
-      $opt{'mode'} = $mode;
-    } else {
-      # backward compatibility, no good fix for this yet as some people may
-      # still have "invoice_latex_statement" and such options
-      $opt{'template'} = 'statement';
-      $opt{'notice_name'} = 'Statement';
+      my $msg_template = qsearchs('msg_template',{ msgnum => $msgnum});
+      unless ($msg_template) {
+        warn "send_receipt could not load msg_template";
+        return;
+      }
+
+      my $cust_msg = $msg_template->prepare(
+          'cust_main'     => $cust_main,
+          'object'        => $self,
+          'from_config'   => 'payment_receipt_from',
+          'substitutions' => \%substitutions,
+          'msgtype'       => 'receipt',
+      );
+      $error = $cust_msg ? $cust_msg->insert : 'error preparing msg_template';
+      if ($error) {
+        warn "send_receipt: $error";
+        return;
+      }
+
+      my $queue = new FS::queue {
+        'job'     => 'FS::cust_msg::process_send',
+        'paynum'  => $self->paynum,
+        'custnum' => $cust_main->custnum,
+      };
+      $error = $queue->insert( $cust_msg->custmsgnum );
+
+    }
+    else {
+      my $queue = new FS::queue {
+        'job'     => 'FS::cust_bill::queueable_email',
+        'paynum'  => $self->paynum,
+        'custnum' => $cust_main->custnum,
+      };
+
+      my %opt = (
+        'invnum'      => $cust_bill->invnum,
+        'no_coupon'   => 1,
+      );
+
+      if ( my $mode = $conf->config('payment_receipt_statement_mode') ) {
+        $opt{'mode'} = $mode;
+      } else {
+        # backward compatibility, no good fix for this yet as some people may
+        # still have "invoice_latex_statement" and such options
+        $opt{'template'} = 'statement';
+        $opt{'notice_name'} = 'Statement';
+      }
+
+      $error = $queue->insert(%opt);
     }
 
-    $error = $queue->insert(%opt);
+
 
   }
   
diff --git a/httemplate/config/config-process.cgi b/httemplate/config/config-process.cgi
index 3d57b310c..d84edce00 100644
--- a/httemplate/config/config-process.cgi
+++ b/httemplate/config/config-process.cgi
@@ -75,7 +75,7 @@
         configCell.innerHTML = <% $value |js_string %>;
 %     } elsif ( $type eq 'select-sub' && ! $i->multiple ) {
         configCell.innerHTML =
-          <% $conf->config($i->key, $agentnum) |js_string %> + ': ' +
+          <% $conf->exists($i->key, $agentnum) ? $conf->config($i->key, $agentnum) : '' |js_string %> + ': ' +
           <% &{ $i->option_sub }( $conf->config($i->key, $agentnum) ) |js_string %>;
 %     } else {
         //alert('unknown type <% $type %>');
@@ -164,7 +164,7 @@ foreach my $type ( ref($i->type) ? @{$i->type} : $i->type ) {
     or ( $type =~ /^select(-(sub|part_svc|part_pkg|pkg_class|agent))?$/
          || $i->multiple )
   ) {
-    if ( scalar(@{[ $cgi->param($i->key.$n) ]}) ) {
+    if ( scalar(@{[ $cgi->param($i->key.$n) ]}) && $cgi->param($i->key.$n) ne '' ) {
       my $error = &{$i->validate}([ $cgi->param($i->key.$n) ], $n) if $i->validate;
       push @error, $error if $error;
       $conf->set($i->key, join("\n", @{[ $cgi->param($i->key.$n) ]} ), $agentnum);

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/Conf.pm                        |  7 ++++
 FS/FS/cust_pay.pm                    | 62 ++++++++++++++++++++++++++----------
 httemplate/config/config-process.cgi |  4 +--
 3 files changed, 54 insertions(+), 19 deletions(-)




More information about the freeside-commits mailing list