First page Back Continue Last page Text

Notes:


Budget Cells also are a predicates, this means that for each movement, we can query applicable budget cells and check if this movement will exceed the budget or not, this can for example be used as constraints and guards for workflow transitions.

When defining the budget, the matrix box in BudgetLine_view sets membership criterion base category list and membership criterion category list on each Budget Cell based on the cell coordinates and the categories on the budget line.

We can use domain tool utility to search all budget cells that can be applied on a context movement, but we usually have to translate categories defined on the movement to predicate categories on the budget cell. In the example above, the Purchase Invoice Transaction Line is the movement for which we want to search predicates, but we can simply search with the categories on the movement: The group will be the group category from the destination section on the movement, the source will be the destination category on the movement. We'll use something like this:

budget_cell_list = portal.portal_domains.searchPredicateList(

context=movement.asContext(categories=(

'group/%s' % movement.getDestinationSectionValue().getGroup(),

'source/%s' % movement.getDestination()))

In the example above, both cell for N1:G1 and N1:G1.1 have to be checked for excessive consumption.

Of course, this translation is different from one budget structure to another. The translation is also different from one movement portal type to another, for example on a sale invoice transaction, we would have taken the group from the source_section's group, and the source from the source.

One possible generic implementation could be:

for budget in portal.budget_module.searchFolder(validation_state='validated'):

budget_model = budget.getSpecialiseValue(portal_type='Budget Model')

context_list = budget_model.asPredicateContextList(delivery)

for context in context_list:

# search budget cell predicates and check if budget_cell.getAvailableBudget() >= context.getQuantity()

In this implementation, the translation from movement categories to predicate context categories is again delegated to the budget model.

Note that we pass the delivery to asPredicateContextList, because we want to group movements impacting the same budget cell together, to prevent situations where individual movements do not exceed available budget, but all movements together exceed.

This asPredicateContextList looks similar to getAggregatedAmountList again, the budget model can be seen as a transformation ?

This is not implemented, and so far the predicate context is returned by a custom ad-hoc script.