[freeside-commits] branch master updated. 0ec0b91b7c383d626dd75b0c2b2d3969e5bdcbc7

Christopher Burger burgerc at freeside.biz
Fri Dec 28 12:52:29 PST 2018


The branch, master has been updated
       via  0ec0b91b7c383d626dd75b0c2b2d3969e5bdcbc7 (commit)
      from  c8d7489992fc09eb8903f8071de77ae79e343e02 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 0ec0b91b7c383d626dd75b0c2b2d3969e5bdcbc7
Author: Christopher Burger <burgerc at freeside.biz>
Date:   Fri Dec 28 15:52:02 2018 -0500

    RT# 32917 - Added ability for taxes to be charged prior to applying the discount

diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm
index 7cc84a9f0..290c89daf 100644
--- a/FS/FS/Schema.pm
+++ b/FS/FS/Schema.pm
@@ -2318,6 +2318,7 @@ sub tables_hashref {
         'setuptax',    'char', 'NULL',       1, '', '', # Y = setup tax exempt
         'recurtax',    'char', 'NULL',       1, '', '', # Y = recur tax exempt
         'source',   'varchar', 'NULL', $char_d, '', '',
+        'charge_prediscount', 'char', 'NULL', 1, '', '', # Y = charge this tax pre discount
       ],
       'primary_key' => 'taxnum',
       'unique' => [],
diff --git a/FS/FS/TaxEngine/internal.pm b/FS/FS/TaxEngine/internal.pm
index 5f5d2295a..6fb1ca756 100644
--- a/FS/FS/TaxEngine/internal.pm
+++ b/FS/FS/TaxEngine/internal.pm
@@ -105,6 +105,15 @@ sub taxline {
     my $taxable_charged = $cust_bill_pkg->setup + $cust_bill_pkg->recur
       or next; # don't create zero-amount exemptions
 
+    ## re-add the discounted amount if the tax needs to be charged pre discount
+    if ($tax_object->charge_prediscount) {
+      my $discount_amount = 0;
+      foreach my $discount (@{$cust_bill_pkg->discounts}) {
+        $discount_amount += $discount->amount;
+      }
+      $taxable_charged += $discount_amount;
+    }
+
     # XXX the following procedure should probably be in cust_bill_pkg
 
     if ( $exempt_cust ) {
diff --git a/httemplate/edit/cust_main_county.html b/httemplate/edit/cust_main_county.html
index 9cc5131a2..b0823098f 100644
--- a/httemplate/edit/cust_main_county.html
+++ b/httemplate/edit/cust_main_county.html
@@ -14,6 +14,7 @@
                    'setuptax' => 'This tax not applicable to setup fees',
                    'recurtax' => 'This tax not applicable to recurring fees',
                    'exempt_amount' => 'Monthly exemption per customer ($25 "Texas tax")',
+                   'charge_prediscount' => 'Charge this tax prior to any discounts',
                  },
      'fields' => \@fields,
    )
@@ -60,6 +61,9 @@ push @fields,
   'taxname',
   { field=>'tax',      type=>'percentage', },
 
+  { type=>'tablebreak-tr-title', value=>'Charging options' },
+  { field=>'charge_prediscount', type=>'checkbox', value=>'Y', },
+
   { type=>'tablebreak-tr-title', value=>'Exemptions' },
   { field=>'setuptax', type=>'checkbox', value=>'Y', },
   { field=>'recurtax', type=>'checkbox', value=>'Y', },

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/Schema.pm                       | 1 +
 FS/FS/TaxEngine/internal.pm           | 9 +++++++++
 httemplate/edit/cust_main_county.html | 4 ++++
 3 files changed, 14 insertions(+)




More information about the freeside-commits mailing list