WIP: validation don

This commit is contained in:
Adrien Bourmault 2022-10-08 22:37:31 +02:00
parent 035f44b4b5
commit fb9159376f
No known key found for this signature in database
GPG Key ID: 6EB408FE0ACEC664
3 changed files with 29 additions and 23 deletions

View File

@ -26,7 +26,7 @@
\vspace*{-9ex} \vspace*{-9ex}
\begin{flushright} \begin{flushright}
\huge Reçu fiscal au titre de dons \huge Reçu fiscal au titre du don n°NUMERO-DON
\end{flushright} \end{flushright}
} }

View File

@ -113,42 +113,45 @@ def validate(record):
"WHERE tr.notes LIKE '%{}%' and id_account = 469".format(record) "WHERE tr.notes LIKE '%{}%' and id_account = 469".format(record)
# Note: su.id_service = 1 parceque la cotisation correspond au service 1 # Note: su.id_service = 1 parceque la cotisation correspond au service 1
print(gestion_read(request))
return
try: try:
answer = gestion_read(request)["results"][-1] answer = gestion_read(request)["results"][-1]
except: except:
print(gestion_read(request)) return False
raise(Exception)
name, surname, address, postal_code, city, email, amount, mode, truc = \
get_file_content_all(WORKDIR+"/transition/"+record).split("\n")
date = datetime.datetime.strptime( date = datetime.datetime.strptime(
answer["date"],'%Y-%m-%d').strftime("%d/%m/%Y") answer["date"],'%Y-%m-%d').strftime("%d/%m/%Y")
filename = "{}_reçu_{}".format( filename = "{}_reçu_{}_{}".format(
answer["nom"].replace(" ", "_"), name,
record,
date.replace("/", ".")) 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(" VALIDATION DON")
BUF.append("") BUF.append("")
# Generate receipt # 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("ANNEE-CIVILE", answer["date"][:4])
latexfile = latexfile.replace("NOM-DONATEUR", answer["nom"]) latexfile = latexfile.replace("NOM-DONATEUR", name)
latexfile = latexfile.replace("STATUT-DONATEUR", answer["statut_juridique"]) latexfile = latexfile.replace("STATUT-DONATEUR", "Personne physique") # XXX
latexfile = latexfile.replace("ADRESSE-DONATEUR", "{}, {} {}".format( latexfile = latexfile.replace("ADRESSE-DONATEUR", "{}, {} {}".format(
answer["adresse"], address,
answer["code_postal"], postal_code,
answer["ville"])) city))
latexfile = latexfile.replace("SOMME", "{},{}".format( latexfile = latexfile.replace("SOMME", "{},{}".format(
str(answer["amount"])[:-2], str(answer["credit"])[:-2],
str(answer["amount"])[-2:])) str(answer["credit"])[-2:]))
latexfile = latexfile.replace("DATE-VERSEMENT", date) latexfile = latexfile.replace("DATE-VERSEMENT", date)
latexfile = latexfile.replace("MODE-VERSEMENT", answer["true_reference"]) latexfile = latexfile.replace("MODE-VERSEMENT", answer["reference"])
latexfile = latexfile.replace("FORME-DON", answer["true_reference"]) latexfile = latexfile.replace("FORME-DON", "Déclaration de don manuel") # XXX
latexfile = latexfile.replace("NATURE-DON", answer["true_reference"]) latexfile = latexfile.replace("NATURE-DON", "Numéraire") # XXX
try: try:
os.remove(WORKDIR+"/validé/"+filename+".tex") os.remove(WORKDIR+"/validé/"+filename+".tex")
@ -159,7 +162,7 @@ def validate(record):
# Preparing mail # Preparing mail
mailheaders = get_file_content_all(RECEPT_MAIL_HEADERS).replace("COURRIEL-DON", mailheaders = get_file_content_all(RECEPT_MAIL_HEADERS).replace("COURRIEL-DON",
answer["email"]) + "\n" email) + "\n"
mailtext = get_file_content_all(RECEPT_MAIL) + "\n" mailtext = get_file_content_all(RECEPT_MAIL) + "\n"
mailtattach = get_file_content_all(RECEPT_MAIL_ATTACHMENT) + "\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) sendmail_with_attachment(mailheaders, mailtext, mailtattach, data, ending)
# The end # The end
os.remove(WORKDIR+"/transition/"+donor) os.remove(WORKDIR+"/transition/"+record)
return True
def check_record(intent): def check_record(intent):
numero, content = get_file_content_all(intent).split("|") numero, content = get_file_content_all(intent).split("|")
@ -199,7 +204,8 @@ def validate_donors():
# Validate record # Validate record
for record in os.listdir(WORKDIR+"/transition"): for record in os.listdir(WORKDIR+"/transition"):
validate(record) if not validate(record):
print("Ouais faut notifier")
def main(): def main():
setup_workdir() setup_workdir()