Skip to content

Commit

Permalink
Merge pull request #21 from openimis/develop
Browse files Browse the repository at this point in the history
MERGING develop into release/24.04
  • Loading branch information
delcroip authored Mar 28, 2024
2 parents 5134f9f + d3a1c25 commit 28374c2
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 21 deletions.
2 changes: 1 addition & 1 deletion calcrule_social_protection/calculation_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def calculate_if_active_for_object(cls, payment_plan, **kwargs):
return cls.calculate(payment_plan, **kwargs)

@classmethod
def active_for_object(cls, payment_plan):
def active_for_object(cls, payment_plan, **kwargs):
return cls.check_calculation(payment_plan)

@classmethod
Expand Down
6 changes: 3 additions & 3 deletions calcrule_social_protection/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"type": "number",
"name": "fixed_batch",
"label": {
"en": "Fixed batch",
"fr": "Fixed batch"
"en": "Fixed amount",
"fr": "Lot fixe"
},
"rights": {
"read": "157101",
Expand All @@ -24,7 +24,7 @@
"name": "limit_per_single_transaction",
"label": {
"en": "Limit Per Single Transaction",
"fr": "Limit Per Single Transaction"
"fr": "Limite par transaction unique"
},
"rights": {
"read": "157101",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ class BuilderToBenefitConverter:
TYPE = None

@classmethod
def to_benefit_obj(cls, entity, amount, payment_plan):
def to_benefit_obj(cls, entity, amount, payment_plan, payment_cycle):
benefit = {}
cls._build_individual(benefit, entity)
cls._build_code(benefit)
cls._build_amount(benefit, amount)
cls._build_date_dates(benefit, payment_plan)
cls._build_date_dates(benefit, payment_plan, payment_cycle)
cls._build_type(benefit)
cls._build_status(benefit)
return benefit
Expand All @@ -36,9 +36,8 @@ def _build_amount(cls, benefit, amount):
benefit["amount"] = amount

@classmethod
def _build_date_dates(cls, benefit, payment_plan):
from core import datetime, datetimedelta
benefit["date_due"] = f"{datetime.date.today() + datetimedelta(days=30)}"
def _build_date_dates(cls, benefit, payment_plan, payment_cycle):
benefit["date_due"] = f"{payment_cycle.end_date}"
benefit["date_valid_from"] = f"{ payment_plan.benefit_plan.date_valid_from}"
benefit["date_valid_to"] = f"{payment_plan.benefit_plan.date_valid_to}"

Expand Down
11 changes: 5 additions & 6 deletions calcrule_social_protection/converters/builder/builder_to_bill.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ class BuilderToBillConverter:
TYPE = None

@classmethod
def to_bill_obj(cls, payment_plan, entity, amount, end_date):
def to_bill_obj(cls, payment_plan, entity, amount, end_date, payment_cycle):
bill = {}
cls._build_subject(bill, entity)
cls._build_thirdparty(bill, payment_plan)
cls._build_code(bill)
cls._build_price(bill, amount)
cls._build_terms(bill, payment_plan, entity, end_date)
cls._build_date_dates(bill, payment_plan)
cls._build_date_dates(bill, payment_plan, payment_cycle)
cls._build_currency(bill)
cls._build_status(bill)
return bill
Expand Down Expand Up @@ -46,10 +46,9 @@ def _build_price(cls, bill, amount):
bill["amount_net"] = amount

@classmethod
def _build_date_dates(cls, bill, payment_plan):
from core import datetime, datetimedelta
bill["date_due"] = f"{datetime.date.today() + datetimedelta(days=30)}"
bill["date_bill"] = f"{datetime.date.today()}"
def _build_date_dates(cls, bill, payment_plan, payment_cycle):
bill["date_due"] = f"{payment_cycle.end_date}"
bill["date_bill"] = f"{payment_cycle.start_date}"
bill["date_valid_from"] = f"{ payment_plan.benefit_plan.date_valid_from}"
bill["date_valid_to"] = f"{payment_plan.benefit_plan.date_valid_to}"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,13 @@ def convert(cls, payment_plan, **kwargs):
converter = kwargs.get('converter')
converter_item = kwargs.get('converter_item')
converter_benefit = kwargs.get('converter_benefit')
payment_cycle = kwargs.get('payment_cycle')
convert_results = cls._convert_entity_to_bill(
converter, converter_item, payment_plan, entity, amount, end_date
converter, converter_item, payment_plan, entity, amount, end_date, payment_cycle
)
convert_results['user'] = kwargs.get('user', None)
convert_results_benefit = cls._convert_entity_to_benefit(
converter_benefit, payment_plan, entity, amount
converter_benefit, payment_plan, entity, amount, payment_cycle
)
user = convert_results['user']
if not cls.is_exceed_limit:
Expand Down Expand Up @@ -139,10 +140,10 @@ def create_and_save_business_entities(

@classmethod
def _convert_entity_to_bill(
cls, converter, converter_item, payment_plan, entity, amount, end_date
cls, converter, converter_item, payment_plan, entity, amount, end_date, payment_cycle
):
bill = converter.to_bill_obj(
payment_plan, entity, amount, end_date
payment_plan, entity, amount, end_date, payment_cycle
)
bill_line_items = [
converter_item.to_bill_item_obj(payment_plan, entity, amount)
Expand All @@ -155,9 +156,9 @@ def _convert_entity_to_bill(

@classmethod
def _convert_entity_to_benefit(
cls, converter_benefit, payment_plan, entity, amount
cls, converter_benefit, payment_plan, entity, amount, payment_cycle
):
benefit = converter_benefit.to_benefit_obj(entity, amount, payment_plan)
benefit = converter_benefit.to_benefit_obj(entity, amount, payment_plan, payment_cycle)
return {
'benefit_data': benefit,
'type_conversion': 'beneficiary - benefit'
Expand Down

0 comments on commit 28374c2

Please sign in to comment.