fix: validation for difference account
(cherry picked from commit fb819c558e)
This commit is contained in:
committed by
Mergify
parent
b507e63375
commit
150cc5a664
@@ -430,17 +430,29 @@ class StockEntry(StockController):
|
||||
).format(frappe.bold(self.company))
|
||||
)
|
||||
|
||||
elif (
|
||||
self.is_opening == "Yes"
|
||||
and frappe.db.get_value("Account", d.expense_account, "report_type") == "Profit and Loss"
|
||||
):
|
||||
acc_details = frappe.get_cached_value(
|
||||
"Account",
|
||||
d.expense_account,
|
||||
["account_type", "report_type"],
|
||||
as_dict=True,
|
||||
)
|
||||
|
||||
if self.is_opening == "Yes" and acc_details.report_type == "Profit and Loss":
|
||||
frappe.throw(
|
||||
_(
|
||||
"Difference Account must be a Asset/Liability type account, since this Stock Entry is an Opening Entry"
|
||||
"Difference Account must be a Asset/Liability type account (Temporary Opening), since this Stock Entry is an Opening Entry"
|
||||
),
|
||||
OpeningEntryAccountError,
|
||||
)
|
||||
|
||||
if acc_details.account_type == "Stock":
|
||||
frappe.throw(
|
||||
_(
|
||||
"At row {0}: the Difference Account must not be a Stock type account, please change the Account Type for the account {1} or select a different account"
|
||||
).format(d.idx, get_link_to_form("Account", d.expense_account)),
|
||||
OpeningEntryAccountError,
|
||||
)
|
||||
|
||||
def validate_warehouse(self):
|
||||
"""perform various (sometimes conditional) validations on warehouse"""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user