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}
\begin{flushright}
\huge Reçu fiscal au titre de dons
\huge Reçu fiscal au titre du don n°NUMERO-DON
\end{flushright}
}

View File

@ -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()