Skip to content

Api reference

components.guarantee_catalog.public.commands

sync_guarantee_catalog

guarantee_catalog module-attribute

guarantee_catalog = AppGroup(
    name="guarantee_catalog",
    help="Main command group for the Guarantee Catalog component",
)

sync_guarantee_catalog

sync_guarantee_catalog(dry_run=False)

Synchronize guarantee catalog from YAML configuration to database.

This command: 1. Reads the guarantee catalog configuration from guarantees.yaml 2. Validates the structure and relationships of the configuration 3. Clears existing guarantee catalog entries from the database 4. Stores the new configuration in the database

The --dry-run flag can be used to validate and test the sync without committing changes.

This command is typically run as a scheduled task to ensure the database reflects the latest guarantee catalog configuration.

Source code in components/guarantee_catalog/public/commands/sync_guarantee_catalog.py
@guarantee_catalog.command()
@command_with_dry_run
def sync_guarantee_catalog(dry_run: bool = False) -> None:
    """Synchronize guarantee catalog from YAML configuration to database.

    This command:
    1. Reads the guarantee catalog configuration from guarantees.yaml
    2. Validates the structure and relationships of the configuration
    3. Clears existing guarantee catalog entries from the database
    4. Stores the new configuration in the database

    The --dry-run flag can be used to validate and test the sync without committing changes.

    This command is typically run as a scheduled task to ensure
    the database reflects the latest guarantee catalog configuration.
    """
    from components.guarantee_catalog.internal.business_logic.actions.guarantee_definitions_import.sync_guarantee_catalog import (
        load_guarantee_catalog_from_yaml,
    )
    from components.guarantee_catalog.public.dependencies import get_app_dependency

    app_dependency = get_app_dependency()
    country = app_dependency.get_country_code()
    product_type = app_dependency.get_product_type()
    catalog_file_path = app_dependency.get_guarantee_yaml_file_path()

    if not catalog_file_path.exists():
        raise click.BadParameter(
            f"Catalog file not found for product_type '{product_type.value}': {catalog_file_path}"
        )

    click.echo(
        f"Syncing guarantee catalog for product_type '{product_type.value}' "
        f"from '{catalog_file_path}' with dry_run={dry_run}"
    )

    load_guarantee_catalog_from_yaml(
        file_path=catalog_file_path,
        country=country.value,
        product_type=product_type.value,
        commit=not dry_run,
    )

    click.echo("Syncing completed")

components.guarantee_catalog.public.dependencies

COMPONENT_NAME module-attribute

COMPONENT_NAME = 'guarantee_catalog'

GuaranteeCatalogDependency

Bases: ABC

get_country_code abstractmethod

get_country_code()

Return the country code for the current country.

Source code in components/guarantee_catalog/public/dependencies.py
@abstractmethod
def get_country_code(self) -> Country:
    """Return the country code for the current country."""

get_guarantee_yaml_file_path abstractmethod

get_guarantee_yaml_file_path()

Implement get_guarantee_yaml_file_path

Source code in components/guarantee_catalog/public/dependencies.py
@abstractmethod
def get_guarantee_yaml_file_path(self) -> Path:
    """Implement get_guarantee_yaml_file_path"""

get_product_type abstractmethod

get_product_type()

Return the product type for this dependency.

Source code in components/guarantee_catalog/public/dependencies.py
@abstractmethod
def get_product_type(self) -> ProductType:
    """Return the product type for this dependency."""

validate_coverage_rules

validate_coverage_rules(request)

Validates country-specific coverage rules for a given coverage against guarantee definitions.

Source code in components/guarantee_catalog/public/dependencies.py
def validate_coverage_rules(
    self,
    request: ValidateCoverageRulesRequest,  # noqa: ARG002
) -> list[GuaranteeCatalogError]:
    """Validates country-specific coverage rules for a given coverage against guarantee definitions."""
    return []

get_app_dependency

get_app_dependency()
Source code in components/guarantee_catalog/public/dependencies.py
def get_app_dependency() -> GuaranteeCatalogDependency:  # noqa: D103
    from flask import current_app

    return cast("CustomFlask", current_app).get_component_dependency(COMPONENT_NAME)  # type: ignore[no-any-return]

set_app_dependency

set_app_dependency(dependency)
Source code in components/guarantee_catalog/public/dependencies.py
def set_app_dependency(dependency: GuaranteeCatalogDependency) -> None:  # noqa: D103
    from flask import current_app

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

components.guarantee_catalog.public.entities

coverage_rules

AggregatedLimitParameter module-attribute

AggregatedLimitParameter = (
    InstantiatedBundleChoiceParameter
    | InstantiatedCategoryParameter
)

CoverageRule

Bases: CoverageRuleBaseModel

Model representing an instantiated guarantee (coverage rule) with its chosen expression type, parameters and optional eligibility items.

bundle_choice_business_id instance-attribute
bundle_choice_business_id
eligibility_items class-attribute instance-attribute
eligibility_items = None
expression_type instance-attribute
expression_type
guarantee_business_id instance-attribute
guarantee_business_id
parameters instance-attribute
parameters

CoverageRuleBaseModel

Bases: BaseModel

Base Pydantic model for all coverage-rule-related models.

Config

Pydantic model configuration.

Attributes:

Name Type Description
frozen

Makes all models immutable after creation

frozen class-attribute instance-attribute
frozen = True

CoverageRuleParameter

Bases: CoverageRuleBaseModel

Model representing a parameter value for a coverage rule.

type instance-attribute
type
value instance-attribute
value

CoverageRuleValidationContext dataclass

CoverageRuleValidationContext(
    guarantee_business_id=None,
    bundle_choice_business_id=None,
    category_business_id=None,
    parameter_type=None,
)

Bases: DataClassJsonMixin

Context information for a coverage rule validation error.

bundle_choice_business_id class-attribute instance-attribute
bundle_choice_business_id = None
category_business_id class-attribute instance-attribute
category_business_id = None
guarantee_business_id class-attribute instance-attribute
guarantee_business_id = None
parameter_type class-attribute instance-attribute
parameter_type = None

InstantiatedBundleChoiceParameter

Bases: CoverageRuleParameter

Model representing a parameter value for a bundle choice.

bundle_choice_business_id instance-attribute
bundle_choice_business_id

InstantiatedCategoryParameter

Bases: CoverageRuleParameter

Model representing a parameter value for a category.

category_business_id instance-attribute
category_business_id

PropagatedParameter module-attribute

PropagatedParameter = (
    InstantiatedBundleChoiceParameter
    | InstantiatedCategoryParameter
)

ValidateCoverageRulesRequest

Bases: CoverageRuleBaseModel

Model representing a request to validate a set of coverage rules.

Includes: - List of coverage rules - Propagated parameters for bundle choices and categories - Aggregated limit parameters for bundle choices and categories - Selected category IDs to validate required coverage rules

aggregated_limit_parameters instance-attribute
aggregated_limit_parameters
coverage_rules instance-attribute
coverage_rules
propagated_parameters instance-attribute
propagated_parameters
selected_categories instance-attribute
selected_categories

errors

GuaranteeCatalogError

GuaranteeCatalogError(
    error_type,
    description,
    guarantee_id=None,
    bundle_choice_id=None,
    category_id=None,
    param_type=None,
    **kwargs
)

Bases: BaseErrorCode

Error class for guarantee catalog validation failures.

Initialize a guarantee catalog error with type and description.

Source code in components/guarantee_catalog/public/entities/errors.py
def __init__(
    self,
    error_type: GuaranteeCatalogErrorType,
    description: str,
    guarantee_id: str | None = None,
    bundle_choice_id: str | None = None,
    category_id: str | None = None,
    param_type: GuaranteeParameterType | None = None,
    **kwargs: Any,
) -> None:
    """Initialize a guarantee catalog error with type and description."""
    super().__init__(
        99999, error_type.value, description, **kwargs
    )  # TODO: remove code when it becomes optional after a PR that will be opened soon.
    self.guarantee_id = guarantee_id
    self.bundle_choice_id = bundle_choice_id
    self.category_id = category_id
    self.param_type = param_type
builder_coverage_lower_level_than_source classmethod
builder_coverage_lower_level_than_source(
    guarantee_id,
    bundle_choice_id,
    description,
    missing_eligibility_items=None,
    param_type=None,
)

Create error for target coverage less premium than source.

Source code in components/guarantee_catalog/public/entities/errors.py
@classmethod
def builder_coverage_lower_level_than_source(
    cls,
    guarantee_id: str,
    bundle_choice_id: str,
    description: str,
    missing_eligibility_items: list[str] | None = None,
    param_type: GuaranteeParameterType | None = None,
) -> GuaranteeCatalogError:
    """Create error for target coverage less premium than source."""
    return cls(
        error_type=GuaranteeCatalogErrorType.builder_coverage_lower_level_than_source,
        description=description,
        guarantee_id=guarantee_id,
        bundle_choice_id=bundle_choice_id,
        missing_eligibility_items=missing_eligibility_items,
        param_type=param_type,
    )
bundle_choice_id instance-attribute
bundle_choice_id = bundle_choice_id
bundle_choice_not_found classmethod
bundle_choice_not_found(
    bundle_choice_id, guarantee_id=None
)

Create error for non-existent bundle choice.

Source code in components/guarantee_catalog/public/entities/errors.py
@classmethod
def bundle_choice_not_found(
    cls, bundle_choice_id: str, guarantee_id: str | None = None
) -> GuaranteeCatalogError:
    """Create error for non-existent bundle choice."""
    return cls(
        error_type=GuaranteeCatalogErrorType.bundle_choice_not_found,
        description="Bundle choice does not exist in catalog",
        bundle_choice_id=bundle_choice_id,
        guarantee_id=guarantee_id,
    )
category_id instance-attribute
category_id = category_id
duplicate_guarantee classmethod
duplicate_guarantee(guarantee_id, bundle_choice_id)

Create error for duplicate guarantee in bundle choice.

Source code in components/guarantee_catalog/public/entities/errors.py
@classmethod
def duplicate_guarantee(
    cls, guarantee_id: str, bundle_choice_id: str
) -> GuaranteeCatalogError:
    """Create error for duplicate guarantee in bundle choice."""
    return cls(
        error_type=GuaranteeCatalogErrorType.duplicate_guarantee,
        description="Duplicate guarantee and bundle choice combination",
        guarantee_id=guarantee_id,
        bundle_choice_id=bundle_choice_id,
    )
duplicate_parameter classmethod
duplicate_parameter(
    param_type,
    level_name,
    identifier,
    is_limit=False,
    guarantee_id=None,
    bundle_choice_id=None,
    category_id=None,
)

Create error for duplicate parameters within the same level.

Source code in components/guarantee_catalog/public/entities/errors.py
@classmethod
def duplicate_parameter(
    cls,
    param_type: GuaranteeParameterType,
    level_name: str,
    identifier: str,
    is_limit: bool = False,
    guarantee_id: str | None = None,
    bundle_choice_id: str | None = None,
    category_id: str | None = None,
) -> GuaranteeCatalogError:
    """Create error for duplicate parameters within the same level."""
    param_type_name = "limit" if is_limit else "propagated parameter"
    return cls(
        error_type=GuaranteeCatalogErrorType.duplicate_parameter,
        description=f"Duplicate {param_type_name} type {param_type} for {level_name} {identifier}",
        param_type=param_type,
        level_name=level_name,
        identifier=identifier,
        guarantee_id=guarantee_id,
        bundle_choice_id=bundle_choice_id,
        category_id=category_id,
    )
exactly_one_bundle_choice_required classmethod
exactly_one_bundle_choice_required(
    bundle_choice_id, other_bundle_choice_id
)

Create error for incompatible bundle choice.

Source code in components/guarantee_catalog/public/entities/errors.py
@classmethod
def exactly_one_bundle_choice_required(
    cls,
    bundle_choice_id: str,
    other_bundle_choice_id: str,
) -> GuaranteeCatalogError:
    """Create error for incompatible bundle choice."""
    return cls(
        error_type=GuaranteeCatalogErrorType.exactly_one_bundle_choice_required,
        description=f"Exactly one of '{bundle_choice_id}' or '{other_bundle_choice_id}' must be selected",
        bundle_choice_id=bundle_choice_id,
    )
guarantee_from_unselected_category classmethod
guarantee_from_unselected_category(
    guarantee_id, bundle_choice_id, category_id
)

Create error for guarantee from unselected category.

Source code in components/guarantee_catalog/public/entities/errors.py
@classmethod
def guarantee_from_unselected_category(
    cls, guarantee_id: str, bundle_choice_id: str, category_id: str
) -> GuaranteeCatalogError:
    """Create error for guarantee from unselected category."""
    return cls(
        error_type=GuaranteeCatalogErrorType.guarantee_from_unselected_category,
        description=f"Guarantee '{guarantee_id}' belongs to unselected category '{category_id}'",
        guarantee_id=guarantee_id,
        bundle_choice_id=bundle_choice_id,
        category_id=category_id,
    )
guarantee_id instance-attribute
guarantee_id = guarantee_id
guarantee_not_found classmethod
guarantee_not_found(guarantee_id, bundle_choice_id)

Create error for non-existent guarantee.

Source code in components/guarantee_catalog/public/entities/errors.py
@classmethod
def guarantee_not_found(
    cls, guarantee_id: str, bundle_choice_id: str | None
) -> GuaranteeCatalogError:
    """Create error for non-existent guarantee."""
    return cls(
        error_type=GuaranteeCatalogErrorType.guarantee_not_found,
        description=f"Guarantee {guarantee_id} does not exist",
        guarantee_id=guarantee_id,
        bundle_choice_id=bundle_choice_id,
    )
guarantee_not_in_bundle_choice classmethod
guarantee_not_in_bundle_choice(
    guarantee_id, bundle_choice_id
)

Create error for guarantee that doesn't belong to the specified bundle choice.

Source code in components/guarantee_catalog/public/entities/errors.py
@classmethod
def guarantee_not_in_bundle_choice(
    cls, guarantee_id: str, bundle_choice_id: str
) -> GuaranteeCatalogError:
    """Create error for guarantee that doesn't belong to the specified bundle choice."""
    return cls(
        error_type=GuaranteeCatalogErrorType.guarantee_not_in_bundle_choice,
        description=f"Guarantee '{guarantee_id}' is not part of bundle choice '{bundle_choice_id}'",
        guarantee_id=guarantee_id,
        bundle_choice_id=bundle_choice_id,
    )
invalid_parameter_format classmethod
invalid_parameter_format(
    param_type,
    level_name,
    identifier,
    guarantee_id=None,
    bundle_choice_id=None,
    category_id=None,
)

Create error for invalid parameter format.

Source code in components/guarantee_catalog/public/entities/errors.py
@classmethod
def invalid_parameter_format(
    cls,
    param_type: GuaranteeParameterType,
    level_name: str,
    identifier: str,
    guarantee_id: str | None = None,
    bundle_choice_id: str | None = None,
    category_id: str | None = None,
) -> GuaranteeCatalogError:
    """Create error for invalid parameter format."""
    return cls(
        error_type=GuaranteeCatalogErrorType.invalid_parameter_format,
        description=f"Invalid parameter value of {param_type}  format at {level_name} for ID {identifier}",
        param_type=param_type,
        level_name=level_name,
        identifier=identifier,
        guarantee_id=guarantee_id,
        bundle_choice_id=bundle_choice_id,
        category_id=category_id,
    )
mandatory_bundle_missing classmethod
mandatory_bundle_missing(category_id, bundle_id)

Create error for missing mandatory bundle.

Source code in components/guarantee_catalog/public/entities/errors.py
@classmethod
def mandatory_bundle_missing(
    cls, category_id: str, bundle_id: str
) -> GuaranteeCatalogError:
    """Create error for missing mandatory bundle."""
    return cls(
        error_type=GuaranteeCatalogErrorType.mandatory_bundle_missing,
        description="Mandatory bundle not selected",
        category_id=category_id,
        bundle_id=bundle_id,
    )
missing_bundle_choice_guarantee classmethod
missing_bundle_choice_guarantee(
    guarantee_id, bundle_choice_id
)

Create error for missing guarantee from bundle choice.

Source code in components/guarantee_catalog/public/entities/errors.py
@classmethod
def missing_bundle_choice_guarantee(
    cls, guarantee_id: str, bundle_choice_id: str
) -> GuaranteeCatalogError:
    """Create error for missing guarantee from bundle choice."""
    return cls(
        error_type=GuaranteeCatalogErrorType.missing_bundle_choice_guarantee,
        description="Required guarantee from selected bundle choice is missing",
        guarantee_id=guarantee_id,
        bundle_choice_id=bundle_choice_id,
    )
missing_mandatory_eligibility_item classmethod
missing_mandatory_eligibility_item(
    guarantee_id,
    bundle_choice_id,
    missing_eligibility_items,
)

Create error for missing mandatory eligibility items.

Source code in components/guarantee_catalog/public/entities/errors.py
@classmethod
def missing_mandatory_eligibility_item(
    cls,
    guarantee_id: str,
    bundle_choice_id: str,
    missing_eligibility_items: set[str],
) -> GuaranteeCatalogError:
    """Create error for missing mandatory eligibility items."""
    return cls(
        error_type=GuaranteeCatalogErrorType.missing_mandatory_eligibility_item,
        description="Missing mandatory eligibility items",
        guarantee_id=guarantee_id,
        bundle_choice_id=bundle_choice_id,
        missing_eligibility_items=missing_eligibility_items,
    )
missing_parameter classmethod
missing_parameter(
    missing_types,
    level_name,
    identifier,
    param_type,
    guarantee_id=None,
    bundle_choice_id=None,
    category_id=None,
)

Create error for missing required parameters.

Source code in components/guarantee_catalog/public/entities/errors.py
@classmethod
def missing_parameter(
    cls,
    missing_types: set[str],
    level_name: str,
    identifier: str,
    param_type: GuaranteeParameterType,
    guarantee_id: str | None = None,
    bundle_choice_id: str | None = None,
    category_id: str | None = None,
) -> GuaranteeCatalogError:
    """Create error for missing required parameters."""
    return cls(
        error_type=GuaranteeCatalogErrorType.missing_parameter,
        description=f"Missing parameters of types: {', '.join(missing_types)} at {level_name} for ID {identifier}",
        missing_types=list(missing_types),
        level_name=level_name,
        identifier=identifier,
        guarantee_id=guarantee_id,
        bundle_choice_id=bundle_choice_id,
        param_type=param_type,
        category_id=category_id,
    )
missing_propagated_limit classmethod
missing_propagated_limit(
    level_name, identifier, param_type
)

Create error for missing propagated limit parameter.

Source code in components/guarantee_catalog/public/entities/errors.py
@classmethod
def missing_propagated_limit(
    cls,
    level_name: str,
    identifier: str,
    param_type: GuaranteeParameterType,
) -> GuaranteeCatalogError:
    """Create error for missing propagated limit parameter."""
    return cls(
        error_type=GuaranteeCatalogErrorType.missing_propagated_limit,
        description=f"Propagated limit parameter '{param_type}' is missing for {level_name} '{identifier}'",
        level_name=level_name,
        identifier=identifier,
        param_type=param_type,
    )
multiple_bundle_choices classmethod
multiple_bundle_choices(bundle_choice_id, guarantee_id)

Create error for multiple bundle choices selected from same bundle.

Source code in components/guarantee_catalog/public/entities/errors.py
@classmethod
def multiple_bundle_choices(
    cls, bundle_choice_id: str, guarantee_id: str
) -> GuaranteeCatalogError:
    """Create error for multiple bundle choices selected from same bundle."""
    return cls(
        error_type=GuaranteeCatalogErrorType.multiple_bundle_choices,
        description="Multiple bundle choices selected for the same bundle",
        bundle_choice_id=bundle_choice_id,
        guarantee_id=guarantee_id,
    )
no_eligibility_items_selected classmethod
no_eligibility_items_selected(
    guarantee_id, bundle_choice_id
)

Create error if no eligibility items are selected.

Source code in components/guarantee_catalog/public/entities/errors.py
@classmethod
def no_eligibility_items_selected(
    cls, guarantee_id: str, bundle_choice_id: str
) -> GuaranteeCatalogError:
    """Create error if no eligibility items are selected."""
    return cls(
        error_type=GuaranteeCatalogErrorType.no_eligibility_item_selected,
        description="The guarantee requires to pick at least one eligibility item; if none are desired, deactivate the guarantee",
        guarantee_id=guarantee_id,
        bundle_choice_id=bundle_choice_id,
    )
param_type instance-attribute
param_type = param_type
parameter_below_business_min classmethod
parameter_below_business_min(
    param_type,
    level_name,
    identifier,
    min_value,
    guarantee_id=None,
    bundle_choice_id=None,
    category_id=None,
)

Create error for parameter below business minimum.

Source code in components/guarantee_catalog/public/entities/errors.py
@classmethod
def parameter_below_business_min(
    cls,
    param_type: GuaranteeParameterType,
    level_name: str,
    identifier: str,
    min_value: float,
    guarantee_id: str | None = None,
    bundle_choice_id: str | None = None,
    category_id: str | None = None,
) -> GuaranteeCatalogError:
    """Create error for parameter below business minimum."""
    return cls(
        error_type=GuaranteeCatalogErrorType.parameter_below_business_min,
        description=f"Parameter value of {param_type} is below business minimum at {level_name} for ID {identifier}",
        param_type=param_type,
        level_name=level_name,
        identifier=identifier,
        guarantee_id=guarantee_id,
        bundle_choice_id=bundle_choice_id,
        min_value=min_value,
        category_id=category_id,
    )
parameter_below_pricer_min classmethod
parameter_below_pricer_min(
    param_type,
    level_name,
    identifier,
    min_value,
    guarantee_id=None,
    bundle_choice_id=None,
    category_id=None,
)

Create error for parameter below pricer minimum.

Source code in components/guarantee_catalog/public/entities/errors.py
@classmethod
def parameter_below_pricer_min(
    cls,
    param_type: GuaranteeParameterType,
    level_name: str,
    identifier: str,
    min_value: float,
    guarantee_id: str | None = None,
    bundle_choice_id: str | None = None,
    category_id: str | None = None,
) -> GuaranteeCatalogError:
    """Create error for parameter below pricer minimum."""
    return cls(
        error_type=GuaranteeCatalogErrorType.parameter_below_pricer_min,
        description=f"Parameter value of {param_type}  is below pricer minimum at {level_name} for ID {identifier}",
        param_type=param_type,
        level_name=level_name,
        identifier=identifier,
        guarantee_id=guarantee_id,
        bundle_choice_id=bundle_choice_id,
        min_value=min_value,
        category_id=category_id,
    )
parameter_exceeds_business_max classmethod
parameter_exceeds_business_max(
    param_type,
    level_name,
    identifier,
    max_value,
    guarantee_id=None,
    bundle_choice_id=None,
    category_id=None,
)

Create error for parameter exceeding business maximum.

Source code in components/guarantee_catalog/public/entities/errors.py
@classmethod
def parameter_exceeds_business_max(
    cls,
    param_type: GuaranteeParameterType,
    level_name: str,
    identifier: str,
    max_value: float,
    guarantee_id: str | None = None,
    bundle_choice_id: str | None = None,
    category_id: str | None = None,
) -> GuaranteeCatalogError:
    """Create error for parameter exceeding business maximum."""
    return cls(
        error_type=GuaranteeCatalogErrorType.parameter_exceeds_business_max,
        description=f"Parameter value of {param_type}  exceeds business maximum at {level_name} for ID {identifier}",
        param_type=param_type,
        level_name=level_name,
        identifier=identifier,
        guarantee_id=guarantee_id,
        bundle_choice_id=bundle_choice_id,
        max_value=max_value,
        category_id=category_id,
    )
parameter_exceeds_fiscal_max classmethod
parameter_exceeds_fiscal_max(
    param_type,
    level_name,
    identifier,
    max_value,
    guarantee_id=None,
    bundle_choice_id=None,
    category_id=None,
)

Create error for parameter exceeding fiscal maximum.

Source code in components/guarantee_catalog/public/entities/errors.py
@classmethod
def parameter_exceeds_fiscal_max(
    cls,
    param_type: GuaranteeParameterType,
    level_name: str,
    identifier: str,
    max_value: float,
    guarantee_id: str | None = None,
    bundle_choice_id: str | None = None,
    category_id: str | None = None,
) -> GuaranteeCatalogError:
    """Create error for parameter exceeding fiscal maximum."""
    return cls(
        error_type=GuaranteeCatalogErrorType.parameter_exceeds_fiscal_max,
        description=f"Parameter value of {param_type} exceeds fiscal max at {level_name} for ID {identifier}",
        param_type=param_type,
        level_name=level_name,
        identifier=identifier,
        guarantee_id=guarantee_id,
        bundle_choice_id=bundle_choice_id,
        max_value=max_value,
        category_id=category_id,
    )
parameter_exceeds_pricer_max classmethod
parameter_exceeds_pricer_max(
    param_type,
    level_name,
    identifier,
    max_value,
    guarantee_id=None,
    bundle_choice_id=None,
    category_id=None,
)

Create error for parameter exceeding pricer maximum.

Source code in components/guarantee_catalog/public/entities/errors.py
@classmethod
def parameter_exceeds_pricer_max(
    cls,
    param_type: GuaranteeParameterType,
    level_name: str,
    identifier: str,
    max_value: float,
    guarantee_id: str | None = None,
    bundle_choice_id: str | None = None,
    category_id: str | None = None,
) -> GuaranteeCatalogError:
    """Create error for parameter exceeding pricer maximum."""
    return cls(
        error_type=GuaranteeCatalogErrorType.parameter_exceeds_pricer_max,
        description=f"Parameter value of {param_type}  exceeds pricer maximum at {level_name} for ID {identifier}",
        param_type=param_type,
        level_name=level_name,
        identifier=identifier,
        guarantee_id=guarantee_id,
        bundle_choice_id=bundle_choice_id,
        max_value=max_value,
        category_id=category_id,
    )
unexpected_parameter classmethod
unexpected_parameter(
    param_type,
    level_name,
    identifier,
    guarantee_id=None,
    bundle_choice_id=None,
    category_id=None,
)

Create error for unexpected parameter that wasn't defined.

Source code in components/guarantee_catalog/public/entities/errors.py
@classmethod
def unexpected_parameter(
    cls,
    param_type: GuaranteeParameterType,
    level_name: str,
    identifier: str,
    guarantee_id: str | None = None,
    bundle_choice_id: str | None = None,
    category_id: str | None = None,
) -> GuaranteeCatalogError:
    """Create error for unexpected parameter that wasn't defined."""
    return cls(
        error_type=GuaranteeCatalogErrorType.unexpected_parameter,
        description=f"Unexpected parameter '{param_type}' provided at {level_name} for ID {identifier}",
        param_type=param_type,
        level_name=level_name,
        identifier=identifier,
        guarantee_id=guarantee_id,
        bundle_choice_id=bundle_choice_id,
        category_id=category_id,
    )
unexpected_parameter_source classmethod
unexpected_parameter_source(
    guarantee_id, bundle_choice_id, param_type
)

Create error for unexpected constant or propagated parameter.

Source code in components/guarantee_catalog/public/entities/errors.py
@classmethod
def unexpected_parameter_source(
    cls,
    guarantee_id: str,
    bundle_choice_id: str,
    param_type: GuaranteeParameterType,
) -> GuaranteeCatalogError:
    """Create error for unexpected constant or propagated parameter."""
    return cls(
        error_type=GuaranteeCatalogErrorType.unexpected_parameter_source,
        description=f"Parameter '{param_type}' for guarantee '{guarantee_id}' is defined as constant or propagated but was provided",
        guarantee_id=guarantee_id,
        bundle_choice_id=bundle_choice_id,
        param_type=param_type,
    )
unknown_eligibility_item classmethod
unknown_eligibility_item(
    guarantee_id, bundle_choice_id, eligibility_item_id
)

Create error for unknown eligibility item.

Source code in components/guarantee_catalog/public/entities/errors.py
@classmethod
def unknown_eligibility_item(
    cls, guarantee_id: str, bundle_choice_id: str, eligibility_item_id: str
) -> GuaranteeCatalogError:
    """Create error for unknown eligibility item."""
    return cls(
        error_type=GuaranteeCatalogErrorType.unknown_eligibility_item,
        description=f"Unknown eligibility item '{eligibility_item_id}' for guarantee '{guarantee_id}' in bundle choice '{bundle_choice_id}'",
        guarantee_id=guarantee_id,
        bundle_choice_id=bundle_choice_id,
        eligibility_item_id=eligibility_item_id,
    )
unsupported_expression_type classmethod
unsupported_expression_type(
    expression_type, guarantee_id, bundle_choice_id
)

Create error for unsupported expression type.

Source code in components/guarantee_catalog/public/entities/errors.py
@classmethod
def unsupported_expression_type(
    cls,
    expression_type: str,
    guarantee_id: str,
    bundle_choice_id: str | None,
) -> GuaranteeCatalogError:
    """Create error for unsupported expression type."""
    return cls(
        error_type=GuaranteeCatalogErrorType.unsupported_expression_type,
        description=f"Expression type {expression_type} is not supported for guarantee {guarantee_id}",
        expression_error_type=expression_type,
        guarantee_id=guarantee_id,
        bundle_choice_id=bundle_choice_id,
    )

GuaranteeCatalogErrorType

Bases: AlanBaseEnum

Error types for guarantee catalog validation.

builder_coverage_lower_level_than_source class-attribute instance-attribute
builder_coverage_lower_level_than_source = (
    "builder_coverage_lower_level_than_source"
)
bundle_choice_not_found class-attribute instance-attribute
bundle_choice_not_found = 'bundle_choice_not_found'
duplicate_guarantee class-attribute instance-attribute
duplicate_guarantee = 'duplicate_guarantee'
duplicate_parameter class-attribute instance-attribute
duplicate_parameter = 'duplicate_parameter'
exactly_one_bundle_choice_required class-attribute instance-attribute
exactly_one_bundle_choice_required = (
    "exactly_one_bundle_choice_required"
)
guarantee_from_unselected_category class-attribute instance-attribute
guarantee_from_unselected_category = (
    "guarantee_from_unselected_category"
)
guarantee_not_found class-attribute instance-attribute
guarantee_not_found = 'guarantee_not_found'
guarantee_not_in_bundle_choice class-attribute instance-attribute
guarantee_not_in_bundle_choice = (
    "guarantee_not_in_bundle_choice"
)
invalid_parameter_format class-attribute instance-attribute
invalid_parameter_format = 'invalid_parameter_format'
mandatory_bundle_missing class-attribute instance-attribute
mandatory_bundle_missing = 'mandatory_bundle_missing'
missing_bundle_choice_guarantee class-attribute instance-attribute
missing_bundle_choice_guarantee = (
    "missing_bundle_choice_guarantee"
)
missing_mandatory_eligibility_item class-attribute instance-attribute
missing_mandatory_eligibility_item = (
    "missing_mandatory_eligibility_item"
)
missing_parameter class-attribute instance-attribute
missing_parameter = 'missing_parameter'
missing_propagated_limit class-attribute instance-attribute
missing_propagated_limit = 'missing_propagated_limit'
multiple_bundle_choices class-attribute instance-attribute
multiple_bundle_choices = 'multiple_bundle_choices'
no_eligibility_item_selected class-attribute instance-attribute
no_eligibility_item_selected = (
    "no_eligibility_item_selected"
)
parameter_below_business_min class-attribute instance-attribute
parameter_below_business_min = (
    "parameter_below_business_min"
)
parameter_below_pricer_min class-attribute instance-attribute
parameter_below_pricer_min = 'parameter_below_pricer_min'
parameter_diverges_from_constant_value class-attribute instance-attribute
parameter_diverges_from_constant_value = (
    "parameter_diverges_from_constant_value"
)
parameter_exceeds_business_max class-attribute instance-attribute
parameter_exceeds_business_max = (
    "parameter_exceeds_business_max"
)
parameter_exceeds_fiscal_max class-attribute instance-attribute
parameter_exceeds_fiscal_max = (
    "parameter_exceeds_fiscal_max"
)
parameter_exceeds_pricer_max class-attribute instance-attribute
parameter_exceeds_pricer_max = (
    "parameter_exceeds_pricer_max"
)
unexpected_parameter class-attribute instance-attribute
unexpected_parameter = 'unexpected_parameter'
unexpected_parameter_source class-attribute instance-attribute
unexpected_parameter_source = 'unexpected_parameter_source'
unknown_eligibility_item class-attribute instance-attribute
unknown_eligibility_item = 'unknown_eligibility_item'
unsupported_expression_type class-attribute instance-attribute
unsupported_expression_type = 'unsupported_expression_type'

guarantee_definition

Bundle dataclass

Bundle(
    *,
    business_identifier,
    product_type,
    is_optional,
    bundle_choices,
    display_name=None
)

Bases: DataClassJsonMixin

A guarantee bundle.

Contains multiple bundle choices.

bundle_choices instance-attribute
bundle_choices
business_identifier instance-attribute
business_identifier
display_name class-attribute instance-attribute
display_name = None
is_optional instance-attribute
is_optional
product_type instance-attribute
product_type

BundleChoice dataclass

BundleChoice(
    *,
    business_identifier,
    product_type,
    guarantees,
    display_name=None,
    premiumness=None,
    propagated_parameters=list(),
    aggregated_limit_parameters=list(),
    is_default,
    status
)

Bases: DataClassJsonMixin

A guarantee bundle choice.

Groups guarantees that must be offered together.

aggregated_limit_parameters class-attribute instance-attribute
aggregated_limit_parameters = field(default_factory=list)
business_identifier instance-attribute
business_identifier
display_name class-attribute instance-attribute
display_name = None
guarantees instance-attribute
guarantees
is_default instance-attribute
is_default
premiumness class-attribute instance-attribute
premiumness = None
product_type instance-attribute
product_type
propagated_parameters class-attribute instance-attribute
propagated_parameters = field(default_factory=list)
status instance-attribute
status

Category dataclass

Category(
    *,
    business_identifier,
    product_type,
    bundles,
    display_name=None,
    propagated_parameters=list(),
    aggregated_limit_parameters=list()
)

Bases: DataClassJsonMixin

A guarantee category.

Groups related bundles together with shared parameters.

aggregated_limit_parameters class-attribute instance-attribute
aggregated_limit_parameters = field(default_factory=list)
bundles instance-attribute
bundles
business_identifier instance-attribute
business_identifier
display_name class-attribute instance-attribute
display_name = None
product_type instance-attribute
product_type
propagated_parameters class-attribute instance-attribute
propagated_parameters = field(default_factory=list)

Guarantee dataclass

Guarantee(
    *,
    business_identifier,
    product_type,
    expressions,
    display_name=None,
    tax_bracket_tag=None,
    metadata=None,
    eligibility_items=list()
)

Bases: DataClassJsonMixin

A guarantee, ie a representation of a (Alan-defined) type of care.

Contains all information needed to define a guarantee including its expressions and eligibility items.

__post_init__
__post_init__()

Dataclass post-initialization hook.

Source code in components/guarantee_catalog/public/entities/guarantee_definition.py
def __post_init__(self) -> None:
    """Dataclass post-initialization hook."""
    # NB: Must use object.__setattr__ for assignment in post_init for Frozen
    # dataclass, see doc: https://docs.python.org/3/library/dataclasses.html#frozen-instances
    object.__setattr__(
        self,
        "_expressions_by_type",
        {str(expression.type): expression for expression in self.expressions},
    )
business_identifier instance-attribute
business_identifier
display_name class-attribute instance-attribute
display_name = None
eligibility_items class-attribute instance-attribute
eligibility_items = field(default_factory=list)
expressions instance-attribute
expressions
get_expression
get_expression(expression_type)

Get an expression by its type.

Source code in components/guarantee_catalog/public/entities/guarantee_definition.py
def get_expression(
    self, expression_type: GuaranteeExpressionType
) -> GuaranteeExpression:
    """Get an expression by its type."""
    try:
        return self._expressions_by_type[str(expression_type)]
    except KeyError:
        raise GuaranteeCatalogError.unsupported_expression_type(
            expression_type=expression_type,
            guarantee_id=self.business_identifier,
            bundle_choice_id=None,
        )
metadata class-attribute instance-attribute
metadata = None
product_type instance-attribute
product_type
tax_bracket_tag class-attribute instance-attribute
tax_bracket_tag = None

GuaranteeCatalog dataclass

GuaranteeCatalog(*, country, product_type, categories)

Bases: DataClassJsonMixin

A guarantee catalog.

Contains all guarantees.

  • Guarantees are regrouped into categories->bundles->bundle_choices->guarantees.
  • Each guarantee can be in several bundle_choices. However, a guarantee can be in only one bundle and only one category.
  • By transition:
    • Each bundle_choice is in exactly one bundle.
    • Each bundle is in exactly one category.
__post_init__
__post_init__()

Dataclass post-initialization hook.

Source code in components/guarantee_catalog/public/entities/guarantee_definition.py
def __post_init__(self) -> None:
    """Dataclass post-initialization hook."""
    # NB: Must use object.__setattr__ for assignment in post_init for Frozen
    # dataclass, see doc: https://docs.python.org/3/library/dataclasses.html#frozen-instances

    bundle_choices_by_guarantee: defaultdict[str, list[BundleChoice]] = defaultdict(
        list
    )
    bundle_by_guarantee: dict[str, Bundle] = {}
    category_by_guarantee: dict[str, Category] = {}
    guarantee_by_guarantee_identifier: dict[str, Guarantee] = {}

    for category in self.categories:
        for bundle in category.bundles:
            for bundle_choice in bundle.bundle_choices:
                for guarantee in bundle_choice.guarantees:
                    guarantee_id = guarantee.business_identifier
                    guarantee_by_guarantee_identifier[guarantee_id] = guarantee
                    bundle_choices_by_guarantee[guarantee_id].append(bundle_choice)
                    if (
                        guarantee_id in category_by_guarantee
                        and category_by_guarantee[guarantee_id] != category
                    ) or (
                        guarantee_id in bundle_by_guarantee
                        and bundle_by_guarantee[guarantee_id] != bundle
                    ):
                        raise ValueError(
                            f"A guarantee ({guarantee_id}) may appear in several bundle choices, "
                            "but it belongs to only one category or bundle",
                        )
                    bundle_by_guarantee[guarantee_id] = bundle
                    category_by_guarantee[guarantee_id] = category

    object.__setattr__(self, "_bundle_by_guarantee_identifier", bundle_by_guarantee)
    object.__setattr__(
        self, "_bundle_choices_by_guarantee_identifier", bundle_choices_by_guarantee
    )
    object.__setattr__(
        self, "_category_by_guarantee_identifier", category_by_guarantee
    )
    object.__setattr__(
        self,
        "_guarantee_by_guarantee_identifier",
        guarantee_by_guarantee_identifier,
    )
categories instance-attribute
categories
country instance-attribute
country
get_bundle_by_guarantee
get_bundle_by_guarantee(guarantee_id)

Get the bundle containing a given guarantee.

Source code in components/guarantee_catalog/public/entities/guarantee_definition.py
def get_bundle_by_guarantee(self, guarantee_id: str) -> Bundle:
    """Get the bundle containing a given guarantee."""
    try:
        return self._bundle_by_guarantee_identifier[guarantee_id]
    except KeyError:
        raise GuaranteeCatalogError.guarantee_not_found(
            guarantee_id=guarantee_id, bundle_choice_id=None
        )
get_bundle_choices_by_guarantee
get_bundle_choices_by_guarantee(guarantee_id)

Get all bundle choices for a given guarantee.

Source code in components/guarantee_catalog/public/entities/guarantee_definition.py
def get_bundle_choices_by_guarantee(self, guarantee_id: str) -> list[BundleChoice]:
    """Get all bundle choices for a given guarantee."""
    try:
        return self._bundle_choices_by_guarantee_identifier[guarantee_id]
    except KeyError:
        raise GuaranteeCatalogError.guarantee_not_found(
            guarantee_id=guarantee_id, bundle_choice_id=None
        )
get_category_by_guarantee
get_category_by_guarantee(guarantee_id)

Get the category containing a given guarantee.

Source code in components/guarantee_catalog/public/entities/guarantee_definition.py
def get_category_by_guarantee(self, guarantee_id: str) -> Category:
    """Get the category containing a given guarantee."""
    try:
        return self._category_by_guarantee_identifier[guarantee_id]
    except KeyError:
        raise GuaranteeCatalogError.guarantee_not_found(
            guarantee_id=guarantee_id, bundle_choice_id=None
        )
get_guarantee
get_guarantee(identifier)

Get a guarantee by its identifier.

Source code in components/guarantee_catalog/public/entities/guarantee_definition.py
def get_guarantee(self, identifier: str) -> Guarantee:
    """Get a guarantee by its identifier."""
    try:
        return self._guarantee_by_guarantee_identifier[identifier]
    except KeyError:
        raise GuaranteeCatalogError.guarantee_not_found(
            guarantee_id=identifier, bundle_choice_id=None
        )
get_guarantee_or_none
get_guarantee_or_none(identifier)

Get a guarantee by its identifier if it exists.

Source code in components/guarantee_catalog/public/entities/guarantee_definition.py
def get_guarantee_or_none(self, identifier: str) -> Guarantee | None:
    """Get a guarantee by its identifier if it exists."""
    return self._guarantee_by_guarantee_identifier.get(identifier)
product_type instance-attribute
product_type

GuaranteeEligibilityItem dataclass

GuaranteeEligibilityItem(
    *,
    business_identifier,
    product_type,
    is_optional,
    display_name=None
)

Bases: DataClassJsonMixin

An eligibility item for a guarantee.

Defines what the guarantee applies to.

An eligibility item can be optional (guarantee must cover it) or not (guarantee may or may not cover it).

business_identifier instance-attribute
business_identifier
display_name class-attribute instance-attribute
display_name = None
is_optional instance-attribute
is_optional
product_type instance-attribute
product_type

GuaranteeExpression dataclass

GuaranteeExpression(
    *,
    type,
    product_type,
    parameters=list(),
    status,
    is_default
)

Bases: DataClassJsonMixin

A guarantee expression.

Defines how a guarantee is reimbursed using a specific type and optional parameters.

is_default instance-attribute
is_default
parameters class-attribute instance-attribute
parameters = field(default_factory=list)
product_type instance-attribute
product_type
status instance-attribute
status
type instance-attribute
type

GuaranteeParameter dataclass

GuaranteeParameter(
    *,
    type,
    source,
    business_min=None,
    business_max=None,
    fiscal_max=None,
    pricer_min=None,
    pricer_max=None,
    pricer_step=None,
    constant_value=None
)

Bases: DataClassJsonMixin

A parameter for a guarantee expression.

business_max class-attribute instance-attribute
business_max = None
business_min class-attribute instance-attribute
business_min = None
constant_value class-attribute instance-attribute
constant_value = None
fiscal_max class-attribute instance-attribute
fiscal_max = None
pricer_max class-attribute instance-attribute
pricer_max = None
pricer_min class-attribute instance-attribute
pricer_min = None
pricer_step class-attribute instance-attribute
pricer_step = None
source instance-attribute
source
type instance-attribute
type

guarantee_definition_for_display

GetGuaranteesForDisplayResponse dataclass

GetGuaranteesForDisplayResponse(*, categories)

Bases: DataClassJsonMixin

Model representing the complete response for the guarantees definition endpoint. Contains the full hierarchy of categories, bundles, and guarantees for a given country.

categories instance-attribute
categories

components.guarantee_catalog.public.enums

es_category_ref

ES category identifiers from catalog_guarantees.yaml.

EsCategoryRef

Bases: AlanBaseEnum

ES category identifiers from catalog_guarantees.yaml.

These identifiers correspond to the identifier field in the categories section of the ES health plan guarantee catalog.

es_complementary_module class-attribute instance-attribute
es_complementary_module = 'es_complementary_module'
es_core_product class-attribute instance-attribute
es_core_product = 'es_core_product'
es_other class-attribute instance-attribute
es_other = 'es_other'

es_guarantee_ref

ES guarantee identifiers from catalog_guarantees.yaml.

ES_ADDONS_REFS module-attribute

ES_ADDONS_REFS = frozenset(
    {
        es_optical,
        es_pharmacy,
        es_preexisting_conditions,
        es_premium_reimbursement,
        es_physio_nutrition,
    }
)

ES_ALAN_ESSENTIAL_ALLOWED_GUARANTEES module-attribute

ES_ALAN_ESSENTIAL_ALLOWED_GUARANTEES = frozenset(
    {es_alan_essential, es_assistance}
)

ES_CORE_PRODUCT_REFS module-attribute

ES_CORE_PRODUCT_REFS = frozenset(
    {es_alan_essential, es_alan_access, es_alan_health}
)

EsGuaranteeRef

Bases: AlanBaseEnum

ES guarantee identifiers from catalog_guarantees.yaml.

These identifiers correspond to the identifier field in the ES health plan guarantee catalog.

es_alan_access class-attribute instance-attribute
es_alan_access = 'es_alan_access'
es_alan_essential class-attribute instance-attribute
es_alan_essential = 'es_alan_essential'
es_alan_health class-attribute instance-attribute
es_alan_health = 'es_alan_health'
es_assistance class-attribute instance-attribute
es_assistance = 'es_assistance'
es_optical class-attribute instance-attribute
es_optical = 'es_optical'
es_pharmacy class-attribute instance-attribute
es_pharmacy = 'es_pharmacy'
es_physio_nutrition class-attribute instance-attribute
es_physio_nutrition = 'es_physio_nutrition'
es_preexisting_conditions class-attribute instance-attribute
es_preexisting_conditions = 'es_preexisting_conditions'
es_premium_reimbursement class-attribute instance-attribute
es_premium_reimbursement = 'es_premium_reimbursement'
es_therapy_session class-attribute instance-attribute
es_therapy_session = 'es_therapy_session'

guarantee_eligible_beneficiary_enums

GuaranteeCatalogGuaranteeEligibleBeneficiaryParameterType

Bases: AlanBaseEnum

Type of parameter for a guarantee eligible beneficiary.

These parameters define additional eligibility criteria for beneficiaries. This enum is incomplete and will be filled in at a later date as we define more beneficiary parameter types.

status class-attribute instance-attribute
status = 'status'

GuaranteeEligibleBeneficiaryType

Bases: AlanBaseEnum

Type of eligible beneficiary for a guarantee.

ascendant class-attribute instance-attribute
ascendant = 'ascendant'
child class-attribute instance-attribute
child = 'child'
partner class-attribute instance-attribute
partner = 'partner'
self class-attribute instance-attribute
self = 'self'

guarantee_eligible_event_enums

GuaranteeCatalogGuaranteeEligibleEventParameterType

Bases: AlanBaseEnum

Type of parameter for a guarantee eligible event.

These parameters define additional eligibility criteria for events.

is_covered_by_ss class-attribute instance-attribute
is_covered_by_ss = 'is_covered_by_ss'
is_occupational_disease_or_accident class-attribute instance-attribute
is_occupational_disease_or_accident = (
    "is_occupational_disease_or_accident"
)
min_duration_days class-attribute instance-attribute
min_duration_days = 'min_duration_days'
requires_hospitalization class-attribute instance-attribute
requires_hospitalization = 'requires_hospitalization'
work_stoppage_valid_reasons class-attribute instance-attribute
work_stoppage_valid_reasons = 'work_stoppage_valid_reasons'

GuaranteeEligibleEventType

Bases: AlanBaseEnum

Type of eligible event for a guarantee.

This is the global enum used for DB storage. Use the per-product-type sets below for validation of which event types are valid for each product.

death class-attribute instance-attribute
death = 'death'
health_care class-attribute instance-attribute
health_care = 'health_care'
permanent_disability class-attribute instance-attribute
permanent_disability = 'permanent_disability'
work_stoppage class-attribute instance-attribute
work_stoppage = 'work_stoppage'

GuaranteeEligibleEventUserType

Bases: AlanBaseEnum

Who the event happens to.

ascendant class-attribute instance-attribute
ascendant = 'ascendant'
child class-attribute instance-attribute
child = 'child'
partner class-attribute instance-attribute
partner = 'partner'
self class-attribute instance-attribute
self = 'self'

WorkStoppageValidReason

Bases: AlanBaseEnum

Valid reasons for work stoppage events.

Synced with InternalizedWorkStoppageReason from prevoyance_claim_management.

accident_caused_by_third_party class-attribute instance-attribute
accident_caused_by_third_party = (
    "accident_caused_by_third_party"
)
accident_not_caused_by_third_party class-attribute instance-attribute
accident_not_caused_by_third_party = (
    "accident_not_caused_by_third_party"
)
adoption_leave class-attribute instance-attribute
adoption_leave = 'adoption_leave'
disease class-attribute instance-attribute
disease = 'disease'
maternity_leave class-attribute instance-attribute
maternity_leave = 'maternity_leave'
paternity_leave class-attribute instance-attribute
paternity_leave = 'paternity_leave'
professional_accident class-attribute instance-attribute
professional_accident = 'professional_accident'
professional_disease class-attribute instance-attribute
professional_disease = 'professional_disease'
spa_covered_by_ss class-attribute instance-attribute
spa_covered_by_ss = 'spa_covered_by_ss'

guarantee_eligible_member_enums

GuaranteeCatalogGuaranteeEligibleMemberParameterType

Bases: AlanBaseEnum

Type of parameter for a guarantee eligible member.

These parameters define additional eligibility criteria for members. This enum is incomplete and will be filled in at a later date as we define more member parameter types.

max_hours_worked_in_trimester class-attribute instance-attribute
max_hours_worked_in_trimester = (
    "max_hours_worked_in_trimester"
)
max_tenure_months class-attribute instance-attribute
max_tenure_months = 'max_tenure_months'
max_tenure_or_less_than_200_hours_per_trimester class-attribute instance-attribute
max_tenure_or_less_than_200_hours_per_trimester = (
    "max_tenure_or_less_than_200_hours_per_trimester"
)
min_covered_presence_days class-attribute instance-attribute
min_covered_presence_days = 'min_covered_presence_days'
min_hours_worked_in_trimester class-attribute instance-attribute
min_hours_worked_in_trimester = (
    "min_hours_worked_in_trimester"
)
min_tenure_months class-attribute instance-attribute
min_tenure_months = 'min_tenure_months'

guarantee_expression_type

GuaranteeExpressionType

Bases: AlanBaseEnum

Enumeration of all possible guarantee expression types. Defines how a guarantee's reimbursement is calculated.

cumulative_copayment class-attribute instance-attribute
cumulative_copayment = 'cumulative_copayment'
cumulative_limit class-attribute instance-attribute
cumulative_limit = 'cumulative_limit'
cumulative_limit_on_percent_reimburement_monthly_social_security_ceiling class-attribute instance-attribute
cumulative_limit_on_percent_reimburement_monthly_social_security_ceiling = "cumulative_limit_on_percent_reimburement_monthly_social_security_ceiling"
cumulative_limit_per_side class-attribute instance-attribute
cumulative_limit_per_side = 'cumulative_limit_per_side'
get_before_and_after_parameter_types classmethod
get_before_and_after_parameter_types(expression_type)

Returns the before and after parameter types (if any) for a given expression type.

Source code in components/guarantee_catalog/public/enums/guarantee_expression_type.py
@classmethod
def get_before_and_after_parameter_types(
    cls, expression_type: GuaranteeExpressionType
) -> tuple[GuaranteeParameterType, GuaranteeParameterType] | None:
    """Returns the before and after parameter types (if any) for a given expression type."""
    match expression_type:
        case GuaranteeExpressionType.percent_reimbursement_ss_before_after_count_limit:
            before = GuaranteeParameterType.percent_reimbursement_ss
            after = GuaranteeParameterType.percent_reimbursement_ss_after_count_limit_reached
            return before, after
        case GuaranteeExpressionType.max_reimbursement_per_care_before_after_count_limit:
            before = GuaranteeParameterType.max_reimbursement_per_care
            after = GuaranteeParameterType.max_reimbursement_per_care_after_count_limit_reached
            return before, after
        case _:
            return None
get_pricer_main_and_extra_param_types classmethod
get_pricer_main_and_extra_param_types(expression_type)

Returns the main and extra parameter types used by the pricer for a given expression type.

The pricer uses these parameters as inputs to compute pure premiums for guarantees: - main_parameter_type: The primary parameter that affects the pure premium calculation - extra_parameter_type: An optional secondary parameter that may also influence the calculation

For example, for percent_reimbursement_ss: - main_parameter_type is percent_reimbursement_ss - no extra_parameter_type is needed The pure premium will depend only on the value of percent_reimbursement_ss.

Parameters:

Name Type Description Default
expression_type GuaranteeExpressionType

The type of guarantee expression

required

Returns:

Type Description
GuaranteeParameterType

A tuple containing:

Optional[GuaranteeParameterType]
  • The main parameter type (GuaranteeParameterType)
tuple[GuaranteeParameterType, Optional[GuaranteeParameterType]]
  • The extra parameter type if any, None otherwise
Source code in components/guarantee_catalog/public/enums/guarantee_expression_type.py
@classmethod
def get_pricer_main_and_extra_param_types(
    cls, expression_type: GuaranteeExpressionType
) -> tuple[GuaranteeParameterType, Optional[GuaranteeParameterType]]:
    """Returns the main and extra parameter types used by the pricer for a given expression type.

    The pricer uses these parameters as inputs to compute pure premiums for guarantees:
    - main_parameter_type: The primary parameter that affects the pure premium calculation
    - extra_parameter_type: An optional secondary parameter that may also influence the calculation

    For example, for percent_reimbursement_ss:
    - main_parameter_type is percent_reimbursement_ss
    - no extra_parameter_type is needed
    The pure premium will depend only on the value of percent_reimbursement_ss.

    Args:
        expression_type: The type of guarantee expression

    Returns:
        A tuple containing:
        - The main parameter type (GuaranteeParameterType)
        - The extra parameter type if any, None otherwise
    """
    pricer_parameters: dict[
        GuaranteeExpressionType,
        tuple[GuaranteeParameterType, Optional[GuaranteeParameterType]],
    ] = {
        cls.cumulative_copayment: (
            GuaranteeParameterType.cumulative_copayment,
            None,
        ),
        cls.cumulative_limit: (GuaranteeParameterType.cumulative_limit, None),
        cls.cumulative_limit_per_side: (
            GuaranteeParameterType.cumulative_limit,
            None,
        ),
        cls.lump_sum: (GuaranteeParameterType.lump_sum, None),
        cls.max_reimbursement_per_care: (
            GuaranteeParameterType.max_reimbursement_per_care,
            None,
        ),
        cls.max_reimbursement_per_care_before_after_count_limit: (
            GuaranteeParameterType.max_reimbursement_per_care,
            GuaranteeParameterType.max_reimbursement_per_care_after_count_limit_reached,
        ),
        cls.max_reimbursement_per_care_with_count_limit: (
            GuaranteeParameterType.max_reimbursement_per_care,
            GuaranteeParameterType.count_limit,
        ),
        cls.max_reimbursement_per_care_with_count_limit_and_frame_amount: (
            GuaranteeParameterType.max_reimbursement_per_care,
            None,
        ),
        cls.max_reimbursement_per_care_with_cumulative_limit: (
            GuaranteeParameterType.cumulative_limit,
            GuaranteeParameterType.max_reimbursement_per_care,
        ),
        cls.percent_reimbursement_ss: (
            GuaranteeParameterType.percent_reimbursement_ss,
            None,
        ),
        cls.percent_reimbursement_ss_before_after_count_limit: (
            GuaranteeParameterType.percent_reimbursement_ss,
            GuaranteeParameterType.percent_reimbursement_ss_after_count_limit_reached,
        ),
        cls.percent_reimbursement_ss_with_cumulative_limit: (
            GuaranteeParameterType.cumulative_limit,
            None,
        ),
        cls.percent_reimbursement_ss_with_count_limit: (
            GuaranteeParameterType.percent_reimbursement_ss,
            GuaranteeParameterType.count_limit,
        ),
        cls.percent_reimbursement_total_cost: (
            GuaranteeParameterType.percent_reimbursement_total_cost,
            None,
        ),
        cls.percent_reimbursement_total_cost_with_count_limit: (
            GuaranteeParameterType.percent_reimbursement_total_cost,
            None,
        ),
        cls.percent_reimbursement_total_cost_with_cumulative_limit: (
            GuaranteeParameterType.percent_reimbursement_total_cost,
            GuaranteeParameterType.cumulative_limit,
        ),
        cls.percent_reimbursement_with_cumulative_and_count_limit_per_side: (
            GuaranteeParameterType.cumulative_limit,
            None,
        ),
        cls.pre_post: (
            GuaranteeParameterType.pre_duration_in_months,
            GuaranteeParameterType.post_duration_in_months,
        ),
        cls.reimburse_full_cost: (GuaranteeParameterType.reimburse_full_cost, None),
        cls.reimburse_full_cost_with_count_limit: (
            GuaranteeParameterType.count_limit,
            None,
        ),
        cls.reimburse_full_cost_with_count_limit_per_side: (
            GuaranteeParameterType.reimburse_full_cost,
            None,
        ),
        cls.reimburse_full_cost_with_waiting_period: (
            GuaranteeParameterType.waiting_period_in_months,
            None,
        ),
    }
    return pricer_parameters[expression_type]
get_required_parameter_types classmethod
get_required_parameter_types(expression_type)

Returns set of required parameter types for a given expression type.

Source code in components/guarantee_catalog/public/enums/guarantee_expression_type.py
@classmethod
def get_required_parameter_types(
    cls, expression_type: GuaranteeExpressionType
) -> set[GuaranteeParameterType]:
    """Returns set of required parameter types for a given expression type."""
    required_parameters: dict[
        GuaranteeExpressionType, set[GuaranteeParameterType]
    ] = {
        cls.cumulative_limit: {
            GuaranteeParameterType.cumulative_limit,
            GuaranteeParameterType.limit_window,
        },
        cls.cumulative_limit_per_side: {
            GuaranteeParameterType.cumulative_limit,
            GuaranteeParameterType.limit_window,
        },
        cls.percent_reimbursement_ss: {
            GuaranteeParameterType.percent_reimbursement_ss,
        },
        cls.percent_reimbursement_total_cost: {
            GuaranteeParameterType.percent_reimbursement_total_cost,
        },
        cls.percent_reimbursement_total_cost_with_count_limit: {
            GuaranteeParameterType.percent_reimbursement_total_cost,
            GuaranteeParameterType.count_limit,
            GuaranteeParameterType.limit_window,
        },
        cls.percent_reimbursement_total_cost_with_cumulative_limit: {
            GuaranteeParameterType.percent_reimbursement_total_cost,
            GuaranteeParameterType.cumulative_limit,
            GuaranteeParameterType.limit_window,
        },
        cls.percent_reimbursement_ss_with_count_limit: {
            GuaranteeParameterType.percent_reimbursement_ss,
            GuaranteeParameterType.count_limit,
            GuaranteeParameterType.limit_window,
        },
        cls.reimburse_full_cost_with_count_limit: {
            GuaranteeParameterType.count_limit,
            GuaranteeParameterType.limit_window,
            GuaranteeParameterType.reimburse_full_cost,
        },
        cls.percent_reimbursement_ss_with_cumulative_limit: {
            GuaranteeParameterType.cumulative_limit,
            GuaranteeParameterType.limit_window,
            GuaranteeParameterType.percent_reimbursement_ss,
        },
        cls.percent_reimbursement_with_cumulative_and_count_limit_per_side: {
            GuaranteeParameterType.cumulative_limit,
            GuaranteeParameterType.limit_window,
            GuaranteeParameterType.count_limit,
            GuaranteeParameterType.always_reimburse_100_pct_ss,
        },
        cls.max_reimbursement_per_care: {
            GuaranteeParameterType.max_reimbursement_per_care,
        },
        cls.max_reimbursement_per_care_before_after_count_limit: {
            GuaranteeParameterType.max_reimbursement_per_care,
            GuaranteeParameterType.count_limit,
            GuaranteeParameterType.limit_window,
            GuaranteeParameterType.max_reimbursement_per_care_after_count_limit_reached,
        },
        cls.max_reimbursement_per_care_with_count_limit: {
            GuaranteeParameterType.max_reimbursement_per_care,
            GuaranteeParameterType.count_limit,
            GuaranteeParameterType.limit_window,
        },
        cls.max_reimbursement_per_care_with_count_limit_and_frame_amount: {
            GuaranteeParameterType.max_reimbursement_per_care,
            GuaranteeParameterType.frame_amount,
            GuaranteeParameterType.count_limit,
            GuaranteeParameterType.limit_window,
        },
        cls.max_reimbursement_per_care_with_cumulative_limit: {
            GuaranteeParameterType.max_reimbursement_per_care,
            GuaranteeParameterType.cumulative_limit,
            GuaranteeParameterType.limit_window,
        },
        cls.percent_reimbursement_ss_before_after_count_limit: {
            GuaranteeParameterType.percent_reimbursement_ss,
            GuaranteeParameterType.count_limit,
            GuaranteeParameterType.limit_window,
            GuaranteeParameterType.percent_reimbursement_ss_after_count_limit_reached,
        },
        cls.pre_post: {
            GuaranteeParameterType.pre_duration_in_months,
            GuaranteeParameterType.post_duration_in_months,
        },
        cls.lump_sum: {
            GuaranteeParameterType.lump_sum,
        },
        cls.cumulative_copayment: {
            GuaranteeParameterType.cumulative_copayment,
            GuaranteeParameterType.limit_window,
        },
        cls.reimburse_full_cost: {
            GuaranteeParameterType.reimburse_full_cost,
        },
        cls.reimburse_full_cost_with_count_limit_per_side: {
            GuaranteeParameterType.count_limit,
            GuaranteeParameterType.limit_window,
            GuaranteeParameterType.reimburse_full_cost,
        },
        cls.reimburse_full_cost_with_waiting_period: {
            GuaranteeParameterType.reimburse_full_cost,
            GuaranteeParameterType.waiting_period_in_months,
        },
        cls.percent_reimbursement_fixed_contribution: {
            GuaranteeParameterType.percent_reimbursement_fixed_contribution,
        },
        cls.percent_reimbursement_coinsurance: {
            GuaranteeParameterType.percent_reimbursement_coinsurance,
        },
        cls.percent_reimbursement_coinsurance_and_ss: {
            GuaranteeParameterType.percent_reimbursement_coinsurance,
            GuaranteeParameterType.percent_reimbursement_ss,
        },
        cls.percent_reimbursement_monthly_social_security_ceiling: {
            GuaranteeParameterType.percent_reimbursement_monthly_social_security_ceiling,
        },
        cls.lump_sum_and_percent_reimbursement_ss: {
            GuaranteeParameterType.lump_sum,
            GuaranteeParameterType.percent_reimbursement_ss,
        },
        cls.cumulative_limit_on_percent_reimburement_monthly_social_security_ceiling: {
            GuaranteeParameterType.percent_reimbursement_monthly_social_security_ceiling,
            GuaranteeParameterType.limit_window,
        },
    }
    return required_parameters[expression_type]
is_priceable property
is_priceable

Returns True if the expression type is priceable, False otherwise.

lump_sum class-attribute instance-attribute
lump_sum = 'lump_sum'
lump_sum_and_percent_reimbursement_ss class-attribute instance-attribute
lump_sum_and_percent_reimbursement_ss = (
    "lump_sum_and_percent_reimbursement_ss"
)
max_reimbursement_per_care class-attribute instance-attribute
max_reimbursement_per_care = 'max_reimbursement_per_care'
max_reimbursement_per_care_before_after_count_limit class-attribute instance-attribute
max_reimbursement_per_care_before_after_count_limit = (
    "max_reimbursement_per_care_before_after_count_limit"
)
max_reimbursement_per_care_with_count_limit class-attribute instance-attribute
max_reimbursement_per_care_with_count_limit = (
    "max_reimbursement_per_care_with_count_limit"
)
max_reimbursement_per_care_with_count_limit_and_frame_amount class-attribute instance-attribute
max_reimbursement_per_care_with_count_limit_and_frame_amount = "max_reimbursement_per_care_with_count_limit_and_frame_amount"
max_reimbursement_per_care_with_cumulative_limit class-attribute instance-attribute
max_reimbursement_per_care_with_cumulative_limit = (
    "max_reimbursement_per_care_with_cumulative_limit"
)
percent_reimbursement_coinsurance class-attribute instance-attribute
percent_reimbursement_coinsurance = (
    "percent_reimbursement_coinsurance"
)
percent_reimbursement_coinsurance_and_ss class-attribute instance-attribute
percent_reimbursement_coinsurance_and_ss = (
    "percent_reimbursement_coinsurance_and_ss"
)
percent_reimbursement_fixed_contribution class-attribute instance-attribute
percent_reimbursement_fixed_contribution = (
    "percent_reimbursement_fixed_contribution"
)
percent_reimbursement_monthly_social_security_ceiling class-attribute instance-attribute
percent_reimbursement_monthly_social_security_ceiling = (
    "percent_reimbursement_monthly_social_security_ceiling"
)
percent_reimbursement_ss class-attribute instance-attribute
percent_reimbursement_ss = 'percent_reimbursement_ss'
percent_reimbursement_ss_before_after_count_limit class-attribute instance-attribute
percent_reimbursement_ss_before_after_count_limit = (
    "percent_reimbursement_ss_before_after_count_limit"
)
percent_reimbursement_ss_with_count_limit class-attribute instance-attribute
percent_reimbursement_ss_with_count_limit = (
    "percent_reimbursement_ss_with_count_limit"
)
percent_reimbursement_ss_with_cumulative_limit class-attribute instance-attribute
percent_reimbursement_ss_with_cumulative_limit = (
    "percent_reimbursement_ss_with_cumulative_limit"
)
percent_reimbursement_total_cost class-attribute instance-attribute
percent_reimbursement_total_cost = (
    "percent_reimbursement_total_cost"
)
percent_reimbursement_total_cost_with_count_limit class-attribute instance-attribute
percent_reimbursement_total_cost_with_count_limit = (
    "percent_reimbursement_total_cost_with_count_limit"
)
percent_reimbursement_total_cost_with_cumulative_limit class-attribute instance-attribute
percent_reimbursement_total_cost_with_cumulative_limit = (
    "percent_reimbursement_total_cost_with_cumulative_limit"
)
percent_reimbursement_with_cumulative_and_count_limit_per_side class-attribute instance-attribute
percent_reimbursement_with_cumulative_and_count_limit_per_side = "percent_reimbursement_with_cumulative_and_count_limit_per_side"
pre_post class-attribute instance-attribute
pre_post = 'pre_post'
reimburse_full_cost class-attribute instance-attribute
reimburse_full_cost = 'reimburse_full_cost'
reimburse_full_cost_with_count_limit class-attribute instance-attribute
reimburse_full_cost_with_count_limit = (
    "reimburse_full_cost_with_count_limit"
)
reimburse_full_cost_with_count_limit_per_side class-attribute instance-attribute
reimburse_full_cost_with_count_limit_per_side = (
    "reimburse_full_cost_with_count_limit_per_side"
)
reimburse_full_cost_with_waiting_period class-attribute instance-attribute
reimburse_full_cost_with_waiting_period = (
    "reimburse_full_cost_with_waiting_period"
)

guarantee_parameter_source

GuaranteeParameterSource

Bases: AlanBaseEnum

Enumeration defining the possible sources of a guarantee parameter value.

constant class-attribute instance-attribute
constant = 'constant'
propagated class-attribute instance-attribute
propagated = 'propagated'
user class-attribute instance-attribute
user = 'user'

guarantee_parameter_type

GuaranteeParameterType

Bases: AlanBaseEnum

Enumeration of all possible guarantee parameter types.

always_reimburse_100_pct_ss class-attribute instance-attribute
always_reimburse_100_pct_ss = 'always_reimburse_100_pct_ss'
count_limit class-attribute instance-attribute
count_limit = 'count_limit'
cumulative_copayment class-attribute instance-attribute
cumulative_copayment = 'cumulative_copayment'
cumulative_limit class-attribute instance-attribute
cumulative_limit = 'cumulative_limit'
format_value
format_value(value)

Format the provided value of the parameter according to its type.

Source code in components/guarantee_catalog/public/enums/guarantee_parameter_type.py
def format_value(self, value: Any) -> Any:
    """Format the provided value of the parameter according to its type."""
    formatter = self.get_value_formatter(self)
    return formatter(value)
frame_amount class-attribute instance-attribute
frame_amount = 'frame_amount'
get_limit_types classmethod
get_limit_types()

Returns set of parameter types that are limits.

Source code in components/guarantee_catalog/public/enums/guarantee_parameter_type.py
@classmethod
def get_limit_types(cls) -> set["GuaranteeParameterType"]:
    """Returns set of parameter types that are limits."""
    return {
        cls.count_limit,
        cls.limit_window,
        cls.cumulative_limit,
    }
get_value_formatter classmethod
get_value_formatter(parameter_type)

Return the type of the value for the parameter.

Source code in components/guarantee_catalog/public/enums/guarantee_parameter_type.py
@classmethod
def get_value_formatter(
    cls, parameter_type: "GuaranteeParameterType"
) -> Callable[[Any], Any]:
    """Return the type of the value for the parameter."""
    from shared.blueprints.admin_tools.helpers import parse_bool

    if parameter_type in [
        cls.percent_reimbursement_ss,
        cls.percent_reimbursement_total_cost,
        cls.percent_reimbursement_ss_after_count_limit_reached,
        cls.count_limit,
        cls.pre_duration_in_months,
        cls.post_duration_in_months,
        cls.waiting_period_in_months,
        cls.cumulative_copayment,
        cls.percent_reimbursement_fixed_contribution,
        cls.percent_reimbursement_coinsurance,
        cls.percent_reimbursement_monthly_social_security_ceiling,
    ]:
        # Old builder product versions may store '350.0' instead of '350'
        # in their parameter value. Thus we do not use `int` directly
        return lambda x: int(float(x))
    elif parameter_type in [
        cls.max_reimbursement_per_care,
        cls.max_reimbursement_per_care_after_count_limit_reached,
        cls.frame_amount,
        cls.cumulative_limit,
        cls.lump_sum,
    ]:
        return float
    elif parameter_type in [
        cls.reimburse_full_cost,
        cls.always_reimburse_100_pct_ss,
    ]:
        return parse_bool
    elif parameter_type in [cls.limit_window]:
        return LimitWindow.validate
    raise ValueError(f"No value type defined for {parameter_type}")
limit_window class-attribute instance-attribute
limit_window = 'limit_window'
lump_sum class-attribute instance-attribute
lump_sum = 'lump_sum'
max_reimbursement_per_care class-attribute instance-attribute
max_reimbursement_per_care = 'max_reimbursement_per_care'
max_reimbursement_per_care_after_count_limit_reached class-attribute instance-attribute
max_reimbursement_per_care_after_count_limit_reached = (
    "max_reimbursement_per_care_after_count_limit_reached"
)
percent_reimbursement_coinsurance class-attribute instance-attribute
percent_reimbursement_coinsurance = (
    "percent_reimbursement_coinsurance"
)
percent_reimbursement_fixed_contribution class-attribute instance-attribute
percent_reimbursement_fixed_contribution = (
    "percent_reimbursement_fixed_contribution"
)
percent_reimbursement_monthly_social_security_ceiling class-attribute instance-attribute
percent_reimbursement_monthly_social_security_ceiling = (
    "percent_reimbursement_monthly_social_security_ceiling"
)
percent_reimbursement_ss class-attribute instance-attribute
percent_reimbursement_ss = 'percent_reimbursement_ss'
percent_reimbursement_ss_after_count_limit_reached class-attribute instance-attribute
percent_reimbursement_ss_after_count_limit_reached = (
    "percent_reimbursement_ss_after_count_limit_reached"
)
percent_reimbursement_total_cost class-attribute instance-attribute
percent_reimbursement_total_cost = (
    "percent_reimbursement_total_cost"
)
post_duration_in_months class-attribute instance-attribute
post_duration_in_months = 'post_duration_in_months'
pre_duration_in_months class-attribute instance-attribute
pre_duration_in_months = 'pre_duration_in_months'
reimburse_full_cost class-attribute instance-attribute
reimburse_full_cost = 'reimburse_full_cost'
waiting_period_in_months class-attribute instance-attribute
waiting_period_in_months = 'waiting_period_in_months'

product_type

ProductType

Bases: AlanBaseEnum

Product type for guarantee catalog entities.

Represents the combination of country and insurance product line.

be_health class-attribute instance-attribute
be_health = 'be_health'
ca_health class-attribute instance-attribute
ca_health = 'ca_health'
es_health class-attribute instance-attribute
es_health = 'es_health'
fr_health class-attribute instance-attribute
fr_health = 'fr_health'
fr_prevoyance class-attribute instance-attribute
fr_prevoyance = 'fr_prevoyance'

statuses

BundleChoiceStatus

Bases: AlanBaseEnum

Pending choices are stored in the backend, but will not be returned by the API

active class-attribute instance-attribute
active = 'active'
deprecated class-attribute instance-attribute
deprecated = 'deprecated'
expert class-attribute instance-attribute
expert = 'expert'
pending class-attribute instance-attribute
pending = 'pending'

GuaranteeExpressionStatus

Bases: AlanBaseEnum

Pending choices are stored in the backend, but will not be returned by the API

active class-attribute instance-attribute
active = 'active'
deprecated class-attribute instance-attribute
deprecated = 'deprecated'
expert class-attribute instance-attribute
expert = 'expert'
pending class-attribute instance-attribute
pending = 'pending'

components.guarantee_catalog.public.queries

guarantees_definition

get_guarantee_catalog

get_guarantee_catalog()

Returns all guarantee categories and their complete hierarchy for the current app's product type.

Source code in components/guarantee_catalog/public/queries/guarantees_definition.py
def get_guarantee_catalog() -> GuaranteeCatalog:
    """Returns all guarantee categories and their complete hierarchy for the current app's product type."""
    app_dependency = get_app_dependency()
    return _get_guarantee_catalog(
        country=app_dependency.get_country_code().value,
        product_type=app_dependency.get_product_type().value,
    )

validate_guarantee_catalog_from_yaml

validate_guarantee_catalog_from_yaml()

Validate the guarantee catalog YAML file for the current app.

This function validates the default guarantee catalog YAML file (as configured in app dependencies) without persisting any changes. Primarily used for testing to ensure the production YAML is well-formed and meets all validation rules.

Raises:

Type Description
YAMLError

If the YAML file is malformed

GuaranteeDefinitionError

If any validation fails (parameter constraints, references, uniqueness checks, etc.)

Source code in components/guarantee_catalog/public/queries/guarantees_definition.py
def validate_guarantee_catalog_from_yaml() -> None:
    """Validate the guarantee catalog YAML file for the current app.

    This function validates the default guarantee catalog YAML file (as configured in app dependencies)
    without persisting any changes. Primarily used for testing to ensure the production YAML
    is well-formed and meets all validation rules.

    Raises:
        yaml.YAMLError: If the YAML file is malformed
        GuaranteeDefinitionError: If any validation fails (parameter constraints,
            references, uniqueness checks, etc.)
    """
    app_dependency = get_app_dependency()
    parse_guarantee_catalog_yaml(
        file_path=app_dependency.get_guarantee_yaml_file_path(),
        product_type=app_dependency.get_product_type().value,
    )

validate_coverage_rules

validate_coverage_rules

validate_coverage_rules(request)

Validates coverage rules for a given coverage against guarantee definitions.

Source code in components/guarantee_catalog/public/queries/validate_coverage_rules.py
def validate_coverage_rules(
    request: ValidateCoverageRulesRequest,
) -> list[GuaranteeCatalogError]:
    """Validates coverage rules for a given coverage against guarantee definitions."""
    app_dependency = get_app_dependency()
    global_errors = _validate_coverage_rules(
        country=app_dependency.get_country_code().value,
        product_type=app_dependency.get_product_type().value,
        request=request,
    )
    country_specific_errors = app_dependency.validate_coverage_rules(request)

    return global_errors + country_specific_errors

validate_target_coverage_rule_is_equal_or_better_than_source

validate_target_coverage_rule_is_equal_or_better_than_source(
    source, target
)

Validate that target coverage rule is equal to or better than source coverage rule.

Source code in components/guarantee_catalog/public/queries/validate_coverage_rules.py
def validate_target_coverage_rule_is_equal_or_better_than_source(
    source: CoverageRule, target: CoverageRule
) -> list[GuaranteeCatalogError]:
    """Validate that target coverage rule is equal to or better than source coverage rule."""
    return _validate_target_coverage_rule_is_equal_or_better_than_source(source, target)

components.guarantee_catalog.public.test_helpers

load_guarantee_catalog

load_guarantee_catalog

load_guarantee_catalog(app_dependency=None)

Load the guarantee catalog.

Parameters:

Name Type Description Default
app_dependency GuaranteeCatalogDependency | None

The app dependency to use. If not provided, the default app dependency will be used.

None
Source code in components/guarantee_catalog/public/test_helpers/load_guarantee_catalog.py
def load_guarantee_catalog(
    app_dependency: GuaranteeCatalogDependency | None = None,
) -> None:
    """Load the guarantee catalog.

    Args:
        app_dependency: The app dependency to use. If not provided, the default app dependency will be used.
    """
    from components.guarantee_catalog.internal.business_logic.actions.guarantee_definitions_import.sync_guarantee_catalog import (
        load_guarantee_catalog_from_yaml,
    )

    if app_dependency is None:
        from components.guarantee_catalog.public.dependencies import get_app_dependency

        app_dependency = get_app_dependency()

    country = app_dependency.get_country_code()
    product_type = app_dependency.get_product_type()
    catalog_file_path = app_dependency.get_guarantee_yaml_file_path()

    load_guarantee_catalog_from_yaml(
        file_path=catalog_file_path,
        country=country.value,
        product_type=product_type.value,
        commit=True,
    )