From 6ad84d66cc38e20eba9135ac03e20bbb61e03b88 Mon Sep 17 00:00:00 2001 From: Luis Mendoza Date: Wed, 11 Feb 2026 20:49:15 +0000 Subject: [PATCH 1/5] fix(accounts): compute tax net_amount in JS controller (cherry picked from commit 153ad99f85ad5ef8a1b52663cd121328bf589f73) # Conflicts: # erpnext/public/js/controllers/taxes_and_totals.js --- .../public/js/controllers/taxes_and_totals.js | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/erpnext/public/js/controllers/taxes_and_totals.js b/erpnext/public/js/controllers/taxes_and_totals.js index a4b4de19303..44281e80c93 100644 --- a/erpnext/public/js/controllers/taxes_and_totals.js +++ b/erpnext/public/js/controllers/taxes_and_totals.js @@ -173,9 +173,21 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments { if (!tax.dont_recompute_tax) { tax.item_wise_tax_detail = {}; } +<<<<<<< HEAD var tax_fields = ["total", "tax_amount_after_discount_amount", "tax_amount_for_current_item", "grand_total_for_current_item", "tax_fraction_for_current_item", "grand_total_fraction_for_current_item"]; +======= + var tax_fields = [ + "net_amount", + "total", + "tax_amount_after_discount_amount", + "tax_amount_for_current_item", + "grand_total_for_current_item", + "tax_fraction_for_current_item", + "grand_total_fraction_for_current_item", + ]; +>>>>>>> 153ad99f85 (fix(accounts): compute tax net_amount in JS controller) if (cstr(tax.charge_type) != "Actual" && !(me.discount_amount_applied && me.frm.doc.apply_discount_on=="Grand Total")) { @@ -363,7 +375,7 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments { var item_tax_map = me._load_item_tax_rate(item.item_tax_rate); $.each(doc.taxes, function(i, tax) { // tax_amount represents the amount of tax for the current step - var current_tax_amount = me.get_current_tax_amount(item, tax, item_tax_map); + var [current_net_amount, current_tax_amount] = me.get_current_tax_amount(item, tax, item_tax_map); if (frappe.flags.round_row_wise_tax) { current_tax_amount = flt(current_tax_amount, precision("tax_amount", tax)); } @@ -380,6 +392,7 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments { if (tax.charge_type != "Actual" && !(me.discount_amount_applied && me.frm.doc.apply_discount_on=="Grand Total")) { tax.tax_amount += current_tax_amount; + tax.net_amount += current_net_amount; } // store tax_amount for current item as it will be used for @@ -494,11 +507,15 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments { current_tax_amount = tax_rate * item.qty; } +<<<<<<< HEAD if (!tax.dont_recompute_tax) { this.set_item_wise_tax(item, tax, tax_rate, current_tax_amount); } return current_tax_amount; +======= + return [current_net_amount, current_tax_amount]; +>>>>>>> 153ad99f85 (fix(accounts): compute tax net_amount in JS controller) } set_item_wise_tax(item, tax, tax_rate, current_tax_amount) { @@ -532,7 +549,15 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments { } tax.tax_amount = flt(tax.tax_amount, precision("tax_amount", tax)); +<<<<<<< HEAD tax.tax_amount_after_discount_amount = flt(tax.tax_amount_after_discount_amount, precision("tax_amount", tax)); +======= + tax.net_amount = flt(tax.net_amount, precision("net_amount", tax)); + tax.tax_amount_after_discount_amount = flt( + tax.tax_amount_after_discount_amount, + precision("tax_amount", tax) + ); +>>>>>>> 153ad99f85 (fix(accounts): compute tax net_amount in JS controller) } round_off_base_values(tax) { From 86c628521e4cb4dad15327530a66faf141888503 Mon Sep 17 00:00:00 2001 From: Luis Mendoza Date: Wed, 11 Feb 2026 21:18:44 +0000 Subject: [PATCH 2/5] style: prettier formatting (cherry picked from commit 485166b668b372ecff00e6638ced930b73bff3bc) --- erpnext/public/js/controllers/taxes_and_totals.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/erpnext/public/js/controllers/taxes_and_totals.js b/erpnext/public/js/controllers/taxes_and_totals.js index 44281e80c93..35f2b90f695 100644 --- a/erpnext/public/js/controllers/taxes_and_totals.js +++ b/erpnext/public/js/controllers/taxes_and_totals.js @@ -375,7 +375,11 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments { var item_tax_map = me._load_item_tax_rate(item.item_tax_rate); $.each(doc.taxes, function(i, tax) { // tax_amount represents the amount of tax for the current step - var [current_net_amount, current_tax_amount] = me.get_current_tax_amount(item, tax, item_tax_map); + var [current_net_amount, current_tax_amount] = me.get_current_tax_amount( + item, + tax, + item_tax_map + ); if (frappe.flags.round_row_wise_tax) { current_tax_amount = flt(current_tax_amount, precision("tax_amount", tax)); } From 516ad9021b4ea102f2571da49c7bb2793a24f13f Mon Sep 17 00:00:00 2001 From: Luis Mendoza Date: Wed, 18 Feb 2026 16:44:56 +0000 Subject: [PATCH 3/5] fix(accounts): round and convert net_amount to company currency in JS tax controller (cherry picked from commit b10b20539471879da0fcaf64648cf22d598b7f82) # Conflicts: # erpnext/public/js/controllers/taxes_and_totals.js --- erpnext/public/js/controllers/taxes_and_totals.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/erpnext/public/js/controllers/taxes_and_totals.js b/erpnext/public/js/controllers/taxes_and_totals.js index 35f2b90f695..5f069539754 100644 --- a/erpnext/public/js/controllers/taxes_and_totals.js +++ b/erpnext/public/js/controllers/taxes_and_totals.js @@ -382,6 +382,7 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments { ); if (frappe.flags.round_row_wise_tax) { current_tax_amount = flt(current_tax_amount, precision("tax_amount", tax)); + current_net_amount = flt(current_net_amount, precision("net_amount", tax)); } // Adjust divisional loss to the last item @@ -447,8 +448,12 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments { for (const [i, tax] of doc.taxes.entries()) { me.round_off_totals(tax); +<<<<<<< HEAD me.set_in_company_currency(tax, ["tax_amount", "tax_amount_after_discount_amount"]); +======= + me.set_in_company_currency(tax, ["tax_amount", "tax_amount_after_discount_amount", "net_amount"]); +>>>>>>> b10b205394 (fix(accounts): round and convert net_amount to company currency in JS tax controller) me.round_off_base_values(tax); From e5282a48aef0a24ba3412e4bd6fa0ddc1c56f073 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Thu, 26 Feb 2026 13:52:23 +0530 Subject: [PATCH 4/5] chore: resolve conflicts --- .../public/js/controllers/taxes_and_totals.js | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/erpnext/public/js/controllers/taxes_and_totals.js b/erpnext/public/js/controllers/taxes_and_totals.js index 5f069539754..7c210476737 100644 --- a/erpnext/public/js/controllers/taxes_and_totals.js +++ b/erpnext/public/js/controllers/taxes_and_totals.js @@ -173,11 +173,6 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments { if (!tax.dont_recompute_tax) { tax.item_wise_tax_detail = {}; } -<<<<<<< HEAD - var tax_fields = ["total", "tax_amount_after_discount_amount", - "tax_amount_for_current_item", "grand_total_for_current_item", - "tax_fraction_for_current_item", "grand_total_fraction_for_current_item"]; -======= var tax_fields = [ "net_amount", "total", @@ -187,7 +182,6 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments { "tax_fraction_for_current_item", "grand_total_fraction_for_current_item", ]; ->>>>>>> 153ad99f85 (fix(accounts): compute tax net_amount in JS controller) if (cstr(tax.charge_type) != "Actual" && !(me.discount_amount_applied && me.frm.doc.apply_discount_on=="Grand Total")) { @@ -448,12 +442,7 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments { for (const [i, tax] of doc.taxes.entries()) { me.round_off_totals(tax); -<<<<<<< HEAD - me.set_in_company_currency(tax, - ["tax_amount", "tax_amount_after_discount_amount"]); -======= me.set_in_company_currency(tax, ["tax_amount", "tax_amount_after_discount_amount", "net_amount"]); ->>>>>>> b10b205394 (fix(accounts): round and convert net_amount to company currency in JS tax controller) me.round_off_base_values(tax); @@ -516,15 +505,11 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments { current_tax_amount = tax_rate * item.qty; } -<<<<<<< HEAD if (!tax.dont_recompute_tax) { this.set_item_wise_tax(item, tax, tax_rate, current_tax_amount); } - return current_tax_amount; -======= return [current_net_amount, current_tax_amount]; ->>>>>>> 153ad99f85 (fix(accounts): compute tax net_amount in JS controller) } set_item_wise_tax(item, tax, tax_rate, current_tax_amount) { @@ -558,15 +543,11 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments { } tax.tax_amount = flt(tax.tax_amount, precision("tax_amount", tax)); -<<<<<<< HEAD - tax.tax_amount_after_discount_amount = flt(tax.tax_amount_after_discount_amount, precision("tax_amount", tax)); -======= tax.net_amount = flt(tax.net_amount, precision("net_amount", tax)); tax.tax_amount_after_discount_amount = flt( tax.tax_amount_after_discount_amount, precision("tax_amount", tax) ); ->>>>>>> 153ad99f85 (fix(accounts): compute tax net_amount in JS controller) } round_off_base_values(tax) { From 717c5b25eb22a1936ecfde6dc979ab8f20670bd4 Mon Sep 17 00:00:00 2001 From: David Arnold Date: Wed, 4 Dec 2024 14:08:50 +0100 Subject: [PATCH 5/5] fix: client-side taxes calculation (#44510) closes: #44328 --- erpnext/public/js/controllers/taxes_and_totals.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/erpnext/public/js/controllers/taxes_and_totals.js b/erpnext/public/js/controllers/taxes_and_totals.js index 7c210476737..4f327cebd5a 100644 --- a/erpnext/public/js/controllers/taxes_and_totals.js +++ b/erpnext/public/js/controllers/taxes_and_totals.js @@ -475,6 +475,7 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments { get_current_tax_amount(item, tax, item_tax_map) { var tax_rate = this._get_tax_rate(tax, item_tax_map); var current_tax_amount = 0.0; + var current_net_amount = 0.0; // To set row_id by default as previous row. if(["On Previous Row Amount", "On Previous Row Total"].includes(tax.charge_type)) { @@ -487,21 +488,27 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments { } } if(tax.charge_type == "Actual") { + current_net_amount = item.net_amount // distribute the tax amount proportionally to each item row var actual = flt(tax.tax_amount, precision("tax_amount", tax)); current_tax_amount = this.frm.doc.net_total ? ((item.net_amount / this.frm.doc.net_total) * actual) : 0.0; } else if(tax.charge_type == "On Net Total") { + if (tax.account_head in item_tax_map) { + current_net_amount = item.net_amount + }; current_tax_amount = (tax_rate / 100.0) * item.net_amount; } else if(tax.charge_type == "On Previous Row Amount") { + current_net_amount = this.frm.doc["taxes"][cint(tax.row_id) - 1].tax_amount_for_current_item current_tax_amount = (tax_rate / 100.0) * this.frm.doc["taxes"][cint(tax.row_id) - 1].tax_amount_for_current_item; - } else if(tax.charge_type == "On Previous Row Total") { + current_net_amount = this.frm.doc["taxes"][cint(tax.row_id) - 1].grand_total_for_current_item current_tax_amount = (tax_rate / 100.0) * this.frm.doc["taxes"][cint(tax.row_id) - 1].grand_total_for_current_item; } else if (tax.charge_type == "On Item Quantity") { + // don't sum current net amount due to the field being a currency field current_tax_amount = tax_rate * item.qty; }