projects
/
freeside.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
bug squashing for multiple usage classes
[freeside.git]
/
FS
/
FS
/
tax_rate.pm
diff --git
a/FS/FS/tax_rate.pm
b/FS/FS/tax_rate.pm
index
0601032
..
bfb9c8c
100644
(file)
--- a/
FS/FS/tax_rate.pm
+++ b/
FS/FS/tax_rate.pm
@@
-199,7
+199,7
@@
sub check {
|| $self->ut_textn('data_vendor')
|| $self->ut_textn('location')
|| $self->ut_foreign_key('taxclassnum', 'tax_class', 'taxclassnum')
|| $self->ut_textn('data_vendor')
|| $self->ut_textn('location')
|| $self->ut_foreign_key('taxclassnum', 'tax_class', 'taxclassnum')
- || $self->ut_numbern('effective_date')
+ || $self->ut_
s
numbern('effective_date')
|| $self->ut_float('tax')
|| $self->ut_floatn('excessrate')
|| $self->ut_money('taxbase')
|| $self->ut_float('tax')
|| $self->ut_floatn('excessrate')
|| $self->ut_money('taxbase')
@@
-397,7
+397,12
@@
sub taxline {
my $taxable_units = 0;
unless ($self->recurtax =~ /^Y$/i) {
if ($self->unittype == 0) {
my $taxable_units = 0;
unless ($self->recurtax =~ /^Y$/i) {
if ($self->unittype == 0) {
- $taxable_units += $_->units foreach @cust_bill_pkg;
+ my %seen = ();
+ foreach (@cust_bill_pkg) {
+ $taxable_units += $_->units
+ unless $seen{$_->pkgnum};
+ $seen{$_->pkgnum}++;
+ }
}elsif ($self->unittype == 1) {
return qq!fatal: can't (yet) handle fee with minute unit type!;
}elsif ($self->unittype == 2) {
}elsif ($self->unittype == 1) {
return qq!fatal: can't (yet) handle fee with minute unit type!;
}elsif ($self->unittype == 2) {
@@
-642,6
+647,8
@@
sub batch_import {
if ( $error ) {
$dbh->rollback if $oldAutoCommit;
if ( $error ) {
$dbh->rollback if $oldAutoCommit;
+ my $hashref = $insert{$_};
+ $line = join(", ", map { "$_ => ". $hashref->{$_} } keys(%$hashref) );
return "can't insert tax_rate for $line: $error";
}
return "can't insert tax_rate for $line: $error";
}
@@
-667,13
+674,15
@@
sub batch_import {
#join(" ", map { "$_ => ". $old->{$_} } @fields);
join(" ", map { "$_ => ". $old->{$_} } keys(%$old) );
}
#join(" ", map { "$_ => ". $old->{$_} } @fields);
join(" ", map { "$_ => ". $old->{$_} } keys(%$old) );
}
- my $new = new FS::tax_rate(
$insert{$_}
);
+ my $new = new FS::tax_rate(
{ $old->hash, %{$insert{$_}}, 'manual' => '' }
);
$new->taxnum($old->taxnum);
my $error = $new->replace($old);
if ( $error ) {
$dbh->rollback if $oldAutoCommit;
$new->taxnum($old->taxnum);
my $error = $new->replace($old);
if ( $error ) {
$dbh->rollback if $oldAutoCommit;
- return "can't insert tax_rate for $line: $error";
+ my $hashref = $insert{$_};
+ $line = join(", ", map { "$_ => ". $hashref->{$_} } keys(%$hashref) );
+ return "can't replace tax_rate for $line: $error";
}
$imported++;
}
$imported++;
@@
-703,7
+712,9
@@
sub batch_import {
if ( $error ) {
$dbh->rollback if $oldAutoCommit;
if ( $error ) {
$dbh->rollback if $oldAutoCommit;
- return "can't insert tax_rate for $line: $error";
+ my $hashref = $delete{$_};
+ $line = join(", ", map { "$_ => ". $hashref->{$_} } keys(%$hashref) );
+ return "can't delete tax_rate for $line: $error";
}
$imported++;
}
$imported++;
@@
-711,7
+722,7
@@
sub batch_import {
$dbh->commit or die $dbh->errstr if $oldAutoCommit;
$dbh->commit or die $dbh->errstr if $oldAutoCommit;
- return "Empty file!" unless
$imported
;
+ return "Empty file!" unless
($imported || $format eq 'cch-update')
;
''; #no error
''; #no error
@@
-831,7
+842,7
@@
sub process_batch {
unlink $file or warn "Can't delete $file: $!";
}
unlink $file or warn "Can't delete $file: $!";
}
- $error = "No DETAIL supplied"
+ $error
||
= "No DETAIL supplied"
unless ($files{detail});
open my $fh, "< $dir/". $files{detail}
or $error ||= "Can't open DETAIL file: $!";
unless ($files{detail});
open my $fh, "< $dir/". $files{detail}
or $error ||= "Can't open DETAIL file: $!";