[freeside-commits] branch FREESIDE_4_BRANCH updated. 28653a47f8288302d2121b80a60f3375f99fa481

Ivan ivan at 420.am
Fri Sep 22 10:26:30 PDT 2017


The branch, FREESIDE_4_BRANCH has been updated
       via  28653a47f8288302d2121b80a60f3375f99fa481 (commit)
      from  11b7e1145d378aea6180d110becb23219350d397 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 28653a47f8288302d2121b80a60f3375f99fa481
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Fri Sep 22 10:26:29 2017 -0700

    compliance solutions, RT#77676

diff --git a/FS/FS/tax_rate_location.pm b/FS/FS/tax_rate_location.pm
index 0377a7d..ad3618a 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

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/tax_rate_location.pm |   34 ++++++++++++++++++----------------
 1 file changed, 18 insertions(+), 16 deletions(-)




More information about the freeside-commits mailing list