From ff5142be3e974a4acd62ed9171359a77068da219 Mon Sep 17 00:00:00 2001 From: Diptanil Saha Date: Tue, 1 Apr 2025 12:40:47 +0530 Subject: [PATCH] fix: pos checking opened entry closed or not (#46726) * fix: pos checking opened entry closed or not * fix: linter issue * fix: linter issue --- .../pos_closing_entry/pos_closing_entry.py | 5 +++++ .../page/point_of_sale/pos_controller.js | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+) 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 7e6faee9d6..196298ceb7 100644 --- a/erpnext/accounts/doctype/pos_closing_entry/pos_closing_entry.py +++ b/erpnext/accounts/doctype/pos_closing_entry/pos_closing_entry.py @@ -128,6 +128,11 @@ class POSClosingEntry(StatusUpdater): def on_submit(self): consolidate_pos_invoices(closing_entry=self) + frappe.publish_realtime( + f"poe_{self.pos_opening_entry}_closed", + self, + docname=f"POS Opening Entry/{self.pos_opening_entry}", + ) def on_cancel(self): unconsolidate_pos_invoices(closing_entry=self) diff --git a/erpnext/selling/page/point_of_sale/pos_controller.js b/erpnext/selling/page/point_of_sale/pos_controller.js index 5fa1050cd0..118aab289b 100644 --- a/erpnext/selling/page/point_of_sale/pos_controller.js +++ b/erpnext/selling/page/point_of_sale/pos_controller.js @@ -132,6 +132,25 @@ erpnext.PointOfSale.Controller = class { this.make_app(); } }); + + frappe.realtime.on(`poe_${this.pos_opening}_closed`, (data) => { + if (data) { + frappe.dom.freeze(); + frappe.msgprint({ + title: __("POS Closed"), + indicator: "orange", + message: __("POS has been closed at {0}. Please refresh the page.", [ + frappe.datetime.str_to_user(data.creation).bold(), + ]), + primary_action_label: __("Refresh"), + primary_action: { + action() { + window.location.reload(); + }, + }, + }); + } + }); } set_opening_entry_status() { -- GitLab