diff options
author | Mark Wells <mark@freeside.biz> | 2016-11-16 14:07:57 -0800 |
---|---|---|
committer | Mark Wells <mark@freeside.biz> | 2016-11-16 14:11:53 -0800 |
commit | 1be5a5bf99a52edd36ea8bade4786b9d082f557d (patch) | |
tree | 539f02a7495bac7987f6cddf939e7389ad4e77e1 /FS/FS/geocode_Mixin.pm | |
parent | 4c4689fcc39ce5829a48aec2cd60bf4efdc827bc (diff) |
lock table for tax district updates, #73185
Diffstat (limited to 'FS/FS/geocode_Mixin.pm')
-rw-r--r-- | FS/FS/geocode_Mixin.pm | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/FS/FS/geocode_Mixin.pm b/FS/FS/geocode_Mixin.pm index 46f8128..ef16e74 100644 --- a/FS/FS/geocode_Mixin.pm +++ b/FS/FS/geocode_Mixin.pm @@ -260,6 +260,7 @@ sub process_district_update { die $@ if $@; die "$class has no location data" if !$class->can('location_hash'); + my $error; my $conf = FS::Conf->new; my $method = $conf->config('tax_district_method') or return; #nothing to do if null @@ -269,9 +270,11 @@ sub process_district_update { my $tax_info = get_district({ $self->location_hash }, $method); return unless $tax_info; - $self->set('district', $tax_info->{'district'} ); - my $error = $self->replace; - die $error if $error; + if ($self->district ne $tax_info->{'district'}) { + $self->set('district', $tax_info->{'district'} ); + $error = $self->replace; + die $error if $error; + } my %hash = map { $_ => uc( $tax_info->{$_} ) } qw( district city county state country ); @@ -281,6 +284,9 @@ sub process_district_update { my $taxname = $conf->config('tax_district_taxname'); # there must be exactly one cust_main_county for each district+taxclass. # do NOT exclude taxes that are zero. + + # mutex here so that concurrent queue jobs can't make duplicates. + FS::cust_main_county->lock_table; foreach my $taxclass (@classes) { my @existing = qsearch('cust_main_county', { %hash, |