# coding: utf-8
-from datetime import datetime
+from datetime import datetime, date
from decimal import Decimal
from django.contrib.auth.models import User
cursor.execute('TRUNCATE rh_dossier')
cursor.execute('TRUNCATE rh_remuneration')
cursor.execute('TRUNCATE rh_dossiercommentaire')
+ cursor.execute('TRUNCATE rh_responsableimplantation')
odette = User.objects.get(username='odette.tremblay')
type_contrat_inconnu = rh.TypeContrat.objects.create(
nom='Inconnu',
nom_long='Inconnu',
)
- dossiers = legacy.Dossiers.objects.annotate(timestamp_modif=Max('historique__stamp'))
+ dossiers = legacy.Dossiers.objects.annotate(timestamp_modif=Max('historique__stamp')) \
+ .order_by('no_dossier')
for dossier in dossiers:
date_modification = datetime.fromtimestamp(dossier.timestamp_modif) \
if dossier.timestamp_modif else None
remplacement=False,
supprime=False
)
+
+ # Commentaires
if dossier.remarque:
rh.DossierCommentaire.objects.create(
dossier=dossier1,
texte=dossier.remarque,
owner=odette
)
+
+ # Responsables d'implantation
+ today = date.today().isoformat()
+ if not dossier.date_fin_mandat or dossier.date_fin_mandat >= today:
+ if dossier.responsable_implantation_1:
+ responsable, created = rh.ResponsableImplantation.objects.get_or_create(
+ implantation_id=dossier.id_implantation_1
+ )
+ responsable.employe_id = dossier.employe_id
+ responsable.save()
+ if dossier.responsable_implantation_2:
+ responsable, created = rh.ResponsableImplantation.objects.get_or_create(
+ implantation_id=dossier.id_implantation_2
+ )
+ responsable.employe_id = dossier.employe_id
+ responsable.save()
+
+ # Contrats
rh.Contrat.objects.create(
dossier=dossier1,
type_contrat_id=dossier.id_type_contrat or type_contrat_inconnu.id,
supprime=False
)
-
+ # Rémunération
remuns_precedentes = {}
charges_precedentes = None
pourcentage_charges = 0
if remun.type_remuneration.nature_remuneration != 'Charges' and remun.montant != 0:
devise, created = rh.Devise.objects.get_or_create(code=remun.code_devise)
- try:
- rh_remun = rh.Remuneration.objects.create(
- dossier=dossier1,
- type_id=remun.type_remuneration_id,
- type_revalorisation_id=remun.id_type_revalorisation,
- montant=remun.montant,
- devise=devise,
- supprime=False,
- date_debut=date_debut,
- date_fin=date_fin
- )
- except:
- import pdb; pdb.set_trace()
+ rh_remun = rh.Remuneration.objects.create(
+ dossier=dossier1,
+ type_id=remun.type_remuneration_id,
+ type_revalorisation_id=remun.id_type_revalorisation,
+ montant=remun.montant,
+ devise=devise,
+ supprime=False,
+ date_debut=date_debut,
+ date_fin=date_fin
+ )
# Se souvenir de ce type de rémunération
if remun.type_remuneration.type_paiement == u'Régulier':