X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Fcust_main_county.pm;h=652ff33aeb05e84fe2ac75fae6af79850012baac;hp=075ac32789bd10efd23c48e130ff19dce8bc5fcd;hb=53ed077b4901be22b3ca5405a093364b6f6b6407;hpb=35c18f29bc29dedfe2fa4ef037390d90b17f87ba diff --git a/FS/FS/cust_main_county.pm b/FS/FS/cust_main_county.pm index 075ac3278..652ff33ae 100644 --- a/FS/FS/cust_main_county.pm +++ b/FS/FS/cust_main_county.pm @@ -277,7 +277,7 @@ sub taxline { my $cust_bill = $taxables->[0]->cust_bill; my $custnum = $cust_bill ? $cust_bill->custnum : $opt{'custnum'}; my $invoice_time = $cust_bill ? $cust_bill->_date : $opt{'invoice_time'}; - my $cust_main = FS::cust_main->by_key($custnum) if $custnum > 0; + my $cust_main = FS::cust_main->by_key($custnum) if $custnum; # (to avoid complications with estimated tax on quotations, assume it's # taxable if there is no customer) #if (!$cust_main) { @@ -285,18 +285,21 @@ sub taxline { #} # set a flag if the customer is tax-exempt - my $exempt_cust; + my ($exempt_cust, $exempt_cust_taxname); my $conf = FS::Conf->new; - if ( $conf->exists('cust_class-tax_exempt') ) { - my $cust_class = $cust_main->cust_class; - $exempt_cust = $cust_class->tax if $cust_class; - } else { - $exempt_cust = $cust_main->tax; - } + if ( $cust_main ) { + if ( $conf->exists('cust_class-tax_exempt') ) { + my $cust_class = $cust_main->cust_class; + $exempt_cust = $cust_class->tax if $cust_class; + } else { + $exempt_cust = $cust_main->tax; + } - # set a flag if the customer is exempt from this tax here - my $exempt_cust_taxname = $cust_main->tax_exemption($self->taxname) - if $self->taxname; + # set a flag if the customer is exempt from this tax here + if ( $self->taxname ) { + $exempt_cust_taxname = $cust_main->tax_exemption($self->taxname); + } + } # Gather any exemptions that are already attached to these cust_bill_pkgs # so that we can deduct them from the customer's monthly limit. @@ -320,9 +323,8 @@ sub taxline { my $part_pkg = $cust_bill_pkg->part_pkg; my $part_fee = $cust_bill_pkg->part_fee; - my $locationnum = $cust_pkg - ? $cust_pkg->locationnum - : $cust_main->bill_locationnum; + my $locationnum = $cust_bill_pkg->tax_locationnum + || $cust_main->ship_locationnum; my @new_exemptions; my $taxable_charged = $cust_bill_pkg->setup + $cust_bill_pkg->recur