Api reference
components.recovery.public.actions ¶
formal_notice ¶
Formal notice executor: sends a registered postal letter and notification email.
FormalNoticeAudience ¶
FormalNoticeEmailSender ¶
Bases: Protocol
Contract for country-specific formal notice email dispatch.
Receives pre-formatted display strings and dispatches the notification email through the country's mail infrastructure.
__call__ ¶
__call__(
*,
email,
language,
recipient_name,
contract_name,
invoice_number,
total_debt_amount,
next_action_date,
recovery_timeline_entries,
virtual_iban_data,
uses_professional_dashboard
)
Dispatch one formal notice notification email to a single recipient.
Source code in components/recovery/public/actions/formal_notice.py
FormalNoticeExecutor ¶
FormalNoticeExecutor(
adapter_class,
*,
country_code,
invoicer,
postal_use_case_key,
payment_delay_days,
letter_configs,
send_email
)
Send a formal notice registered letter and notification email.
Reusable executor for any recovery plan that needs to send a formal
notice letter and email notification. Requires:
- BalanceRecoveryAdapter subclass for country-specific data retrieval
- country_code for postal letter routing
- invoicer AlanLegalEntity used to resolve the legal mention
via BillingSubscription.get_legal_mention and the footer signature logo
- postal_use_case_key matching a registered postal use case
- payment_delay_days legal formal deadline for payment
- letter_configs dict mapping language → FormalNoticeLetterConfig
- FormalNoticeEmailSender for dispatching notification emails
Source code in components/recovery/public/actions/formal_notice.py
__call__ ¶
Generate formal notice PDF, send via postal letter, send notification emails.
Source code in components/recovery/public/actions/formal_notice.py
send_emails ¶
send_emails(
*,
case,
adapter,
recipients,
contract_display_name,
invoice_number,
total_debt_amount,
currency,
virtual_iban
)
Send notification emails to all recipients.
Source code in components/recovery/public/actions/formal_notice.py
send_letter ¶
send_letter(
*,
case,
recipient,
contract_display_info,
total_debt_amount,
currency,
virtual_iban,
payment_reference
)
Generate letter PDF and send as registered postal letter.
Source code in components/recovery/public/actions/formal_notice.py
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 | |
FormalNoticeLetterConfig
dataclass
¶
FormalNoticeLetterConfig(
*,
sending_city,
vat_number_label,
legal_paragraph,
legal_reference_line,
footer_tagline=None
)
Per-language template config for formal notice postal letter documents.
formal_notice_pdf ¶
PDF generator for the formal notice letter.
generate_formal_notice_pdf ¶
generate_formal_notice_pdf(
*,
language,
total_debt_amount,
current_date,
sending_city,
contract_display_name,
contract_display_ref,
contract_start_date,
first_unpaid_due_date,
full_name,
is_company,
is_individual_contract,
vat_number_label,
vat_number,
virtual_iban,
virtual_bic,
account_holder_name,
payment_reference,
payment_delay_days,
legal_paragraph,
legal_reference_line,
footer_tagline=None,
footer_legal_text=None,
footer_logo_filename=None
)
Generate formal notice PDF.
Source code in components/recovery/public/actions/formal_notice_pdf.py
payment_failure ¶
Payment failure notification executor and variant enum.
PaymentFailureEmailSender ¶
Bases: Protocol
Contract for country-specific payment failure email dispatch.
Implementations receive pre-formatted display strings from the executor and are responsible for building the email and dispatching it through the country's mail infrastructure.
Example BE implementation: a function decorated with @be_async_mailer
that returns MailerParams, the decorator handles async queueing,
rendering, delivery, and audit logging.
__call__ ¶
__call__(
*,
email,
language,
recipient_name,
contract_name,
invoice_month,
invoice_number,
invoice_amount,
total_debt_amount,
variant,
next_action_date,
recovery_timeline_entries,
virtual_iban_data,
uses_professional_dashboard,
show_prior_invoices_unpaid_amount_line
)
Dispatch one payment failure notification email to a single recipient.
Source code in components/recovery/public/actions/payment_failure.py
PaymentFailureNotificationExecutor ¶
Send a payment failure email to the contractee.
Reusable executor for any recovery plan action that needs to notify about
a failed payment. Requires a BalanceRecoveryAdapter subclass and a
country-specific PaymentFailureEmailSender implementation::
executor = PaymentFailureNotificationExecutor(
MyBalanceRecoveryAdapter, send_email=my_send_email_function
)
The email variant is determined from the failure or dispute reason of the latest payment on the newest unpaid invoice.
Pair with HasFailedPaymentCondition to guard plan actions so this
executor only runs when a failed payment actually exists.
Source code in components/recovery/public/actions/payment_failure.py
__call__ ¶
Retrieve the last failed payment and total debt, determine the failure variant, and dispatch emails.
Source code in components/recovery/public/actions/payment_failure.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 | |
PaymentFailureVariant ¶
Bases: StrEnum
Domain variants for the payment failure email.
cannot_debit
class-attribute
instance-attribute
¶
The debit was rejected due to a problem with the payment method itself.
from_reason
classmethod
¶
Map a failure/dispute reason to the appropriate variant.
Source code in components/recovery/public/actions/payment_failure.py
insufficient_funds
class-attribute
instance-attribute
¶
The SEPA debit was attempted but the account balance was low.
missing_mandate
class-attribute
instance-attribute
¶
No valid SEPA direct debit mandate at the time of the debit.
payment_declined
class-attribute
instance-attribute
¶
Payment was declined, used for failed or disputed payments or as a generic fallback.
suspension ¶
Benefits suspension executors.
SuspensionEmailToBeneficiarySender ¶
Bases: Protocol
Protocol for country-specific suspension email dispatch to the beneficiary audience.
Implementations receive pre-formatted display values from the executor and are responsible for building the email and dispatching it through the country's mail infrastructure.
Example BE implementation: a function decorated with @be_async_mailer
that returns MailerParams, the decorator handles async queueing,
rendering, delivery, and audit logging.
__call__ ¶
Send one suspension email to a single beneficiary.
Source code in components/recovery/public/actions/suspension.py
SuspensionEmailToContracteeSender ¶
Bases: Protocol
Protocol for country-specific suspension email dispatch to the contractee audience.
Implementations receive pre-formatted display values from the executor and are responsible for building the email and dispatching it through the country's mail infrastructure.
Example BE implementation: a function decorated with @be_async_mailer
that returns MailerParams, the decorator handles async queueing,
rendering, delivery and audit logging.
__call__ ¶
__call__(
*,
email,
language,
contract_name,
recipient_name,
invoice_number,
total_debt_amount,
contract_termination_date,
uses_professional_dashboard,
virtual_iban_data,
recovery_timeline_entries
)
Send one suspension email to a single contractee.
Source code in components/recovery/public/actions/suspension.py
SuspensionInstallExecutor ¶
SuspensionInstallExecutor(
adapter_class,
*,
send_email_to_beneficiary,
send_email_to_contractee,
termination_action_name
)
Suspend benefits of an entity in recovery and notify its recipients.
Reusable executor for any recovery plan action that needs to block reimbursements of an entity and inform the corresponsing contractees and beneficiaries that their benefits have been suspended.
Requires:
- BalanceRecoveryAdapter subclass for country-specific data retrieval;
- send_email_to_beneficiary country-specific email sender targeting the entity
which is not responsible for settling the debt but is impacted by the suspension;
- send_email_to_contractee country-specific email sender targeting the entity
which contracted and is responsible for handling the debt;
- termination_action_name country-specific name of the recovery plan action
which terminates the contract;
Source code in components/recovery/public/actions/suspension.py
__call__ ¶
Install a reimbursement blocker on the recovery case's entity and notify the contractees and beneficiaries.
Source code in components/recovery/public/actions/suspension.py
SuspensionLiftExecutor ¶
Lift the benefits suspension from an entity in recovery.
Reusable executor for any recovery plan action that needs to deactivate a reimbursement blocker.
Requires:
- BalanceRecoveryAdapter subclass for country-specific data retrieval;
Source code in components/recovery/public/actions/suspension.py
__call__ ¶
Lift a reimbursement blocker from the recovery case's entity.
Source code in components/recovery/public/actions/suspension.py
suspension_warning ¶
Suspension warning notification executor.
SuspensionWarningEmailSender ¶
Bases: Protocol
Contract for country-specific suspension warning email dispatch.
Implementations receive pre-formatted display strings from the executor and are responsible for building the email and dispatching it through the country's mail infrastructure.
Example BE implementation: a function decorated with @be_async_mailer
that returns MailerParams, the decorator handles async queueing,
rendering, delivery, and audit logging.
__call__ ¶
__call__(
*,
email,
language,
contract_name,
recipient_name,
invoice_number,
total_debt_amount,
contract_termination_date,
recovery_timeline_entries,
virtual_iban_data,
uses_professional_dashboard
)
Dispatch one suspension warning email to a single recipient.
Source code in components/recovery/public/actions/suspension_warning.py
SuspensionWarningExecutor ¶
Send a suspension warning email to the contractee.
Reusable executor for any recovery plan action that needs to warn about an upcoming benefits suspension.
Requires:
- BalanceRecoveryAdapter subclass for country-specific data retrieval
- send_email country/product-specific email sender that builds and dispatches
the email through the country's mail infrastructure.
- termination_action_name contry/product-specific name of a recovery plan action
that terminates the contract.
Source code in components/recovery/public/actions/suspension_warning.py
__call__ ¶
Retrieve the newest unpaid invoice and total debt, then dispatch emails.
Source code in components/recovery/public/actions/suspension_warning.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | |
unpaid_invoice ¶
Unpaid invoice notification executor and variant enum.
UnpaidInvoiceEmailSender ¶
Bases: Protocol
Contract for country-specific unpaid invoice email dispatch.
Implementations receive pre-formatted display strings from the executor and are responsible for building the email and dispatching it through the country's mail infrastructure.
Example BE implementation: a function decorated with @be_async_mailer
that returns MailerParams, the decorator handles async queueing,
rendering, delivery, and audit logging.
__call__ ¶
__call__(
*,
email,
language,
recipient_name,
contract_name,
invoice_month,
invoice_number,
invoice_amount,
total_debt_amount,
remaining_amount,
variant,
next_action_date,
recovery_timeline_entries,
virtual_iban_data,
uses_professional_dashboard,
show_prior_invoices_unpaid_amount_line
)
Dispatch one unpaid invoice notification email to a single recipient.
Source code in components/recovery/public/actions/unpaid_invoice.py
UnpaidInvoiceNotificationExecutor ¶
Send an unpaid invoice notification email to the contractee.
Reusable executor for any recovery plan action that needs to notify about
an unpaid invoice when there is no failed, blocked, or disputed payment.
Requires a BalanceRecoveryAdapter subclass and a country-specific
UnpaidInvoiceEmailSender implementation::
executor = UnpaidInvoiceNotificationExecutor(
MyBalanceRecoveryAdapter, send_email=my_send_email_function
)
The email variant (partial_payment, late_payment, missing_debit, existing_debt) is determined from the invoice settlement status, payment history, and contract payment method.
Pair with NotCondition(HasFailedPaymentCondition(...)) to guard plan
actions so this executor only runs when no failed payment exists.
Source code in components/recovery/public/actions/unpaid_invoice.py
__call__ ¶
Retrieve the newest unpaid invoice, determine the variant, and dispatch emails.
Source code in components/recovery/public/actions/unpaid_invoice.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 | |
UnpaidInvoiceNotificationVariant ¶
Bases: StrEnum
Domain variants for the unpaid invoice notification email.
existing_debt
class-attribute
instance-attribute
¶
Invoice is considered unsettled due to pre-existing old debt.
late_payment
class-attribute
instance-attribute
¶
Payment not yet received for contracts paid by credit transfer.
missing_debit
class-attribute
instance-attribute
¶
Invoice has no payments and was not charged, typically indicates a missing payment method.
partial_payment
class-attribute
instance-attribute
¶
Invoice was paid but only partially, some amount remains unpaid.
components.recovery.public.adapters ¶
BalanceRecoveryAdapter ¶
Bases: RecoveryAdapter
Adapter for balance-based recovery (unpaid invoices).
get_contract_balance
abstractmethod
¶
Recovery-relevant balance in minor currency units. Positive = debt.
get_contract_display_info
abstractmethod
¶
Return display info for this contract as of on_date.
get_last_payment_if_failed
abstractmethod
¶
Return the last failed/blocked/disputed payment on the newest unpaid invoice.
Returns None if the latest payment is not failed or no unpaid invoice exists.
Source code in components/recovery/public/adapters.py
get_newest_unpaid_invoice
abstractmethod
¶
Return the newest unpaid invoice for this contract.
get_oldest_unpaid_invoice
abstractmethod
¶
Return the oldest unpaid invoice for this contract.
get_recovery_metadata ¶
Return current balance and unpaid invoice ids as BalanceMetadata,
attached to recovery events during detection and evaluation.
Source code in components/recovery/public/adapters.py
get_unpaid_invoices
abstractmethod
¶
Return unpaid invoices for this contract. Used by metadata and useful for recovery actions and conditions.
Source code in components/recovery/public/adapters.py
get_virtual_iban
abstractmethod
¶
Return virtual IBAN details to settle debt by bank transfer payments.
invoice_has_payments
abstractmethod
¶
is_credit_transfer_contract
abstractmethod
¶
Whether this contract uses credit transfer (wire) as payment method.
is_resolved ¶
Resolved when balance is zero or negative.
resolve_letter_recipients
abstractmethod
¶
Return the data needed to send a postal letter for this contract.
e.g: single recipient: the company itself for company contracts, the primary member for personal contracts.
Source code in components/recovery/public/adapters.py
resolve_notification_recipients
abstractmethod
¶
Return email recipients for recovery notifications for this contract.
resolve_suspension_target
abstractmethod
¶
translate_timeline_entry
abstractmethod
¶
Return localized description for a recovery timeline action.
ContractDisplayInfo
dataclass
¶
PaymentInfo
dataclass
¶
RecoveryAdapter ¶
Bases: ABC
Base adapter for any recovery type.
get_contracts_requiring_recovery_case
abstractmethod
¶
Identify contracts that require opening a new recovery case.
Implementors must:
- Query contracts matching recovery criteria.
- Exclude contracts
already_in_recovery. - Exclude contracts where
is_excluded()returns True. - Apply local timing/threshold filters if any.
Example for balance recovery: query active contracts with positive balance, exclude those with balance <= 15 EUR, exclude those whose newest invoice is too recent for recovery.
Source code in components/recovery/public/adapters.py
get_recovery_metadata
abstractmethod
¶
Contextual data attached to recovery events created during engine detection and evaluation, for trail and debugging.
Example for balance recovery:: BalanceMetadata(balance_amount=15000, currency="EUR", unpaid_invoice_ids=[12345])
Source code in components/recovery/public/adapters.py
get_recovery_reference_date
abstractmethod
¶
Date reference for plan action scheduling. Set once at case creation, never updated.
Example: if reference_date is Jan 31 (invoice due date), an action
with delay_from_reference_date=timedelta(days=15) fires on or
after Feb 15.
Returns None if no meaningful date exists (actions rely solely on
delay_from_previous).
Source code in components/recovery/public/adapters.py
is_excluded
abstractmethod
¶
Whether this contract is exempt from recovery.
Examples: special agreement, contract under legal dispute, test/internal contract.
Existing recovery cases are closed immediately during evaluation.
The same conditions should also be checked during detection by
get_contracts_requiring_recovery_case to prevent opening a new
case in the next engine run.
Source code in components/recovery/public/adapters.py
is_resolved
abstractmethod
¶
Whether the recovery condition is satisfied.
Example for balance recovery: resolved when outstanding balance <= 0 (debt fully paid or credited). Once resolved, the case enters a safeguard period before closing.
Source code in components/recovery/public/adapters.py
RecoveryLetterRecipient
dataclass
¶
RecoveryLetterRecipient(
*,
recipient_id,
is_company,
full_name,
address,
language,
vat_number=None
)
RecoveryNotificationRecipient
dataclass
¶
A recipient for recovery notification emails.
SuspensionTarget
dataclass
¶
Entity whose benefits should be suspended.
An "entity" is any uniquely identifiable object that can be used to resolve a reimbursement beneficiary in the claims engine (e.g. account, company, profile, policy, contract).
This class contains properties required to identify an entity to install a reimbursement blocker on.
UnpaidInvoice
dataclass
¶
UnpaidInvoice(
*,
invoice_id,
invoice_number,
period,
amount,
currency,
due_date,
remaining_balance,
settlement_status
)
Unpaid invoice details used for metadata, conditions, and notifications.
amount
instance-attribute
¶
Total invoice amount in minor currency units (e.g. cents for EUR).
components.recovery.public.blueprints ¶
components.recovery.public.commands ¶
evaluate_recovery_case ¶
Evaluate a single recovery case.
concurrency_group prevents two jobs for the same case running in parallel.
deduplicate=True prevents duplicate jobs: if a job of the same case already enqueued, it won't be enqueued again.
Source code in components/recovery/public/commands.py
run_recovery ¶
Detect new recovery cases and evaluate existing ones.
Source code in components/recovery/public/commands.py
components.recovery.public.conditions ¶
Shared recovery action conditions.
AndCondition ¶
Conjunction of recovery action conditions: True if all wrapped conditions return True.
Source code in components/recovery/public/conditions.py
__call__ ¶
HasFailedPaymentCondition ¶
Recovery action condition: true when the newest unpaid invoice's last payment is failed, blocked, or disputed.
Source code in components/recovery/public/conditions.py
__call__ ¶
Return True if the contract has a failed payment on its newest unpaid invoice.
Source code in components/recovery/public/conditions.py
HasNewerUnpaidInvoiceCondition ¶
Recovery action condition: true when the newest unpaid invoice's due date is later than the case's reference date.
Used to detect that a new billing cycle's invoice is unpaid (not just the original one the case opened on). Returns False if there's no newest unpaid.
Source code in components/recovery/public/conditions.py
__call__ ¶
Return True if there is a newest unpaid invoice issued after the case's reference date.
Source code in components/recovery/public/conditions.py
HasOutstandingBalanceCondition ¶
Recovery action condition: true if contract balance is positive.
Source code in components/recovery/public/conditions.py
__call__ ¶
Return True while the balance is still positive.
NotCondition ¶
Negates another recovery action condition.
Source code in components/recovery/public/conditions.py
components.recovery.public.entities ¶
RecoveryCase
dataclass
¶
RecoveryCase(
*,
id,
contract_ref,
contract_type,
country,
status,
reference_date,
created_at,
updated_at,
events
)
Read-only view of a recovery case.
contract_identifier
property
¶
ContractIdentifier derived from contract_ref + contract_type.
RecoveryCaseStatus ¶
Bases: AlanBaseEnum
Status of a recovery case.
A status change occurs following:
- Automatic transitions driven by RecoveryEngine lifecycle check.
- Manual transitions (e.g. put_on_hold) via RecoveryService.
active
class-attribute
instance-attribute
¶
Case is actively being processed through recovery actions.
closed
class-attribute
instance-attribute
¶
Case is fully closed (after safeguard period for resolution, termination, or exclusion).
on_hold
class-attribute
instance-attribute
¶
Case is paused (e.g. deadline extension, manual hold).
resolved
class-attribute
instance-attribute
¶
Balance cleared, waiting resolution_safeguard_period before closing.
Prevents premature closure since payments can be disputed or reversed. If debt returns during safeguard, case is reactivated instead of opening a new case and restarting the recovery plan.
RecoveryEvent
dataclass
¶
RecoveryEvent(
*,
id,
recovery_case_id,
category,
event_name,
metadata,
actor_global_user_id,
created_at
)
Read-only view of a recovery event.
RecoveryEventCategory ¶
Bases: AlanBaseEnum
Category of a recovery event.
lifecycle_event
class-attribute
instance-attribute
¶
A case status change, automatic (via engine evaluation) or manual
(via service actions). See RecoveryLifecycleEventName.
recovery_action
class-attribute
instance-attribute
¶
A plan action was executed. Plans are country and contract specific
sequences defined via RecoveryPlan.
RecoveryLifecycleEventName ¶
Bases: AlanBaseEnum
Name of a lifecycle event on a recovery case.
case_opened
class-attribute
instance-attribute
¶
New case created during detection, identified by
RecoveryAdapter.get_contracts_requiring_recovery_case
(e.g. unpaid balance above threshold for balance recovery).
closed_on_resolve
class-attribute
instance-attribute
¶
Debt resolved on a plan with no safeguard period, the case is closed
immediately instead of waiting in a resolved state.
excluded
class-attribute
instance-attribute
¶
Contract became exempt from recovery (e.g. under legal dispute,
special agreement, or contracts not eligible for regular recovery),
specific rules are defined by RecoveryAdapter.is_excluded.
hold_expired
class-attribute
instance-attribute
¶
Hold's expires_at reached, case automatically resumes.
hold_resumed
class-attribute
instance-attribute
¶
Case manually resumed from hold before expiry, or when hold doesn't have an expiry.
plan_completed
class-attribute
instance-attribute
¶
All plan actions executed (or bypassed) with no resolution. Case is closed.
put_on_hold
class-attribute
instance-attribute
¶
Case manually paused (e.g. payment deadline extension granted to the member).
No actions progress while on hold. Optional HoldMetadata.expires_at for auto-expiry.
reactivated
class-attribute
instance-attribute
¶
Debt returned during safeguard period (e.g. payment reversed). Actions resume from where they left off instead of restarting the plan.
resolved
class-attribute
instance-attribute
¶
Recovery condition satisfied (e.g. debt fully paid). Case enters
safeguard period (resolution_safeguard_period) before closing.
safeguard_completed
class-attribute
instance-attribute
¶
Safeguard period elapsed and resolution still holds. Case is closed.
components.recovery.public.plan ¶
Public API for defining and registering recovery plans.
Contains plan types and action protocols.
RecoveryAction
dataclass
¶
RecoveryAction(
*,
name,
execute,
delay_from_previous=None,
delay_from_reference_date=None,
condition=None,
is_projected_in_timeline=True
)
One step in a recovery plan's action sequence.
condition
class-attribute
instance-attribute
¶
Optional precondition. The action is bypassed once next action's timing arrives and this condition is still False.
delay_from_previous
class-attribute
instance-attribute
¶
Min delay since last executed action (or case creation for first action).
delay_from_reference_date
class-attribute
instance-attribute
¶
Delay relative to the case's reference date (e.g. invoice due date).
is_projected_in_timeline
class-attribute
instance-attribute
¶
Whether this action appears in projected recovery timeline entries (upcoming). Actions already executed always appear in the timeline regardless of this flag.
You can set to False for conditional actions whose future execution is uncertain, when showing them as upcoming could mislead the consumer into assuming they will happen.
name
instance-attribute
¶
Unique name within the plan (e.g. 'formal_notice', 'terminate_contract').
RecoveryActionCondition ¶
Bases: Protocol
Checks whether an action's precondition is met before execution.
RecoveryActionExecutor ¶
RecoveryPlan
dataclass
¶
RecoveryPlan(
*,
country,
contract_type,
actions,
resolution_safeguard_period,
on_resolved=None,
on_closed=None
)
Recovery plan blueprint.
actions
instance-attribute
¶
Ordered sequence of recovery actions executed from first to last.
on_closed
class-attribute
instance-attribute
¶
Executor to run when case is closed after safeguard period.
on_resolved
class-attribute
instance-attribute
¶
Executor to run when case is resolved (e.g. lift service suspension).
resolution_safeguard_period
instance-attribute
¶
How long a resolved case stays open before auto-closing.
None means no safeguard: the case is closed immediately on resolve.
components.recovery.public.plan_registry ¶
RecoveryPlanRegistry ¶
Registry of recovery plans keyed by (country, contract_type).
Plans are registered at app startup by each country's bootstrap. Each entry co-locates a plan with its adapter class.
Example::
_entries = {
(CountryPrefix.france, ContractType.health): (fr_health_recovery_plan, FrHealthRecoveryAdapter),
(CountryPrefix.belgium, ContractType.health): (be_health_recovery_plan, BeHealthRecoveryAdapter),
}
get
classmethod
¶
Return (plan, adapter) for a (country, contract_type) pair.
The adapter_class is instantiated via the adapter_class constructor on each call to provide a fresh adapter instance per use.
Source code in components/recovery/public/plan_registry.py
register
classmethod
¶
Register a recovery plan with its adapter class. Raises if key already taken.
Stores (plan, adapter_class) under the key (plan.country, plan.contract_type).
Example::
RecoveryPlanRegistry.register(BE_HEALTH_PLAN, BeHealthRecoveryAdapter)
Source code in components/recovery/public/plan_registry.py
components.recovery.public.service ¶
CaseDetectionResult
dataclass
¶
CaseEvaluationResult
dataclass
¶
CaseEvaluationResult(
*,
lifecycle_event=None,
action_event=None,
pending_action=None,
noop_reason=None,
actions_bypassed=()
)
Summary of evaluating a single recovery case.
action_event
class-attribute
instance-attribute
¶
Recovery action event executed from the plan, if any.
actions_bypassed
class-attribute
instance-attribute
¶
Action names that were bypassed during this evaluation (condition never met, next action timing arrived).
lifecycle_event
class-attribute
instance-attribute
¶
Lifecycle event applied (e.g. resolved, excluded, reactivated).
noop_reason
class-attribute
instance-attribute
¶
Why the evaluation produced no effect (no lifecycle transition, no action executed).
pending_action
class-attribute
instance-attribute
¶
Next Action that couldn't execute yet (timing or condition not met).
EvaluationNoopReason ¶
Bases: AlanBaseEnum
Why case evaluation produced no effect.
case_on_hold
class-attribute
instance-attribute
¶
Case is on hold — no lifecycle check or action progression.
case_resolved
class-attribute
instance-attribute
¶
Case is resolved and waiting for safeguard period to elapse.
condition_not_met
class-attribute
instance-attribute
¶
Next action's condition is False and following action's timing hasn't arrived yet.
from_status
classmethod
¶
Map a non-active case status to its noop reason.
Source code in components/recovery/internal/engine/results.py
timing_not_met
class-attribute
instance-attribute
¶
Next action's timing constraints not yet satisfied.
RecoveryService ¶
Public facade for recovery case detection and evaluation.
Wraps RecoveryEngine for a specific (country, contract_type) pair, resolved
from the RecoveryPlanRegistry. Callers (typically commands) use three methods:
detect_and_open_new_cases: find eligible contracts and create cases.get_evaluable_cases: list non-closed cases to feed into evaluation.evaluate_case: run lifecycle check + action progression on one case.
Each method manages its own transaction; callers need no session handling.
Source code in components/recovery/public/service.py
detect_and_open_new_cases ¶
Scan for contracts eligible for recovery and open new cases.
Per-contract errors are caught and counted (not raised), so detection is partially tolerant to individual failures.
Source code in components/recovery/public/service.py
evaluate_case ¶
Evaluate a single recovery case: lifecycle check then action progression.
Runs in its own transaction. Plan callbacks (on_resolved, on_closed)
and action side-effects execute in nested sub-transactions, if any fails,
the entire evaluation rolls back and the case remains unchanged.
Source code in components/recovery/public/service.py
get_evaluable_cases ¶
Return all non-closed cases as frozen public entities.
get_open_case_by_contract_identifier ¶
Return the open (non-closed) case for a contract identifier, or None if none is open.
Source code in components/recovery/public/service.py
components.recovery.public.timeline ¶
RecoveryTimeline ¶
Bases: Timeline['RecoveryTimelineEntry']
Projected timeline of recovery actions for a recovery case.
RecoveryTimelineEntry
dataclass
¶
One entry in a recovery timeline projection.
TimelineEntryStatus ¶
Bases: AlanBaseEnum
Status of a recovery timeline entry.