Contribution plan calculation rule: legacy contribution
github: https://github.com/openimis/openimis-be-calcrule-contribution-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 |
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/