...
calculate(instance, *args)
NEED TO BE DEFINED ON RULE LEVEL
Function that will do the calculation based on the parameters
...
getLinkedClass(List[classname])
NEED TO BE DEFINED ON RULE LEVEL
that function will return the possible instance that can have a link to the calculation
Module function/Service
NEED TO BE DEFINED ON MODULE LEVEL
This function has two steps
1- getRuleDetails(classname)
define which calculation has param for the class name
...
return the CalculationRulesDetails json object
runCalculationRules(instance, context)
1- getRuleDetails(instance.__class__)
2- for each rule
if activeForObject(instance)
calculate(instance)
getParamteres(ClassName, instance)
#className is the class name of the object where the calculation param need to be added
#instance is where the link with a calculation need to be found, like the CPB in case of PH insuree or Contract Details
This function has two steps
1- getRuleDetails(className)
2- define if the calculation should be used
for each “eligible“ ruleDetails,
check checkCalculation(instance) #check if the calculation is really concerning the class for that context checkCalculation(instance)
return the ruleDetails that are valid to classname and related to instance
(should have)getLinkedClass(List[ClassName] = None)
#List[ClassName] is send from FE, by checking the class used in page where the user ave access if None (in case too difficult to do on the FE) all liked class will be retrieve
for all calculation rules:
res.amend (getLinkedClass(List[ClassName])
Authorities
Calculation (prefix 153)
...
Calculations Frontend Module
...
(NICE TO HAVE, or via Django Admin)Calculation management page
...