this should fix credits pushing typeset invoices off the right
[freeside.git] / FS / FS / part_pkg_taxrate.pm
index 9e1c723..aaf7f60 100644 (file)
@@ -248,8 +248,8 @@ sub batch_import {
 
         $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;
@@ -295,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;
@@ -384,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