X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Fcust_bill_pkg_tax_location.pm;h=4a641bec6a14185f9e78f3c149e7bea6c5b42684;hp=140982e536a4686e96245ab94fe0f7f67efe2b0a;hb=ffa18709ee8a4d05e18d2d406cf73afe79e52524;hpb=54a357b171aa44f9399b4c146acd2afd3b686075 diff --git a/FS/FS/cust_bill_pkg_tax_location.pm b/FS/FS/cust_bill_pkg_tax_location.pm index 140982e53..4a641bec6 100644 --- a/FS/FS/cust_bill_pkg_tax_location.pm +++ b/FS/FS/cust_bill_pkg_tax_location.pm @@ -1,18 +1,16 @@ package FS::cust_bill_pkg_tax_location; +use base qw( FS::Record ); use strict; -use base qw( FS::Record ); -use FS::Record qw( qsearch qsearchs ); +use List::Util qw(sum min); +use FS::Record qw( dbh qsearch qsearchs ); use FS::cust_bill_pkg; use FS::cust_pkg; -use FS::cust_location; use FS::cust_bill_pay_pkg; use FS::cust_credit_bill_pkg; use FS::cust_main_county; use FS::Log; -use List::Util qw(sum min); - =head1 NAME FS::cust_bill_pkg_tax_location - Object methods for cust_bill_pkg_tax_location records @@ -124,10 +122,10 @@ sub check { || $self->ut_foreign_key('billpkgnum', 'cust_bill_pkg', 'billpkgnum' ) || $self->ut_number('taxnum') #cust_bill_pkg/tax_rate key, based on taxtype || $self->ut_enum('taxtype', [ qw( FS::cust_main_county FS::tax_rate ) ] ) - || $self->ut_foreign_key('pkgnum', 'cust_pkg', 'pkgnum' ) + || $self->ut_number('pkgnum', 'cust_pkg', 'pkgnum' ) || $self->ut_foreign_key('locationnum', 'cust_location', 'locationnum' ) || $self->ut_money('amount') - || $self->ut_foreign_key('taxable_billpkgnum', 'cust_bill_pkg', 'billpkgnum') + || $self->ut_foreign_keyn('taxable_billpkgnum', 'cust_bill_pkg', 'billpkgnum') ; return $error if $error; @@ -138,13 +136,6 @@ sub check { Returns the associated cust_bill_pkg object (i.e. the tax charge). -=cut - -sub cust_bill_pkg { - my $self = shift; - qsearchs( 'cust_bill_pkg', { 'billpkgnum' => $self->billpkgnum } ); -} - =item taxable_cust_bill_pkg Returns the cust_bill_pkg object for the I charge. @@ -153,11 +144,17 @@ Returns the cust_bill_pkg object for the I charge. Returns the associated cust_location object +=item taxname + +Returns the tax name (for populating the itemdesc field). + =cut -sub cust_location { +sub taxname { my $self = shift; - qsearchs( 'cust_location', { 'locationnum' => $self->locationnum } ); + my $cust_main_county = FS::cust_main_county->by_key($self->taxnum) + or return ''; + $cust_main_county->taxname || 'Tax'; } =item desc @@ -243,7 +240,7 @@ sub upgrade_taxable_billpkgnum { # FS::cust_bill_pkg. my ($class, %opt) = @_; - my $dbh = FS::UID::dbh(); + my $dbh = dbh; my $oldAutoCommit = $FS::UID::AutoCommit; local $FS::UID::AutoCommit = 0; my $log = FS::Log->new('upgrade_taxable_billpkgnum'); @@ -341,7 +338,7 @@ sub upgrade_taxable_billpkgnum { } #for $i } else { # the more complicated case - $log->warn("mismatched charges and tax links in pkg#$pkgnum", + $log->warning("mismatched charges and tax links in pkg#$pkgnum", object => $cust_bill); my $tax_amount = sum(map {$_->amount} @tax_links); # remove all tax link records and recreate them to be 1:1 with