summaryrefslogtreecommitdiff
path: root/FS/FS/tax_class.pm
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2013-05-08 03:52:42 -0700
committerIvan Kohler <ivan@freeside.biz>2013-05-08 03:52:42 -0700
commitbee0671782e7a40961cf406cd7a10675fed6b3ba (patch)
tree55151e662f43caa30762fe702308713a49dc71b4 /FS/FS/tax_class.pm
parent57a9a48d9a56255a3a05821c0090acac6c1f0336 (diff)
debug CCH update adding a tax class, RT#21687
Diffstat (limited to 'FS/FS/tax_class.pm')
-rw-r--r--FS/FS/tax_class.pm31
1 files changed, 21 insertions, 10 deletions
diff --git a/FS/FS/tax_class.pm b/FS/FS/tax_class.pm
index bfec2c0..c8fe889 100644
--- a/FS/FS/tax_class.pm
+++ b/FS/FS/tax_class.pm
@@ -169,7 +169,8 @@ sub batch_import {
$hook = sub {
my $hash = shift;
-
+use Data::Dumper;
+warn Dumper($hash);
if ($hash->{'table'} eq 'DETAIL') {
push @{$data->{'taxcat'}}, [ $hash->{'value'}, $hash->{'description'} ]
if ($hash->{'name'} eq 'TAXCAT' &&
@@ -194,6 +195,7 @@ sub batch_import {
($name eq 'TAXCAT' ? $value : '%')."'",
);
foreach (@tax_class) {
+warn "deleting ". $_->taxclass. ' '. $_->description. "\n";
my $error = $_->delete;
return $error if $error;
}
@@ -253,14 +255,23 @@ sub batch_import {
}
}
- my $tax_class =
- new FS::tax_class( { 'data_vendor' => 'cch',
- 'taxclass' => $type->[0].':'.$cat->[0],
- 'description' => $type->[1].':'.$cat->[1],
- } );
- my $error = $tax_class->insert;
- return $error if $error;
+ my %hash = ( 'data_vendor' => 'cch',
+ 'taxclass' => $type->[0].':'.$cat->[0],
+ 'description' => $type->[1].':'.$cat->[1],
+ );
+ unless ( qsearchs('tax_class', \%hash) ) {
+ my $tax_class = new FS::tax_class \%hash;
+ my $error = $tax_class->insert;
+
+ return "can't insert tax_class for ".
+ " old TAXTYPE ". $type->[0].':'.$type->[1].
+ " and new TAXCAT ". $cat->[0].':'. $cat->[1].
+ " : $error"
+ if $error;
+ }
+
$imported++;
+
}
}
@@ -283,7 +294,7 @@ sub batch_import {
'description' => $type->[1].':'.$cat->[1],
} );
my $error = $tax_class->insert;
- return $error if $error;
+ return "can't insert tax_class for new TAXTYPE $type and TAXCAT $cat: $error" if $error;
$imported++;
}
}
@@ -363,7 +374,7 @@ sub batch_import {
my $error = &{$endhook}();
if ( $error ) {
$dbh->rollback if $oldAutoCommit;
- return "can't insert tax_class for $line: $error";
+ return "can't run end hook: $error";
}
$dbh->commit or die $dbh->errstr if $oldAutoCommit;