Skip to content

Commit

Permalink
fix: allow nested accounts to be validated with accounting dimensions
Browse files Browse the repository at this point in the history
  • Loading branch information
Rohan Bansal committed May 2, 2024
1 parent 22c345a commit 0ded850
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion erpnext/accounts/general_ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from frappe import _
from frappe.model.meta import get_field_precision
from frappe.utils import cint, flt, formatdate, getdate, now
from frappe.utils.nestedset import get_descendants_of

import erpnext
from erpnext.accounts.doctype.accounting_dimension.accounting_dimension import (
Expand Down Expand Up @@ -704,7 +705,12 @@ def validate_allowed_dimensions(gl_entry, dimension_filter_map):
dimension = key[0]
account = key[1]

if gl_entry.account == account:
if frappe.get_cached_value("Account", account, "is_group"):
accounts = get_descendants_of("Account", account)
else:
accounts = [account]

if gl_entry.account in accounts:
if value["is_mandatory"] and not gl_entry.get(dimension):
frappe.throw(
_("{0} is mandatory for account {1}").format(
Expand Down

0 comments on commit 0ded850

Please sign in to comment.