Skip to content

Api reference

components.member_lifecycle.public.commands

generate_frontend_types_file

generate_frontend_typescript_types_files

generate_frontend_typescript_types_files(dry_run)

Use flask generate_frontend_typescript_types_files --execute to generate the frontend typescript types.

  • File: "frontend/modules/member-lifecycle/add-dependents/src/queryTypes.ts"
  • Types: all enums and entities
Source code in components/member_lifecycle/public/commands/generate_frontend_types_file.py
@member_lifecycle_commands.command()
@command_with_dry_run
def generate_frontend_typescript_types_files(dry_run: bool) -> None:
    """
    Use `flask generate_frontend_typescript_types_files --execute` to generate the frontend typescript types.

    - File: "frontend/modules/member-lifecycle/add-dependents/src/queryTypes.ts"
    - Types: all enums and entities
    """
    from shared.codegen.typescript import (
        generate_typescript_enums_and_interfaces,
    )

    generate_typescript_enums_and_interfaces(
        target_filename_path_from_git_root="frontend/modules/member-lifecycle/add-dependents/src/queryTypes.ts",
        types_to_generate=[
            # Enums
        ],
        dry_run=dry_run,
    )

components.member_lifecycle.public.consts

MEMBER_LIFECYCLE_COMPONENT_NAME module-attribute

MEMBER_LIFECYCLE_COMPONENT_NAME = 'member_lifecycle'

components.member_lifecycle.public.dependencies

AddDependentsDependency

AddDependentsDependency(price_provider)

AddDependentsDependency defines the interface that apps using the add_dependents subcomponent need to implement

Source code in components/member_lifecycle/subcomponents/add_dependents/protected/dependencies.py
def __init__(self, price_provider: PriceProvider):
    self.price_provider = price_provider

are_user_reimbursements_blocked

are_user_reimbursements_blocked(user_id)

The method will return whether the user's (primary or dependent) reimbursements are blocked.

Source code in components/member_lifecycle/subcomponents/add_dependents/protected/dependencies.py
def are_user_reimbursements_blocked(
    self,
    user_id: str,
) -> bool:
    """
    The method will return whether the user's (primary or dependent) reimbursements are blocked.
    """
    raise NotImplementedError()

can_add_dependents

can_add_dependents(user_id, start_date)

The method will return True if the user can add dependents

Source code in components/member_lifecycle/subcomponents/add_dependents/protected/dependencies.py
def can_add_dependents(self, user_id: str, start_date: date) -> bool:
    """The method will return True if the user can add dependents"""
    raise NotImplementedError()

contract_allows_partner

contract_allows_partner(user_id, at_date)

The method will return True if the primary's contract allows to add a partner

Source code in components/member_lifecycle/subcomponents/add_dependents/protected/dependencies.py
def contract_allows_partner(self, user_id: str, at_date: date) -> bool:
    """The method will return True if the primary's contract allows to add a partner"""
    raise NotImplementedError()

create_dependent

create_dependent(user_id, payload)

The method will create the dependent for the primary user. Returns: The insurance profile ID of the created dependent.

Source code in components/member_lifecycle/subcomponents/add_dependents/protected/dependencies.py
def create_dependent(
    self,
    user_id: str,
    payload: CreateDependentPayload,
) -> str | None:
    """
    The method will create the dependent for the primary user.
    Returns:
        The insurance profile ID of the created dependent.
    """
    raise NotImplementedError()

get_age_boundaries_by_dependent_type

get_age_boundaries_by_dependent_type(user_id, at_date=None)

The method will return the age boundaries of a dependent for the user Boundaries are included, meaning the dependent age should be withing those boundaries, including the boundaries.

Source code in components/member_lifecycle/subcomponents/add_dependents/protected/dependencies.py
def get_age_boundaries_by_dependent_type(
    self, user_id: str, at_date: date | None = None
) -> DependentsAgeBoundaries:
    """
    The method will return the age boundaries of a dependent for the user
    Boundaries are included, meaning the dependent age should be withing those boundaries,
    including the boundaries.
    """
    raise NotImplementedError()

get_beneficiaries_linked_to_user_on

get_beneficiaries_linked_to_user_on(
    user_id,
    on_date=None,
    enrollment_type=None,
    include_future=False,
)

The method will return the beneficiaries linked to the user coverage on a specific date. The beneficiaries contain the primary and their dependents.

Source code in components/member_lifecycle/subcomponents/add_dependents/protected/dependencies.py
def get_beneficiaries_linked_to_user_on(
    self,
    user_id: str,
    on_date: date | None = None,
    enrollment_type: EnrollmentType | None = None,
    include_future: bool = False,
) -> list[BeneficiaryInfo]:
    """
    The method will return the beneficiaries linked to the user coverage on a specific date.
    The beneficiaries contain the primary and their dependents.
    """
    raise NotImplementedError()

get_child_account_minimum_age

get_child_account_minimum_age()

Returns the minimum age required for a child dependent to have an Alan account. Returns None if child dependents are not allowed to have accounts.

Source code in components/member_lifecycle/subcomponents/add_dependents/protected/dependencies.py
def get_child_account_minimum_age(self) -> int | None:
    """
    Returns the minimum age required for a child dependent to have an Alan account.
    Returns None if child dependents are not allowed to have accounts.
    """
    raise NotImplementedError()

get_debt_balance

get_debt_balance(user_id, on_date)

The method will return the debt balance in cents for the user.

Source code in components/member_lifecycle/subcomponents/add_dependents/protected/dependencies.py
def get_debt_balance(self, user_id: str, on_date: date) -> int:
    """
    The method will return the debt balance in cents for the user.
    """
    raise NotImplementedError()

get_default_coverage_module

get_default_coverage_module(
    user_id, at_date, with_details=False
)

Returns the default coverage module that will be applied to new dependents

Source code in components/member_lifecycle/subcomponents/add_dependents/protected/dependencies.py
def get_default_coverage_module(
    self,
    user_id: str,
    at_date: date,
    with_details: bool = False,
) -> DefaultCoverageModuleInfo | None:
    """
    Returns the default coverage module that will be applied to new dependents
    """
    raise NotImplementedError()

get_dependent_tax_benefit_type

get_dependent_tax_benefit_type(user_id, on_date)

The method will return the dependent tax benefit type if eligible else returns None.

Source code in components/member_lifecycle/subcomponents/add_dependents/protected/dependencies.py
def get_dependent_tax_benefit_type(
    self,
    user_id: str,
    on_date: date,
) -> DependentTaxBenefitType | None:
    """
    The method will return the dependent tax benefit type if eligible else returns None.
    """
    raise NotImplementedError()

get_health_contract_info

get_health_contract_info(
    user_id, on_date, new_dependent_birth_date=None
)

The method will return the user's health contract info, including affiliation delay if present

Source code in components/member_lifecycle/subcomponents/add_dependents/protected/dependencies.py
def get_health_contract_info(
    self,
    user_id: str,
    on_date: date,
    new_dependent_birth_date: date | None = None,
) -> HealthContractInfo:
    """The method will return the user's health contract info, including affiliation delay if present"""
    raise NotImplementedError()

get_household_declaration

get_household_declaration(user_id, at_date)

The method will return the household declaration data for the user.

Source code in components/member_lifecycle/subcomponents/add_dependents/protected/dependencies.py
def get_household_declaration(
    self,
    user_id: str,
    at_date: date,
) -> HouseholdDeclaration:
    """
    The method will return the household declaration data for the user.
    """
    raise NotImplementedError()

get_minimum_coverage_months

get_minimum_coverage_months()

The method will return the minimum number of months of coverage required for the dependent.

Source code in components/member_lifecycle/subcomponents/add_dependents/protected/dependencies.py
def get_minimum_coverage_months(self) -> int | None:
    """
    The method will return the minimum number of months of coverage required for the dependent.
    """
    raise NotImplementedError()

get_past_dependents

get_past_dependents(user_id, on_date, birthdate=None)

This method will return the past dependents of the user, relative to the start date of the current or next affiliation on on_date and, if provided, with a specific birthdate. It will exclude dependents that are active on or after on_date.

Source code in components/member_lifecycle/subcomponents/add_dependents/protected/dependencies.py
def get_past_dependents(
    self, user_id: str, on_date: date, birthdate: date | None = None
) -> list[PastDependent]:
    """
    This method will return the past dependents of the user, relative to the start
    date of the current or next affiliation on on_date and, if provided, with a specific birthdate.
    It will exclude dependents that are active on or after on_date.
    """
    raise NotImplementedError()

get_past_dependents_national_identification

get_past_dependents_national_identification(
    past_dependents,
)

The method will return the SSN of a past dependent.

Source code in components/member_lifecycle/subcomponents/add_dependents/protected/dependencies.py
def get_past_dependents_national_identification(
    self, past_dependents: list[PastDependent]
) -> list[NationalIdentification]:
    """
    The method will return the SSN of a past dependent.
    """
    raise NotImplementedError()

get_possible_start_dates

get_possible_start_dates(
    user_id,
    new_dependent_birth_date,
    coverage_start_date_scenario,
    at_date=None,
    existing_dependent_user_id=None,
)

The method will return the possible coverage start dates for the user.

Source code in components/member_lifecycle/subcomponents/add_dependents/protected/dependencies.py
def get_possible_start_dates(
    self,
    user_id: str,
    new_dependent_birth_date: date,
    coverage_start_date_scenario: CoverageStartDateScenario,
    at_date: date | None = None,
    existing_dependent_user_id: str | None = None,
) -> list[date]:
    """
    The method will return the possible coverage start dates for the user.
    """
    raise NotImplementedError()

get_prices_and_conditions_config

get_prices_and_conditions_config(user_id, on_date)

The method will return the features enablement for prices and conditions

Source code in components/member_lifecycle/subcomponents/add_dependents/protected/dependencies.py
def get_prices_and_conditions_config(
    self, user_id: str, on_date: date
) -> PricesAndConditionsConfig:
    """The method will return the features enablement for prices and conditions"""
    raise NotImplementedError()

is_primary_focus_enabled

is_primary_focus_enabled(user_id, on_date)

The method will return whether the primary focus feature is enabled or not.

Source code in components/member_lifecycle/subcomponents/add_dependents/protected/dependencies.py
def is_primary_focus_enabled(self, user_id: str, on_date: date) -> bool:
    """
    The method will return whether the primary focus feature is enabled or not.
    """
    raise NotImplementedError()

price_provider instance-attribute

price_provider = price_provider

require_gender

require_gender()

The method will return whether the add dependent flow requires a gender to be provided.

Source code in components/member_lifecycle/subcomponents/add_dependents/protected/dependencies.py
def require_gender(self) -> bool:
    """
    The method will return whether the add dependent flow requires a gender to be provided.
    """
    raise NotImplementedError()

should_request_payment_method_for_user_subscription

should_request_payment_method_for_user_subscription(
    user_id,
    on_date,
    new_dependent_birth_date=None,
    new_dependent_enrollment_type=None,
    declared_income_in_cents=None,
)

The method will return whether we should request payment method for the user's subscription.

Source code in components/member_lifecycle/subcomponents/add_dependents/protected/dependencies.py
def should_request_payment_method_for_user_subscription(
    self,
    user_id: str,
    on_date: date,
    new_dependent_birth_date: date | None = None,
    new_dependent_enrollment_type: BeneficiaryEnrollmentType | None = None,
    declared_income_in_cents: int | None = None,
) -> bool:
    """
    The method will return whether we should request payment method for the user's subscription.
    """
    raise NotImplementedError()

upload_identification_certificate_for_user

upload_identification_certificate_for_user(
    user_id, attestation_file, on_date=None
)

Upload an identification file for a given user.

Source code in components/member_lifecycle/subcomponents/add_dependents/protected/dependencies.py
def upload_identification_certificate_for_user(
    self,
    user_id: str,
    attestation_file: FileStorage,
    on_date: date | None = None,
) -> None:
    """
    Upload an identification file for a given user.
    """
    raise NotImplementedError()

upsert_household_declaration

upsert_household_declaration(
    user_id, has_partner, has_children, effective_date
)

The method will create the household declaration for the user.

Source code in components/member_lifecycle/subcomponents/add_dependents/protected/dependencies.py
def upsert_household_declaration(
    self,
    user_id: str,
    has_partner: bool,
    has_children: bool,
    effective_date: date,
) -> None:
    """
    The method will create the household declaration for the user.
    """
    raise NotImplementedError()

MemberLifecycleDependency

MemberLifecycleDependency(add_dependents)

MemberLifecycleDependency defines the interface that apps using the member_lifecycle component need to implement

Source code in components/member_lifecycle/internal/dependencies/member_lifecycle.py
def __init__(self, add_dependents: AddDependentsDependency):
    self.add_dependents = add_dependents

add_dependents instance-attribute

add_dependents = add_dependents

merge_users

merge_users(
    source_user_id, target_user_id, actor_id, commit=True
)

The method will merge the source user into the target user and return some logs about the changes

Source code in components/member_lifecycle/internal/dependencies/member_lifecycle.py
def merge_users(
    self,
    source_user_id: str,
    target_user_id: str,
    actor_id: str | None,
    commit: bool = True,
) -> list[str]:
    """The method will merge the source user into the target user and return some logs about the changes"""
    raise NotImplementedError()

NationalIdentification dataclass

NationalIdentification(user_id, type=None, number=None)

Bases: DataClassJsonMixin

Represents the national registration type and number Example for FR: - type = SSN - number = 189059912035995

number class-attribute instance-attribute

number = None

type class-attribute instance-attribute

type = None

user_id instance-attribute

user_id

PastDependent dataclass

PastDependent(user_id, profile_id)

Represents dependent user information returned by the get_past_dependents method

profile_id instance-attribute

profile_id

user_id instance-attribute

user_id

set_app_dependency

set_app_dependency(dependency)

Sets the member_lifecycle dependency to the app so it can be accessed within this component at runtime

Source code in components/member_lifecycle/internal/dependencies/member_lifecycle.py
def set_app_dependency(dependency: MemberLifecycleDependency) -> None:
    """Sets the member_lifecycle dependency to the app so it can be accessed within this component at runtime"""
    from flask import current_app

    cast("CustomFlask", current_app).add_component_dependency(
        MEMBER_LIFECYCLE_COMPONENT_NAME, dependency
    )

components.member_lifecycle.public.entities

AffiliationDelay dataclass

AffiliationDelay(
    threshold_months,
    duration_months,
    new_dependent_coverage_start_date=None,
)

Bases: DataClassJsonMixin

duration_months instance-attribute

duration_months

new_dependent_coverage_start_date class-attribute instance-attribute

new_dependent_coverage_start_date = None

threshold_months instance-attribute

threshold_months

AgeBoundaries dataclass

AgeBoundaries(min, max)

Bases: DataClassJsonMixin

Represents the min and max age of a dependent.

max instance-attribute

max

min instance-attribute

min

BeneficiaryInfo dataclass

BeneficiaryInfo(
    identification_type,
    identification_id,
    first_name,
    beneficiary_type,
    birth_date=None,
    user_id=None,
)

Bases: DataClassJsonMixin

beneficiary_type instance-attribute

beneficiary_type

birth_date class-attribute instance-attribute

birth_date = None

first_name instance-attribute

first_name

identification_id instance-attribute

identification_id

identification_type instance-attribute

identification_type

user_id class-attribute instance-attribute

user_id = None

ChildDefinitionRule dataclass

ChildDefinitionRule(
    child_definition_rules_all_required=False, rules=list()
)

Bases: DataClassJsonMixin

child_definition_rules_all_required class-attribute instance-attribute

child_definition_rules_all_required = False

rules class-attribute instance-attribute

rules = field(default_factory=list)

ChildDefinitionRuleValue

Bases: AlanBaseEnum

child_benefit_received class-attribute instance-attribute

child_benefit_received = child_benefit_received

child_fiscally_at_charge class-attribute instance-attribute

child_fiscally_at_charge = child_fiscally_at_charge
child_legal_guardianship = child_legal_guardianship

child_same_address class-attribute instance-attribute

child_same_address = child_same_address

grandchild_fiscally_at_charge_or_same_address class-attribute instance-attribute

grandchild_fiscally_at_charge_or_same_address = (
    grandchild_fiscally_at_charge_or_same_address
)

CoverageModuleInfo dataclass

CoverageModuleInfo(
    coverage_module_name,
    coverages,
    is_upgrade,
    partner_price=None,
    child_price=None,
)

Bases: DataClassJsonMixin

child_price class-attribute instance-attribute

child_price = None

coverage_module_name instance-attribute

coverage_module_name

coverages instance-attribute

coverages

is_upgrade instance-attribute

is_upgrade

partner_price class-attribute instance-attribute

partner_price = None

CoverageStartDateScenario

Bases: AlanBaseEnum

Scenarios for determining coverage start date for new dependents - newborn_within_2_months = the dependent is a newborn born within 2 months of the current date - newborn_more_2_months = the dependent is a newborn born more than 2 months of the current date - onboarding_month = the add dependent occurs during the 1st month of the primary coverage (onboarding month) - default_scenario = refers to all other scenarios execpt the ones mentioned above - unique = refers to the others countries than France, where there is only one coverage start date option

The wording of the ENUMS matters
  • It is used in the frontend screen to pick the right description

default_scenario class-attribute instance-attribute

default_scenario = 'default'

newborn_more_2_months class-attribute instance-attribute

newborn_more_2_months = 'newborn_more_2_months'

newborn_within_2_months class-attribute instance-attribute

newborn_within_2_months = 'newborn_within_2_months'

onboarding_month class-attribute instance-attribute

onboarding_month = 'onboarding_month'

unique class-attribute instance-attribute

unique = 'unique'

CoverageType

Bases: AlanBaseEnum

CoverageType describes each class of guarantee.

Note: "ambulatory" means "daily care" + "dental".

WARNING: These values are consumed by frontend/mobile clients Any changes to the values must be reflected there.

ASSISTANCE_ABROAD class-attribute instance-attribute

ASSISTANCE_ABROAD = 'assistance_abroad'

DAILY_CARE class-attribute instance-attribute

DAILY_CARE = 'ambulatory'

DENTAL class-attribute instance-attribute

DENTAL = 'dental'

HOSPITALIZATION class-attribute instance-attribute

HOSPITALIZATION = 'hospitalization'

HOSPITALIZATION_SHARED_ROOM class-attribute instance-attribute

HOSPITALIZATION_SHARED_ROOM = 'hospitalization_shared_room'

HOSPITALIZATION_SINGLE_ROOM class-attribute instance-attribute

HOSPITALIZATION_SINGLE_ROOM = 'hospitalization_single_room'

HOSPITALIZATION_SINGLE_ROOM_WITH_SUPPLEMENTS class-attribute instance-attribute

HOSPITALIZATION_SINGLE_ROOM_WITH_SUPPLEMENTS = (
    "hospitalization_single_room_with_supplements"
)

PRE_POST class-attribute instance-attribute

PRE_POST = 'pre_post'

SEVERE_ILLNESS class-attribute instance-attribute

SEVERE_ILLNESS = 'severe_illness'

CreateDependentPayload dataclass

CreateDependentPayload(
    dependent_user_id,
    first_name,
    last_name,
    birth_date,
    coverage_start_date,
    type,
    gender=None,
    coverage_module_name=None,
    settlement_iban=None,
    ssn=None,
    referent_ssns=None,
    selected_income_bracket_data=None,
    income_brackets_data=None,
    birth_ranks=None,
    supplementary_insurance=False,
)

birth_date instance-attribute

birth_date

birth_ranks class-attribute instance-attribute

birth_ranks = None

coverage_module_name class-attribute instance-attribute

coverage_module_name = None

coverage_start_date instance-attribute

coverage_start_date

dependent_user_id instance-attribute

dependent_user_id

first_name instance-attribute

first_name

gender class-attribute instance-attribute

gender = field(default=None, metadata={'by_value': True})

income_brackets_data class-attribute instance-attribute

income_brackets_data = None

last_name instance-attribute

last_name

referent_ssns class-attribute instance-attribute

referent_ssns = None

selected_income_bracket_data class-attribute instance-attribute

selected_income_bracket_data = None

settlement_iban class-attribute instance-attribute

settlement_iban = None

ssn class-attribute instance-attribute

ssn = None

supplementary_insurance class-attribute instance-attribute

supplementary_insurance = False

type instance-attribute

type

DefaultCoverageModuleInfo dataclass

DefaultCoverageModuleInfo(coverage_module_name, coverages)

Bases: DataClassJsonMixin

coverage_module_name instance-attribute

coverage_module_name

coverages instance-attribute

coverages

DependentSpecs dataclass

DependentSpecs(
    dependent_birthdate,
    dependent_type,
    dependent_coverage_module_name=None,
    start_date=None,
)

dependent_birthdate instance-attribute

dependent_birthdate

dependent_coverage_module_name class-attribute instance-attribute

dependent_coverage_module_name = None

dependent_type instance-attribute

dependent_type

start_date class-attribute instance-attribute

start_date = None

DependentsAgeBoundaries dataclass

DependentsAgeBoundaries(partner, child)

Bases: DataClassJsonMixin

Represents the age boundaries of dependents depending on their type.

child instance-attribute

child

partner instance-attribute

partner

HealthContractInfo dataclass

HealthContractInfo(
    dependents_participation,
    waiting_period,
    affiliation_delay,
    primary_coverage_start_date,
    is_direct_billing,
    is_partner_coverage_mandatory,
    is_children_coverage_mandatory,
    retroactive_affiliation_window,
)

Bases: DataClassJsonMixin

The fields will be None if the information cannot be matched to the expected dataclass.

affiliation_delay instance-attribute

affiliation_delay

dependents_participation instance-attribute

dependents_participation

is_children_coverage_mandatory instance-attribute

is_children_coverage_mandatory

is_direct_billing instance-attribute

is_direct_billing

is_partner_coverage_mandatory instance-attribute

is_partner_coverage_mandatory

primary_coverage_start_date instance-attribute

primary_coverage_start_date

retroactive_affiliation_window instance-attribute

retroactive_affiliation_window

waiting_period instance-attribute

waiting_period

HouseholdDeclaration dataclass

HouseholdDeclaration(
    has_partner, has_children, effective_date
)

Bases: DataClassJsonMixin

effective_date instance-attribute

effective_date

has_children instance-attribute

has_children

has_partner instance-attribute

has_partner

IdentificationFlowType

Bases: AlanBaseEnum

Type of identification flow.

ssn class-attribute instance-attribute

ssn = 'ssn'

NewDependentsPriceBreakdown dataclass

NewDependentsPriceBreakdown(
    total_policy_price, new_dependent_price
)

Bases: DataClassJsonMixin

Represents the price breakdown for a new dependent.

new_dependent_price instance-attribute

new_dependent_price

total_policy_price instance-attribute

total_policy_price

The total price of all the policy members + new dependent

PartnerDefinitionRule dataclass

PartnerDefinitionRule(
    partner_definition_rules_all_required=False,
    rules=list(),
)

Bases: DataClassJsonMixin

partner_definition_rules_all_required class-attribute instance-attribute

partner_definition_rules_all_required = False

rules class-attribute instance-attribute

rules = field(default_factory=list)

PartnerDefinitionRuleValue

Bases: AlanBaseEnum

partner_same_address_affiliate_before_65 class-attribute instance-attribute

partner_same_address_affiliate_before_65 = (
    partner_same_address_affiliate_before_65
)

partner_same_address_affiliate_before_66 class-attribute instance-attribute

partner_same_address_affiliate_before_66 = (
    partner_same_address_affiliate_before_66
)

partner_same_address_affiliate_before_67 class-attribute instance-attribute

partner_same_address_affiliate_before_67 = (
    partner_same_address_affiliate_before_67
)

partner_same_address_affiliate_before_retirement_age class-attribute instance-attribute

partner_same_address_affiliate_before_retirement_age = (
    partner_same_address_affiliate_before_retirement_age
)

partner_same_address_affiliation class-attribute instance-attribute

partner_same_address_affiliation = (
    partner_same_address_affiliation
)

Price dataclass

Price(
    currency,
    amount=None,
    min_amount=None,
    max_amount=None,
    min_discounted_amount=None,
    max_discounted_amount=None,
    tooltip_keys=None,
    tooltip_params=None,
)

Bases: DataClassJsonMixin

Source code in components/member_lifecycle/subcomponents/prices/internal/domain/entities/dependent_price.py
def __init__(
    self,
    currency: str,
    amount: Optional[AmountInCents] = None,
    min_amount: Optional[AmountInCents] = None,
    max_amount: Optional[AmountInCents] = None,
    min_discounted_amount: Optional[AmountInCents] = None,
    max_discounted_amount: Optional[AmountInCents] = None,
    tooltip_keys: Optional[list[str]] = None,
    tooltip_params: Optional[dict[str, Any]] = None,
):
    if amount is not None:
        self.min_amount = self.max_amount = amount
    elif min_amount is not None and max_amount is not None:
        self.min_amount = min_amount
        self.max_amount = max_amount
    else:
        raise ValueError(
            "Provide either `amount` or both (`min_amount` and `max_amount`)."
        )
    self.currency = currency
    self.min_discounted_amount = min_discounted_amount
    self.max_discounted_amount = max_discounted_amount
    self.tooltip_keys = tooltip_keys
    self.tooltip_params = tooltip_params
    self.__post_init__()

__post_init__

__post_init__()
Source code in components/member_lifecycle/subcomponents/prices/internal/domain/entities/dependent_price.py
def __post_init__(self) -> None:
    self.is_fixed_price = self.min_amount == self.max_amount
    self.is_free = self.min_amount == 0 and self.max_amount == 0

currency instance-attribute

currency = currency

is_fixed_price class-attribute instance-attribute

is_fixed_price = field(init=False)

is_free class-attribute instance-attribute

is_free = field(init=False)

max_amount instance-attribute

max_amount

max_discounted_amount class-attribute instance-attribute

max_discounted_amount = max_discounted_amount

min_amount instance-attribute

min_amount

min_discounted_amount class-attribute instance-attribute

min_discounted_amount = min_discounted_amount

tooltip_keys class-attribute instance-attribute

tooltip_keys = tooltip_keys

tooltip_params class-attribute instance-attribute

tooltip_params = tooltip_params

PricesAndConditionsConfig dataclass

PricesAndConditionsConfig(
    child_covered_until_max_age,
    membership,
    fr_social_security,
    be_social_security,
    be_fiscally_dependent_age,
    has_mandatory_dependents_coverage,
    show_prices_link,
    partner_definition_rules,
    child_definition_rules,
)

Bases: DataClassJsonMixin

Configuration for the PricesAndConditions component.

be_fiscally_dependent_age instance-attribute

be_fiscally_dependent_age

be_social_security instance-attribute

be_social_security

child_covered_until_max_age instance-attribute

child_covered_until_max_age

child_definition_rules instance-attribute

child_definition_rules

fr_social_security instance-attribute

fr_social_security

has_mandatory_dependents_coverage instance-attribute

has_mandatory_dependents_coverage

membership instance-attribute

membership

partner_definition_rules instance-attribute

partner_definition_rules
show_prices_link

RetroactiveAffiliationWindow dataclass

RetroactiveAffiliationWindow(
    start_date,
    window_duration_in_days,
    end_date=isodate_field(),
)

Bases: DataClassJsonMixin

end_date class-attribute instance-attribute

end_date = isodate_field()

start_date instance-attribute

start_date

window_duration_in_days instance-attribute

window_duration_in_days

WaitingPeriod dataclass

WaitingPeriod(
    duration_in_months,
    start_date=isodate_field(),
    end_date=isodate_field(),
)

Bases: DataClassJsonMixin

Represents the waiting period for health contract.

duration_in_months instance-attribute

duration_in_months

end_date class-attribute instance-attribute

end_date = isodate_field()

start_date class-attribute instance-attribute

start_date = isodate_field()

components.member_lifecycle.public.enums

AddDependentSuccessScreenWidgetType

Bases: AlanBaseEnum

Global enum to determine which widget must be displayed in the AddDependentSuccess screen

The wording of the ENUMS matters
  • It is used in the frontend screen to pick the right widget to display

coverage class-attribute instance-attribute

coverage = 'coverage'

tp_card class-attribute instance-attribute

tp_card = 'tp_card'

CoverageStartDateScenario

Bases: AlanBaseEnum

Scenarios for determining coverage start date for new dependents - newborn_within_2_months = the dependent is a newborn born within 2 months of the current date - newborn_more_2_months = the dependent is a newborn born more than 2 months of the current date - onboarding_month = the add dependent occurs during the 1st month of the primary coverage (onboarding month) - default_scenario = refers to all other scenarios execpt the ones mentioned above - unique = refers to the others countries than France, where there is only one coverage start date option

The wording of the ENUMS matters
  • It is used in the frontend screen to pick the right description

default_scenario class-attribute instance-attribute

default_scenario = 'default'

newborn_more_2_months class-attribute instance-attribute

newborn_more_2_months = 'newborn_more_2_months'

newborn_within_2_months class-attribute instance-attribute

newborn_within_2_months = 'newborn_within_2_months'

onboarding_month class-attribute instance-attribute

onboarding_month = 'onboarding_month'

unique class-attribute instance-attribute

unique = 'unique'

Currency

Bases: AlanBaseEnum

Currency codes used in the add dependent flow. ISO 4217 compliant currency codes.

CAD class-attribute instance-attribute

CAD = 'CAD'

EUR class-attribute instance-attribute

EUR = 'EUR'

DependentTaxBenefitType

Bases: AlanBaseEnum

Global enum to determine which tax benefit the dependent is eligible to. The list is expected to evolved with future tax benefits.

The wording of the ENUMS matters
  • It is used in the frontend screen to pick the right information to display

madelin class-attribute instance-attribute

madelin = 'madelin'

components.member_lifecycle.public.ports

PriceProvider

get_dependents_price_breakdown

get_dependents_price_breakdown(
    user_id,
    dependent_specs,
    on_date,
    declared_income_in_cents=None,
)

Returns the price breakdown for a new dependent. This is used to display the prices when adding a new dependent.

Source code in components/member_lifecycle/subcomponents/prices/internal/domain/ports/price_provider.py
def get_dependents_price_breakdown(
    self,
    user_id: str,
    dependent_specs: DependentSpecs,
    on_date: date,
    declared_income_in_cents: Optional[int] = None,
) -> NewDependentsPriceBreakdown:
    """
    Returns the price breakdown for a new dependent.
    This is used to display the prices when adding a new dependent.
    """
    raise NotImplementedError()

components.member_lifecycle.public.queries

can_dependent_be_invited_to_create_an_account

can_dependent_be_invited_to_create_an_account(
    enrollment_type, dependent_birth_date
)
Source code in components/member_lifecycle/subcomponents/add_dependents/internal/invite_dependent/queries.py
def can_dependent_be_invited_to_create_an_account(
    enrollment_type: EnrollmentType | None,
    dependent_birth_date: date | None,
) -> bool:
    # A child dependent doesn't need its own SSN to create an account
    # cf Linear ticket with Legal: https://linear.app/alan-eu/issue/LEG-1525/legal-requirement-16-17yo-dependents-account-creation-without-ssn#comment-b01424ab

    if enrollment_type is None:
        raise ValueError("The dependent is missing an enrollment type")

    if enrollment_type == EnrollmentType.primary:
        raise ValueError("The invited member must be a dependent")

    if enrollment_type == EnrollmentType.partner:
        return True

    # TODO: A discussion will be open to refacto the get_child_account_minimum_age. As the invitation and its triggers should be owned by ML globaly rather than in a dependency
    app_dependency = get_app_dependency().add_dependents
    child_account_minimum_age = app_dependency.get_child_account_minimum_age()
    if (
        enrollment_type == EnrollmentType.child
        and child_account_minimum_age is not None
        and dependent_birth_date is not None
    ):
        return age_on(dependent_birth_date, utctoday()) >= child_account_minimum_age
    return False

get_child_definition_rules

get_child_definition_rules(health_contract_id)

Build child definition rules from health contract settings.

Source code in components/member_lifecycle/subcomponents/add_dependents/internal/get_dependent_definition_rules/queries.py
def get_child_definition_rules(
    health_contract_id: str,
) -> ChildDefinitionRule | None:
    """Build child definition rules from health contract settings."""
    settings = get_health_contract_settings_for_contract(
        health_contract_id=health_contract_id,
        feature_name=HealthContractSettingFeatureName.child_definition,
        is_activated=True,
    )
    if settings is None:
        return None
    return ChildDefinitionRule(
        child_definition_rules_all_required=any(
            rule.feature_value
            == HealthContractSettingFeatureValue.child_definition_rules_all_required
            for rule in settings
        ),
        rules=cast(
            "list[ChildDefinitionRuleValue]",
            [
                rule.feature_value
                for rule in settings
                if rule.feature_value
                != HealthContractSettingFeatureValue.child_definition_rules_all_required
            ],
        ),
    )

get_partner_definition_rules

get_partner_definition_rules(health_contract_id)

Build partner definition rules from health contract settings.

Source code in components/member_lifecycle/subcomponents/add_dependents/internal/get_dependent_definition_rules/queries.py
def get_partner_definition_rules(
    health_contract_id: str,
) -> PartnerDefinitionRule | None:
    """Build partner definition rules from health contract settings."""
    settings = get_health_contract_settings_for_contract(
        health_contract_id=health_contract_id,
        feature_name=HealthContractSettingFeatureName.partner_definition,
        is_activated=True,
    )
    if settings is None:
        return None
    return PartnerDefinitionRule(
        partner_definition_rules_all_required=any(
            rule.feature_value
            == HealthContractSettingFeatureValue.partner_definition_rules_all_required
            for rule in settings
        ),
        rules=cast(
            "list[PartnerDefinitionRuleValue]",
            [
                rule.feature_value
                for rule in settings
                if rule.feature_value
                != HealthContractSettingFeatureValue.partner_definition_rules_all_required
            ],
        ),
    )

has_existing_partner

has_existing_partner(user_id, at_date=None)
Source code in components/member_lifecycle/subcomponents/add_dependents/internal/beneficiaries/queries.py
def has_existing_partner(
    user_id: str,
    at_date: date | None = None,
) -> bool:
    existing_partner = first_or_none(
        get_beneficiaries_linked_to_user_on(
            user_id=user_id,
            on_date=at_date,
            enrollment_type=EnrollmentType.partner,
            include_future=True,
        )
    )
    return bool(existing_partner)

has_reached_maximum_number_of_dependents

has_reached_maximum_number_of_dependents(
    user_id, at_date=None
)
Source code in components/member_lifecycle/subcomponents/add_dependents/internal/beneficiaries/queries.py
def has_reached_maximum_number_of_dependents(
    user_id: str,
    at_date: date | None = None,
) -> bool:
    beneficiaries = get_beneficiaries_linked_to_user_on(
        user_id=user_id,
        on_date=at_date,
        include_future=True,
    )
    return len(beneficiaries) >= MAX_NUMBER_OF_DEPENDENTS

should_show_province_alert

should_show_province_alert()
Source code in components/member_lifecycle/subcomponents/add_dependents/internal/beneficiaries/queries.py
def should_show_province_alert() -> bool:
    return get_current_app_name() == AppName.ALAN_CA

should_trigger_household_not_declared_notification

should_trigger_household_not_declared_notification(user_id)
Source code in components/member_lifecycle/subcomponents/add_dependents/internal/household_declaration/queries.py
def should_trigger_household_not_declared_notification(user_id: str) -> bool:
    if get_current_app_name() == AppName.ALAN_FR:
        return should_trigger_household_not_declared_notification_FR(user_id)
    return False