mirror of
https://github.com/frappe/erpnext.git
synced 2026-06-07 15:12:51 +00:00
fix: validate root type as well
This commit is contained in:
@@ -326,10 +326,15 @@ class JournalEntry(AccountsController):
|
|||||||
|
|
||||||
def validate_depr_account_and_depr_entry_voucher_type(self):
|
def validate_depr_account_and_depr_entry_voucher_type(self):
|
||||||
for d in self.get("accounts"):
|
for d in self.get("accounts"):
|
||||||
|
root_type = frappe.get_cached_value("Account", d.account, "root_type")
|
||||||
if (
|
if (
|
||||||
d.reference_type == "Asset"
|
d.reference_type == "Asset"
|
||||||
and d.reference_name
|
and d.reference_name
|
||||||
and (d.account_type == "Depreciation" or self.voucher_type == "Depreciation Entry")
|
and (
|
||||||
|
d.account_type == "Depreciation"
|
||||||
|
or self.voucher_type == "Depreciation Entry"
|
||||||
|
or root_type == "Expense"
|
||||||
|
)
|
||||||
and d.debit
|
and d.debit
|
||||||
):
|
):
|
||||||
if d.account_type != "Depreciation":
|
if d.account_type != "Depreciation":
|
||||||
@@ -340,7 +345,7 @@ class JournalEntry(AccountsController):
|
|||||||
_("Journal Entry type should be set as Depreciation Entry for asset depreciation")
|
_("Journal Entry type should be set as Depreciation Entry for asset depreciation")
|
||||||
)
|
)
|
||||||
|
|
||||||
if frappe.get_cached_value("Account", d.account, "root_type") != "Expense":
|
if root_type != "Expense":
|
||||||
frappe.throw(_("Account {0} should be of type Expense").format(d.account))
|
frappe.throw(_("Account {0} should be of type Expense").format(d.account))
|
||||||
|
|
||||||
def validate_stock_accounts(self):
|
def validate_stock_accounts(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user