X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_bill_pkg.pm;h=4448da62e35d13139f31ed6c173865e956da4790;hb=16062ec78d33d4d3b9c996eb057a331837fc65f8;hp=2aa2a6fabe150b2afedefab28faffd60726a5d6c;hpb=428a33ad6d0e01621717840d2db4861f4bee6c21;p=freeside.git diff --git a/FS/FS/cust_bill_pkg.pm b/FS/FS/cust_bill_pkg.pm index 2aa2a6fab..4448da62e 100644 --- a/FS/FS/cust_bill_pkg.pm +++ b/FS/FS/cust_bill_pkg.pm @@ -26,6 +26,7 @@ use FS::cust_bill_pkg_discount_void; 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; @@ -299,13 +300,12 @@ sub insert { } # 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"; } } @@ -363,6 +363,7 @@ sub void { 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 }) ) { @@ -422,6 +423,7 @@ sub delete { cust_tax_exempt_pkg cust_bill_pay_pkg cust_credit_bill_pkg + cust_bill_pkg_fee )) { foreach my $linked ( qsearch($table, { billpkgnum=>$self->billpkgnum }) ) { @@ -835,6 +837,8 @@ sub _item_discount { description => $self->mt('Discount'), amount => 0, ext_description => \@ext, + pkgpart => $self->pkgpart, + feepart => $self->feepart, # maybe should show quantity/unit discount? }; foreach my $pkg_discount (@pkg_discounts) { @@ -1014,10 +1018,12 @@ sub usage { my $sql = 'SELECT SUM(COALESCE(amount,0)) FROM cust_bill_pkg_detail '. ' WHERE billpkgnum = '. $self->billpkgnum; - if ($classnum =~ /^(\d+)$/) { - $sql .= " AND classnum = $1"; - } elsif (defined($classnum) and $classnum eq '') { - $sql .= " AND classnum IS NULL"; + 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; @@ -1151,35 +1157,6 @@ sub tax_location { } } -=item part_X - -Returns the L or L 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