mirror of
https://github.com/frappe/erpnext.git
synced 2025-12-03 18:35:36 +00:00
fix: check root type instead of account type
This commit is contained in:
@@ -326,26 +326,13 @@ class JournalEntry(AccountsController):
|
||||
|
||||
def validate_depr_account_and_depr_entry_voucher_type(self):
|
||||
for d in self.get("accounts"):
|
||||
root_type = frappe.get_cached_value("Account", d.account, "root_type")
|
||||
if (
|
||||
d.reference_type == "Asset"
|
||||
and d.reference_name
|
||||
and (
|
||||
d.account_type == "Depreciation"
|
||||
or self.voucher_type == "Depreciation Entry"
|
||||
or root_type == "Expense"
|
||||
)
|
||||
and d.debit
|
||||
):
|
||||
if d.account_type != "Depreciation":
|
||||
frappe.throw(_("Account {0} should be of type Depreciation").format(d.account))
|
||||
|
||||
if d.account_type == "Depreciation":
|
||||
if self.voucher_type != "Depreciation Entry":
|
||||
frappe.throw(
|
||||
_("Journal Entry type should be set as Depreciation Entry for asset depreciation")
|
||||
)
|
||||
|
||||
if root_type != "Expense":
|
||||
if frappe.get_cached_value("Account", d.account, "root_type") != "Expense":
|
||||
frappe.throw(_("Account {0} should be of type Expense").format(d.account))
|
||||
|
||||
def validate_stock_accounts(self):
|
||||
@@ -466,7 +453,7 @@ class JournalEntry(AccountsController):
|
||||
if (
|
||||
d.reference_type == "Asset"
|
||||
and d.reference_name
|
||||
and d.account_type == "Depreciation"
|
||||
and frappe.get_cached_value("Account", d.account, "root_type") == "Expense"
|
||||
and d.debit
|
||||
):
|
||||
asset = frappe.get_cached_doc("Asset", d.reference_name)
|
||||
|
||||
Reference in New Issue
Block a user