Calculation rule: Social Protection
Calculation Rule Summary: Social Protection: GitHub - openimis/openimis-be-calcrule_social_protection_py: Calculation rule for social protection scheme
Version:
1Status:
activeUUID:
32d96b58-898a-460a-b357-5fd4b95cd87cCalculation Rule Name:
Calculation rule: social protectionDescription:
DESCRIPTION_CONTRIBUTION_VALUATIONType:
social_protectionSub-Type:
benefit_planDate Valid From:
2000-01-01Date Valid To:
NoneFrom-To: Loaded from
FROM_TO(used in conversion patterns)Impacted Classes: Defined in
CLASS_RULE_PARAM_VALIDATIONPrimary Class:
PaymentPlan
Impacted Parameters
Based on CLASS_RULE_PARAM_VALIDATION, this rule defines parameters related to PaymentPlan. These include attributes like type, name, label, rights, relevance, and condition. Parameters are evaluated for visibility (relevance) and validity (condition) using the Handsontable Formula Parser.
CLASS_RULE_PARAM_VALIDATION = [
{
"class": "PaymentPlan",
"parameters": [
{
"type": "number",
"name": "fixed_batch",
"label": {
"en": "Fixed amount",
"fr": "Lot fixe"
},
"rights": {
"read": "157101",
"write": "157102",
"update": "157103",
"replace": "157206"
},
"relevance": "True",
"condition": "INPUT>=0",
"default": "0"
},
{
"type": "number",
"name": "limit_per_single_transaction",
"label": {
"en": "Limit Per Single Transaction",
"fr": "Limite par transaction unique"
},
"rights": {
"read": "157101",
"write": "157102",
"update": "157103",
"replace": "157206"
},
"relevance": "True",
"condition": "INPUT>=0",
"default": ""
}
]
}
]
FROM_TO = None
DESCRIPTION_CONTRIBUTION_VALUATION = F"" \
F"This is example of calculation rule module," \
F" skeleton generated automaticallly via command"Template Methods
run_calculation_rules(sender, instance, user, context)
Triggers the rule only if the instance is a PaymentPlan. Delegates to calculate_if_active_for_object.
calculate_if_active_for_object(payment_plan)
Runs calculate() if active_for_object() returns True.
active_for_object(payment_plan)
Returns whether the rule is relevant for the instance by running check_calculation().
check_calculation(payment_plan)
Delegates eligibility checks to the strategy engine via:
BenefitPackageStrategyStorage.choose_strategy(payment_plan).check_calculation(...)calculate(payment_plan, **kwargs)
Main calculation logic delegated to strategy:
BenefitPackageStrategyStorage.choose_strategy(payment_plan).calculate(...)convert(payment_plan, **kwargs)
Handles transformation/conversion logic (e.g., for bill creation or other financial document structuring).
🔁 Converters & Strategies
Strategies for how to calculate or convert are imported from:
calcrule_social_protection.strategies.BenefitPackageStrategyStorageThese encapsulate different behavior depending on the nature of the benefit package.
Services & Signal Integration
get_linked_class(sender, class_name)
Returns class relationships such as:
PaymentPlan → CalculationBenefitPlan → PaymentPlanBeneficiary → BenefitPlan
get_parameters(sender, class_name, instance)
Returns relevant parameters if the class is in CLASS_NAME_CHECK or is validated via UUID. Relevance and condition logic apply.
run_convert(payment_plan, **kwargs)
Triggers conversion logic using strategy-specific convert methods.
get_payment_cycle_parameters(**kwargs)
Extracts contextually relevant values (like user_id, start_date, etc.) for use in calculations or conversions.
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/