summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2017-09-22 10:26:25 -0700
committerIvan Kohler <ivan@freeside.biz>2017-09-22 10:26:25 -0700
commit5f7c4a6025b9e3a49bee72dbc06cac37a45e6f10 (patch)
tree4fc7ed33fa616ce8d33a9e16ed88980c2f75470e
parent147c94865852a93bf192ef15e931e456d487b69b (diff)
compliance solutions, RT#77676
-rw-r--r--FS/FS/tax_rate_location.pm34
1 files changed, 18 insertions, 16 deletions
diff --git a/FS/FS/tax_rate_location.pm b/FS/FS/tax_rate_location.pm
index 0377a7d04..ad3618a98 100644
--- a/FS/FS/tax_rate_location.pm
+++ b/FS/FS/tax_rate_location.pm
@@ -118,20 +118,12 @@ sub check {
;
return $error if $error;
- my @unique = qw( data_vendor geocode );
- push @unique, qw( state country )
- if $self->data_vendor eq 'compliance_solutions';
-
- my $t;
- $t = qsearchs( 'tax_rate_location',
- { disabled => '',
- ( map { $_ => $self->$_ } @unique ),
- },
- )
+ my $t = '';
+ $t = $self->existing_search
unless $self->disabled;
$t = $self->by_key( $self->taxratelocationnum )
- if ( !$t && $self->taxratelocationnum );
+ if !$t && $self->taxratelocationnum;
return "geocode ". $self->geocode. " already in use for this vendor"
if ( $t && $t->taxratelocationnum != $self->taxratelocationnum );
@@ -157,11 +149,7 @@ record.
sub find_or_insert {
my $self = shift;
- my $existing = qsearchs('tax_rate_location', {
- disabled => '',
- data_vendor => $self->data_vendor,
- geocode => $self->geocode
- });
+ my $existing = $self->existing_search;
if ($existing) {
my $update = 0;
foreach (qw(city county state country)) {
@@ -180,6 +168,20 @@ sub find_or_insert {
}
}
+sub existing_search {
+ my $self = shift;
+
+ my @unique = qw( data_vendor geocode );
+ push @unique, qw( state country )
+ if $self->data_vendor eq 'compliance_solutions';
+
+ qsearchs( 'tax_rate_location',
+ { disabled => '',
+ map { $_ => $self->$_ } @unique
+ }
+ );
+}
+
=back
=head1 CLASS METHODS