diff --git a/aio/aio-proxy/aio_proxy/doc/open-api.yml b/aio/aio-proxy/aio_proxy/doc/open-api.yml index 76e9a505..d15cb333 100755 --- a/aio/aio-proxy/aio_proxy/doc/open-api.yml +++ b/aio/aio-proxy/aio_proxy/doc/open-api.yml @@ -167,6 +167,17 @@ paths: example: "11,76" schema: type: string + - name: epci + in: query + description: >- + + Liste des epci valides. Ce paramètre filtre sur les + établissements et accepte une valeur unique ou une liste de valeurs + séparées par des virgules. + required: false + example: "200058519,248100737" + schema: + type: string - name: egapro_renseignee in: query description: >- @@ -696,6 +707,13 @@ paths: Date de création de l'établissement (source : base SIRENE). example: "2003-01-01" + date_fermeture: + type: string + nullable: true + format: date + description: >- + Date de fermeture de l'établissement (source : base + historique SIRENE). date_debut_activite: type: string format: date @@ -869,6 +887,12 @@ paths: description: >- Code région de l'établissement (source : base SIRENE). + epci: + type: string + nullable: true + example: "200058519" + description: >- + Numéro siren de l'EPCI. siret: type: string example: "35600000000048" @@ -890,6 +914,12 @@ paths: example: "1991-01-01" description: >- Date de création de l'unité légale (source : base SIRENE). + date_fermeture: + type: string + format: date + description: >- + Date de fermeture de l'unité légale (source : base + historique SIRENE). tranche_effectif_salarie: type: string example: "53" @@ -1085,6 +1115,12 @@ paths: description: >- Région de l'établissement (source : base SIRENE). + epci: + type: string + nullable: true + example: "200058519" + description: >- + Numéro siren de l'EPCI. siret: type: string example: "35600000000048" @@ -1536,6 +1572,13 @@ paths: Date de création de l'établissement (source : base SIRENE). example: "2003-01-01" + date_fermeture: + type: string + nullable: true + format: date + description: >- + Date de fermeture de l'établissement (source : base + historique SIRENE). date_debut_activite: type: string format: date @@ -1708,6 +1751,12 @@ paths: description: >- Code région de l'établissement (source : base SIRENE). + epci: + type: string + nullable: true + example: "200058519" + description: >- + Numéro siren de l'EPCI. siret: type: string example: "35600000000048" @@ -1729,6 +1778,12 @@ paths: example: "1991-01-01" description: >- Date de création de l'unité légale (source : base SIRENE). + date_fermeture: + type: string + format: date + description: >- + Date de fermeture de l'unité légale (source : base + historique SIRENE). tranche_effectif_salarie: type: string example: "53" @@ -1925,6 +1980,12 @@ paths: description: >- Région de l'établissement (source : base SIRENE). + epci: + type: string + nullable: true + example: "200058519" + description: >- + Numéro siren de l'EPCI. siret: type: string example: "35600000000048" diff --git a/aio/aio-proxy/aio_proxy/request/field_values.py b/aio/aio-proxy/aio_proxy/request/field_values.py index 2edeb26e..1fce5f62 100644 --- a/aio/aio-proxy/aio_proxy/request/field_values.py +++ b/aio/aio-proxy/aio_proxy/request/field_values.py @@ -103,6 +103,10 @@ "valid_values": r"^((0[1-9])|([1-8][0-9])|(9[0-8])|(2A)|(2B))[0-9]{3}$", "alias": "activite_principale", }, + "epci": { + "valid_values": r"^\d{9}$", + "alias": "epci", + }, "type_personne": { "valid_values": ["ELU", "DIRIGEANT"], "alias": "type_personne", diff --git a/aio/aio-proxy/aio_proxy/request/search_params_model.py b/aio/aio-proxy/aio_proxy/request/search_params_model.py index f0480813..289aa61b 100644 --- a/aio/aio-proxy/aio_proxy/request/search_params_model.py +++ b/aio/aio-proxy/aio_proxy/request/search_params_model.py @@ -35,6 +35,7 @@ class SearchParams(BaseModel): tranche_effectif_salarie_unite_legale: list | None = None convention_collective_renseignee: bool | None = None egapro_renseignee: bool | None = None + epci: list | None = None est_bio: bool | None = None est_finess: bool | None = None est_uai: bool | None = None @@ -136,6 +137,7 @@ def make_uppercase(cls, value: str) -> str: "activite_principale_unite_legale", "code_collectivite_territoriale", "commune", + "epci", "code_postal", "include", "include_admin", @@ -145,7 +147,7 @@ def convert_str_to_list(cls, str_of_values: str) -> list[str]: list_of_values = str_to_list(clean_str(str_of_values)) return list_of_values - @field_validator("code_postal", "commune", mode="after") + @field_validator("code_postal", "commune", "epci", mode="after") def list_of_values_should_match_regular_expression( cls, list_values: list[str], info ) -> list[str]: diff --git a/aio/aio-proxy/aio_proxy/response/format_search_results.py b/aio/aio-proxy/aio_proxy/response/format_search_results.py index 526f34c5..8eef98ac 100644 --- a/aio/aio-proxy/aio_proxy/response/format_search_results.py +++ b/aio/aio-proxy/aio_proxy/response/format_search_results.py @@ -50,6 +50,7 @@ def get_field(field, default=None): "caractere_employeur": get_field("caractere_employeur"), "annee_categorie_entreprise": get_field("annee_categorie_entreprise"), "date_creation": get_field("date_creation_unite_legale"), + "date_fermeture": get_field("date_fermeture"), "date_mise_a_jour": get_field("date_mise_a_jour"), "date_mise_a_jour_insee": get_field("date_mise_a_jour_insee"), "date_mise_a_jour_rne": get_field("date_mise_a_jour_rne"), diff --git a/aio/aio-proxy/aio_proxy/response/formatters/etablissements.py b/aio/aio-proxy/aio_proxy/response/formatters/etablissements.py index 5db6e327..948df094 100644 --- a/aio/aio-proxy/aio_proxy/response/formatters/etablissements.py +++ b/aio/aio-proxy/aio_proxy/response/formatters/etablissements.py @@ -26,10 +26,12 @@ def get_field(field, default=None): "coordonnees": get_field("coordonnees"), "date_creation": get_field("date_creation"), "date_debut_activite": get_field("date_debut_activite"), + "date_fermeture": get_field("date_fermeture"), "date_mise_a_jour": None, "date_mise_a_jour_insee": get_field("date_mise_a_jour_insee"), "departement": get_field("departement"), "distribution_speciale": get_field("distribution_speciale"), + "epci": get_field("epci"), "est_siege": get_field("est_siege", False), "etat_administratif": get_field("etat_administratif"), "geo_adresse": get_field("geo_adresse"), @@ -83,6 +85,8 @@ def format_etablissements_list(etablissements=None): "cedex", "code_pays_etranger", "complement_adresse", + "date_mise_a_jour", + "date_mise_a_jour_insee", "departement", "distribution_speciale", "geo_adresse", @@ -93,8 +97,6 @@ def format_etablissements_list(etablissements=None): "libelle_voie", "numero_voie", "type_voie", - "date_mise_a_jour", - "date_mise_a_jour_insee", ] etablissements_formatted = [] if etablissements: diff --git a/aio/aio-proxy/aio_proxy/response/unite_legale_model.py b/aio/aio-proxy/aio_proxy/response/unite_legale_model.py index 0ea7e22b..20b32cb2 100644 --- a/aio/aio-proxy/aio_proxy/response/unite_legale_model.py +++ b/aio/aio-proxy/aio_proxy/response/unite_legale_model.py @@ -17,10 +17,12 @@ class Etablissement(BaseModel): coordonnees: str | None = None date_creation: str | None = None date_debut_activite: str | None = None + date_fermeture: str | None = None date_mise_a_jour: str | None = None date_mise_a_jour_insee: str | None = None departement: str | None = None distribution_speciale: str | None = None + epci: str | None = None est_siege: bool = False etat_administratif: str | None = None geo_adresse: str | None = None @@ -121,6 +123,7 @@ class UniteLegaleResponse(BaseModel): caractere_employeur: str | None = None annee_categorie_entreprise: str | None = None date_creation: str | None = None + date_fermeture: str | None = None date_mise_a_jour: str | None = None date_mise_a_jour_insee: str | None = None date_mise_a_jour_rne: str | None = None diff --git a/aio/aio-proxy/aio_proxy/search/filters/nested_etablissements_filters.py b/aio/aio-proxy/aio_proxy/search/filters/nested_etablissements_filters.py index 48c590b6..f922a182 100644 --- a/aio/aio-proxy/aio_proxy/search/filters/nested_etablissements_filters.py +++ b/aio/aio-proxy/aio_proxy/search/filters/nested_etablissements_filters.py @@ -27,7 +27,7 @@ def build_etablissements_filters(search_params): # Id filters are used in the `should` clause id_filters = ["id_finess", "id_rge", "id_uai", "id_convention_collective"] # Text filters are used in the `must` clause - text_filters = ["departement", "code_postal", "commune", "region"] + text_filters = ["departement", "code_postal", "commune", "epci", "region"] # Bool filters are used in both `must` and `must_not` clauses depending on the # filter value bool_filters = [ diff --git a/aio/aio-proxy/aio_proxy/search/helpers/etablissements_filters_used.py b/aio/aio-proxy/aio_proxy/search/helpers/etablissements_filters_used.py index 527bf338..127aa820 100644 --- a/aio/aio-proxy/aio_proxy/search/helpers/etablissements_filters_used.py +++ b/aio/aio-proxy/aio_proxy/search/helpers/etablissements_filters_used.py @@ -4,6 +4,7 @@ def is_any_etablissement_filter_used(search_params) -> bool: "code_postal", "convention_collective_renseignee", "departement", + "epci", "est_bio", "est_finess", "est_organisme_formation", diff --git a/aio/aio-proxy/aio_proxy/tests/e2e_tests/test_api.py b/aio/aio-proxy/aio_proxy/tests/e2e_tests/test_api.py index 15973c94..6d2f3b85 100755 --- a/aio/aio-proxy/aio_proxy/tests/e2e_tests/test_api.py +++ b/aio/aio-proxy/aio_proxy/tests/e2e_tests/test_api.py @@ -590,3 +590,13 @@ def test_siren_rne_and_insee(api_response_tester): api_response_tester.assert_api_response_code_200(path) assert response.json()["results"][0]["date_mise_a_jour_rne"] is not None assert response.json()["results"][0]["date_mise_a_jour_insee"] is not None + + +def test_epci(api_response_tester): + path = "search?epci=248100737" + response = api_response_tester.get_api_response(path) + api_response_tester.assert_api_response_code_200(path) + assert ( + response.json()["results"][0]["matching_etablissements"][0]["epci"] + == "248100737" + )