diff options
author | Ivan Kohler <ivan@freeside.biz> | 2013-06-06 11:34:11 -0700 |
---|---|---|
committer | Ivan Kohler <ivan@freeside.biz> | 2013-06-06 11:34:11 -0700 |
commit | b6f044c11390e856caff9996e8c052e3086a482b (patch) | |
tree | 90a38dd5859bc15ea41c1a42af2c8d5667b56d67 /FS/FS | |
parent | 8f90756a88b7326dc01bfc9b6d73958e65f84629 (diff) | |
parent | 3db6956f45d19e9f5d8704a2b3bd75bbd6f97947 (diff) |
Merge branch 'FREESIDE_3_BRANCH' of git.freeside.biz:/home/git/freeside into FREESIDE_3_BRANCH
Diffstat (limited to 'FS/FS')
-rw-r--r-- | FS/FS/cust_location.pm | 35 | ||||
-rw-r--r-- | FS/FS/cust_main.pm | 36 | ||||
-rw-r--r-- | FS/FS/h_cust_location.pm | 26 |
3 files changed, 61 insertions, 36 deletions
diff --git a/FS/FS/cust_location.pm b/FS/FS/cust_location.pm index d772dab08..a834859ba 100644 --- a/FS/FS/cust_location.pm +++ b/FS/FS/cust_location.pm @@ -643,6 +643,41 @@ sub in_county_sql { } } +=back + +=head2 SUBROUTINES + +=over 4 + +=item process_censustract_update LOCATIONNUM + +Queueable function to update the census tract to the current year (as set in +the 'census_year' configuration variable) and retrieve the new tract code. + +=cut + +sub process_censustract_update { + eval "use FS::GeocodeCache"; + die $@ if $@; + my $locationnum = shift; + my $cust_location = + qsearchs( 'cust_location', { locationnum => $locationnum }) + or die "locationnum '$locationnum' not found!\n"; + + my $conf = FS::Conf->new; + my $new_year = $conf->config('census_year') or return; + my $loc = FS::GeocodeCache->new( $cust_location->location_hash ); + $loc->set_censustract; + my $error = $loc->get('censustract_error'); + die $error if $error; + $cust_location->set('censustract', $loc->get('censustract')); + $cust_location->set('censusyear', $new_year); + $error = $cust_location->replace; + die $error if $error; + return; +} + + sub process_set_coord { my $job = shift; # avoid starting multiple instances of this job diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index f21932cf6..8bb1a3515 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -5017,42 +5017,6 @@ sub process_bill_and_collect { $cust_main->bill_and_collect( %$param ); } -=item process_censustract_update CUSTNUM - -Queueable function to update the census tract to the current year (as set in -the 'census_year' configuration variable) and retrieve the new tract code. - -=cut - -sub process_censustract_update { - eval "use FS::Misc::Geo qw(get_censustract)"; - die $@ if $@; - my $custnum = shift; - my $cust_main = qsearchs( 'cust_main', { custnum => $custnum }) - or die "custnum '$custnum' not found!\n"; - - my $new_year = $conf->config('census_year') or return; - my $new_tract = get_censustract({ $cust_main->location_hash }, $new_year); - if ( $new_tract =~ /^\d/ ) { - # then it's a tract code - $cust_main->set('censustract', $new_tract); - $cust_main->set('censusyear', $new_year); - - local($ignore_expired_card) = 1; - local($ignore_illegal_zip) = 1; - local($ignore_banned_card) = 1; - local($skip_fuzzyfiles) = 1; - local($import) = 1; #prevent automatic geocoding (need its own variable?) - my $error = $cust_main->replace; - die $error if $error; - } - else { - # it's an error message - die $new_tract; - } - return; -} - #starting to take quite a while for big dbs # (JRNL: journaled so it only happens once per database) # - seq scan of h_cust_main (yuck), but not going to index paycvv, so diff --git a/FS/FS/h_cust_location.pm b/FS/FS/h_cust_location.pm new file mode 100644 index 000000000..fc3a93061 --- /dev/null +++ b/FS/FS/h_cust_location.pm @@ -0,0 +1,26 @@ +package FS::h_cust_location; + +use strict; +use base qw( FS::h_Common FS::cust_location ); + +sub table { 'h_cust_location' }; + +=head1 NAME + +FS::h_cust_location - Historical customer location records. + +=head1 DESCRIPTION + +An FS::h_cust_location object represents historical changes to a customer +location record. These records normally don't change, so this isn't +terribly useful. + +=head1 SEE ALSO + +L<FS::cust_location>, L<FS::h_Common>, L<FS::Record>, schema.html from the +base documentation. + +=cut + +1; + |