Skip to content

Commit

Permalink
enregistrement du code NAF dans Metabase
Browse files Browse the repository at this point in the history
  • Loading branch information
sblondon committed May 24, 2024
1 parent a3ec04e commit 668f3d0
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 0 deletions.
2 changes: 2 additions & 0 deletions impact/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
CODE_PAYS_PORTUGAL = 99139
CODE_PAYS_CANADA = 99401

CODE_NAF_CEREALES = "01.11Z"


@pytest.fixture
def alice(django_user_model):
Expand Down
1 change: 1 addition & 0 deletions impact/metabase/management/commands/sync_metabase.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def _insert_entreprises(self):
if entreprise.categorie_juridique
else None,
pays=entreprise.pays,
code_NAF=entreprise.code_NAF,
est_interet_public=entreprise.est_interet_public,
est_cotee=entreprise.est_cotee,
appartient_groupe=entreprise.appartient_groupe,
Expand Down
18 changes: 18 additions & 0 deletions impact/metabase/migrations/0017_entreprise_code_naf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2.11 on 2024-05-24 09:11
from django.db import migrations
from django.db import models


class Migration(migrations.Migration):

dependencies = [
("metabase", "0016_entreprise_est_interet_public_entreprise_pays"),
]

operations = [
migrations.AddField(
model_name="entreprise",
name="code_NAF",
field=models.CharField(max_length=6, null=True),
),
]
1 change: 1 addition & 0 deletions impact/metabase/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class Entreprise(models.Model):
date_derniere_qualification = models.DateField(null=True)
categorie_juridique = models.CharField(max_length=50, null=True)
pays = models.CharField(max_length=50, null=True)
code_NAF = models.CharField(max_length=6, null=True)
est_interet_public = models.BooleanField(null=True)
est_cotee = models.BooleanField(null=True)
appartient_groupe = models.BooleanField(null=True)
Expand Down
3 changes: 3 additions & 0 deletions impact/metabase/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from api.tests.fixtures import mock_api_bges # noqa
from api.tests.fixtures import mock_api_egapro # noqa
from conftest import CODE_NAF_CEREALES
from conftest import CODE_PAYS_PORTUGAL
from entreprises.models import ActualisationCaracteristiquesAnnuelles
from entreprises.models import CaracteristiquesAnnuelles
Expand Down Expand Up @@ -69,6 +70,7 @@ def test_synchronise_une_entreprise_qualifiee_sans_groupe(
date_derniere_qualification=date_derniere_qualification,
categorie_juridique_sirene=5699,
code_pays_etranger_sirene=CODE_PAYS_PORTUGAL,
code_NAF=CODE_NAF_CEREALES,
effectif=CaracteristiquesAnnuelles.EFFECTIF_MOINS_DE_10,
effectif_permanent=CaracteristiquesAnnuelles.EFFECTIF_MOINS_DE_10,
effectif_outre_mer=CaracteristiquesAnnuelles.EFFECTIF_OUTRE_MER_MOINS_DE_250,
Expand Down Expand Up @@ -129,6 +131,7 @@ def test_synchronise_une_entreprise_qualifiee_sans_groupe(
assert metabase_entreprise.denomination == "Entreprise A"
assert metabase_entreprise.categorie_juridique == "SOCIETE_ANONYME"
assert metabase_entreprise.pays == "Portugal"
assert metabase_entreprise.code_NAF == CODE_NAF_CEREALES
assert (
metabase_entreprise.date_cloture_exercice
== date_cloture_dernier_exercice.replace(
Expand Down

0 comments on commit 668f3d0

Please sign in to comment.