From db53a789be480aace3ea05850ba60cbb7d3a3983 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 31 Jul 2015 16:53:13 +0530 Subject: [PATCH] [fix] Tax calculation while discount applied on net total --- erpnext/controllers/taxes_and_totals.py | 6 +++--- erpnext/public/js/controllers/taxes_and_totals.js | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/erpnext/controllers/taxes_and_totals.py b/erpnext/controllers/taxes_and_totals.py index 6b59cea00d..d526f66baf 100644 --- a/erpnext/controllers/taxes_and_totals.py +++ b/erpnext/controllers/taxes_and_totals.py @@ -219,7 +219,7 @@ class calculate_taxes_and_totals(object): # adjust Discount Amount loss in last tax iteration if i == (len(self.doc.get("taxes")) - 1) and self.discount_amount_applied \ - and self.doc.discount_amount: + and self.doc.discount_amount and self.doc.apply_discount_on == "Grand Total": self.adjust_discount_amount_loss(tax) @@ -303,9 +303,9 @@ class calculate_taxes_and_totals(object): for tax in self.doc.get("taxes"): if tax.category in ["Valuation and Total", "Total"]: if tax.add_deduct_tax == "Add": - self.doc.taxes_and_charges_added += flt(tax.tax_amount) + self.doc.taxes_and_charges_added += flt(tax.tax_amount_after_discount_amount) else: - self.doc.taxes_and_charges_deducted += flt(tax.tax_amount) + self.doc.taxes_and_charges_deducted += flt(tax.tax_amount_after_discount_amount) self.doc.round_floats_in(self.doc, ["taxes_and_charges_added", "taxes_and_charges_deducted"]) diff --git a/erpnext/public/js/controllers/taxes_and_totals.js b/erpnext/public/js/controllers/taxes_and_totals.js index 1e238d6934..0b3ca7f2a8 100644 --- a/erpnext/public/js/controllers/taxes_and_totals.js +++ b/erpnext/public/js/controllers/taxes_and_totals.js @@ -256,7 +256,8 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({ me.round_off_totals(tax); // adjust Discount Amount loss in last tax iteration - if ((i == me.frm.doc["taxes"].length - 1) && me.discount_amount_applied && me.frm.doc.apply_discount_on == "Grand Total") + if ((i == me.frm.doc["taxes"].length - 1) && me.discount_amount_applied + && me.frm.doc.apply_discount_on == "Grand Total" && me.frm.doc.discount_amount) me.adjust_discount_amount_loss(tax); } }); @@ -365,9 +366,9 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({ $.each(this.frm.doc["taxes"] || [], function(i, tax) { if (in_list(["Valuation and Total", "Total"], tax.category)) { if(tax.add_deduct_tax == "Add") { - me.frm.doc.taxes_and_charges_added += flt(tax.tax_amount); + me.frm.doc.taxes_and_charges_added += flt(tax.tax_amount_after_discount_amount); } else { - me.frm.doc.taxes_and_charges_deducted += flt(tax.tax_amount); + me.frm.doc.taxes_and_charges_deducted += flt(tax.tax_amount_after_discount_amount); } } })