You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current implementation of budget validation needs some refactor. On large sites, Purchase Orders with 100 items timeout while submitting.
Bottlenecks
Unavoidable nested-loop
Purchase Order can have any number of Items 'I', each item can have any number of dimensions 'D', and each dimension can have budgets for different fiscal years 'B'.
This structure lends itself to be handled by nested-loop - (I x D x B), like so
Unlike GL Entry, PO has all the 'Items' and dimensions already available while validating. Deduplication can be done beforehand. Only validate for each unique key - (expense_account, dimension)
Cache the results for each key - (expense_account, dimension) - new method with clear parameters
Issue
The current implementation of budget validation needs some refactor. On large sites, Purchase Orders with 100 items timeout while submitting.
Bottlenecks
Unavoidable nested-loop
Purchase Order can have any number of Items 'I', each item can have any number of dimensions 'D', and each dimension can have budgets for different fiscal years 'B'.
This structure lends itself to be handled by nested-loop - (I x D x B), like so
Methods are too generic
validate_expense_against_budget()
is too generic. It implicitly handles individual GL Entries and 'Items' (from Purchase Order) passed as args.erpnext/erpnext/accounts/doctype/budget/budget.py
Line 143 in c7d6923
The text was updated successfully, but these errors were encountered: