version = 1
status = active
UUID = 2aee6d54-eef4-4ee6-1c47-2793cfa5f9a8
calculation_rule_name = “payment: fee for service “
type = account_receivable
sub_type = contribution
dateValidTo = None
dateValidFrom = 2000-01-01
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)
Code Block |
---|
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, *args[date_from, date_to, productid, location])
instance.__class__ == ContractDetails OR Policies
https://github.com/openimis/openimis-be-policy_py/blob/develop/policy/values.py
convert(from, to, **agrs)
from = ‘Contract' / 'Policy’
to = 'Invoice'
argv (for all invoices, )date_from, date_to,, product_id, location
Registration on signals from other module(existing or not):
Policy activated
if active_for_object(ContractDetails/Policy, 'submit', type, sub_type):
calculate(cls, <contribution>, *args[date_from, date_to, productid, location])
getLinkedClass(classname)
Code Block |
---|
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 | |||||
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 |
| |||||
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 | ||||||
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)
contractApprovedinvoiceCreationFromCalculation
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 | |||
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 |