remove useless line
[freeside.git] / FS / FS / tax_rate.pm
index d468e60..0d9156b 100644 (file)
@@ -560,9 +560,11 @@ sub batch_import {
                             /^(\d{4})(\d{2})(\d{2})$/ && ($r="$1/$2/$3");
                             $r;
                           };
-    $column_callbacks[8] = $date_format;
+    my $trim = sub { my $r = shift; $r =~ s/^\s*//; $r =~ s/\s*$//; $r };
     push @column_lengths, qw( 10 1 1 8 8 5 8 8 8 1 2 2 30 8 8 10 2 8 2 1 2 2 );
     push @column_lengths, 1 if $format eq 'cch-update';
+    push @column_callbacks, $trim foreach (@column_lengths); # 5, 6, 15, 17 esp
+    $column_callbacks[8] = $date_format;
   }
   
   my $line;
@@ -913,10 +915,12 @@ sub process_batch_import {
                                 UNLINK   => 0,     #meh
                               ) or die "can't open temp file: $!\n";
 
+      my $insert_pattern = ($format eq 'cch-update') ? qr/"I"\s*$/ : qr/I\s*$/;
+      my $delete_pattern = ($format eq 'cch-update') ? qr/"D"\s*$/ : qr/D\s*$/;
       while(<$fh>) {
         my $handle = '';
-        $handle = $ifh if $_ =~ /"I"\s*$/;
-        $handle = $dfh if $_ =~ /"D"\s*$/;
+        $handle = $ifh if $_ =~ /$insert_pattern/;
+        $handle = $dfh if $_ =~ /$delete_pattern/;
         unless ($handle) {
           $error = "bad input line: $_" unless $handle;
           last;