package FS::cust_credit_bill_pkg;
+use base qw( FS::cust_main_Mixin FS::Record );
use strict;
-use vars qw( @ISA );
use FS::Record qw( qsearch qsearchs dbh );
-use FS::cust_main_Mixin;
-use FS::cust_credit_bill;
-use FS::cust_bill_pkg;
use FS::cust_bill_pkg_tax_location;
use FS::cust_bill_pkg_tax_rate_location;
use FS::cust_tax_exempt_pkg;
-@ISA = qw( FS::cust_main_Mixin FS::Record );
-
=head1 NAME
FS::cust_credit_bill_pkg - Object methods for cust_credit_bill_pkg records
=item creditbillpkgnum - primary key
-=item creditbillnum - Credit application to the overall invoice (see L<FS::cust_credit::bill>)
+=item creditbillnum - Credit application to the overall invoice (see L<FS::cust_credit_bill>)
=item billpkgnum - Line item to which credit is applied (see L<FS::cust_bill_pkg>)
if ($taxable_per_month >= 0) { #panic if its subzero?
my $groupby = join(',',
- qw(taxnum year month exempt_monthly exempt_cust
+ qw(taxnum taxtype year month exempt_monthly exempt_cust
exempt_cust_taxname exempt_setup exempt_recur));
my $sum = 'SUM(amount)';
my @exemptions = qsearch(
# (above the remaining taxable charge amount). We'll "de-exempt"
# that much, or the amount of the new credit, whichever is smaller.
if ($amount > $credit_per_month) {
- "cust_bill_pkg ". $self->billpkgnum. " Reducing.\n";
+ #warn "cust_bill_pkg ". $self->billpkgnum. " Reducing.\n";
$amount = $credit_per_month;
}
} elsif ( $exemption->exempt_setup or $exemption->exempt_recur ) {
'amount' => sprintf('%.2f', 0-$amount),
};
- my $error = $cust_tax_exempt_pkg->insert;
- if ( $error ) {
- $dbh->rollback if $oldAutoCommit;
- return "error inserting cust_tax_exempt_pkg: $error";
+ if ( $cust_tax_exempt_pkg->cust_main_county ) {
+
+ my $error = $cust_tax_exempt_pkg->insert;
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return "error inserting cust_tax_exempt_pkg: $error";
+ }
+
}
+
} #foreach $exemption
}
$self->SUPER::check;
}
-sub cust_credit_bill {
- my $self = shift;
- qsearchs('cust_credit_bill', { 'creditbillnum' => $self->creditbillnum } );
-}
-
-sub cust_bill_pkg {
- my $self = shift;
- qsearchs('cust_bill_pkg', { 'billpkgnum' => $self->billpkgnum } );
-}
-
sub cust_bill_pkg_tax_Xlocation {
my $self = shift;
if ($self->billpkgtaxlocationnum) {