erpnext
erpnext copied to clipboard
Include descendant accounts during accounting dimension validation
Is your feature request related to a problem? Please describe. During GL Entry creation, the system validates the applied account against the allowed accounting dimensions. This works well for non-group accounts, but if a group account is provided, the system should validate against all descendant accounts as well.
Describe the solution you'd like
The following code runs the validation of the GL Entry account against applicable individual accounts: https://github.com/frappe/erpnext/blob/41695e601d41d5a0b0b6e7f7c2e6a36c3064b277/erpnext/accounts/general_ledger.py#L704-L707
Which could be changed to:
dimension = key[0]
account = key[1]
if frappe.get_cached_value('Account', account, 'is_group'):
accounts = get_descendants_of('Account', account)
else:
accounts = [account]
if gl_entry.account in accounts:
to include descendant accounts as well.
I don't think this is a feature request, I think it's a bug. Accounting Dimension Filter allows you to select either node or group accounts. Selecting a node account works as expected but selecting a group account has no effect. Certainly from the users perspective this is a bug even if it doesn't raise an error.