Skip to content

Commit

Permalink
[O-Pagaio] Régularisation congés non pris (avec tests non régression)
Browse files Browse the repository at this point in the history
  • Loading branch information
bsongis committed Jun 7, 2017
1 parent 4c440b6 commit 312b4db
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 15 deletions.
26 changes: 11 additions & 15 deletions sqlobjects.py
Original file line number Diff line number Diff line change
Expand Up @@ -1887,26 +1887,22 @@ def GetNombreJoursCongesPris(self, debut, fin):
date = debut
# print "GetNombreJoursCongesPris(%s - %s)" % (debut, fin)
while date <= fin:
state = self.inscrit.GetStateSimple(date)
if creche.facturation_jours_feries == ABSENCES_DEDUITES_EN_SEMAINES:
if date in creche.periodes_fermeture:
# print date
jours += 1
elif state in (VACANCES, ABSENT):
reference = self.GetJourneeReference(date)
if reference.GetNombreHeures() > 0:
# print date
jours += 1
elif creche.facturation_jours_feries == ABSENCES_DEDUITES_EN_JOURS:
if state == VACANCES:
if self.mode in (MODE_FORFAIT_HEBDOMADAIRE, MODE_FORFAIT_MENSUEL):
if date in creche.periodes_fermeture or date in self.inscrit.jours_conges:
# print date
jours += 1
else:
if state in (ABSENT, VACANCES):
reference = self.GetJourneeReference(date)
if reference.GetNombreHeures() > 0:
state = self.inscrit.GetStateSimple(date)
if creche.facturation_jours_feries == ABSENCES_DEDUITES_EN_JOURS:
if state == VACANCES:
# print date
jours += 1
else:
if state in (ABSENT, VACANCES):
reference = self.GetJourneeReference(date)
if reference.GetNombreHeures() > 0:
# print date
jours += 1
date += datetime.timedelta(1)
return jours

Expand Down
28 changes: 28 additions & 0 deletions tests/nonreg.py
Original file line number Diff line number Diff line change
Expand Up @@ -933,6 +933,8 @@ def setUp(self):
creche.temps_facturation = FACTURATION_FIN_MOIS
creche.repartition = REPARTITION_MENSUALISATION_CONTRAT_DEBUT_FIN_INCLUS
creche.facturation_periode_adaptation = PERIODE_ADAPTATION_GRATUITE
self.AddConge("26/12/2016", "31/12/2016")
self.AddConge("24/04/2017", "29/04/2017")

def test_adaptation_a_cheval_sur_2_mois(self):
inscrit = self.AddInscrit()
Expand Down Expand Up @@ -978,6 +980,32 @@ def test_changement_de_contrat(self):
facture = Facture(inscrit, 2017, 2)
self.assertPrec2Equals(facture.cotisation_mensuelle, 525.52)

def test_regularisation_conges_non_pris_mode_forfait_hebdomadaire(self):
inscrit = self.AddInscrit()
inscription = Inscription(inscrit, creation=False)
inscription.mode = MODE_FORFAIT_HEBDOMADAIRE
inscription.forfait_mensuel_heures = 32.0
inscription.semaines_conges = 5
inscription.debut = datetime.date(2016, 9, 12)
inscription.fin = datetime.date(2017, 8, 31)
inscription.depart = datetime.date(2017, 4, 30)
inscrit.inscriptions.append(inscription)
facture = Facture(inscrit, 2017, 4)
self.assertPrec2Equals(facture.regularisation, 188.19)

def test_regularisation_conges_non_pris_mode_temps_partiel(self):
inscrit = self.AddInscrit()
inscription = Inscription(inscrit, creation=False)
inscription.mode = MODE_TEMPS_PARTIEL
inscription.semaines_conges = 7
inscription.debut = datetime.date(2017, 3, 1)
inscription.fin = datetime.date(2017, 8, 31)
inscription.depart = datetime.date(2017, 5, 31)
inscription.reference[0].AddActivity(114, 210, 0, -1) # 9.5h
inscrit.inscriptions.append(inscription)
facture = Facture(inscrit, 2017, 5)
self.assertPrec2Equals(facture.regularisation, 152.00)


if __name__ == '__main__':
unittest.main()

0 comments on commit 312b4db

Please sign in to comment.