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 e8b20c7e086ac9e091e1ab0ad4c58eaa3a893ea0..7504c79141bb007cc6dcca444c6c1e7ab90d204c 100644 --- a/erpnext/accounts/doctype/pos_closing_entry/pos_closing_entry.js +++ b/erpnext/accounts/doctype/pos_closing_entry/pos_closing_entry.js @@ -121,42 +121,15 @@ frappe.ui.form.on("POS Closing Entry", { }, before_save: async function (frm) { - if (frm.doc.__unsaved) { - frappe.dom.freeze(__("Processing Sales! Please Wait...")); - frm.set_value("grand_total", 0); - frm.set_value("net_total", 0); - frm.set_value("total_quantity", 0); - frm.set_value("taxes", []); + frappe.dom.freeze(__("Processing Sales! Please Wait...")); - for (let row of frm.doc.payment_reconciliation) { - row.expected_amount = row.opening_amount; - } + frm.set_value("grand_total", 0); + frm.set_value("net_total", 0); + frm.set_value("total_quantity", 0); + frm.set_value("taxes", []); - await Promise.all([ - frappe.call({ - method: "erpnext.accounts.doctype.pos_closing_entry.pos_closing_entry.get_pos_invoices", - args: { - start: frappe.datetime.get_datetime_as_string(frm.doc.period_start_date), - end: frappe.datetime.get_datetime_as_string(frm.doc.period_end_date), - pos_profile: frm.doc.pos_profile, - user: frm.doc.user, - }, - callback: (r) => { - let pos_invoices = r.message; - for (let doc of pos_invoices) { - 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_taxes(doc, frm); - refresh_fields(frm); - set_html_data(frm); - } - set_closing_amount(frm); - }, - }), - ]); - frappe.dom.unfreeze(); + for (let row of frm.doc.payment_reconciliation) { + row.expected_amount = row.opening_amount; } await Promise.all([ @@ -202,7 +175,6 @@ function set_form_data(data, frm) { refresh_payments(d, frm, true); refresh_taxes(d, frm); }); - set_closing_amount(frm); } function add_to_pos_transaction(d, frm) { @@ -237,14 +209,6 @@ function refresh_payments(d, frm, is_new) { }); } -function set_closing_amount(frm) { - frm.doc.payment_reconciliation.forEach((pm) => { - if (pm.closing_amount === 0) { - pm.closing_amount = pm.expected_amount; - } - }); -} - function refresh_taxes(d, frm) { d.taxes.forEach((t) => { const tax = frm.doc.taxes.find((tx) => tx.account_head === t.account_head && tx.rate === t.rate); diff --git a/erpnext/accounts/doctype/pos_closing_entry/pos_closing_entry.py b/erpnext/accounts/doctype/pos_closing_entry/pos_closing_entry.py index 2003bad2abbd6016ee99942399d78d4086544b89..fda868cfe5135df7bb94f4b7e83597db73443d09 100644 --- a/erpnext/accounts/doctype/pos_closing_entry/pos_closing_entry.py +++ b/erpnext/accounts/doctype/pos_closing_entry/pos_closing_entry.py @@ -1,6 +1,7 @@ # Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors # For license information, please see license.txt + import frappe from frappe import _ from frappe.utils import flt, get_datetime @@ -13,6 +14,43 @@ from erpnext.controllers.status_updater import StatusUpdater class POSClosingEntry(StatusUpdater): + # begin: auto-generated types + # This code is auto-generated. Do not modify anything in this block. + + from typing import TYPE_CHECKING + + if TYPE_CHECKING: + from frappe.types import DF + + from erpnext.accounts.doctype.pos_closing_entry_detail.pos_closing_entry_detail import ( + POSClosingEntryDetail, + ) + from erpnext.accounts.doctype.pos_closing_entry_taxes.pos_closing_entry_taxes import ( + POSClosingEntryTaxes, + ) + from erpnext.accounts.doctype.pos_invoice_reference.pos_invoice_reference import ( + POSInvoiceReference, + ) + + amended_from: DF.Link | None + company: DF.Link + error_message: DF.SmallText | None + grand_total: DF.Currency + net_total: DF.Currency + payment_reconciliation: DF.Table[POSClosingEntryDetail] + period_end_date: DF.Datetime + period_start_date: DF.Datetime + pos_opening_entry: DF.Link + pos_profile: DF.Link + pos_transactions: DF.Table[POSInvoiceReference] + posting_date: DF.Date + posting_time: DF.Time + status: DF.Literal["Draft", "Submitted", "Queued", "Failed", "Cancelled"] + taxes: DF.Table[POSClosingEntryTaxes] + total_quantity: DF.Float + user: DF.Link + # end: auto-generated types + def validate(self): self.posting_date = self.posting_date or frappe.utils.nowdate() self.posting_time = self.posting_time or frappe.utils.nowtime()