Skip to content

Commit

Permalink
Fix contract + test insureepolicy + flake
Browse files Browse the repository at this point in the history
  • Loading branch information
delcroip committed Oct 30, 2024
1 parent 067ebf4 commit f3429a1
Show file tree
Hide file tree
Showing 31 changed files with 1,957 additions and 1,365 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ It is dedicated to be deployed as a module of [openimis-be_py](https://github.co
* tblContractContributionPlanDetails > ContractContributionPlanDetails

## Listened Django Signals
- post_save - Payment: handles service activate_contracted_policies - only when payment
- post_save - Payment: handles service activate_contracted_policies - only when payment
is related to the contract/contracts. (it is verified by this post save)
Another payments are omitted in processing.

## GraphQl Queries
* contract
* contract
* contractDetails
* contractContributionPlanDetails

Expand All @@ -35,7 +35,7 @@ Another payments are omitted in processing.
## Additional mutation log helper in Create graphQl mutations - ObjectMutation from core
- "ObjectMutation" from openimis-be-core_py - models.py
- "object_mutated" method allows the creation of an object to update the xxxMutation easily.
- dedicated for createContract and createContractDetails graphQl mutations
- dedicated for createContract and createContractDetails graphQl mutations
- more info about it and how it was implemented here in Contract module in models.py in class ObjectMutation in docs string

## Services
Expand All @@ -48,10 +48,10 @@ Another payments are omitted in processing.
- renew
- delete
- get_negative_amount_amendment
- terminate_contract
- terminate_contract
- ContractDetails
- update_from_ph_insuree
- ph_insuree_to_contract_details
- get_details_from_ph_insuree
- ph_insuree_to_contract_details
- ContractContributionPlanDetails - CRUD services, replace
- create_ccpd (ccpd - acronym of contract contribution plan details)
- contract_valuation
Expand Down Expand Up @@ -90,8 +90,8 @@ Another payments are omitted in processing.


## bulk operations - required configuration
- for 'bulk approve contract' and 'bulk counter contract' graphQL mutations
- for 'bulk approve contract' and 'bulk counter contract' graphQL mutations
- running rabbitmq docker image
- running celery within "{imis_directory}/openimis-be_py/venv/bin/celery":
- running celery within "{imis_directory}/openimis-be_py/venv/bin/celery":
`-A openIMIS worker --loglevel=DEBUG --without-gossip --without-mingle --without-heartbeat -Ofair`
- without this required steps you won't be able to bulk counter/approve contract
- without this required steps you won't be able to bulk counter/approve contract
3 changes: 1 addition & 2 deletions contract/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@

default_app_config = 'contract.apps.ContractConfig'
default_app_config = "contract.apps.ContractConfig"
3 changes: 1 addition & 2 deletions contract/admin.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
from django.contrib import admin

# from django.contrib import admin
# Register your models here.
3 changes: 1 addition & 2 deletions contract/apps.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from django.apps import AppConfig


MODULE_NAME = "contract"


Expand Down Expand Up @@ -59,6 +58,6 @@ def __load_config(self, cfg):

def ready(self):
from core.models import ModuleConfiguration

cfg = ModuleConfiguration.get_or_default(MODULE_NAME, DEFAULT_CFG)
self.__load_config(cfg)
import contract.signals
161 changes: 41 additions & 120 deletions contract/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,147 +2,68 @@
"ContractState": [
{
"value": "1",
"label":
{
"fr": "Demande d'information",
"en": "Request for information"
}
"label": {"fr": "Demande d'information", "en": "Request for information"},
},
{
"value": "2",
"label":
{
"fr": "Brouillon",
"en": "Draft"
}
},
{
"value": "3",
"label":
{
"fr": "Offre",
"en": "offer"
}
},
{
"value": "4",
"label":
{
"fr": "En negociation",
"en": "Negotiable"

}
},
{
"value": "5",
"label":
{
"fr": "Apprové",
"en": "executable"

}
},
{
"value": "6",
"label":
{
"fr": "addendum",
"en": "addendum"
}
},
{
"value": "7",
"label":
{
"fr": "En cours",
"en": "effective"
}
},
{
"value": "8",
"label":
{
"fr": "Appliqué",
"en": "executed"

}
},
{
"value": "9",
"label":
{
"fr": "Suspendu",
"en": "Disputed"
}
},
{
"value": "10",
"label":
{
"fr": "Terminé",
"en": "terminated"
}
},
{
"value": "11",
"label":
{
"fr": "révision demandé",
"en": "counter"
}
}]
{"value": "2", "label": {"fr": "Brouillon", "en": "Draft"}},
{"value": "3", "label": {"fr": "Offre", "en": "offer"}},
{"value": "4", "label": {"fr": "En negociation", "en": "Negotiable"}},
{"value": "5", "label": {"fr": "Apprové", "en": "executable"}},
{"value": "6", "label": {"fr": "addendum", "en": "addendum"}},
{"value": "7", "label": {"fr": "En cours", "en": "effective"}},
{"value": "8", "label": {"fr": "Appliqué", "en": "executed"}},
{"value": "9", "label": {"fr": "Suspendu", "en": "Disputed"}},
{"value": "10", "label": {"fr": "Terminé", "en": "terminated"}},
{"value": "11", "label": {"fr": "révision demandé", "en": "counter"}},
]
}


def get_message_approved_contract(code, name, contact_name, due_amount, payment_reference, language='en'):
def get_message_approved_contract(
code, name, contact_name, due_amount, payment_reference, language="en"
):
message_payment_notification = {
"payment_notification":
{"en":
F"""
Dear {contact_name}
"payment_notification": {
"en": f"""
Dear {contact_name}
The contract {code} - {name} was approved.
Please proceed to the payment of {due_amount} with the reference {payment_reference}.
Best regards,
"""
,
"fr":
F"""
Please proceed to the payment of {due_amount} with the reference {payment_reference}.
Best regards,
""",
"fr": f"""
Monsieur, Madame {contact_name}
le contract {code} - {name} à été apprové.
Veuillez faire un paiement de < CONTRACT - DUEAMOUNT > avec la référence {payment_reference}.
Meilleurs Salutations
"""
}
Meilleurs Salutations
""",
}
}
return message_payment_notification["payment_notification"][language]


def get_message_counter_contract(code, name, contact_name, language='en'):
def get_message_counter_contract(code, name, contact_name, language="en"):
message_payment_notification = {
"payment_notification":
{"en":
F"""
Dear {contact_name}
"payment_notification": {
"en": f"""
Dear {contact_name}
The contract {code} - {name} was counter.
Please proceed recheck the information and correct the issues, in case of questions please check contact us.
Please proceed recheck the information and correct the issues,
in case of questions please check contact us.
Best regards,
"""
,
"fr":
F"""
Best regards,
""",
"fr": f"""
Monsieur, Madame {contact_name}
le contract {code} - {name} à été contré.
Veuillez verifier les information saisie, en cas de question veuillez nous contacter.
Meilleurs Salutations
"""
}
Meilleurs Salutations
""",
}
}
return message_payment_notification["payment_notification"][language]
2 changes: 1 addition & 1 deletion contract/gql/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .gql_types import *
# from .gql_types import *
1 change: 0 additions & 1 deletion contract/gql/gql_mutations/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
from .input_types import *
39 changes: 27 additions & 12 deletions contract/gql/gql_mutations/contract_details_mutations.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
from core.gql.gql_mutations import DeleteInputType
from core.gql.gql_mutations.base_mutation import BaseMutation, BaseDeleteMutation, \
BaseHistoryModelCreateMutationMixin, BaseHistoryModelUpdateMutationMixin, \
BaseHistoryModelDeleteMutationMixin
from .mutations import ContractDetailsFromPHInsureeMutationMixin
from contract.gql.gql_mutations import ContractDetailsCreateInputType, ContractDetailsUpdateInputType, \
ContractDetailsCreateFromInsureeInputType
from core.gql.gql_mutations.base_mutation import (
BaseDeleteMutation,
BaseHistoryModelCreateMutationMixin,
BaseHistoryModelDeleteMutationMixin,
BaseHistoryModelUpdateMutationMixin,
BaseMutation,
)

from contract.gql.gql_mutations.input_types import (
ContractDetailsCreateFromInsureeInputType,
ContractDetailsCreateInputType,
ContractDetailsUpdateInputType,
)
from contract.models import ContractDetails, ContractDetailsMutation

from .mutations import ContractDetailsFromPHInsureeMutationMixin


class CreateContractDetailsMutation(BaseHistoryModelCreateMutationMixin, BaseMutation):
_mutation_class = "ContractDetailsMutation"
Expand All @@ -17,11 +26,13 @@ class CreateContractDetailsMutation(BaseHistoryModelCreateMutationMixin, BaseMut
def _mutate(cls, user, **data):
client_mutation_id = data.get("client_mutation_id")
if "client_mutation_id" in data:
data.pop('client_mutation_id')
data.pop("client_mutation_id")
if "client_mutation_label" in data:
data.pop('client_mutation_label')
data.pop("client_mutation_label")
contract_detail = cls.create_object(user=user, object_data=data)
ContractDetailsMutation.object_mutated(user, client_mutation_id=client_mutation_id, contract_detail=contract_detail)
ContractDetailsMutation.object_mutated(
user, client_mutation_id=client_mutation_id, contract_detail=contract_detail
)
return None

class Input(ContractDetailsCreateInputType):
Expand All @@ -37,7 +48,9 @@ class Input(ContractDetailsUpdateInputType):
pass


class DeleteContractDetailsMutation(BaseHistoryModelDeleteMutationMixin, BaseDeleteMutation):
class DeleteContractDetailsMutation(
BaseHistoryModelDeleteMutationMixin, BaseDeleteMutation
):
_mutation_class = "ContractDetailsMutation"
_mutation_module = "contract"
_model = ContractDetails
Expand All @@ -46,10 +59,12 @@ class Input(DeleteInputType):
pass


class CreateContractDetailByPolicyHolderInsureeMutation(ContractDetailsFromPHInsureeMutationMixin, BaseMutation):
class CreateContractDetailByPolicyHolderInsureeMutation(
ContractDetailsFromPHInsureeMutationMixin, BaseMutation
):
_mutation_class = "CreateContractDetailByPolicyHolderInsureetMutation"
_mutation_module = "contract"
_model = ContractDetails

class Input(ContractDetailsCreateFromInsureeInputType):
pass
pass
Loading

0 comments on commit f3429a1

Please sign in to comment.