mirror of
https://github.com/frappe/erpnext.git
synced 2026-09-14 01:20:41 +00:00
fix: restrict Party Type/Party to Receivable/Payable accounts in Journal Entry
Journal Entry validation only checked party details when an account was of type Receivable/Payable, but never restricted setting a Party Type or Party against accounts of other types. This regressed v14 behavior where party info could only be captured for Receivable/Payable accounts. Add a branch to validate_party() that throws when a Party Type or Party is set on an account that is not Receivable/Payable, with a clear message. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -613,6 +613,12 @@ class JournalEntry(AccountsController):
|
|||||||
d.idx, d.account, d.party_type
|
d.idx, d.account, d.party_type
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
elif d.party_type or d.party:
|
||||||
|
frappe.throw(
|
||||||
|
_(
|
||||||
|
"Row {0}: Party Type and Party can only be set for Receivable / Payable account, but account {1} is of type {2}"
|
||||||
|
).format(d.idx, d.account, account_type or _("None"))
|
||||||
|
)
|
||||||
|
|
||||||
def check_credit_limit(self):
|
def check_credit_limit(self):
|
||||||
customers = list(
|
customers = list(
|
||||||
|
|||||||
@@ -609,6 +609,13 @@ class TestJournalEntry(ERPNextTestSuite):
|
|||||||
jv.save()
|
jv.save()
|
||||||
self.assertRaises(frappe.ValidationError, jv.submit)
|
self.assertRaises(frappe.ValidationError, jv.submit)
|
||||||
|
|
||||||
|
def test_party_not_allowed_for_non_receivable_payable_account(self):
|
||||||
|
customer = make_customer("_Test New Customer")
|
||||||
|
jv = make_journal_entry(account1="_Test Cash - _TC", account2="_Test Bank - _TC", amount=100, save=False)
|
||||||
|
jv.accounts[0].party_type = "Customer"
|
||||||
|
jv.accounts[0].party = customer
|
||||||
|
self.assertRaises(frappe.ValidationError, jv.save)
|
||||||
|
|
||||||
|
|
||||||
def make_journal_entry(
|
def make_journal_entry(
|
||||||
account1,
|
account1,
|
||||||
|
|||||||
Reference in New Issue
Block a user