Contribution plan calculation rule: legacy contribution

github: GitHub - openimis/openimis-be-calcrule_contribution_legacy_py: Calculation rule that will host the logic to have the policy value and policy creation logic for legacy

version = 1
status = active
UUID = 2aee6d54-eef4-4ee6-1c47-2793cfa5f9a8
calculation_rule_name = โ€œContribution: legacyโ€œ

type = account_receivable

sub_type = contribution

dateValidTo = None

dateValidFrom = 2000-01-01

from_to: [{โ€œfromโ€:โ€Policyโ€,โ€toโ€:โ€Invoiceโ€}, {โ€œfromโ€:โ€ContractContributionPlanDetailsโ€,โ€toโ€:โ€InvoiceLineโ€},]

list of impacted parameters: NULL (will take data from product, claims โ€ฆ )

description = โ€œ This calculation will, for the selected level and product, calculate how much the insuree will have to pay based on the product modeling, it will also manage the conversion into an invoiceโ€œ

Service

activeForObject(self, instance, context, type, sub_type)
instance.__class__ == (ContributionPan and context IN (submit)) and self.checkCalculation(instance)
check_calculation(cls, 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 // for legacy the calculation is valid for all famillies else if class == Familly match = True break
calculate(cls, instance, โ€œcontextโ€œ: value/duration/members default null, *args[date_from, date_to, productid, location])
instance.__class__ == ContractContributionPlanDetails OR Policies

ย 

convert(from, to, obj_from)

to convert a โ€œfromโ€ object (obj_from) to a to object

from = โ€˜Contract' / 'Policyโ€™

to = 'Invoice'

obj_from policy/contract obj

Wrappers are required to attach โ€œconvertโ€œ function to those signal

  • Policy activated (obj_from is the instance from the signal data)

returns the obj_to

convert_batch(from, to, **agrv)

โ†’ only required for informal sector

argv : product or dateStart, dateEnd, location (optionnal)

Informal sector / from Policy to Invoice: this function will take the all polices related to the product (all product if not specified) that have no invoice and were created in the period specified in the specified location if any

Save the invoice in database

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)

ย 

Converter

informal sector

1 invoice per policy, with 1 invoiceLineItem, dependants might be documented in the details invoiceItemLine

Invoice:

field

type

comment

subject_type

json

Familly

subject_id

json

FamillyID

ย thirdparty_type

str

Insuree

ย thirdparty_id

id/uuid

InsureeID

ย code

ย strย 

IV-[PRODUCT code]-CHFID-YYMM

ย date_due

ย dateย 

policy effective date

ย date_invoice

ย dateย 

Date of the enrolment

ย *dateValidFrom

ย dateย 

validFrom: policy effective date

ย *dateValidTo

ย dateย 

validTo: policy expiry date

ย amount_discount

ย floatย 

total of the detail discount

ย amount_net

ย floatย 

Total without tax

ย tax_analysis

ย jsonย 

null

ย amount_total

ย floatย 

total net

ย status

ย intย 

validated

ย currency_rcp_code

ย strย 

default-curency

ย currency_code

ย strย 

default-curency-code

ย note

ย bigttextย 

ย 

ย terms

ย bigttextย 

ย 

InvoiceItem

field

type

comment

HistoryBusinessModel fields

ย 

validFrom: Policy efective date

validTo:Policy exiry date

line_id

ย 

policy_id

line_type

ย 

policy

code

ย strย 

PRODUCT-code

description

ย strย 

PRODUCT-label

details

ย jsonย 

Dependant otherName, name, gender, age, relation to insuree

ledger_account

ย intย 

Product premium accounting code

quantity

ย floatย 

1

unit_price

ย typeย 

BASE Policy Value

discount

ย floatย 

renewal discount โ€ฆ

ย tax_rate

ย Calculation uuidย 

null

tax_analysis

json

amount_total

float

net +tax

amount_net

ย 

qty * unitprice - discount

ย 

ย 

Contribution overall process (documentation purpose only) unit price
Contract:

the invoice of a contract will match the contract value and details.

Registration on signals from other module(existing or not)

  • contractApproved

  • invoiceCreationFromCalculation

Converters:

Invoice

field

type

comment

subject_type

str

Contract

subject_id

id/uuid

ContractID

ย thirdparty_type

str

PolicyHolder

ย thirdparty_id

id/uuid

PolicyHolderID

ย code

ย strย 

IV-[contract code]

ย date_due

ย dateย 

contract-payment-due

ย date_invoice

ย dateย 

Date of the contract approved

ย *dateValidFrom

ย dateย 

validFrom: contract validFrom

ย *dateValidTo

ย dateย 

validTo:contract validTo

ย amount_discount

ย floatย 

total of the detail discount

ย amount_net

ย floatย 

Total without tax

ย tax_analysis

ย jsonย 

ย amount_total

ย floatย 

total net

ย status

ย intย 

validated

ย currency_rcp_code

ย strย 

default-curency

ย currency_code

ย strย 

default-curency-code

ย note

ย bigttextย 



ย terms

ย bigttextย 





invoiceItem

field

type

comment

HistoryBusinessModel fields

ย 

validFrom: contractDetails validFrom

validTo:contract contractDetails validTo

line_id

ย 

ContractContributionPlanDetails id

line_type

ย 

ContractContributionPlanDetails

code

ย strย 

Product-code

description

ย strย 

product-desc

details

ย jsonย 

Dependant otherName, name, gender, age, relation to insuree

ledger_account

ย intย 

Product premium accounting code

quantity

ย floatย 

1

unit_price

ย typeย 

contractdetail Value

discount

ย floatย 



ย tax_rate

ย Calculation uuidย 

null

tax_analysis

json

amount_total

float

net

amount_net

ย 

qty * unitprice - discount



Did you encounter a problem or do you have a suggestion?

Please contact our Service Desk



This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. https://creativecommons.org/licenses/by-sa/4.0/