diff options
| author | Mitch Jackson <mitch@freeside.biz> | 2018-05-19 20:05:15 +0000 |
|---|---|---|
| committer | Mitch Jackson <mitch@freeside.biz> | 2018-05-19 21:34:25 +0000 |
| commit | 63c66b013cbb8429b4f0f3796dd8ea5fe221a2c1 (patch) | |
| tree | 664c7e712ce7022403189d856e9cb94c64354927 | |
| parent | a1b5ab1539ec4fd31154975f5066adbea978826c (diff) | |
RT# 78190 Fix taxes on fees for sectioned invoices
Fix taxes charged on a billing-event fee, such as a late fee,
displayed incorrectly on some sectioned invoices
| -rw-r--r-- | FS/FS/Template_Mixin.pm | 1 | ||||
| -rw-r--r-- | FS/FS/cust_bill_pkg.pm | 26 |
2 files changed, 25 insertions, 2 deletions
diff --git a/FS/FS/Template_Mixin.pm b/FS/FS/Template_Mixin.pm index 0d8687846..ebdcd6d46 100644 --- a/FS/FS/Template_Mixin.pm +++ b/FS/FS/Template_Mixin.pm @@ -3184,6 +3184,7 @@ sub _items_fee { push @items, { feepart => $cust_bill_pkg->feepart, + billpkgnum => $cust_bill_pkg->billpkgnum, amount => sprintf('%.2f', $cust_bill_pkg->setup + $cust_bill_pkg->recur), description => $desc, pkg_tax => \@pkg_tax, diff --git a/FS/FS/cust_bill_pkg.pm b/FS/FS/cust_bill_pkg.pm index a36520b77..983f62bed 100644 --- a/FS/FS/cust_bill_pkg.pm +++ b/FS/FS/cust_bill_pkg.pm @@ -1848,7 +1848,29 @@ sub _pkg_tax_list { # Duplicates can be identified by billpkgtaxlocationnum column. my $self = shift; - return unless $self->pkgnum; + + my $search_selector; + if ( $self->pkgnum ) { + + # For taxes applied to normal billing items + $search_selector = + ' cust_bill_pkg_tax_location.pkgnum = ' + . dbh->quote( $self->pkgnum ); + + } elsif ( $self->feepart ) { + + # For taxes applied to fees, when the fee is not attached to a package + # i.e. late fees, billing events fees + $search_selector = + ' cust_bill_pkg_tax_location.taxable_billpkgnum = ' + . dbh->quote( $self->billpkgnum ); + + } else { + warn "_pkg_tax_list() unhandled case breaking taxes into sections"; + warn "_pkg_tax_list() $_: ".$self->$_ + for qw(pkgnum billpkgnum feepart); + return; + } map +{ billpkgtaxlocationnum => $_->billpkgtaxlocationnum, @@ -1874,7 +1896,7 @@ sub _pkg_tax_list { ' WHERE '. ' cust_bill_pkg.invnum = ' . dbh->quote( $self->invnum ) . ' AND '. - ' cust_bill_pkg_tax_location.pkgnum = ' . dbh->quote( $self->pkgnum ), + $search_selector }); } |
