NG auth: autocreate records for external users, RT#21563
[freeside.git] / FS / FS / tax_class.pm
index 15f9a42..bfec2c0 100644 (file)
@@ -253,23 +253,14 @@ sub batch_import {
             }
           }
 
-          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;
-          }
-
+          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 $error if $error;
           $imported++;
-          
         }
       }
 
@@ -292,7 +283,7 @@ sub batch_import {
                                  'description' => $type->[1].':'.$cat->[1],
                              } );
           my $error = $tax_class->insert;
-          return "can't insert tax_class for new TAXTYPE $type and TAXCAT $cat: $error" if $error;
+          return $error if $error;
           $imported++;
         }
       }
@@ -372,7 +363,7 @@ sub batch_import {
   my $error = &{$endhook}();
   if ( $error ) {
     $dbh->rollback if $oldAutoCommit;
-    return "can't run end hook: $error";
+    return "can't insert tax_class for $line: $error";
   }
 
   $dbh->commit or die $dbh->errstr if $oldAutoCommit;