X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_bill_pkg.pm;h=c825c15672bdeb37919d0f6fb34f5b4711ebcfd8;hb=7b125e587a4d1ee0aca692e23ea7897f671855ae;hp=cd049d121ce156530e23370f41efc274786deecf;hpb=63a268637b2d51a8766412617724b9436439deb6;p=freeside.git diff --git a/FS/FS/cust_bill_pkg.pm b/FS/FS/cust_bill_pkg.pm index cd049d121..c825c1567 100644 --- a/FS/FS/cust_bill_pkg.pm +++ b/FS/FS/cust_bill_pkg.pm @@ -174,6 +174,17 @@ sub insert { } } + if ( $self->get('discounts') ) { + foreach my $cust_bill_pkg_discount ( @{$self->get('discounts')} ) { + $cust_bill_pkg_discount->billpkgnum($self->billpkgnum); + $error = $cust_bill_pkg_discount->insert; + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return "error inserting cust_bill_pkg_discount: $error"; + } + } + } + if ( $self->_cust_tax_exempt_pkg ) { foreach my $cust_tax_exempt_pkg ( @{$self->_cust_tax_exempt_pkg} ) { $cust_tax_exempt_pkg->billpkgnum($self->billpkgnum); @@ -666,7 +677,10 @@ sub disintegrate { $cust_bill_pkg{''}->recur( $classless ); $cust_bill_pkg{$class} = $cust_bill_pkg_usage; } - delete $cust_bill_pkg{''} unless $cust_bill_pkg{''}->recur; + warn "Unexpected classless usage value: ". $cust_bill_pkg{''}->recur + if ($cust_bill_pkg{''}->recur && $cust_bill_pkg{''}->recur < 0); + delete $cust_bill_pkg{''} + unless ($cust_bill_pkg{''}->recur && $cust_bill_pkg{''}->recur > 0); } # # sort setup,recur,'', and the rest numeric && return @@ -763,10 +777,10 @@ sub cust_bill_pkg_display { my $type = $opt{type} if exists $opt{type}; my @result; - if ( scalar( $self->get('display') ) ) { + if ( $self->get('display') ) { @result = grep { defined($type) ? ($type eq $_->type) : 1 } @{ $self->get('display') }; - }else{ + } else { my $hashref = { 'billpkgnum' => $self->billpkgnum }; $hashref->{type} = $type if defined($type);