From bb3eb8117043ceea1558ea85349511d23bb704b1 Mon Sep 17 00:00:00 2001 From: rethik Date: Mon, 3 Feb 2025 19:22:37 +0530 Subject: [PATCH 1/3] fix: add validate to allow equity account and party_type shareholder (cherry picked from commit 2c8e3f3409bd755ebd0ce7faa22f7aa1ac148d7a) --- erpnext/accounts/party.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/party.py b/erpnext/accounts/party.py index 0df9dcb0683..38c69ca7eb9 100644 --- a/erpnext/accounts/party.py +++ b/erpnext/accounts/party.py @@ -765,7 +765,11 @@ def validate_account_party_type(self): if self.party_type and self.party: account_type = frappe.get_cached_value("Account", self.account, "account_type") - if account_type and (account_type not in ["Receivable", "Payable"]): + if ( + account_type + and (account_type not in ["Receivable", "Payable", "Equity"]) + and self.party_type != "Shareholder" + ): frappe.throw( _( "Party Type and Party can only be set for Receivable / Payable account

" "{0}" From 552b5a79ce338bd518e1f10d841c99d102002612 Mon Sep 17 00:00:00 2001 From: rethik Date: Mon, 3 Feb 2025 19:29:59 +0530 Subject: [PATCH 2/3] test: add unit test to validate account type and party type (cherry picked from commit 9422ce5aee303c738de4fda9dc01cc02fd1bbfc9) --- .../accounts/doctype/gl_entry/test_gl_entry.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/erpnext/accounts/doctype/gl_entry/test_gl_entry.py b/erpnext/accounts/doctype/gl_entry/test_gl_entry.py index f6ed163bff5..6ff378559c0 100644 --- a/erpnext/accounts/doctype/gl_entry/test_gl_entry.py +++ b/erpnext/accounts/doctype/gl_entry/test_gl_entry.py @@ -124,3 +124,20 @@ class TestGLEntry(unittest.TestCase): str(e), "Party Type and Party can only be set for Receivable / Payable account_Test Account Cost for Goods Sold - _TC", ) + + def test_validate_account_party_type_shareholder(self): + jv = make_journal_entry( + "Opening Balance Equity - _TC", + "Cash - _TC", + 100, + "_Test Cost Center - _TC", + save=False, + submit=False, + ) + + for row in jv.accounts: + row.party_type = "Shareholder" + break + + jv.save().submit() + self.assertEqual(1, jv.docstatus) From 0d2115197e5345b532cdee80dfcb0029acea348e Mon Sep 17 00:00:00 2001 From: rethik Date: Tue, 4 Feb 2025 11:07:41 +0530 Subject: [PATCH 3/3] fix: remove party type from validate (cherry picked from commit f82837a4a28d387a4e80ec0df9729ddfa104240f) --- erpnext/accounts/party.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/erpnext/accounts/party.py b/erpnext/accounts/party.py index 38c69ca7eb9..f2e86ef2b2e 100644 --- a/erpnext/accounts/party.py +++ b/erpnext/accounts/party.py @@ -765,11 +765,7 @@ def validate_account_party_type(self): if self.party_type and self.party: account_type = frappe.get_cached_value("Account", self.account, "account_type") - if ( - account_type - and (account_type not in ["Receivable", "Payable", "Equity"]) - and self.party_type != "Shareholder" - ): + if account_type and (account_type not in ["Receivable", "Payable", "Equity"]): frappe.throw( _( "Party Type and Party can only be set for Receivable / Payable account

" "{0}"