fix: honor account freezing date when cancelling vouchers

make_reverse_gl_entries passed adv_adj as the company argument to
check_freezing_date, so the freeze-date check silently no-op'd on
cancellation (no company matched). Pass company explicitly so
cancellations respect the freezing date like submissions do.

Adds a regression test covering cancellation after the freeze date.
This commit is contained in:
Nabin Hait
2026-05-27 01:01:43 +05:30
parent 234c4a45b8
commit 3ec6387425
2 changed files with 9 additions and 1 deletions

View File

@@ -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):

View File

@@ -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)