From 21a75eb2ba45dcfaf838b934f4486c339456afa6 Mon Sep 17 00:00:00 2001 From: Afshan Date: Fri, 19 Jun 2020 14:36:56 +0530 Subject: [PATCH] fix: set row_id by default as previous row for On Previous Row Amount and On Previous Row Total --- erpnext/public/js/controllers/taxes_and_totals.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/erpnext/public/js/controllers/taxes_and_totals.js b/erpnext/public/js/controllers/taxes_and_totals.js index 28fb6490254..46bb3d3540c 100644 --- a/erpnext/public/js/controllers/taxes_and_totals.js +++ b/erpnext/public/js/controllers/taxes_and_totals.js @@ -329,6 +329,17 @@ erpnext.taxes_and_totals = erpnext.payments.extend({ var tax_rate = this._get_tax_rate(tax, item_tax_map); var current_tax_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)) { + if (tax.idx == 1) { + frappe.throw( + __("Cannot select charge type as 'On Previous Row Amount' or 'On Previous Row Total' for first row")) + } + if (!tax.row_id) { + tax.row_id = tax.idx - 1; + } + } + if(tax.charge_type == "Actual") { // distribute the tax amount proportionally to each item row var actual = flt(tax.tax_amount, precision("tax_amount", tax));