From af9bdfeaa320308fafb5c3a1b3da9859482bf9d1 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 12 Dec 2017 18:50:05 +0530 Subject: [PATCH] Fixed calculation of taxes and totals if tax is entered as Actual, for Deduction or valuation (#11965) --- erpnext/controllers/taxes_and_totals.py | 3 ++- erpnext/public/js/controllers/taxes_and_totals.js | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/erpnext/controllers/taxes_and_totals.py b/erpnext/controllers/taxes_and_totals.py index e85e56b4d6..4b73abdef5 100644 --- a/erpnext/controllers/taxes_and_totals.py +++ b/erpnext/controllers/taxes_and_totals.py @@ -399,7 +399,8 @@ class calculate_taxes_and_totals(object): for tax in self.doc.get("taxes"): if tax.charge_type == "Actual": - actual_taxes_dict.setdefault(tax.idx, tax.tax_amount) + tax_amount = self.get_tax_amount_if_for_valuation_or_deduction(tax.tax_amount, tax) + actual_taxes_dict.setdefault(tax.idx, tax_amount) elif tax.row_id in actual_taxes_dict: actual_tax_amount = flt(actual_taxes_dict.get(tax.row_id, 0)) * flt(tax.rate) / 100 actual_taxes_dict.setdefault(tax.idx, actual_tax_amount) diff --git a/erpnext/public/js/controllers/taxes_and_totals.js b/erpnext/public/js/controllers/taxes_and_totals.js index 84624b8997..960807a5c8 100644 --- a/erpnext/public/js/controllers/taxes_and_totals.js +++ b/erpnext/public/js/controllers/taxes_and_totals.js @@ -521,9 +521,11 @@ erpnext.taxes_and_totals = erpnext.payments.extend({ var actual_taxes_dict = {}; $.each(this.frm.doc["taxes"] || [], function(i, tax) { - if (tax.charge_type == "Actual") - actual_taxes_dict[tax.idx] = tax.tax_amount; - else if (actual_taxes_dict[tax.row_id] !== null) { + if (tax.charge_type == "Actual") { + var tax_amount = (tax.category == "Valuation") ? 0.0 : tax.tax_amount; + tax_amount *= (tax.add_deduct_tax == "Deduct") ? -1.0 : 1.0; + actual_taxes_dict[tax.idx] = tax_amount; + } else if (actual_taxes_dict[tax.row_id] !== null) { var actual_tax_amount = flt(actual_taxes_dict[tax.row_id]) * flt(tax.rate) / 100; actual_taxes_dict[tax.idx] = actual_tax_amount; }