X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=FS%2FFS%2Ftax_rate.pm;h=d8ee8752039a227836714a7032883b3d1cd5e026;hb=90393980e5f2859ee1e186fa461f48f5129e803e;hp=b375a661be318d5f98ea08e236d3a3926e31d6ce;hpb=1702ffad58949ebe9e4769afeb9fe9c93249cf69;p=freeside.git diff --git a/FS/FS/tax_rate.pm b/FS/FS/tax_rate.pm index b375a661b..d8ee87520 100644 --- a/FS/FS/tax_rate.pm +++ b/FS/FS/tax_rate.pm @@ -18,6 +18,7 @@ use DBIx::DBSchema; use DBIx::DBSchema::Table; use DBIx::DBSchema::Column; use FS::Record qw( qsearch qsearchs dbh dbdef ); +use FS::Conf; use FS::tax_class; use FS::cust_bill_pkg; use FS::cust_tax_location; @@ -443,20 +444,35 @@ sub taxline { my $taxable_units = 0; unless ($self->recurtax =~ /^Y$/i) { - if (( $self->unittype || 0 ) == 0) { + + if (( $self->unittype || 0 ) == 0) { #access line my %seen = (); foreach (@cust_bill_pkg) { $taxable_units += $_->units - unless $seen{$_->pkgnum}; - $seen{$_->pkgnum}++; + unless $seen{$_->pkgnum}++; } - }elsif ($self->unittype == 1) { + + } elsif ($self->unittype == 1) { #minute return $self->_fatal_or_null( 'fee with minute unit type' ); - }elsif ($self->unittype == 2) { - $taxable_units = 1; - }else { + + } elsif ($self->unittype == 2) { #account + + my $conf = new FS::Conf; + if ( $conf->exists('tax-pkg_address') ) { + #number of distinct locations + my %seen = (); + foreach (@cust_bill_pkg) { + $taxable_units++ + unless $seen{$_->cust_pkg->locationnum}++; + } + } else { + $taxable_units = 1; + } + + } else { return $self->_fatal_or_null( 'unknown unit type in tax'. $self->taxnum ); } + } # @@ -1316,7 +1332,7 @@ sub _restore_remembered_tax_products { unless ( $part_pkg_taxproduct ) { return "failed to find part_pkg_taxproduct (". - $taxproduct->{pkgpart}->{$class}. ") for pkgpart $pkgpart\n"; + $taxproduct->{$pkgpart}->{$class}. ") for pkgpart $pkgpart\n"; } if ( $class eq '' ) { @@ -1773,7 +1789,7 @@ sub queue_liability_report { $cgi->param('ending', $param->{ending}); my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi); my $agentnum = $param->{agentnum}; - $agentnum =~ /^(\d+)$/ ? $agentnum = $1 : $agentnum = ''; + if ($agentnum =~ /^(\d+)$/) { $agentnum = $1; } else { $agentnum = ''; }; generate_liability_report( 'beginning' => $beginning, 'ending' => $ending,