mirror of
https://github.com/frappe/erpnext.git
synced 2026-08-12 06:01:46 +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:
@@ -484,6 +484,12 @@ class JournalEntry(AccountsController):
|
||||
d.idx, d.account, d.party_type
|
||||
)
|
||||
)
|
||||
elif d.party_type or d.party:
|
||||
frappe.throw(
|
||||
_(
|
||||
"Row {0}: Party Type or 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):
|
||||
customers = list(
|
||||
|
||||
@@ -662,6 +662,13 @@ class TestJournalEntry(ERPNextTestSuite):
|
||||
jv.save()
|
||||
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 test_validate_reference_doc_debit_against_sales_order_throws(self):
|
||||
"""Characterize: a debit entry linked to a Sales Order is rejected."""
|
||||
from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order
|
||||
|
||||
Reference in New Issue
Block a user