- foreach my $exemption ( @unseen_exemptions ) {
- my $tax_object = $exemption->cust_main_county;
- unless ($tax_object) {
- $dbh->rollback if $oldAutoCommit;
- return "can't find exempted tax";
- }
-
- my $hashref_or_error =
- $tax_object->taxline( [ $cust_bill_pkg ],
- 'custnum' => $cust_bill->custnum,
- 'invoice_time' => $cust_bill->_date,
- );
- unless (ref($hashref_or_error)) {
- $dbh->rollback if $oldAutoCommit;
- return "error calculating taxes: $hashref_or_error";
- }
-
- push @generated_exemptions, @{ $cust_bill_pkg->cust_tax_exempt_pkg };
- }
-
- foreach my $taxnum ( keys %seen ) {
- my $sum = 0;
- $sum += $_->amount for grep {$_->taxnum == $taxnum} @exemptions;
- $sum -= $_->amount for grep {$_->taxnum == $taxnum} @generated_exemptions;
- $sum = sprintf("%.2f", $sum);
- unless ($sum eq '0.00' || $sum eq '-0.00') {
- $dbh->rollback if $oldAutoCommit;
- return "Can't unapply credit without charging tax of $sum";
- }
- }
-
- my $error = $self->SUPER::delete(@_);