fix: POS Closing Entry load all invoices with one request on save (#35819)

fix: load all invoices with one request
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 e6d9fe2..a6c0102 100644
--- a/erpnext/accounts/doctype/pos_closing_entry/pos_closing_entry.js
+++ b/erpnext/accounts/doctype/pos_closing_entry/pos_closing_entry.js
@@ -123,22 +123,29 @@
 			row.expected_amount = row.opening_amount;
 		}
 
-		const pos_inv_promises = frm.doc.pos_transactions.map(
-			row => frappe.db.get_doc("POS Invoice", row.pos_invoice)
-		);
-
-		const pos_invoices = await Promise.all(pos_inv_promises);
-
-		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);
-		}
-
+		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);
+					}
+				}
+			})
+		])
 		frappe.dom.unfreeze();
 	}
 });