diff --git a/database.py b/database.py index 78a33173..28afe55c 100644 --- a/database.py +++ b/database.py @@ -1802,22 +1802,15 @@ def GetState(self, date, mode_arrondi=SANS_ARRONDI): for timeslot in timeslots: heures_realisees += tranche * GetDureeArrondie(self.creche.arrondi_heures, timeslot.debut, timeslot.fin) - if self.creche.nom == "Le Nid Des Trésors" and not inscription.IsInPeriodeAdaptation(date): - # TODO ajouter un paramètre quand la branche SQLAlchemy sera mergée - for timeslot in journee.timeslots: - if timeslot.activity.mode == MODE_PRESENCE: - heures_facturees += tranche * GetDureeArrondie(self.creche.arrondi_facturation, timeslot.debut, timeslot.fin) - heures_facturees = max(heures_facturees, heures_reference) + union = GetUnionHeures(journee, reference) + if inscription.IsInPeriodeAdaptation(date): + if self.creche.facturation_periode_adaptation == FACTURATION_HORAIRES_REELS: + union = journee.timeslots + for timeslot in union: + heures_facturees += tranche * GetDureeArrondie(self.creche.arrondi_facturation_periode_adaptation, timeslot.debut, timeslot.fin) else: - union = GetUnionHeures(journee, reference) - if inscription.IsInPeriodeAdaptation(date): - if self.creche.facturation_periode_adaptation == FACTURATION_HORAIRES_REELS: - union = journee.timeslots - for timeslot in union: - heures_facturees += tranche * GetDureeArrondie(self.creche.arrondi_facturation_periode_adaptation, timeslot.debut, timeslot.fin) - else: - for timeslot in union: - heures_facturees += tranche * GetDureeArrondie(self.creche.arrondi_facturation, timeslot.debut, timeslot.fin) + for timeslot in union: + heures_facturees += tranche * GetDureeArrondie(self.creche.arrondi_facturation, timeslot.debut, timeslot.fin) return State(PRESENT, heures_reference, heures_realisees, heures_facturees) else: diff --git a/facture.py b/facture.py index d39275b6..661aa5f5 100644 --- a/facture.py +++ b/facture.py @@ -315,10 +315,10 @@ def __init__(self, inscrit, annee, mois, options=0): if options & TRACES: print("jour de congé déduit", date, inscrit.jours_conges[date].label) self.jours_vacances.append(date) - self.heures_facturees_par_mode[cotisation.mode_garde] -= duration + # self.heures_facturees_par_mode[cotisation.mode_garde] -= duration self.jours_conges_non_factures.append(date) self.CalculeDeduction(cotisation, duration) - self.raison_deduction.add(inscrit.jours_conges[date].label) + self.raison_deduction.add(inscrit.jours_conges[date].label if inscrit.jours_conges[date].label else "Congés") elif state == MALADE or state == MALADE_SANS_JUSTIFICATIF: if options & TRACES: print("jour maladie", date) diff --git a/tests/test_nonreg.py b/tests/test_nonreg.py index 79e1be47..51195f23 100644 --- a/tests/test_nonreg.py +++ b/tests/test_nonreg.py @@ -1776,5 +1776,37 @@ def test_naissance_en_cours_de_mois(self): self.assert_prec2_equals(161.52, facture.total) +class CoccinellesTests(GertrudeTestCase): + def setUp(self): + GertrudeTestCase.setUp(self) + database.creche.type = TYPE_PARENTAL + database.creche.mode_facturation = FACTURATION_PSU + database.creche.repartition = REPARTITION_MENSUALISATION_12MOIS + database.creche.facturation_periode_adaptation = PERIODE_ADAPTATION_HORAIRES_REELS + database.creche.conges_inscription = GESTION_CONGES_INSCRIPTION_NON_MENSUALISES + database.creche.arrondi_mensualisation_euros = SANS_ARRONDI + + def test_heures_facturees_sur_conges(self): + inscrit = self.add_inscrit() + inscrit.add_conge(CongeInscrit(inscrit=inscrit, debut="29/04/2019", fin="03/05/2019")) + inscrit.add_conge(CongeInscrit(inscrit=inscrit, debut="21/10/2019", fin="25/10/2019")) + inscrit.naissance = datetime.date(2018, 7, 18) + self.add_frere(inscrit, datetime.date(2019, 5, 11)) + self.set_revenus(inscrit, 58495.44) + inscription = inscrit.inscriptions[0] + inscription.mode = MODE_TEMPS_PARTIEL + inscription.debut = datetime.date(2019, 1, 1) + inscription.fin = datetime.date(2019, 12, 31) + inscription.semaines_conges = 0 + for i in range(5): + self.add_inscription_timeslot(inscription, i, 8 * 12, 18.5 * 12) + cotisation = Cotisation(inscrit, datetime.date(2019, 9, 1)) + self.assert_prec2_equals(cotisation.cotisation_mensuelle, 445.90) + facture = Facture(inscrit, 2019, 10, options=TRACES) + self.assert_prec2_equals(343.00, facture.total) + self.assert_prec2_equals(189.00, facture.heures_facturees) + self.assert_prec2_equals(189.00, facture.heures_realisees) + + if __name__ == '__main__': unittest.main()