From ac2ec4c0ce8ea098009340dd7e9756dad7219a5b Mon Sep 17 00:00:00 2001 From: Ivan Kohler Date: Sun, 9 Feb 2014 14:59:10 -0800 Subject: [PATCH] with cust_main-custnum-display_prefix, use prefixed customer numbers on batch import, RT#26319 --- FS/FS/Record.pm | 8 ++++++++ FS/FS/cust_pay.pm | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm index ff8a0cc27..a47cc8bc1 100644 --- a/FS/FS/Record.pm +++ b/FS/FS/Record.pm @@ -1847,6 +1847,9 @@ sub batch_import { my $file = $param->{file}; my $params = $param->{params} || {}; + my $custnum_prefix = $conf->config('cust_main-custnum-display_prefix'); + my $custnum_length = $conf->config('cust_main-custnum-display_length') || 8; + my( $type, $header, $sep_char, $fixedlength_format, $xml_format, $asn_format, $parser_opt, $row_callback, @fields ); @@ -2131,6 +2134,11 @@ sub batch_import { } + if ( $custnum_prefix && $hash{custnum} =~ /^$custnum_prefix(0*([1-9]\d*))$/ + && length($1) == $custnum_length ) { + $hash{custnum} = $2; + } + #my $table = $param->{table}; my $class = "FS::$table"; diff --git a/FS/FS/cust_pay.pm b/FS/FS/cust_pay.pm index b7189a80b..63d7c4835 100644 --- a/FS/FS/cust_pay.pm +++ b/FS/FS/cust_pay.pm @@ -1100,6 +1100,9 @@ sub batch_import { $_date = parse_datetime($_date) if $_date && $_date =~ /\D/; my $paybatch = $param->{'paybatch'}; + my $custnum_prefix = $conf->config('cust_main-custnum-display_prefix'); + my $custnum_length = $conf->config('cust_main-custnum-display_length') || 8; + # here is the agent virtualization my $extra_sql = ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql; @@ -1186,6 +1189,11 @@ sub batch_import { $cust_pay{$field} = shift @columns; } + if ( $custnum_prefix && $cust_pay{custnum} =~ /^$custnum_prefix(0*([1-9]\d*))$/ + && length($1) == $custnum_length ) { + $cust_pay{custnum} = $2; + } + my $cust_pay = new FS::cust_pay( \%cust_pay ); my $error = $cust_pay->insert; -- 2.11.0