diff --git a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py index b2e4ea875d0..3a1ab35db7e 100644 --- a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py @@ -3493,6 +3493,14 @@ class TestSalesInvoice(ERPNextTestSuite): si.submit() frappe.db.set_value("Company", "_Test Company", "accounts_frozen_till_date", None) + def test_sales_invoice_cancellation_post_account_freezing_date(self): + si = create_sales_invoice() + frappe.db.set_value("Company", "_Test Company", "accounts_frozen_till_date", add_days(getdate(), 1)) + try: + self.assertRaises(frappe.ValidationError, si.cancel) + finally: + frappe.db.set_value("Company", "_Test Company", "accounts_frozen_till_date", None) + @ERPNextTestSuite.change_settings("Accounts Settings", {"over_billing_allowance": 0}) @ERPNextTestSuite.change_settings("Selling Settings", {"allow_multiple_items": 1}) def test_over_billing_case_against_delivery_note(self): diff --git a/erpnext/accounts/general_ledger.py b/erpnext/accounts/general_ledger.py index 2c793765946..0c535ff6b4b 100644 --- a/erpnext/accounts/general_ledger.py +++ b/erpnext/accounts/general_ledger.py @@ -640,7 +640,7 @@ def make_reverse_gl_entries( partial_cancel=partial_cancel, ) validate_accounting_period(gl_entries) - check_freezing_date(gl_entries[0]["posting_date"], adv_adj) + check_freezing_date(gl_entries[0]["posting_date"], gl_entries[0]["company"], adv_adj) is_opening = any(d.get("is_opening") == "Yes" for d in gl_entries)