fix: added test for runtime effect
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 a6c0102..8eed573 100644
--- a/erpnext/accounts/doctype/pos_closing_entry/pos_closing_entry.js
+++ b/erpnext/accounts/doctype/pos_closing_entry/pos_closing_entry.js
@@ -185,6 +185,7 @@
 		}
 		if (payment) {
 			payment.expected_amount += flt(p.amount);
+			payment.closing_amount = payment.expected_amount;
 			payment.difference = payment.closing_amount - payment.expected_amount;
 		} else {
 			frm.add_child("payment_reconciliation", {
diff --git a/erpnext/accounts/doctype/pos_closing_entry/pos_closing_entry.json b/erpnext/accounts/doctype/pos_closing_entry/pos_closing_entry.json
index 9d15e6c..a98a24c 100644
--- a/erpnext/accounts/doctype/pos_closing_entry/pos_closing_entry.json
+++ b/erpnext/accounts/doctype/pos_closing_entry/pos_closing_entry.json
@@ -221,6 +221,7 @@
    "read_only": 1
   },
   {
+   "default": "Now",
    "fieldname": "posting_time",
    "fieldtype": "Time",
    "label": "Posting Time",
@@ -235,7 +236,7 @@
    "link_fieldname": "pos_closing_entry"
   }
  ],
- "modified": "2022-08-01 11:37:14.991228",
+ "modified": "2023-08-10 16:25:49.322697",
  "modified_by": "Administrator",
  "module": "Accounts",
  "name": "POS Closing Entry",
diff --git a/erpnext/accounts/doctype/pos_closing_entry/test_pos_closing_entry.py b/erpnext/accounts/doctype/pos_closing_entry/test_pos_closing_entry.py
index 1deb3c5..d2eba1e 100644
--- a/erpnext/accounts/doctype/pos_closing_entry/test_pos_closing_entry.py
+++ b/erpnext/accounts/doctype/pos_closing_entry/test_pos_closing_entry.py
@@ -8,9 +8,11 @@
 from erpnext.accounts.doctype.pos_closing_entry.pos_closing_entry import (
 	make_closing_entry_from_opening,
 )
+from erpnext.accounts.doctype.pos_invoice.pos_invoice import make_sales_return
 from erpnext.accounts.doctype.pos_invoice.test_pos_invoice import create_pos_invoice
 from erpnext.accounts.doctype.pos_opening_entry.test_pos_opening_entry import create_opening_entry
 from erpnext.accounts.doctype.pos_profile.test_pos_profile import make_pos_profile
+from erpnext.selling.page.point_of_sale.point_of_sale import get_items
 from erpnext.stock.doctype.stock_entry.test_stock_entry import make_stock_entry
 
 
@@ -67,6 +69,36 @@
 
 		self.assertTrue(pcv_doc.name)
 
+	def test_pos_qty_for_item(self):
+		"""
+		Test if quantity is calculated correctly for an item in POS Closing Entry
+		"""
+		test_user, pos_profile = init_user_and_profile()
+		opening_entry = create_opening_entry(pos_profile, test_user.name)
+
+		test_item_qty = get_test_item_qty(pos_profile)
+
+		pos_inv1 = create_pos_invoice(rate=3500, do_not_submit=1)
+		pos_inv1.append("payments", {"mode_of_payment": "Cash", "account": "Cash - _TC", "amount": 3500})
+		pos_inv1.submit()
+
+		pos_inv2 = create_pos_invoice(rate=3200, do_not_submit=1)
+		pos_inv2.append("payments", {"mode_of_payment": "Cash", "account": "Cash - _TC", "amount": 3200})
+		pos_inv2.submit()
+
+		# make return entry of pos_inv2
+		pos_return = make_sales_return(pos_inv2.name)
+		pos_return.paid_amount = pos_return.grand_total
+		pos_return.save()
+		pos_return.submit()
+
+		pcv_doc = make_closing_entry_from_opening(opening_entry)
+		pcv_doc.submit()
+
+		opening_entry = create_opening_entry(pos_profile, test_user.name)
+		test_item_qty_after_sales = get_test_item_qty(pos_profile)
+		self.assertEqual(test_item_qty_after_sales, test_item_qty - 1)
+
 	def test_cancelling_of_pos_closing_entry(self):
 		test_user, pos_profile = init_user_and_profile()
 		opening_entry = create_opening_entry(pos_profile, test_user.name)
@@ -123,3 +155,19 @@
 	pos_profile.save()
 
 	return test_user, pos_profile
+
+
+def get_test_item_qty(pos_profile):
+	test_item_pos = get_items(
+		start=0,
+		page_length=40,
+		price_list="Standard Selling",
+		pos_profile=pos_profile.name,
+		search_term="_Test Item",
+		item_group="All Item Groups",
+	)
+
+	test_item_qty = [item for item in test_item_pos["items"] if item["item_code"] == "_Test Item"][0][
+		"actual_qty"
+	]
+	return test_item_qty
diff --git a/erpnext/accounts/doctype/pos_invoice_merge_log/pos_invoice_merge_log.py b/erpnext/accounts/doctype/pos_invoice_merge_log/pos_invoice_merge_log.py
index 4f46aa1..3a684d4 100644
--- a/erpnext/accounts/doctype/pos_invoice_merge_log/pos_invoice_merge_log.py
+++ b/erpnext/accounts/doctype/pos_invoice_merge_log/pos_invoice_merge_log.py
@@ -273,21 +273,6 @@
 			si.flags.ignore_validate = True
 			si.cancel()
 
-	def get_batched_invoices(self, pos_invoice_docs):
-		grouped_batch = []
-		current_batch = []
-		for item in pos_invoice_docs:
-			if not current_batch:
-				current_batch.append(item)
-			elif current_batch[-1].get("is_return") != item.get("is_return"):
-				grouped_batch.append(current_batch)
-				current_batch = [item]
-			else:
-				current_batch.append(item)
-
-		grouped_batch.append(current_batch)
-		return grouped_batch
-
 
 def update_item_wise_tax_detail(consolidate_tax_row, tax_row):
 	consolidated_tax_detail = json.loads(consolidate_tax_row.item_wise_tax_detail)