From 2408966090d2b341053e2247c481d4f08d05a77e Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Sun, 19 Feb 2023 11:37:44 +0530 Subject: [PATCH] fix: Amount for debit and credit notes with 0 qty line items (backport #33902) (#34123) fix: Amount for debit and credit notes with 0 qty line items (#33902) (cherry picked from commit 47c91324b13217db83670c97a6e0488ae78b8b14) Co-authored-by: Deepesh Garg --- erpnext/public/js/controllers/taxes_and_totals.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/erpnext/public/js/controllers/taxes_and_totals.js b/erpnext/public/js/controllers/taxes_and_totals.js index 92796073be7..be4eab03386 100644 --- a/erpnext/public/js/controllers/taxes_and_totals.js +++ b/erpnext/public/js/controllers/taxes_and_totals.js @@ -119,7 +119,16 @@ erpnext.taxes_and_totals = erpnext.payments.extend({ frappe.model.round_floats_in(item); item.net_rate = item.rate; item.qty = item.qty === undefined ? (me.frm.doc.is_return ? -1 : 1) : item.qty; - item.net_amount = item.amount = flt(item.rate * item.qty, precision("amount", item)); + + if (!(me.frm.doc.is_return || me.frm.doc.is_debit_note)) { + item.net_amount = item.amount = flt(item.rate * item.qty, precision("amount", item)); + } + else { + let qty = item.qty || 1; + qty = me.frm.doc.is_return ? -1 * qty : qty; + item.net_amount = item.amount = flt(item.rate * qty, precision("amount", item)); + } + item.item_tax_amount = 0.0; item.total_weight = flt(item.weight_per_unit * item.stock_qty);