}
if ( $self->censustract ) {
- $self->set('censusyear' => $conf->config('census_year') || 2012);
+ $self->set('censusyear' => $conf->config('census_legacy') || 2020);
}
my $oldAutoCommit = $FS::UID::AutoCommit;
return $error;
}
- #false laziness with cust_main, will go away eventually
- if ( !$import and $conf->config('tax_district_method') ) {
+ # If using tax_district_method, for rows in state of Washington,
+ # without a tax district already specified, queue a job to find
+ # the tax district
+ if (
+ !$import
+ && !$self->district
+ && lc $self->state eq 'wa'
+ && $conf->config('tax_district_method')
+ ) {
my $queue = new FS::queue {
'job' => 'FS::geocode_Mixin::process_district_update'
;
return $error if $error;
if ( $self->censustract ne '' ) {
- $self->censustract =~ /^\s*(\d{9})\.?(\d{2})\s*$/
- or return "Illegal census tract: ". $self->censustract;
-
- $self->censustract("$1.$2");
+ if ( $self->censustract =~ /^\s*(\d{9})\.?(\d{2})\s*$/ ) { #old
+ $self->censustract("$1.$2");
+ } elsif ($self->censustract =~ /^\s*(\d{15})\s*$/ ) { #new
+ $self->censustract($1);
+ } else {
+ return "Illegal census tract: ". $self->censustract;
+ }
}
#yikes... this is ancient, pre-dates cust_location and will be harder to
&& $conf->exists('prospect_main-alt_address_format')
&& ! $self->location_kind;
+ # Do not allow bad tax district values in cust_location when
+ # using Washington State district sales tax calculation - would result
+ # in incorrect or missing sales tax on invoices.
+ my $tax_district_method = FS::Conf->new->config('tax_district_method');
+ if (
+ $tax_district_method
+ && $tax_district_method eq 'wa_sales'
+ && $self->district
+ ) {
+ my $cust_main_county = qsearchs(
+ cust_main_county => { district => $self->district }
+ );
+ unless ( ref $cust_main_county ) {
+ return sprintf (
+ 'WA State tax district %s does not exist in tax table',
+ $self->district
+ );
+ }
+ }
+
unless ( $import or qsearch('cust_main_county', {
'country' => $self->country,
'state' => '',
qsearchs( 'cust_location', { locationnum => $locationnum })
or die "locationnum '$locationnum' not found!\n";
- my $new_year = $conf->config('census_year') or return;
+ my $new_year = $conf->config('census_legacy') || 2020;
my $loc = FS::GeocodeCache->new( $cust_location->location_hash );
$loc->set_censustract;
my $error = $loc->get('censustract_error');
die "$error (fixing whitespace in $field, locationnum ".$location->locationnum.')'
if $error;
- if ( $use_districts ) {
+ if (
+ $use_districts
+ && !$location->district
+ && lc $location->state eq 'wa'
+ ) {
my $queue = new FS::queue {
'job' => 'FS::geocode_Mixin::process_district_update'
};