[freeside-commits] branch FREESIDE_2_3_BRANCH updated. a156ba5a5fa5b9b98fa480543f61f74c6c638a83

Ivan ivan at 420.am
Wed May 8 02:55:58 PDT 2013


The branch, FREESIDE_2_3_BRANCH has been updated
       via  a156ba5a5fa5b9b98fa480543f61f74c6c638a83 (commit)
      from  972a6864dc38864bbe7705ef860560e257d4d7a7 (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 a156ba5a5fa5b9b98fa480543f61f74c6c638a83
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Wed May 8 02:55:56 2013 -0700

    fix CCH update adding a TAXCAT, RT#21687

diff --git a/FS/FS/tax_class.pm b/FS/FS/tax_class.pm
index eeb8993..15f9a42 100644
--- a/FS/FS/tax_class.pm
+++ b/FS/FS/tax_class.pm
@@ -253,21 +253,28 @@ sub batch_import {
             }
           }
 
-          my $tax_class =
-            new FS::tax_class( { 'data_vendor' => 'cch',
-                                 'taxclass'    => $type->[0].':'.$cat->[0],
-                                 'description' => $type->[1].':'.$cat->[1],
-                             } );
-          my $error = $tax_class->insert;
-          return "can't insert tax_class for old TAXTYPE $type and new TAXCAT $cat: $error" if $error;
+          my %hash = ( 'data_vendor' => 'cch',
+                       'taxclass'    => $type->[0].':'.$cat->[0],
+                       'description' => $type->[1].':'.$cat->[1],
+                     );
+          unless ( qsearchs('tax_class', \%hash) ) {
+            my $tax_class = new FS::tax_class \%hash;
+            my $error = $tax_class->insert;
+
+            return "can't insert tax_class for ".
+                   " old TAXTYPE ". $type->[0].':'.$type->[1].
+                   " and new TAXCAT ". $cat->[0].':'. $cat->[1].
+                   " : $error"
+              if $error;
+          }
+
           $imported++;
+          
         }
       }
 
-      my %cats = map { $_=>1 } ( @old_cats, @{$data->{'taxcat'}} );
-
       foreach my $type (@{$data->{'taxtype'}}) {
-        foreach my $cat (keys %cats) {
+        foreach my $cat (@old_cats, @{$data->{'taxcat'}}) {
 
           if ( $job ) {  # progress bar
             if ( time - $min_sec > $last ) {

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

Summary of changes:
 FS/FS/tax_class.pm |   27 +++++++++++++++++----------
 1 files changed, 17 insertions(+), 10 deletions(-)




More information about the freeside-commits mailing list