Skip to content

Commit

Permalink
Nouvelles macros SEPA pour les factures
Browse files Browse the repository at this point in the history
  • Loading branch information
bsongis committed Jun 28, 2017
1 parent d325684 commit c69de38
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
9 changes: 2 additions & 7 deletions doc_export_sepa.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,7 @@ def export_sepa(factures):

for facture in factures:
famille = facture.inscrit.famille
if creche.temps_facturation == FACTURATION_FIN_MOIS:
date = facture.date + datetime.timedelta(1)
else:
date = facture.date
day = famille.jour_prelevement_automatique if type(famille.jour_prelevement_automatique) == int else 1
date = date.replace(day=day)
date = facture.GetDatePrelevementAutomatique()
date_premier_prelevement_automatique = famille.date_premier_prelevement_automatique if famille.date_premier_prelevement_automatique else facture.inscrit.inscriptions[0].debut
rcur = (date.month != date_premier_prelevement_automatique.month and date.year != date_premier_prelevement_automatique.year)
payment = {"name": facture.inscrit.nom,
Expand All @@ -75,7 +70,7 @@ def export_sepa(factures):
"type": "RCUR" if rcur else "FRST",
"collection_date": date if rcur else date_premier_prelevement_automatique,
"mandate_id": famille.mandate_id,
"mandate_date": facture.date,
"mandate_date": facture.inscrit.inscriptions[0].debut,
"description": "Facture %s %d" % (months[facture.mois - 1], facture.annee)
}
# print payment
Expand Down
7 changes: 7 additions & 0 deletions facture.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ def GetFactureId(self):
else:
return '%03d%04d%02d' % (self.inscrit.idx, self.annee, self.mois)

def GetDatePrelevementAutomatique(self):
date = self.date
if creche.temps_facturation == FACTURATION_FIN_MOIS:
date += datetime.timedelta(1)
day = self.inscrit.famille.jour_prelevement_automatique
return date.replace(day=(day if type(day) == int else 1))

def Decloture(self):
self.cloture = True
date = GetMonthStart(self.date)
Expand Down
5 changes: 4 additions & 1 deletion functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,7 @@ def GetCrecheFields(creche):
('capacite', creche.GetCapacite()),
('capacite-creche', creche.GetCapacite()),
('amplitude-horaire', creche.GetAmplitudeHoraire()),
('sepa-creditor-id', creche.creditor_id),
]


Expand Down Expand Up @@ -946,6 +947,7 @@ def GetFamilleFields(famille):
('parents', GetParentsString(famille) if famille else ""),
('telephone', GetTelephone(famille) if famille else ""),
('email', GetEmail(famille) if famille else ""),
('sepa-mandate-id', famille.mandate_id),
]
result += GetTarifsFamilleFields(famille)
if famille:
Expand Down Expand Up @@ -1106,7 +1108,8 @@ def GetFactureFields(facture):
('total-sans-activites', facture.total - facture.supplement_activites, FIELD_EUROS),
('site', GetNom(facture.site)),
('total', facture.total, FIELD_EUROS),
('numfact', facture.GetFactureId())
('numfact', facture.GetFactureId()),
('sepa-date-prelevement', facture.GetDatePrelevementAutomatique()),
]
if config.codeclient == "custom":
result.append(('codeclient', facture.inscrit.famille.code_client))
Expand Down

0 comments on commit c69de38

Please sign in to comment.