diff options
author | Mark Wells <mark@freeside.biz> | 2013-06-05 23:12:30 -0700 |
---|---|---|
committer | Mark Wells <mark@freeside.biz> | 2013-06-05 23:12:30 -0700 |
commit | 1271e8451691de07d167402e93ebde8efd902c84 (patch) | |
tree | f8618ff49b2096fb7b4437762e775f962665b6a8 /FS/FS/cust_location.pm | |
parent | 1ef5e596e2dfefb42ae0066b621bf0d66fc03193 (diff) |
freeside-censustract-update + cust_location, #23422
Diffstat (limited to 'FS/FS/cust_location.pm')
-rw-r--r-- | FS/FS/cust_location.pm | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/FS/FS/cust_location.pm b/FS/FS/cust_location.pm index d772dab..a834859 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 |