From 69016a284f5f4f644e75723a4c47908a003ba81c Mon Sep 17 00:00:00 2001 From: diptanilsaha Date: Sat, 8 Nov 2025 12:31:09 +0530 Subject: [PATCH] test: added test to validate disabled pos profile --- .../doctype/pos_profile/test_pos_profile.py | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/erpnext/accounts/doctype/pos_profile/test_pos_profile.py b/erpnext/accounts/doctype/pos_profile/test_pos_profile.py index 029e8ca650f..002c913a7a2 100644 --- a/erpnext/accounts/doctype/pos_profile/test_pos_profile.py +++ b/erpnext/accounts/doctype/pos_profile/test_pos_profile.py @@ -4,6 +4,7 @@ import unittest import frappe from frappe.tests import IntegrationTestCase +from frappe.utils import cint from erpnext.accounts.doctype.pos_profile.pos_profile import ( get_child_nodes, @@ -38,6 +39,50 @@ class TestPOSProfile(IntegrationTestCase): frappe.db.sql("delete from `tabPOS Profile`") + def test_disabled_pos_profile_creation(self): + make_pos_profile(name="_Test POS Profile 001", disabled=1) + + pos_profile = frappe.get_doc("POS Profile", "_Test POS Profile 001") + + if pos_profile: + self.assertEqual(pos_profile.disabled, 1) + + def test_disabled_pos_profile_after_opening(self): + from erpnext.accounts.doctype.pos_closing_entry.test_pos_closing_entry import init_user_and_profile + from erpnext.accounts.doctype.pos_opening_entry.test_pos_opening_entry import create_opening_entry + + test_user, pos_profile = init_user_and_profile() + + if pos_profile: + create_opening_entry(pos_profile, test_user.name) + self.assertEqual(pos_profile.disabled, 0) + + pos_profile.disabled = 1 + self.assertRaises(frappe.ValidationError, pos_profile.save) + + def test_disabled_pos_profile_after_completing_session(self): + from erpnext.accounts.doctype.pos_closing_entry.pos_closing_entry import ( + make_closing_entry_from_opening, + ) + from erpnext.accounts.doctype.pos_closing_entry.test_pos_closing_entry import init_user_and_profile + from erpnext.accounts.doctype.pos_opening_entry.test_pos_opening_entry import ( + create_opening_entry, + ) + + test_user, pos_profile = init_user_and_profile() + + if pos_profile: + opening_entry = create_opening_entry(pos_profile, test_user.name) + + closing_entry = make_closing_entry_from_opening(opening_entry) + closing_entry.submit() + + pos_profile.disabled = 1 + pos_profile.save() + pos_profile.reload() + + self.assertEqual(pos_profile.disabled, 1) + def get_customers_list(pos_profile=None): if pos_profile is None: @@ -117,6 +162,7 @@ def make_pos_profile(**args): "write_off_account": args.write_off_account or "_Test Write Off - _TC", "write_off_cost_center": args.write_off_cost_center or "_Test Write Off Cost Center - _TC", "location": "Block 1" if not args.do_not_set_accounting_dimension else None, + "disabled": cint(args.disabled) or 0, } )