From 3f577779be3c8a2140ffb24947252c15b848a008 Mon Sep 17 00:00:00 2001 From: Ninad1306 Date: Mon, 25 Nov 2024 10:44:25 +0530 Subject: [PATCH] fix: initially closing amt should be equal to expected amt (cherry picked from commit af9524920bc1de7587b8f73363edeab2a486e5a8) --- .../doctype/pos_closing_entry/pos_closing_entry.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/erpnext/accounts/doctype/pos_closing_entry/pos_closing_entry.js b/erpnext/accounts/doctype/pos_closing_entry/pos_closing_entry.js index 5711b27da04..7504c79141b 100644 --- a/erpnext/accounts/doctype/pos_closing_entry/pos_closing_entry.js +++ b/erpnext/accounts/doctype/pos_closing_entry/pos_closing_entry.js @@ -147,7 +147,7 @@ frappe.ui.form.on("POS Closing Entry", { frm.doc.grand_total += flt(doc.grand_total); frm.doc.net_total += flt(doc.net_total); frm.doc.total_quantity += flt(doc.total_qty); - refresh_payments(doc, frm); + refresh_payments(doc, frm, false); refresh_taxes(doc, frm); refresh_fields(frm); set_html_data(frm); @@ -172,7 +172,7 @@ function set_form_data(data, frm) { frm.doc.grand_total += flt(d.grand_total); frm.doc.net_total += flt(d.net_total); frm.doc.total_quantity += flt(d.total_qty); - refresh_payments(d, frm); + refresh_payments(d, frm, true); refresh_taxes(d, frm); }); } @@ -186,7 +186,7 @@ function add_to_pos_transaction(d, frm) { }); } -function refresh_payments(d, frm) { +function refresh_payments(d, frm, is_new) { d.payments.forEach((p) => { const payment = frm.doc.payment_reconciliation.find( (pay) => pay.mode_of_payment === p.mode_of_payment @@ -196,9 +196,7 @@ function refresh_payments(d, frm) { } if (payment) { payment.expected_amount += flt(p.amount); - if (payment.closing_amount === 0) { - payment.closing_amount = payment.expected_amount; - } + if (is_new) payment.closing_amount = payment.expected_amount; payment.difference = payment.closing_amount - payment.expected_amount; } else { frm.add_child("payment_reconciliation", {