[freeside-commits] branch master updated. cfd6a2219e498ec70d30b207b7a82037347ca7b0

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


The branch, master has been updated
       via  cfd6a2219e498ec70d30b207b7a82037347ca7b0 (commit)
      from  6b15465e49ec8404ae6716953e19bfdca0ba9a9d (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 cfd6a2219e498ec70d30b207b7a82037347ca7b0
Author: Mark Wells <mark at freeside.biz>
Date:   Mon Feb 23 15:26:11 2015 -0800

    specify invoice mode for post-payment statements, #33152

diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index 9213681..c4e5af4 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;
@@ -733,6 +734,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,
   },
   
@@ -3054,7 +3079,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 8d69661..a65154e 100644
--- a/FS/FS/cust_bill.pm
+++ b/FS/FS/cust_bill.pm
@@ -1086,6 +1086,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 e8f9aee..8274b3d 100644
--- a/FS/FS/cust_pay.pm
+++ b/FS/FS/cust_pay.pm
@@ -716,13 +716,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