From 074464a707b2c8b83cc50cd0bb067660ef4d0f9f Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 14 Jan 2012 07:05:18 +0000 Subject: improve echeck validation for canada, deprecate echeck-nonus and cust_main-require-bank-branch config in favor of echeck-country, RT#15982 --- httemplate/edit/cust_main/billing.html | 18 +++++++++++++----- httemplate/edit/process/cust_main.cgi | 2 +- httemplate/misc/payment.cgi | 17 ++++++++++++----- httemplate/misc/process/payment.cgi | 4 ++-- httemplate/view/cust_main/billing.html | 11 ++++++++--- 5 files changed, 36 insertions(+), 16 deletions(-) (limited to 'httemplate') diff --git a/httemplate/edit/cust_main/billing.html b/httemplate/edit/cust_main/billing.html index fd078c5da..78fac6c22 100644 --- a/httemplate/edit/cust_main/billing.html +++ b/httemplate/edit/cust_main/billing.html @@ -127,7 +127,7 @@ % my( $account, $aba ) = split('@', $payinfo); % my $branch = ''; % ($branch,$aba) = split('\.',$aba) -% if $conf->exists('cust_main-require-bank-branch'); +% if $conf->config('echeck-country') eq 'CA'; % % my $disabled = 'DISABLED style="background-color: #dddddd"'; % my $text_disabled = 'style="color: #999999"'; @@ -161,6 +161,14 @@ % my $card_billday_select_disabled = $payby eq 'CARD' ? '' : 'DISABLED'; % my $chek_billday_select_disabled = $payby eq 'CHEK' ? '' : 'DISABLED'; % +% #false laziness w/view/cust_main/billing.html and misc/payment.cgi +% my $routing_label = $conf->config('echeck-country') eq 'US' +% ? 'ABA/Routing number' +% : 'Routing number'; +% my $routing_size = $conf->config('echeck-country') eq 'CA' ? 4 : 10; +% my $routing_maxlength = $conf->config('echeck-country') eq 'CA' ? 3 : 9; +% +% % my %payby = ( % % 'CARD' => @@ -235,17 +243,17 @@ % join('', map { qq!" } @FS::cust_main::paytypes). % qq!!. % -% qq!${r}!.emt('ABA/Routing number').qq! !. -% qq! !. +% qq!${r}!.emt($routing_label).qq! !. +% qq! !. % qq!(!.emt('help').qq!)!. % qq!!. % % qq!!. % qq!!. % -% ( $conf->exists('cust_main-require-bank-branch') ? +% ( $conf->config('echeck-country') eq 'CA' ? % qq!$r !.emt('Branch number').qq! -% ! : '' ). +% ! : '' ). % % qq!${r}!.emt('Bank name').qq! !. % qq!!. diff --git a/httemplate/edit/process/cust_main.cgi b/httemplate/edit/process/cust_main.cgi index df6cec9df..f75e2a6ae 100755 --- a/httemplate/edit/process/cust_main.cgi +++ b/httemplate/edit/process/cust_main.cgi @@ -44,7 +44,7 @@ if ( $payby ) { if ( $payby eq 'CHEK' || $payby eq 'DCHK' ) { my $payinfo = $cgi->param('payinfo1'). '@'; $payinfo .= $cgi->param('payinfo3').'.' - if $conf->exists('cust_main-require-bank-branch'); + if $conf->config('echeck-country') eq 'CA'; $payinfo .= $cgi->param('payinfo2'); $cgi->param('payinfo',$payinfo); } diff --git a/httemplate/misc/payment.cgi b/httemplate/misc/payment.cgi index 4a867d28d..093494a06 100644 --- a/httemplate/misc/payment.cgi +++ b/httemplate/misc/payment.cgi @@ -140,7 +140,7 @@ % or die "unparsable payinfo ". $cust_main->payinfo; % ($account, $aba) = ($1, $2); % ($branch,$aba) = split('\.',$aba) -% if $conf->exists('cust_main-require-bank-branch'); +% if $conf->config('echeck-country') eq 'CA'; % $payname = $cust_main->payname; % $ss = $cust_main->ss; % $paytype = $cust_main->getfield('paytype'); @@ -148,6 +148,13 @@ % $stateid = $cust_main->getfield('stateid'); % $stateid_state = $cust_main->getfield('stateid_state'); % } +% +% #false laziness w/{edit,view}/cust_main/billing.html +% my $routing_label = $conf->config('echeck-country') eq 'US' +% ? 'ABA/Routing number' +% : 'Routing number'; +% my $routing_size = $conf->config('echeck-country') eq 'CA' ? 4 : 10; +% my $routing_maxlength = $conf->config('echeck-country') eq 'CA' ? 3 : 9; @@ -158,17 +165,17 @@ - <% mt('ABA/Routing number') |h %> + <% mt($routing_label) |h %> - + (<% mt('help') |h %>) -% if ( $conf->exists('cust_main-require-bank-branch') ) { +% if ( $conf->config('echeck-country') eq 'CA' ) { <% mt('Branch number') |h %> - + % } diff --git a/httemplate/misc/process/payment.cgi b/httemplate/misc/process/payment.cgi index f4f9561dc..506e26684 100644 --- a/httemplate/misc/process/payment.cgi +++ b/httemplate/misc/process/payment.cgi @@ -86,8 +86,8 @@ if ( $payby eq 'CHEK' ) { $cgi->param('payinfo2') =~ /^(\d+)$/ or errorpage("Illegal ABA/routing number ". $cgi->param('payinfo2')); my $payinfo2 = $1; - if ( $conf->exists('cust_main-require-bank-branch') ) { - $cgi->param('payinfo3') =~ /^(\d+)$/ + if ( $conf->config('echeck-country') eq 'CA' ) { + $cgi->param('payinfo3') =~ /^(\d{5})$/ or errorpage("Illegal branch number ". $cgi->param('payinfo2')); $payinfo2 = "$1.$payinfo2"; } diff --git a/httemplate/view/cust_main/billing.html b/httemplate/view/cust_main/billing.html index 6e36e99e8..f1add6fcc 100644 --- a/httemplate/view/cust_main/billing.html +++ b/httemplate/view/cust_main/billing.html @@ -85,7 +85,7 @@ % } elsif ( $cust_main->payby eq 'CHEK' || $cust_main->payby eq 'DCHK') { % my( $account, $aba ) = split('@', $cust_main->paymask ); % my $branch = ''; -% ($branch,$aba) = split('\.',$aba) if $conf->exists('cust_main-require-bank-branch'); +% ($branch,$aba) = split('\.',$aba) if $conf->config('echeck-country') eq 'CA'; % my $autodemand = $cust_main->payby eq 'CHEK' ? 'automatic' : 'on-demand'; @@ -93,12 +93,17 @@ +% #false laziness w/edit/cust_main/billing.html and misc/payment.cgi +% my $routing_label = $conf->config('echeck-country') eq 'US' +% ? 'ABA/Routing number' +% : 'Routing number'; + - <% mt('ABA/Routing code') |h %> + <% mt($routing_label) |h %> <% $aba %> -% if ( $conf->exists('cust_main-require-bank-branch') ) { +% if ( $conf->config('echeck-country') eq 'CA' ) { <% mt('Branch number') |h %> <% $branch %> -- cgit v1.2.1