X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Ftax_rate.pm;h=0d9156b4316d62b7127c296c878872aec4e76afd;hb=399e73ed1e73443523d6889b703d04289ec0e117;hp=d468e6031050cf6bae24a523da4d1b0062e2678b;hpb=9bfc701854c2bd6913d35d3f929d57656b6d2e08;p=freeside.git diff --git a/FS/FS/tax_rate.pm b/FS/FS/tax_rate.pm index d468e6031..0d9156b43 100644 --- a/FS/FS/tax_rate.pm +++ b/FS/FS/tax_rate.pm @@ -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;