diff --git a/controle_don/RECU_FISCAL.tex b/controle_don/RECU_FISCAL.tex index c288014..c9aaa30 100644 --- a/controle_don/RECU_FISCAL.tex +++ b/controle_don/RECU_FISCAL.tex @@ -26,7 +26,7 @@ \vspace*{-9ex} \begin{flushright} - \huge Reçu fiscal au titre de dons + \huge Reçu fiscal au titre du don n°NUMERO-DON \end{flushright} } diff --git a/controle_don/mail_recu_headers b/controle_don/mail_recu_headers.txt similarity index 100% rename from controle_don/mail_recu_headers rename to controle_don/mail_recu_headers.txt diff --git a/controle_don/main.py b/controle_don/main.py index 9b5af17..8636c0c 100755 --- a/controle_don/main.py +++ b/controle_don/main.py @@ -113,42 +113,45 @@ def validate(record): "WHERE tr.notes LIKE '%{}%' and id_account = 469".format(record) # Note: su.id_service = 1 parceque la cotisation correspond au service 1 - print(gestion_read(request)) - - return try: answer = gestion_read(request)["results"][-1] except: - print(gestion_read(request)) - raise(Exception) + return False + + name, surname, address, postal_code, city, email, amount, mode, truc = \ + get_file_content_all(WORKDIR+"/transition/"+record).split("\n") date = datetime.datetime.strptime( answer["date"],'%Y-%m-%d').strftime("%d/%m/%Y") - filename = "{}_reçu_{}".format( - answer["nom"].replace(" ", "_"), + filename = "{}_reçu_{}_{}".format( + name, + record, date.replace("/", ".")) - BUF.append("* {} {}, {} €".format(numero, name, amount)) + BUF.append("* {} {}, {} €".format(record, name, "{},{}".format( + str(answer["credit"])[:-2], + str(answer["credit"])[-2:]))) BUF.append(" VALIDATION DON") BUF.append("") # Generate receipt - latexfile = get_file_content_all("RECU_COTISATION.tex") + latexfile = get_file_content_all("RECU_FISCAL.tex") + latexfile = latexfile.replace("NUMERO-DON", record) latexfile = latexfile.replace("ANNEE-CIVILE", answer["date"][:4]) - latexfile = latexfile.replace("NOM-DONATEUR", answer["nom"]) - latexfile = latexfile.replace("STATUT-DONATEUR", answer["statut_juridique"]) + latexfile = latexfile.replace("NOM-DONATEUR", name) + latexfile = latexfile.replace("STATUT-DONATEUR", "Personne physique") # XXX latexfile = latexfile.replace("ADRESSE-DONATEUR", "{}, {} {}".format( - answer["adresse"], - answer["code_postal"], - answer["ville"])) + address, + postal_code, + city)) latexfile = latexfile.replace("SOMME", "{},{}".format( - str(answer["amount"])[:-2], - str(answer["amount"])[-2:])) + str(answer["credit"])[:-2], + str(answer["credit"])[-2:])) latexfile = latexfile.replace("DATE-VERSEMENT", date) - latexfile = latexfile.replace("MODE-VERSEMENT", answer["true_reference"]) - latexfile = latexfile.replace("FORME-DON", answer["true_reference"]) - latexfile = latexfile.replace("NATURE-DON", answer["true_reference"]) + latexfile = latexfile.replace("MODE-VERSEMENT", answer["reference"]) + latexfile = latexfile.replace("FORME-DON", "Déclaration de don manuel") # XXX + latexfile = latexfile.replace("NATURE-DON", "Numéraire") # XXX try: os.remove(WORKDIR+"/validé/"+filename+".tex") @@ -159,7 +162,7 @@ def validate(record): # Preparing mail mailheaders = get_file_content_all(RECEPT_MAIL_HEADERS).replace("COURRIEL-DON", - answer["email"]) + "\n" + email) + "\n" mailtext = get_file_content_all(RECEPT_MAIL) + "\n" mailtattach = get_file_content_all(RECEPT_MAIL_ATTACHMENT) + "\n" @@ -173,7 +176,9 @@ def validate(record): sendmail_with_attachment(mailheaders, mailtext, mailtattach, data, ending) # The end - os.remove(WORKDIR+"/transition/"+donor) + os.remove(WORKDIR+"/transition/"+record) + + return True def check_record(intent): numero, content = get_file_content_all(intent).split("|") @@ -199,7 +204,8 @@ def validate_donors(): # Validate record for record in os.listdir(WORKDIR+"/transition"): - validate(record) + if not validate(record): + print("Ouais faut notifier") def main(): setup_workdir()