Skip to content

Improve performance on Budget valiation #43939

Closed
@ruthra-kumar

Description

@ruthra-kumar

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):

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions