Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve performance on Budget valiation #43939

Open
ruthra-kumar opened this issue Oct 31, 2024 · 3 comments
Open

Improve performance on Budget valiation #43939

ruthra-kumar opened this issue Oct 31, 2024 · 3 comments
Assignees

Comments

@ruthra-kumar
Copy link
Member

ruthra-kumar commented Oct 31, 2024

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

for x in item / gl entry:
 for dim in all_dimensions:
  for budget in all_budgets:
   calculate_and_validate_expenses()

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.

def validate_expense_against_budget(args, expense_amount=0):

@ruthra-kumar ruthra-kumar self-assigned this Oct 31, 2024
@miteshpc
Copy link

Maybe the logic used for making Trial Balance work with large memory footprint data, can work here too.

@ruthra-kumar
Copy link
Member Author

Maybe the logic used for making Trial Balance work with large memory footprint data, can work here too.

You mean the 'Account Closing Balance' feature?

@nabinhait nabinhait added performance and removed bug labels Nov 4, 2024
@ruthra-kumar
Copy link
Member Author

ruthra-kumar commented Nov 4, 2024

For Purchase Order, there are some

  1. 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)
  2. Cache the results for each key - (expense_account, dimension) - new method with clear parameters

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants