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 --- FS/FS/Conf.pm | 18 +++++++++++------- FS/FS/Upgrade.pm | 10 ++++++++++ FS/FS/cust_main.pm | 11 ++++++----- 3 files changed, 27 insertions(+), 12 deletions(-) (limited to 'FS') diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index 37adffb36..c588493aa 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -3067,6 +3067,17 @@ and customer address. Include units.', 'type' => 'checkbox', }, + { + 'key' => 'echeck-country', + 'section' => 'billing', + 'description' => 'Format electronic check information for the specified country.', + 'type' => 'select', + 'select_hash' => [ 'US' => 'United States', + 'CA' => 'Canada (enables branch)', + 'XX' => 'Other', + ], + }, + { 'key' => 'voip-cust_accountcode_cdr', 'section' => 'telephony', @@ -4716,13 +4727,6 @@ and customer address. Include units.', 'type' => 'checkbox', }, - { - 'key' => 'cust_main-require-bank-branch', - 'section' => 'UI', - 'description' => 'An alternate DCHK/CHEK format; require entry of bank branch number.', - 'type' => 'checkbox', - }, - { 'key' => 'cust-edit-alt-field-order', 'section' => 'UI', diff --git a/FS/FS/Upgrade.pm b/FS/FS/Upgrade.pm index 3134b8c61..cf6158031 100644 --- a/FS/FS/Upgrade.pm +++ b/FS/FS/Upgrade.pm @@ -50,6 +50,16 @@ sub upgrade_config { $conf->touch('geocode-require_nw_coordinates') if $conf->exists('svc_broadband-require-nw-coordinates'); + unless ( $conf->config('echeck-country') ) { + if ( $conf->exists('cust_main-require-bank-branch') ) { + $conf->set('echeck-country', 'CA'); + } elsif ( $conf->exists('echeck-nonus') ) { + $conf->set('echeck-country', 'XX'); + } else { + $conf->set('echeck-country', 'US'); + } + } + upgrade_overlimit_groups($conf); map { upgrade_overlimit_groups($conf,$_->agentnum) } qsearch('agent', {}); diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index eaf70cf64..3b572fad7 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -2032,14 +2032,15 @@ sub check { my $payinfo = $self->payinfo; $payinfo =~ s/[^\d\@\.]//g; - if ( $conf->exists('cust_main-require-bank-branch') ) { - $payinfo =~ /^(\d+)\@(\d+)\.(\d+)$/ or return 'invalid echeck account@branch.bank'; + if ( $conf->config('echeck-country') eq 'CA' ) { + $payinfo =~ /^(\d+)\@(\d{5})\.(\d{3})$/ + or return 'invalid echeck account@branch.bank'; $payinfo = "$1\@$2.$3"; - } elsif ( $conf->exists('echeck-nonus') ) { - $payinfo =~ /^(\d+)\@(\d+)$/ or return 'invalid echeck account@aba'; + } elsif ( $conf->config('echeck-country') eq 'US' ) { + $payinfo =~ /^(\d+)\@(\d{9})$/ or return 'invalid echeck account@aba'; $payinfo = "$1\@$2"; } else { - $payinfo =~ /^(\d+)\@(\d{9})$/ or return 'invalid echeck account@aba'; + $payinfo =~ /^(\d+)\@(\d+)$/ or return 'invalid echeck account@routing'; $payinfo = "$1\@$2"; } $self->payinfo($payinfo); -- cgit v1.2.1