From 87a8c17314c0268109d1a60d8a90c470e2548c3f Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Sat, 11 Feb 2023 11:53:47 +0530 Subject: [PATCH] fix: Amount for debit and credit notes with 0 qty line items (#33902) 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 2ce0c7eb00d..a87c3ec9514 100644 --- a/erpnext/public/js/controllers/taxes_and_totals.js +++ b/erpnext/public/js/controllers/taxes_and_totals.js @@ -126,7 +126,16 @@ erpnext.taxes_and_totals = class TaxesAndTotals extends erpnext.payments { 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);