mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-16 11:39:18 +00:00
Merge pull request #47389 from frappe/mergify/bp/version-14-hotfix/pr-47376
fix: validation for difference account (backport #47376)
This commit is contained in:
@@ -9,7 +9,17 @@ import frappe
|
|||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.model.mapper import get_mapped_doc
|
from frappe.model.mapper import get_mapped_doc
|
||||||
from frappe.query_builder.functions import Sum
|
from frappe.query_builder.functions import Sum
|
||||||
from frappe.utils import cint, comma_or, cstr, flt, format_time, formatdate, getdate, nowdate
|
from frappe.utils import (
|
||||||
|
cint,
|
||||||
|
comma_or,
|
||||||
|
cstr,
|
||||||
|
flt,
|
||||||
|
format_time,
|
||||||
|
formatdate,
|
||||||
|
get_link_to_form,
|
||||||
|
getdate,
|
||||||
|
nowdate,
|
||||||
|
)
|
||||||
|
|
||||||
import erpnext
|
import erpnext
|
||||||
from erpnext.accounts.general_ledger import process_gl_map
|
from erpnext.accounts.general_ledger import process_gl_map
|
||||||
@@ -430,17 +440,29 @@ class StockEntry(StockController):
|
|||||||
).format(frappe.bold(self.company))
|
).format(frappe.bold(self.company))
|
||||||
)
|
)
|
||||||
|
|
||||||
elif (
|
acc_details = frappe.get_cached_value(
|
||||||
self.is_opening == "Yes"
|
"Account",
|
||||||
and frappe.db.get_value("Account", d.expense_account, "report_type") == "Profit and Loss"
|
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(
|
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,
|
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):
|
def validate_warehouse(self):
|
||||||
"""perform various (sometimes conditional) validations on warehouse"""
|
"""perform various (sometimes conditional) validations on warehouse"""
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user