X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_bill_pkg.pm;h=bb071739ef7b07b52b52f95197070836961f48ac;hb=d72073a19a37641e1f8fb888b827be9d7ac74bed;hp=1629b79f5be0b8e3090f0b753666908a2e8e323e;hpb=6115c160d19e6c82e3f713d0d79128fbf45e46da;p=freeside.git diff --git a/FS/FS/cust_bill_pkg.pm b/FS/FS/cust_bill_pkg.pm index 1629b79f5..bb071739e 100644 --- a/FS/FS/cust_bill_pkg.pm +++ b/FS/FS/cust_bill_pkg.pm @@ -11,6 +11,7 @@ use FS::cust_bill_pkg_detail; use FS::cust_bill_pkg_display; use FS::cust_bill_pay_pkg; use FS::cust_credit_bill_pkg; +use FS::cust_tax_exempt_pkg; @ISA = qw( FS::cust_main_Mixin FS::Record ); @@ -29,10 +30,6 @@ FS::cust_bill_pkg - Object methods for cust_bill_pkg records $error = $record->insert; - $error = $new_record->replace($old_record); - - $error = $record->delete; - $error = $record->check; =head1 DESCRIPTION @@ -140,6 +137,44 @@ sub insert { } } + if ( $self->_cust_tax_exempt_pkg ) { + foreach my $cust_tax_exempt_pkg ( @{$self->_cust_tax_exempt_pkg} ) { + $cust_tax_exempt_pkg->billpkgnum($self->billpkgnum); + $error = $cust_tax_exempt_pkg->insert; + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return $error; + } + } + } + + my $tax_location = $self->get('cust_bill_pkg_tax_location'); + if ( $tax_location ) { + foreach my $cust_bill_pkg_tax_location ( @$tax_location ) { + $cust_bill_pkg_tax_location->billpkgnum($self->billpkgnum); + warn $cust_bill_pkg_tax_location; + $error = $cust_bill_pkg_tax_location->insert; + warn $error; + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return $error; + } + } + } + + my $tax_rate_location = $self->get('cust_bill_pkg_tax_rate_location'); + if ( $tax_rate_location ) { + foreach my $cust_bill_pkg_tax_rate_location ( @$tax_rate_location ) { + $cust_bill_pkg_tax_rate_location->billpkgnum($self->billpkgnum); + $error = $cust_bill_pkg_tax_rate_location->insert; + warn $error; + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return $error; + } + } + } + $dbh->commit or die $dbh->errstr if $oldAutoCommit; ''; @@ -156,16 +191,18 @@ sub delete { return "Can't delete cust_bill_pkg records!"; } -=item replace OLD_RECORD - -Currently unimplemented. This would be even more of an accounting nightmare -than deleteing the items. Just don't do it. - -=cut - -sub replace { - return "Can't modify cust_bill_pkg records!"; -} +#alas, bin/follow-tax-rename +# +#=item replace OLD_RECORD +# +#Currently unimplemented. This would be even more of an accounting nightmare +#than deleteing the items. Just don't do it. +# +#=cut +# +#sub replace { +# return "Can't modify cust_bill_pkg records!"; +#} =item check @@ -239,6 +276,23 @@ sub cust_bill { qsearchs( 'cust_bill', { 'invnum' => $self->invnum } ); } +=item previous_cust_bill_pkg + +Returns the previous cust_bill_pkg for this package, if any. + +=cut + +sub previous_cust_bill_pkg { + my $self = shift; + qsearchs({ + 'table' => 'cust_bill_pkg', + 'hashref' => { 'pkgnum' => $self->pkgnum, + 'sdate' => { op=>'<', value=>$self->sdate }, + }, + 'order_by' => 'ORDER BY sdate DESC LIMIT 1', + }); +} + =item details [ OPTION => VALUE ... ] Returns an array of detail information for the invoice line item. @@ -612,6 +666,17 @@ sub cust_bill_pkg_display { } +# reserving this name for my friends FS::{tax_rate|cust_main_county}::taxline +# and FS::cust_main::bill + +sub _cust_tax_exempt_pkg { + my ( $self ) = @_; + + $self->{Hash}->{_cust_tax_exempt_pkg} or + $self->{Hash}->{_cust_tax_exempt_pkg} = []; + +} + =back