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 7e6faee9d625ce16ee0359da42bab0a18c895a77..196298ceb70ef8bef069eef432a75d0b87fbd8ce 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 5fa1050cd011f34295deebba633b094d7a9259a3..118aab289b0b23ad1990dd003e98dc4de0713478 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() {