[freeside-commits] branch FREESIDE_3_BRANCH updated. 4363c9a6aac6d4d3918e355be80d9e86f8c8b641

Mark Wells mark at 420.am
Mon Feb 23 15:26:22 PST 2015


The branch, FREESIDE_3_BRANCH has been updated
       via  4363c9a6aac6d4d3918e355be80d9e86f8c8b641 (commit)
      from  aac2d8662226b1105d157f59983140589bd89c43 (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 4363c9a6aac6d4d3918e355be80d9e86f8c8b641
Author: Mark Wells <mark at freeside.biz>
Date:   Mon Feb 23 15:25:35 2015 -0800

    specify invoice mode for post-payment statements, #33152

diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index ae882f4..07f910d 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -1,6 +1,7 @@
 package FS::Conf;
 
 use vars qw($base_dir @config_items @base_items @card_types $DEBUG);
+use strict;
 use Carp;
 use IO::File;
 use File::Basename;
@@ -732,6 +733,23 @@ my %batch_gateway_options = (
   },
 );
 
+my %invoice_mode_options = (
+  'type'        => 'select-sub',
+  'options_sub' => sub { 
+    my @modes = qsearch({
+        'table' => 'invoice_mode', 
+        'extra_sql' => ' WHERE '.
+          $FS::CurrentUser::CurrentUser->agentnums_sql(null => 1),
+        });
+    map { $_->modenum, $_->modename } @modes;
+  },
+  'option_sub'  => sub { 
+                         my $mode = FS::invoice_mode->by_key(shift);
+                         $mode ? $mode->modename : '',
+                       },
+  'per_agent' => 1,
+);
+
 my @cdr_formats = (
   '' => '',
   'default' => 'Default',
@@ -1721,9 +1739,16 @@ and customer address. Include units.',
   },
 
   {
+    'key'         => 'payment_receipt_statement_mode',
+    'section'     => 'notification',
+    'description' => 'Automatic payments will cause a post-payment statement to be sent to the customer. Select the invoice mode to use for this statement. If unspecified, it will use the "_statement" versions of invoice configuration settings, and have the notice name "Statement".',
+    %invoice_mode_options,
+  },
+
+  {
     'key'         => 'payment_receipt_msgnum',
     'section'     => 'notification',
-    'description' => 'Template to use for payment receipts.',
+    'description' => 'Template to use for manual payment receipts.',
     %msg_template_options,
   },
   
@@ -3046,7 +3071,7 @@ and customer address. Include units.',
 			 },
     'option_sub'  => sub { require FS::Record;
                            require FS::agent_type;
-			   my $agent = FS::Record::qsearchs(
+			   my $agent_type = FS::Record::qsearchs(
 			     'agent_type', { 'typenum'=>shift }
 			   );
                            $agent_type ? $agent_type->atype : '';
diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm
index f57f14f..1a11457 100644
--- a/FS/FS/cust_bill.pm
+++ b/FS/FS/cust_bill.pm
@@ -1121,6 +1121,10 @@ sub queueable_email {
   my $self = qsearchs('cust_bill', { 'invnum' => $opt{invnum} } )
     or die "invalid invoice number: " . $opt{invnum};
 
+  if ( $opt{mode} ) {
+    $self->set('mode', $opt{mode});
+  }
+
   my %args = map {$_ => $opt{$_}} 
              grep { $opt{$_} }
               qw( from notice_name no_coupon template );
diff --git a/FS/FS/cust_pay.pm b/FS/FS/cust_pay.pm
index 1e27851..c2e0955 100644
--- a/FS/FS/cust_pay.pm
+++ b/FS/FS/cust_pay.pm
@@ -728,13 +728,22 @@ sub send_receipt {
        'custnum' => $cust_main->custnum,
     };
 
-    $error = $queue->insert(
+    my %opt = (
       'invnum'      => $cust_bill->invnum,
-      'template'    => 'statement',
-      'notice_name' => 'Statement',
       '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);
+
   }
   
   warn "send_receipt: $error\n" if $error;

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

Summary of changes:
 FS/FS/Conf.pm      |   29 +++++++++++++++++++++++++++--
 FS/FS/cust_bill.pm |    4 ++++
 FS/FS/cust_pay.pm  |   15 ++++++++++++---
 3 files changed, 43 insertions(+), 5 deletions(-)




More information about the freeside-commits mailing list