[freeside-commits] branch FREESIDE_3_BRANCH updated. 99d369a8cd98e5e472539738f9c32ad80f25fa03

Jonathan Prykop jonathan at 420.am
Tue Jul 5 15:19:59 PDT 2016


The branch, FREESIDE_3_BRANCH has been updated
       via  99d369a8cd98e5e472539738f9c32ad80f25fa03 (commit)
       via  dc8a15535f28e96097a4f0fbf51b0aec2c7a7a5b (commit)
      from  a0143763528c659487d677a88a41269c1a9a2802 (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 99d369a8cd98e5e472539738f9c32ad80f25fa03
Author: Jonathan Prykop <jonathan at freeside.biz>
Date:   Tue Jul 5 17:08:43 2016 -0500

    RT#71563: Add agent_custid to credit import [text tweak]

diff --git a/httemplate/misc/cust_credit-import.html b/httemplate/misc/cust_credit-import.html
index 68c566c..cbaac57 100644
--- a/httemplate/misc/cust_credit-import.html
+++ b/httemplate/misc/cust_credit-import.html
@@ -62,7 +62,7 @@ Import a file containing credits.
 Uploaded files can be CSV (comma-separated value) files or Excel spreadsheets.  The file should have a .CSV or .XLS extension.
 <BR><BR>
 
-    <b>Default</b> format has the following field order: <i>custnum, amount, reasonnum, invnum</i><br>
+    <b>Default</b> format has the following field order: <i>custnum, amount, reasonnum, invnum, agent_custid</i><br>
 <BR><BR>
 
 Field information:

commit dc8a15535f28e96097a4f0fbf51b0aec2c7a7a5b
Author: Jonathan Prykop <jonathan at freeside.biz>
Date:   Tue Jul 5 16:51:34 2016 -0500

    RT#71563: Add agent_custid to credit import [v3 merge]

diff --git a/FS/FS/cust_credit.pm b/FS/FS/cust_credit.pm
index 7cb79df..4286d34 100644
--- a/FS/FS/cust_credit.pm
+++ b/FS/FS/cust_credit.pm
@@ -1103,12 +1103,47 @@ use FS::cust_credit_bill;
 sub process_batch_import {
   my $job = shift;
 
+  # some false laziness with FS::cust_pay::process_batch_import
+  my $hashcb = sub {
+    my %hash = @_;
+    my $custnum = $hash{'custnum'};
+    my $agent_custid = $hash{'agent_custid'};
+    # translate agent_custid into regular custnum
+    if ($custnum && $agent_custid) {
+      die "can't specify both custnum and agent_custid\n";
+    } elsif ($agent_custid) {
+      # here is the agent virtualization
+      my $extra_sql = ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql;
+      my %search;
+      $search{'agent_custid'} = $agent_custid
+        if $agent_custid;
+      $search{'custnum'} = $custnum
+        if $custnum;
+      my $cust_main = qsearchs({
+        'table'     => 'cust_main',
+        'hashref'   => \%search,
+        'extra_sql' => $extra_sql,
+      });
+      die "can't find customer with" .
+        ($custnum  ? " custnum $custnum" : '') .
+        ($agent_custid ? " agent_custid $agent_custid" : '') . "\n"
+        unless $cust_main;
+      die "mismatched customer number\n"
+        if $custnum && ($custnum ne $cust_main->custnum);
+      $custnum = $cust_main->custnum;
+    }
+    $hash{'custnum'} = $custnum;
+    delete($hash{'agent_custid'});
+    return %hash;
+  };
+
   my $opt = { 'table'   => 'cust_credit',
               'params'  => [ '_date', 'credbatch' ],
               'formats' => { 'simple' =>
-                               [ 'custnum', 'amount', 'reasonnum', 'invnum' ],
+                               [ 'custnum', 'amount', 'reasonnum', 'invnum', 'agent_custid' ],
                            },
               'default_csv' => 1,
+              'format_hash_callbacks' => { 'simple' => $hashcb },
               'postinsert_callback' => sub {
                 my $cust_credit = shift; #my ($cust_credit, $param ) = @_;
 
diff --git a/httemplate/misc/cust_credit-import.html b/httemplate/misc/cust_credit-import.html
index 9a63a04..68c566c 100644
--- a/httemplate/misc/cust_credit-import.html
+++ b/httemplate/misc/cust_credit-import.html
@@ -67,10 +67,11 @@ Uploaded files can be CSV (comma-separated value) files or Excel spreadsheets.
 
 Field information:
 <ul>
-  <li><i>custnum</i>: Customer number
-  <li><i>amount</i>:
-  <li><i>reasonnum</i>: <A HREF="<%$p%>browse/reason.html?class=R">Credit reason</A>
-  <li><i>invnum</i>: Invoice number
+  <li><i>custnum</i>: This is the freeside customer number. It may be left blank. If specified, agent_custid must be blank.</li></li>
+  <li><i>amount</i>:</li>
+  <li><i>reasonnum</i>: <A HREF="<%$p%>browse/reason.html?class=R">Credit reason</A></li>
+  <li><i>invnum</i>: Invoice number</li>
+  <li><i>agent_custid</i>: This is the reseller's idea of the customer number or identifier. It may be left blank. If specified, custnum must be blank.</li>
 </ul>
 <BR><BR>
 

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

Summary of changes:
 FS/FS/cust_credit.pm                    |   37 ++++++++++++++++++++++++++++++-
 httemplate/misc/cust_credit-import.html |   11 ++++-----
 2 files changed, 42 insertions(+), 6 deletions(-)




More information about the freeside-commits mailing list