use FS::cust_bill_pkg_tax_location_void;
use FS::cust_bill_pkg_tax_rate_location_void;
use FS::cust_tax_exempt_pkg_void;
+use FS::cust_bill_pkg_fee_void;
use FS::part_fee;
use FS::Cursor;
} # foreach my $link
}
- my $cust_event_fee = $self->get('cust_event_fee');
- if ( $cust_event_fee ) {
- $cust_event_fee->set('billpkgnum' => $self->billpkgnum);
- $error = $cust_event_fee->replace;
+ if ( my $fee_origin = $self->get('fee_origin') ) {
+ $fee_origin->set('billpkgnum' => $self->billpkgnum);
+ $error = $fee_origin->replace;
if ( $error ) {
$dbh->rollback if $oldAutoCommit;
- return "error updating cust_event_fee: $error";
+ return "error updating fee origin record: $error";
}
}
cust_bill_pkg_tax_location
cust_bill_pkg_tax_rate_location
cust_tax_exempt_pkg
+ cust_bill_pkg_fee
)) {
foreach my $linked ( qsearch($table, { billpkgnum=>$self->billpkgnum }) ) {
cust_tax_exempt_pkg
cust_bill_pay_pkg
cust_credit_bill_pkg
+ cust_bill_pkg_fee
)) {
foreach my $linked ( qsearch($table, { billpkgnum=>$self->billpkgnum }) ) {
my $usage_total;
foreach my $classnum ($self->usage_classes) {
+ next if $classnum eq ''; # null-class usage is included in 'recur'
my $amount = $self->usage($classnum);
next if $amount == 0; # though if so we shouldn't be here
my $usage_item = FS::cust_bill_pkg->new({
my $sql = 'SELECT SUM(COALESCE(amount,0)) FROM cust_bill_pkg_detail '.
' WHERE billpkgnum = '. $self->billpkgnum;
- $sql .= " AND classnum = $classnum" if defined($classnum);
+ if (defined $classnum) {
+ if ($classnum =~ /^(\d+)$/) {
+ $sql .= " AND classnum = $1";
+ } elsif (defined($classnum) and $classnum eq '') {
+ $sql .= " AND classnum IS NULL";
+ }
+ }
my $sth = dbh->prepare($sql) or die dbh->errstr;
$sth->execute or die $sth->errstr;
my $self = shift;
if ( $self->pkgnum ) { # normal sales
return $self->cust_pkg->tax_locationnum;
- } elsif ( $self->feepart ) { # fees
+ } elsif ( $self->feepart and $self->invnum ) { # fees
return $self->cust_bill->cust_main->ship_locationnum;
} else { # taxes
return '';
my $self = shift;
if ( $self->pkgnum ) { # normal sales
return $self->cust_pkg->tax_location;
- } elsif ( $self->feepart ) { # fees
+ } elsif ( $self->feepart and $self->invnum ) { # fees
return $self->cust_bill->cust_main->ship_location;
} else { # taxes
return;
}
}
-=item part_X
-
-Returns the L<FS::part_pkg> or L<FS::part_fee> object that defines this
-charge. If called on a tax line, returns nothing.
-
-=cut
-
-sub part_X {
- my $self = shift;
- if ( $self->pkgpart_override ) {
- return FS::part_pkg->by_key($self->pkgpart_override);
- } elsif ( $self->pkgnum ) {
- return $self->cust_pkg->part_pkg;
- } elsif ( $self->feepart ) {
- return $self->part_fee;
- } else {
- return;
- }
-}
-
-# stubs
-
-sub part_fee {
- my $self = shift;
- $self->feepart
- ? FS::part_fee->by_key($self->feepart)
- : undef;
-}
-
=back
=head1 CLASS METHODS