X-Git-Url: https://git.auf.org/?p=auf_rh_dae.git;a=blobdiff_plain;f=project%2Flegacy%2Fmanagement%2Fcommands%2Frh_import_legacy.py;h=728f60f685cbe7e0f1d61c10483256d049d647ee;hp=0709494be553c00a227c1ee2bf9cd589255042e0;hb=860c9ec990c494783b911aaa557438e50def2492;hpb=4ce980aec005569ca27615ead6deab23ba785423 diff --git a/project/legacy/management/commands/rh_import_legacy.py b/project/legacy/management/commands/rh_import_legacy.py index 0709494..728f60f 100644 --- a/project/legacy/management/commands/rh_import_legacy.py +++ b/project/legacy/management/commands/rh_import_legacy.py @@ -11,6 +11,14 @@ from django.db.models import Q, Max from project.legacy import models as legacy from project.rh import models as rh +def clean_date(date): + if date == '2003-06-31': # date inexistante (dossier 791-1) + return '2003-06-30' + elif date: + return date + else: + return None + class Command(BaseCommand): help = 'Importe les données du système RH legacy' @@ -147,6 +155,8 @@ def sync_poste(): if dossiers.count() == 0: service = None poste_du_responsable = None + date_debut = None + date_fin = None if dossiers.count() > 0: @@ -173,6 +183,10 @@ def sync_poste(): except: poste_du_responsable = None + # initialiser les dates du poste avec les dates du dossier + date_debut = clean_date(dossier.date_debut_mandat) + date_fin = clean_date(dossier.date_fin_mandat) + # Créer le poste rh_poste = rh.Poste.objects.create( id=poste.id_implantation_postes, @@ -184,6 +198,8 @@ def sync_poste(): service_id=service, supprime=False, responsable_id=poste_du_responsable, + date_debut=date_debut, + date_fin=date_fin, ) if service is None and poste.actif in ('0', 0, False): @@ -303,14 +319,6 @@ def sync_typeremuneration(): def sync_dossier(): - def clean_date(date): - if date == '2003-06-31': # date inexistante (dossier 791-1) - return '2003-06-30' - elif date: - return date - else: - return None - taux_cache = {} def get_taux(annee, devise): taux = taux_cache.get((annee, devise))