From e9f7236da338c797c5f7ce85a14cacd622292692 Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Thu, 15 Sep 2022 00:18:16 +0200 Subject: [PATCH] =?UTF-8?q?WIP:=20contr=C3=B4le=20cotisation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controle_cotisation/mail_instructions.txt | 2 +- .../mail_instructions_headers.txt | 1 + controle_cotisation/main.py | 26 ++++++++++++++++++- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/controle_cotisation/mail_instructions.txt b/controle_cotisation/mail_instructions.txt index 6fb7a82..9e7ba95 100644 --- a/controle_cotisation/mail_instructions.txt +++ b/controle_cotisation/mail_instructions.txt @@ -2,7 +2,7 @@ Bonjour NOM_COTISANT, Je reviens vers vous pour vous informer des modalités de règlement de votre cotisation pour l'année civile ANNEE_CIVILE. Votre numéro de membre est le -NUMERO_MEMBRE et le montant de votre cotisation est MONTANT_COTISATION €. +NUMERO_MEMBRE et le montant de votre cotisation est de MONTANT_COTISATION €. Les moyens de paiement acceptés sont: espèces, chèques et virement bancaire. Vous avez normalement déjà formulé une préférence. Si toutefois vous souhaitez diff --git a/controle_cotisation/mail_instructions_headers.txt b/controle_cotisation/mail_instructions_headers.txt index 327aef4..9d28762 100644 --- a/controle_cotisation/mail_instructions_headers.txt +++ b/controle_cotisation/mail_instructions_headers.txt @@ -1,6 +1,7 @@ Content-Language: fr From: =?UTF-8?Q?Tr=c3=a9sorier_de_Libre_en_Communs?= To: +Bcc: Subject: =?UTF-8?Q?=5bTr=c3=a9sorerie=5d_-_modalit=c3=a9s_de_r=c3=a8glement_de_vo?= =?UTF-8?Q?tre_cotisation_ANNEE_CIVILE?= Content-Type: text/plain; charset="UTF-8" diff --git a/controle_cotisation/main.py b/controle_cotisation/main.py index 2e83b7f..163a25f 100755 --- a/controle_cotisation/main.py +++ b/controle_cotisation/main.py @@ -166,6 +166,20 @@ def gestion_get_amount(member): return gestion_read(request_unpaid)["results"][-1]["amount"] +def gestion_get_date(member): + request_unpaid = "SELECT date FROM services_users su " +\ + "INNER JOIN membres m ON m.id = su.id_user " +\ + "INNER JOIN services s ON s.id = su.id_service " +\ + "LEFT JOIN services_fees sf ON sf.id = su.id_fee " +\ + "INNER JOIN (SELECT id, MAX(date) " +\ + "FROM services_users " +\ + "GROUP BY id_user, id_service) " +\ + "AS su2 ON su2.id = su.id " +\ + "WHERE id_user = {};".format(member) + + + return gestion_read(request_unpaid)["results"][-1]["date"] + def get_member_infos(member): request = "SELECT * FROM membres " +\ "WHERE id = '{}';".format(member) @@ -194,7 +208,7 @@ def check_email_created(member): def notify_expired(member): BUF.append("* {}".format(member)) - BUF.append(" NOTIFICATION TRESORIER") + BUF.append(" EXPIRATION ADHESION") BUF.append("") def notify_unpaid(member): @@ -205,10 +219,20 @@ def notify_unpaid(member): name, numero, email = get_member_infos(member) amount = "{},{}".format(str(gestion_get_amount(member))[:-2], str(gestion_get_amount(member))[-2:]) + year = gestion_get_year(member)[:4] BUF.append("* {} (numero {}), {}, {} €".format(member, numero, name, amount)) BUF.append(" NOTIFICATION MEMBRE") BUF.append("") + + mailheaders = get_file_content_all(MODALITY_MAIL_HEADERS) + "\n" + mailheaders = mailheaders.replace("NOM_COTISANT", name) + mailheaders = mailheaders.replace("NUMERO_MEMBRE", numero) + mailheaders = mailheaders.replace("MONTANT_COTISATION", amount) + mailtext = get_file_content_all(MODALITY_MAIL).replace("ANNEE_CIVILE", year) + mailtext = mailtext.replace("COURRIEL-COTISANT", email) + + sendmail(mailheaders, mailtext) return True def renotify_unpaid(member):