Skip to content

Commit

Permalink
WIP: repatriation of declarations
Browse files Browse the repository at this point in the history
  • Loading branch information
Perrine Letellier committed Dec 23, 2024
1 parent 3e35c37 commit a0c1fac
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion data/etl/teleicare_history/extractor.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import logging

from data.models import Company, IcaEtablissement
from data.models import Company, IcaEtablissement, IcaVersionDeclaration
from data.models.declaration import Declaration, DeclarationStatus

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -46,3 +47,26 @@ def match_companies_on_siret_or_vat():
logger.info(
f"{nb_vat_match} + {nb_siret_match} entreprises réconcilliées sur {len(IcaEtablissement.objects.all())}"
)


def create_declaration_from_teleicare_history():
for company in Company.objects.exclude(siccrf_id=None):
declared_food_supplements = IcaVersionDeclaration.object.filter(
etab_ident=company.siccrf_id, stattdcl_ident_in=[]
)
len(declared_food_supplements)
declaration = Declaration()
declaration.save()


# Pout les déclarations TeleIcare, le status correspond au champ IcaVersionDeclaration.stattdcl_ident
DECLARATION_STATUS_MAPPING = {
1: DeclarationStatus.ONGOING_INSTRUCTION, # 'en cours'
2: DeclarationStatus.AUTHORIZED, # 'autorisé temporaire'
3: DeclarationStatus.AUTHORIZED, # 'autorisé prolongé'
4: DeclarationStatus.AUTHORIZED, # 'autorisé définitif'
5: DeclarationStatus.REJECTED, # 'refusé'
6: DeclarationStatus.WITHDRAWN, # 'arrêt commercialisation'
7: DeclarationStatus.WITHDRAWN, # 'retiré du marché'
8: DeclarationStatus.ABANDONED, # 'abandonné'
}

0 comments on commit a0c1fac

Please sign in to comment.