Api reference
components.global_customer_dashboard.public.actions ¶
employee ¶
generate_employees_export ¶
Generate employees export using global_customer_dashboard component.
Source code in components/global_customer_dashboard/public/actions/employee.py
components.global_customer_dashboard.public.blueprint ¶
global_customer_dashboard_api_blueprint
module-attribute
¶
global_customer_dashboard_api_blueprint = CustomBlueprint(
"global_customer_dashboard_api_blueprint", __name__
)
components.global_customer_dashboard.public.dependencies ¶
GlOBAL_CUSTOMER_DASHBOARD_COMPONENT_NAME
module-attribute
¶
GlobalCustomerDashboardDependency ¶
GlobalCustomerDashboardDependency defines the interface that apps using the global_customer_dashboard component need to implement
get_alerts ¶
get_alerts(
*,
customer_dashboard_page,
context_account_id,
account_id,
company_ids,
operational_scope_ids,
language
)
:return: The method will return a list of alerts to display on the given customer dashboard page
Source code in components/global_customer_dashboard/public/dependencies.py
get_company_details ¶
Get details of a company by its ID. :param company_id: The ID of the company to retrieve details for. :return: A CustomerDashboardCompany object containing the details of the company.
Source code in components/global_customer_dashboard/public/dependencies.py
get_app_dependency ¶
Retrieves at runtime the account_org_tree dependency set by set_app_dependency
Source code in components/global_customer_dashboard/public/dependencies.py
set_app_dependency ¶
Sets the account_org_tree dependency to the app so it can be accessed within this component at runtime
Source code in components/global_customer_dashboard/public/dependencies.py
components.global_customer_dashboard.public.entities ¶
AdminDashboardEmployee
dataclass
¶
AdminDashboardEmployee(
user_id,
first_name,
last_name,
company_id,
invite_email,
employee_type,
external_employee_id,
status_detail,
)
Bases: DataClassJsonMixin
AdminsCountForAdminDashboard
dataclass
¶
AdminsSearchResult
dataclass
¶
AdminsSearchResult(
*,
result_type,
id,
email,
first_name,
last_name,
admined_entity_type,
company_ids
)
Bases: DataClassJsonMixin
Results found for a search on the admins and admin invitations
AdminsSearchResultType ¶
AnyCountryCustomerInsightsDashboard
module-attribute
¶
CriticalRole
dataclass
¶
CustomerDashboardAccount
dataclass
¶
CustomerDashboardAdminInvitation
dataclass
¶
CustomerDashboardAdminInvitationWithEntityIds
dataclass
¶
CustomerDashboardAdminInvitationWithEntityIds(
id,
invite_email,
invitation_date,
responsibilities,
type,
account_id,
company_ids,
scope_ids=None,
)
CustomerDashboardAlert
dataclass
¶
CustomerDashboardAlert(
topic,
urgency,
parameters,
title,
description,
resolution_flow_label,
entities,
)
Bases: DataClassJsonMixin
Alerts displayed in the admin dashboard pages and flagged in the menu via a small badge
CustomerDashboardCompanyAdminInvitationWithCompanies
dataclass
¶
CustomerDashboardCompanyAdminInvitationWithCompanies(
id,
invite_email,
invitation_date,
responsibilities,
type,
companies,
scope_ids=None,
)
CustomerDashboardEmployeeInvitation
dataclass
¶
CustomerDashboardEmployeeInvitation(
id,
invite_email,
invitation_date,
invitation_email_sent_at=None,
)
Bases: DataClassJsonMixin
Represents an employee invitation in the customer dashboard.
CustomerDashboardEmployeeInvitationError
dataclass
¶
CustomerDashboardEmployeeInvitationErrorType ¶
Bases: AlanBaseEnum
Types of errors that can occur when inviting an employee in the customer dashboard. These errors are used to provide feedback to the user when an invitation fails. The error types are used to categorize the reasons for failure, such as: - already_exists: The employee already exists in the system. - employment_blocked_movement: The employee's movement is blocked within Employment's blocked movements. Will be reviewed internally, and re-submitted when underlying issue is resolved. - unknown_error: An unknown error occurred during the invitation process.
CustomerDashboardEmployeesInvitationResponses
dataclass
¶
CustomerInsightsDashboard
dataclass
¶
Bases: Generic[AnyCountryCustomerInsightsDashboard], DataClassJsonMixin
CustomerSubscription
dataclass
¶
CustomerSubscriptionScope ¶
DownloadFile
dataclass
¶
Employee
dataclass
¶
Employee(
user_id,
first_name,
last_name,
employment_id,
company_id,
invite_email,
employee_type,
external_employee_id,
)
Bases: DataClassJsonMixin
EmployeeCounts
dataclass
¶
EmployeeCounts(
*,
company,
company_id_to_name,
professional_category,
ccn,
ccn_id_to_name,
employee_type,
status_detail
)
Bases: DataClassJsonMixin
EmployeeDetails
dataclass
¶
EmployeeInvitationResult
dataclass
¶
EmployeeInvitationResult(
id,
email,
success,
employee=None,
error=None,
error_keys=None,
meta=None,
)
Bases: DataClassJsonMixin, Generic[T]
EmployeeServiceEnrollment
dataclass
¶
EmployeeServiceEnrollment(
id,
user_id,
company_id,
subscription_id,
service,
start_date=isodate_field(),
end_date=optional_isodate_field(),
)
Bases: DataClassJsonMixin
EmployeeWithInactiveReimbursements
dataclass
¶
EmployeesByCcnIdCount
dataclass
¶
EmployeesByCompanyIdCount
dataclass
¶
EmployeesByProfessionalCategoryCount
dataclass
¶
EmployeesByStatusDetailCount
dataclass
¶
EmployeesByTypeCount
dataclass
¶
EmployeesExportFile
dataclass
¶
EmployeesExportFileFormat ¶
ExemptedEmployeeListItem
dataclass
¶
ExemptedEmployeeListItem(
user_id,
first_name,
last_name,
company_id,
invite_email,
employee_type,
external_employee_id,
status_detail,
*,
end_date,
guess_gender
)
Bases: AdminDashboardEmployee
InsuredEmployeeListItem
dataclass
¶
InsuredEmployeeListItem(
user_id,
first_name,
last_name,
company_id,
invite_email,
employee_type,
external_employee_id,
status_detail,
*,
guess_gender,
has_inactive_reimbursements
)
Bases: AdminDashboardEmployee
InviteEmployeesListInvitationParams
dataclass
¶
InvitedEmployeeListItem
dataclass
¶
InvitedEmployeeListItem(
user_id,
first_name,
last_name,
company_id,
invite_email,
employee_type,
external_employee_id,
status_detail,
*,
invite_ssn,
invite_ntt
)
Bases: AdminDashboardEmployee
LastAdminStanding
dataclass
¶
LeanEntitiesByResponsibility
dataclass
¶
PaginatedCustomerDashboardAdminInvitation
dataclass
¶
PaginatedEmployeeWithInactiveReimbursements
dataclass
¶
PaginatedEmployeesForAdminDashboard
dataclass
¶
PaginatedList
dataclass
¶
PaginatedTerminatedEmployeesForAdminDashboard
dataclass
¶
PayfitAffiliationIntegrationCompanySummary
dataclass
¶
PayfitAffiliationIntegrationCompanySummary(
company_id,
company_display_name,
payfit_partner_activated,
payfit_partner_integration_failed,
payfit_partner_activated_on,
payfit_partner_activated_by_admin_first_name,
)
Bases: DataClassJsonMixin
payfit_partner_activated_by_admin_first_name
instance-attribute
¶
PayfitAffiliationIntegrationSummary
dataclass
¶
PayfitAffiliationIntegrationSummary(
payfit_partner_activated,
payfit_partner_integration_failed,
payfit_partner_activated_on,
payfit_partner_activated_by_admin_first_name,
entities_not_using_payfit_partner_suspicion,
company_summaries,
)
ScheduledEmployeeTransfer
dataclass
¶
ScheduledEmployeeTransfer(
id,
user_id,
destination_company_id,
current_company_id,
status,
transfer_date=isodate_field(),
transferred_at=optional_isodate_field(),
)
Bases: DataClassJsonMixin
ScheduledEmployeeTransferStatus ¶
SignedDocument
dataclass
¶
SignedDocumentType ¶
Bases: AlanBaseEnum
es_fresa_general_conditions
class-attribute
instance-attribute
¶
es_fresa_information_notice
class-attribute
instance-attribute
¶
es_fresa_particular_conditions
class-attribute
instance-attribute
¶
es_manzana_general_conditions
class-attribute
instance-attribute
¶
es_manzana_information_notice
class-attribute
instance-attribute
¶
es_manzana_particular_conditions
class-attribute
instance-attribute
¶
healthy_benefits_general_conditions
class-attribute
instance-attribute
¶
healthy_benefits_particular_conditions
class-attribute
instance-attribute
¶
TerminatedEmployee
dataclass
¶
TerminatedEmployee(
user_id,
first_name,
last_name,
company_id,
invite_email,
terminated_employee_type,
)
Bases: DataClassJsonMixin
TerminatedEmployeeDetails
dataclass
¶
TerminatedEmployeeDetails(
user_id,
full_name,
company_id,
invite_email,
terminated_employee_type,
external_employee_id,
start_date,
end_date,
termination_type,
ani_start_date,
theoretical_ani_end_date,
employment_contract_end_date,
)
Bases: DataClassJsonMixin
TerminatedEmployeesByTypeCounts
dataclass
¶
UnpaidLeaveEmployeeListItem
dataclass
¶
UnpaidLeaveEmployeeListItem(
user_id,
first_name,
last_name,
company_id,
invite_email,
employee_type,
external_employee_id,
status_detail,
*,
guess_gender
)
Bases: AdminDashboardEmployee
WellbeingAssessmentDisplayUserInfo
dataclass
¶
critical_roles
module-attribute
¶
file_format_to_mime_type
module-attribute
¶
file_format_to_mime_type = {
csv: "text/csv",
xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
}
components.global_customer_dashboard.public.enums ¶
ACTIVE_EMPLOYEE_TYPES
module-attribute
¶
CustomerDashboardAlertsUrgency ¶
Bases: AlanBaseEnum
Impacts how the alerts are displayed in the admin dashboard. Error and warning error are flagged in the admin dashboard menu too.
CustomerDashboardCompanyAdminInvitationsSortField ¶
EmployeeType ¶
FORMER_EMPLOYEE_TYPES
module-attribute
¶
ProfessionalCategory ¶
Bases: AlanBaseEnum
This enum is used to model both the professional category of persons and abstract objects, such as contracts: - persons can be "cadres", "non_cadres", or NULL which models we don't know their professional category; - abstract entities can be "cadres", "non_cadres", or NULL which models we don't have to apply any constraint on the object regarding the professional category.
StatusDetail ¶
Bases: AlanBaseEnum
Will be used to display more information about the status of an employee.
already_covered_by_alan
class-attribute
instance-attribute
¶
already_covered_by_alan_under_review
class-attribute
instance-attribute
¶
exemption_requested
class-attribute
instance-attribute
¶
fr_exempted_default
class-attribute
instance-attribute
¶
unpaid_leave_default
class-attribute
instance-attribute
¶
components.global_customer_dashboard.public.helpers ¶
admined_entities_api_helper ¶
AdminedEntitiesFiltersParams ¶
admined_entities_filters_request_arguments ¶
Helper to easily add the request arguments for the customer dashboard default entity filtering. This should be used in tandem with auth_check_and_preprocess_admined_entities_params to make some API level conventions transparent for the caller.
@:param transition_mode Set it to True when backward compatibility is needed, for example, when updating an existing API endpoint code.
Source code in components/global_customer_dashboard/public/helpers/admined_entities_api_helper.py
auth_check_and_preprocess_admined_entities_params ¶
Pre-process the request arguments defined by the function admined_entities_filters_request_arguments.
This helper aims at enforcing and automating away some API convention.
Warning: if you type the input params, you must type it as the result of the transformation by this helper. You need to add:
company_ids is typed as set[str] as a compromise between FR where ids are int and other apps rely on UUID
@param transition_mode: set to True if backward compatibility is needed.
Advice is to not use this and create a new API endpoint instead for simplicity.
Typical migration path proposed:
- use the 2 functions defined in this file to an existing API endpoint code with the flag transition_mode set to True
- update the frontend code to send entities filters using the new shared system
- remove the transition_mode flag to disable the transition mode.
More details in this doc: https://www.notion.so/alaninsurance/New-entities-filter-how-to-step-by-step-guide-1c81426e8be780ffba28d81f54236302?d=1ca1426e8be780418682001cb5632d81#1c81426e8be7808abb4bd991d0df273c ⧉
Source code in components/global_customer_dashboard/public/helpers/admined_entities_api_helper.py
71 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 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 | |
backoffice_preprocess_admined_entities_params ¶
Very similar to auth_check_and_preprocess_admined_entities_params but:
- doesn't check if the user can admin entities, it's an Alaner admin.
- doesn't filter out pending companies. In the backoffice we want all admins.
- doesn't expect any entity filtering, just the context_account_id.
Pre-process the request arguments defined by the function admined_entities_filters_request_arguments.
This helper aims at enforcing and automating away some API convention.
Warning: if you type the input params, you must type it as the result of the transformation by this helper. You need to add:
company_ids is typed as set[str] as a compromise between FR where ids are int and other apps rely on UUID
Source code in components/global_customer_dashboard/public/helpers/admined_entities_api_helper.py
user_is_not_only_operational_scope_admin ¶
:param user_id: typed as str to hide differences between countries (FR use int, others UUID) :param context_account_id: :return: true if the current user is only operational scope admin in the context account This is useful to block some API endpoint for operational scope admins, on top the existing data filtering logic that is baked in different place.
Source code in components/global_customer_dashboard/public/helpers/admined_entities_api_helper.py
filter_parser ¶
parse_employee_export_filters ¶
Parse employee export filter parameters into typed filter objects. @param: filters: Raw filter parameters from HTTP requests (strings only) @param: default_employee_types: Default employee types to use if not specified in filters. If None, no default is applied Returns: Dictionary containing parsed filter objects: - filter_employee_types: set[EmployeeType] | None - filter_professional_categories: set[ProfessionalCategory | None] | None - filter_ccn_ids: set[int | None] | None - filter_status_details: set[StatusDetail] | None
Source code in components/global_customer_dashboard/public/helpers/filter_parser.py
parse_employee_export_filters_with_defaults ¶
Parse employee export filters with ACTIVE_EMPLOYEE_TYPES as default.
This is the standard behavior for both employee count and export queries to ensure consistency between the reported count and actual export data.
Source code in components/global_customer_dashboard/public/helpers/filter_parser.py
components.global_customer_dashboard.public.queries ¶
admin ¶
user_can_admin_admined_entities ¶
Source code in components/customer_admin/public/queries.py
user_can_admin_entities_ignore_operational_scopes ¶
⚠️ This function relies on local logic, and doesn't handle operational scopes It should only be used in places where we didn't update for operational scopes yet :param user_id: The id of the admin user :param company_ids: Ids of companies to check :param account_ids: Ids of accounts to check :return: Return true if the given user is a direct or indirect admin of all the given entities
Source code in components/customer_admin/public/queries.py
user_can_read_entities ¶
Source code in components/global_customer_dashboard/external/queries/user.py
admined_entities ¶
get_admined_entities_for_entity_selector ¶
Source code in components/global_customer_dashboard/external/queries/admined_entities.py
employee ¶
get_employees_count_for_export ¶
get_employees_count_for_export(
company_ids,
operational_scope_ids,
employees_generator,
filters=None,
)
Get the count of employees for export efficiently.
Uses existing count queries when possible to avoid materializing the entire dataset in memory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
company_ids
|
list[str]
|
List of company IDs to count employees for |
required |
operational_scope_ids
|
set[UUID] | None
|
Optional operational scope filtering |
required |
employees_generator
|
Any
|
Fallback generator if efficient count isn't available |
required |
filters
|
dict[str, str | list[str]] | None
|
Additional filters to apply (status_details, professional_categories, ccn_ids, employee_types) |
None
|
Returns:
| Type | Description |
|---|---|
int
|
Total count of employees matching the criteria |