From 68d6fc142bfafce21df1a2da5235d45e87656e24 Mon Sep 17 00:00:00 2001 From: khushi8112 Date: Tue, 18 Nov 2025 16:26:35 +0530 Subject: [PATCH] fix: check root type instead of account type --- .../doctype/journal_entry/journal_entry.py | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.py b/erpnext/accounts/doctype/journal_entry/journal_entry.py index aeb8c9970a3..e4aaf4e7a5a 100644 --- a/erpnext/accounts/doctype/journal_entry/journal_entry.py +++ b/erpnext/accounts/doctype/journal_entry/journal_entry.py @@ -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)