X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fgeocode_Mixin.pm;h=b999be0abc30c0921562c0a9d022bbf747de0f67;hb=7c5f50804027577aac17d0fcefedcd0d0b6ca180;hp=46f8128aac2ede5a7e0bc727c8c15ff04ba00e81;hpb=dc4e882662ac72279c008d47903a3978cf227f72;p=freeside.git diff --git a/FS/FS/geocode_Mixin.pm b/FS/FS/geocode_Mixin.pm index 46f8128aa..b999be0ab 100644 --- a/FS/FS/geocode_Mixin.pm +++ b/FS/FS/geocode_Mixin.pm @@ -260,18 +260,22 @@ 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 my $self = $class->by_key($id) or die "object $id not found"; + return if $self->disabled; # dies on error, fine 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 +285,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,