diff --git a/erpnext/accounts/doctype/pos_profile/test_pos_profile.py b/erpnext/accounts/doctype/pos_profile/test_pos_profile.py index f2e3c8fcf59..427748627ed 100644 --- a/erpnext/accounts/doctype/pos_profile/test_pos_profile.py +++ b/erpnext/accounts/doctype/pos_profile/test_pos_profile.py @@ -4,6 +4,11 @@ import unittest import frappe +<<<<<<< HEAD +======= +from frappe.tests import IntegrationTestCase +from frappe.utils import cint +>>>>>>> 69016a284f (test: added test to validate disabled pos profile) from erpnext.accounts.doctype.pos_profile.pos_profile import ( get_child_nodes, @@ -38,6 +43,50 @@ class TestPOSProfile(unittest.TestCase): 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 +166,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, } )