[freeside-commits] branch master updated. 3b8e97b7eb2926aba10dbbf27cd60fe5d098c1b9
Jonathan Prykop
jonathan at 420.am
Tue Jul 5 14:51:51 PDT 2016
The branch, master has been updated
via 3b8e97b7eb2926aba10dbbf27cd60fe5d098c1b9 (commit)
from bb174fcb28d7df1673a9c55edc7d953017b5288f (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 3b8e97b7eb2926aba10dbbf27cd60fe5d098c1b9
Author: Jonathan Prykop <jonathan at freeside.biz>
Date: Tue Jul 5 16:51:34 2016 -0500
RT#71563: Add agent_custid to credit import
diff --git a/FS/FS/cust_credit.pm b/FS/FS/cust_credit.pm
index 094437e..8546372 100644
--- a/FS/FS/cust_credit.pm
+++ b/FS/FS/cust_credit.pm
@@ -1087,12 +1087,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 937010d..d009d1e 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_type.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><i>amount</i>:</li>
+ <li><i>reasonnum</i>: <A HREF="<%$p%>browse/reason_type.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 | 9 ++++----
2 files changed, 41 insertions(+), 5 deletions(-)
More information about the freeside-commits
mailing list