$customHeader
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

contributionValuationRule inherit from absCalculationRule

static version = 1
status = active
static UUID = 0e1b6dd4-04a0-4ee6-ac47-2a99cfa5e9a8
static CalculationRuleName = “CV: percent of income “

dateValidTo = None

dateValidFrom = 2000-01-01

static description = “ This calcutation will add the income in the contract details and PHinsuree and the percentage in the Contribution plan so when a contract valuation is requested then the calculation will determine the value based on the contract details income and CP percentage “
list of impacted class and parameters

{class:"ContributionPlan", ‘parameters':['type':"select",'name':"rate",'label':{'en':'Percentage of income',’fr':'Pourcentage du salaire'},'rights':{'read':"151201", ‘write':'151202','update’:'151203','replace’:'151206'},relevance:"True",condition:".$_>1",'optionSet':[{'value':'5',label:{'en':'5%','fr':'5%'}},{'value':'10',label:{'en':'10%','fr':'10%'}},{'value':'15',label:{'en':'15%','fr':'15%'}},],'default':'5']}

{class:"ContractDetails", ‘parameters':['type':"float",'name':"income",'label':{'en':'Income','fr':'Salaire'},'rights':{'read':"152101", ‘create':"152102”,'update’:”152103",'replace’:”152103"},relevance:"True",condition:"$_>100",'default':'']}

{class:"PolicyHolderInsuree", ‘parameters':['type':"float",'name':"income",'label':{'en':'Income','fr':'Salaire'},'rights':{'read':"150201", ‘create':"150202”,'update’:”150203",'replace’:”150206"},relevance:"True",condition:"$_>100",'default':'']}

relevance and condition are Nice to have.

Methods

ready()

Make sure the now is within dataValid (or after dateValidFrom if dateValidTo is None)

make sure the status is active

then

Register

  • getParameter to getParameter signal

  • getLinkedClass ot getLinkedClass signal

activeForObject(self, instance, context)
instance.__class__ == CCPD and context IN (create,update) and self.checkCalculation(instance)
checkCalculation(self, instance)

class= class of instance

match = False

if class == ContributionPlan

match =self.UUID == instance.calculation

else if class == PH insuree

match = checkCalculation(instance.cpb)

else if class == ContractDetails:

match =checkCalculation(instance.cpb)

else if class == ContractContributionPlanDetails

match =checkCalculation(instance.cp)

else if class == ContributionPlanBundle:

for cp in instance.cp

if checkCalculation(cp)

match = True

break

}

calculate(instance)

if instance.__class__ == ContractContributionPlanDetails

rate = instance.contribution_plan.json_ext.rate

income = instance.contract_details.json_ext.income

CCPD.value = income * rate

return CCPD.value

else Return False

getLinkedClass(classname)

ListClass = []

if class == ContributionPlan or class == None

ListClass.amend(Calculation)

else if class == PH insuree or class == None

ListClass.amend( ContributionPlanBundle)

else if class == ContractDetails or class == None

ListClass.amend( ContributionPlanBundle)

else if class == ContractContributionPlanDetails or class == None

ListClass.amend(ContributionPlan)

else if class == ContributionPlanBundle or class == None

ListClass.amend(ContributionPlan)

return listClass

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,

checkCalculation(instance) #check if the calculation is really concerning the class for that context

return a list only with rule details that matches step 1 and 2

  • No labels