From 271d22fff1fac732ebc39b9b00d37d67900468b4 Mon Sep 17 00:00:00 2001 From: pandiyan Date: Wed, 12 Aug 2026 15:59:16 +0530 Subject: [PATCH] test(accounts): cover reversal of a reverse journal entry also assert that a user without read access on the entry gets a permission error instead of the reversal relationship. (cherry picked from commit 80422d2108137ddafc171bf0d38b025204952bbf) --- .../journal_entry/test_journal_entry.py | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/erpnext/accounts/doctype/journal_entry/test_journal_entry.py b/erpnext/accounts/doctype/journal_entry/test_journal_entry.py index 51922757d05..a34b440a228 100644 --- a/erpnext/accounts/doctype/journal_entry/test_journal_entry.py +++ b/erpnext/accounts/doctype/journal_entry/test_journal_entry.py @@ -248,6 +248,27 @@ class TestJournalEntry(ERPNextTestSuite): self.check_gl_entries() + def test_disallow_reversal_of_a_reversal_journal_entry(self): + from erpnext.accounts.doctype.journal_entry.mapper import make_reverse_journal_entry + + jv = make_journal_entry("_Test Bank - _TC", "Sales - _TC", 100, submit=True) + + rjv = make_reverse_journal_entry(jv.name) + rjv.posting_date = nowdate() + rjv.submit() + + self.assertRaisesRegex( + frappe.ValidationError, + "is already a Reverse Journal Entry", + make_reverse_journal_entry, + rjv.name, + ) + + # the guard must not disclose the reversal to a user who cannot read the entry + frappe.set_user("Guest") + self.addCleanup(frappe.set_user, "Administrator") + self.assertRaises(frappe.PermissionError, make_reverse_journal_entry, rjv.name) + def test_disallow_change_in_account_currency_for_a_party(self): # create jv in USD jv = make_journal_entry("_Test Bank USD - _TC", "_Test Receivable USD - _TC", 100, save=False)