Skip to content

Commit

Permalink
Link default beneficiary status to SocialProtectionConfig for consist…
Browse files Browse the repository at this point in the history
…ency
  • Loading branch information
amschel-de-r committed Dec 11, 2024
1 parent 169e58e commit f74846f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
7 changes: 5 additions & 2 deletions individual/gql_mutations.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from individual.services import IndividualService, GroupService, GroupIndividualService, \
CreateGroupAndMoveIndividualService
from location.models import Location, LocationManager
from social_protection.apps import SocialProtectionConfig


class CreateIndividualInputType(OpenIMISMutation.Input):
Expand All @@ -30,6 +31,7 @@ class UpdateIndividualInputType(CreateIndividualInputType):
RoleEnum = graphene.Enum.from_enum(GroupIndividual.Role)
RecipientTypeEnum = graphene.Enum.from_enum(GroupIndividual.RecipientType)

DEFAULT_BENEFICIARY_STATUS = SocialProtectionConfig.default_beneficiary_status

class CreateGroupIndividualInputType(OpenIMISMutation.Input):
group_id = graphene.UUID(required=False)
Expand Down Expand Up @@ -571,7 +573,8 @@ def _mutate(cls, user, **data):
data.pop('client_mutation_label')
custom_filters = data.pop('custom_filters', None)
benefit_plan_id = data.pop('benefit_plan_id', None)
status = data.pop('status', "ACTIVE")
# TODO check consistency of default status
status = data.pop('status', DEFAULT_BENEFICIARY_STATUS)
service = IndividualService(user)
service.select_individuals_to_benefit_plan(
custom_filters,
Expand Down Expand Up @@ -605,7 +608,7 @@ def _mutate(cls, user, **data):
data.pop('client_mutation_label')
custom_filters = data.pop('custom_filters', None)
benefit_plan_id = data.pop('benefit_plan_id', None)
status = data.pop('status', "ACTIVE")
status = data.pop('status', DEFAULT_BENEFICIARY_STATUS)
service = GroupService(user)
service.select_groups_to_benefit_plan(
custom_filters,
Expand Down
6 changes: 4 additions & 2 deletions individual/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from individual.models import Individual, IndividualDataSource, Group, \
GroupIndividual, IndividualDataSourceUpload, IndividualDataUploadRecords, GroupDataSource
from individual.services import IndividualService, GroupService
from social_protection.apps import SocialProtectionConfig
from location.apps import LocationConfig


Expand All @@ -39,6 +40,7 @@ def patch_details(data_df: pd.DataFrame):
return df_final
return data_df

DEFAULT_BENEFICIARY_STATUS = SocialProtectionConfig.default_beneficiary_status

class Query(ExportableQueryMixin, graphene.ObjectType):
export_patches = {
Expand Down Expand Up @@ -224,7 +226,7 @@ def resolve_individual_enrollment_summary(self, info, **kwargs):
service = IndividualService(user)
custom_filters = kwargs.get("customFilters", None)
benefit_plan_id = kwargs.get("benefitPlanId", None)
status = kwargs.get("status", "ACTIVE")
status = kwargs.get("status", DEFAULT_BENEFICIARY_STATUS)

enrollment_checks = service.run_enrollment_checks(
custom_filters,
Expand Down Expand Up @@ -420,7 +422,7 @@ def resolve_group_enrollment_summary(self, info, **kwargs):
service = GroupService(user)
custom_filters = kwargs.get("customFilters", None)
benefit_plan_id = kwargs.get("benefitPlanId", None)
status = kwargs.get("status", "ACTIVE")
status = kwargs.get("status", DEFAULT_BENEFICIARY_STATUS)

enrollment_checks = service.run_enrollment_checks(
custom_filters,
Expand Down

0 comments on commit f74846f

Please sign in to comment.