X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_main.pm;h=dbb0144ff7b194ccf9769d422d34aaaeddb2083a;hb=7965de6cbd9f9795acc5fc27d6597a5ce63f6434;hp=687e3114bc9ed512deecc0e232649f777f914278;hpb=08fe29390989d98c5247e86416a5a73a241f9522;p=freeside.git diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index 687e3114b..dbb0144ff 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -609,6 +609,20 @@ sub insert { } } + # FS::geocode_Mixin::after_insert or something? + if ( $conf->config('tax_district_method') and !$import ) { + # if anything non-empty, try to look it up + my $queue = new FS::queue { + 'job' => 'FS::geocode_Mixin::process_district_update', + 'custnum' => $self->custnum, + }; + my $error = $queue->insert( ref($self), $self->custnum ); + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return "queueing tax district update: $error"; + } + } + # cust_main exports! warn " exporting\n" if $DEBUG > 1; @@ -1633,6 +1647,25 @@ sub replace { } } + # FS::geocode_Mixin::after_replace ? + # though this will go away anyway once we move customer bill/service + # locations into cust_location + # We can trigger this on any address change--just have to make sure + # not to trigger it on itself. + if ( $conf->config('tax_district_method') and !$import + and ( $self->get('ship_address1') ne $old->get('ship_address1') + or $self->get('address1') ne $old->get('address1') ) ) { + my $queue = new FS::queue { + 'job' => 'FS::geocode_Mixin::process_district_update', + 'custnum' => $self->custnum, + }; + my $error = $queue->insert( ref($self), $self->custnum ); + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return "queueing tax district update: $error"; + } + } + # cust_main exports! my $export_args = $options{'export_args'} || []; @@ -1739,6 +1772,7 @@ sub check { || $self->ut_textn('stateid_state') || $self->ut_textn('invoice_terms') || $self->ut_alphan('geocode') + || $self->ut_alphan('district') || $self->ut_floatn('cdr_termination_percentage') || $self->ut_floatn('credit_limit') || $self->ut_numbern('billday') @@ -1998,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); @@ -2143,8 +2178,9 @@ sub has_ship_address { =item location_hash -Returns a list of key/value pairs, with the following keys: address1, adddress2, -city, county, state, zip, country, and geocode. The shipping address is used if present. +Returns a list of key/value pairs, with the following keys: address1, +adddress2, city, county, state, zip, country, district, and geocode. The +shipping address is used if present. =cut @@ -5000,6 +5036,8 @@ sub process_censustract_update { # then it's a tract code $cust_main->set('censustract', $new_tract); $cust_main->set('censusyear', $new_year); + + local($import) = 1; #prevent automatic geocoding (need its own variable?) my $error = $cust_main->replace; die $error if $error; } @@ -5027,6 +5065,10 @@ sub _upgrade_data { #class method "UPDATE cust_main SET paydate = SUBSTRING(paydate FROM 1 FOR 5) || '0' || SUBSTRING(paydate FROM 6) WHERE SUBSTRING(paydate FROM 7 FOR 1) = '-'"; } + push @statements, #fix the weird BILL with a cc# in payinfo problem + #DCRD to be safe, or CARD? + "UPDATE cust_main SET payby = 'DCRD' WHERE payby = 'BILL' and length(payinfo) = 16"; + foreach my $sql ( @statements ) { my $sth = dbh->prepare($sql) or die dbh->errstr; $sth->execute or die $sth->errstr;