eliminate Argument "" isn't numeric in addition (+) warning
[freeside.git] / FS / FS / part_pkg_taxrate.pm
index 1563621..bc1047e 100644 (file)
@@ -244,12 +244,12 @@ sub batch_import {
       unless ($part_pkg_taxproduct) {
         return "Can't find part_pkg_taxproduct for txmatrix deletion: ".
                join(" ", map { "$_ => ". $hash->{$_} } @fields)
-          if $hash->{'actionflag'} eq 'D';
+          if ($hash->{'actionfield'} && $hash->{'actionflag'} eq 'D');
 
         $part_pkg_taxproduct{'description'} = 
           join(' : ', (map{ $hash->{$_} } qw(groupdesc itemdesc)),
-                      $providers{$hash->{'provider'}},
-                      $customers{$hash->{'customer'}},
+                      $providers{$hash->{'provider'}} || '',
+                      $customers{$hash->{'customer'}} || '',
               );
         $part_pkg_taxproduct = new FS::part_pkg_taxproduct \%part_pkg_taxproduct;
         my $error = $part_pkg_taxproduct->insert;
@@ -279,7 +279,9 @@ sub batch_import {
 
         return "Can't find tax class for txmatrix deletion: ".
                join(" ", map { "$_ => ". $hash->{$_} } @fields)
-          if ($hash->{'actionflag'} eq 'D' && !$tax_class && $class ne ':');
+          if ( $hash->{'actionflag'} && $hash->{'actionflag'} eq 'D' &&
+               !$tax_class && $class ne ':'
+             );
 
         delete($hash->{$_}) foreach @{$map{$item}};
       }
@@ -293,10 +295,18 @@ sub batch_import {
         delete($hash->{actionflag});
 
         my $part_pkg_taxrate = qsearchs('part_pkg_taxrate', $hash);
-        return "Can't find part_pkg_taxrate to delete: ".
-               #join(" ", map { "$_ => ". $hash->{$_} } @fields)
-               join(" ", map { "$_ => *". $hash->{$_}. '*' } keys(%$hash) )
-          unless $part_pkg_taxrate;
+        unless ( $part_pkg_taxrate ) {
+          if ( $hash->{taxproductnum} ) {
+            my $taxproduct =
+              qsearchs( 'part_pkg_taxproduct',
+                        { 'taxproductnum' => $hash->{taxproductnum} }
+                      );
+            $hash->{taxproductnum} .= ' ( '. $taxproduct->taxproduct. ' )'
+              if $taxproduct;
+          }
+          return "Can't find part_pkg_taxrate to delete: ".
+                 join(" ", map { "$_ => *". $hash->{$_}. '*' } keys(%$hash) );
+        }
 
         my $error = $part_pkg_taxrate->delete;
         return $error if $error;
@@ -343,7 +353,7 @@ sub batch_import {
     if ( $job ) {  # progress bar
       if ( time - $min_sec > $last ) {
         my $error = $job->update_statustext(
-          int( 100 * $imported / $count )
+          int( 100 * $imported / $count ). ",Importing tax matrix"
         );
         die $error if $error;
         $last = time;
@@ -382,7 +392,7 @@ sub batch_import {
 
   $dbh->commit or die $dbh->errstr if $oldAutoCommit;
 
-  return "Empty file!" unless $imported;
+  return "Empty file!" unless ( $imported || $format eq 'cch-update' );
 
   ''; #no error