X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpart_pkg_taxrate.pm;h=a7327204017aaa411125f50e56d5c477e461a65f;hb=48fc9f425ec3454f4346089318994ae6c1e080a8;hp=5a1e7baa990c297745b3ad2e0e9af61f3f7e845e;hpb=63a268637b2d51a8766412617724b9436439deb6;p=freeside.git diff --git a/FS/FS/part_pkg_taxrate.pm b/FS/FS/part_pkg_taxrate.pm index 5a1e7baa9..a73272040 100644 --- a/FS/FS/part_pkg_taxrate.pm +++ b/FS/FS/part_pkg_taxrate.pm @@ -5,8 +5,7 @@ use vars qw( @ISA ); use Date::Parse; use DateTime; use DateTime::Format::Strptime; -use FS::UID qw(dbh); -use FS::Record qw( qsearch qsearchs ); +use FS::Record qw( qsearch qsearchs dbh ); use FS::part_pkg_taxproduct; use FS::Misc qw(csv_from_fixed); @@ -292,17 +291,26 @@ sub batch_import { time_zone => 'floating', ); my $dt = $parser->parse_datetime( $hash->{'effdate'} ); - $hash->{'effdate'} = $dt ? $dt->epoch : ''; + return "Can't parse effdate ". $hash->{'effdate'}. ': '. $parser->errstr + unless $dt; + $hash->{'effdate'} = $dt->epoch; $hash->{'country'} = 'US'; # CA is available - delete($hash->{'taxable'}) if ($hash->{'taxable'} eq 'N'); + $hash->{'taxable'} = '' if ($hash->{'taxable'} eq 'N'); if (exists($hash->{actionflag}) && $hash->{actionflag} eq 'D') { delete($hash->{actionflag}); - my $part_pkg_taxrate = qsearchs('part_pkg_taxrate', $hash); - unless ( $part_pkg_taxrate ) { + foreach my $intfield (qw( taxproductnum taxclassnum effdate )) { + if ( $hash->{$intfield} eq '' ) { + return "$intfield is empty in search! -- ". + join(" ", map { "$_ => *". $hash->{$_}. '*' } keys(%$hash) ); + } + } + + my @part_pkg_taxrate = qsearch('part_pkg_taxrate', $hash); + unless ( scalar(@part_pkg_taxrate) || $param->{'delete_only'} ) { if ( $hash->{taxproductnum} ) { my $taxproduct = qsearchs( 'part_pkg_taxproduct', @@ -315,8 +323,10 @@ sub batch_import { join(" ", map { "$_ => *". $hash->{$_}. '*' } keys(%$hash) ); } - my $error = $part_pkg_taxrate->delete; - return $error if $error; + foreach my $part_pkg_taxrate (@part_pkg_taxrate) { + my $error = $part_pkg_taxrate->delete; + return $error if $error; + } delete($hash->{$_}) foreach (keys %$hash); } @@ -375,7 +385,7 @@ sub batch_import { } if ( scalar( @columns ) ) { $dbh->rollback if $oldAutoCommit; - return "Unexpected trailing columns in line (wrong format?): $line"; + return "Unexpected trailing columns in line (wrong format?) importing part_pkg_taxrate: $line"; } my $error = &{$hook}(\%part_pkg_taxrate);