From 9f2cd6d7747a0883177e212829aadfb87c60b3cc Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Thu, 15 Sep 2022 00:00:09 +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/main.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/controle_cotisation/main.py b/controle_cotisation/main.py index 620fc49..0c26abf 100755 --- a/controle_cotisation/main.py +++ b/controle_cotisation/main.py @@ -152,6 +152,20 @@ def gestion_get_unpaid(): return unpaid_members_list.copy() +def gestion_get_amount(member): + request_unpaid = "SELECT amount 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]["id_user"] + def get_member_infos(member): request = "SELECT * FROM membres " +\ "WHERE id = '{}';".format(member) @@ -189,6 +203,8 @@ def notify_unpaid(member): # Get member infos name, numero, email = get_member_infos(member) + amount = gestion_get_amount(member) + print(amount) BUF.append("* {} (numero {}), {}".format(member, numero, name)) BUF.append(" NOTIFICATION MEMBRE") @@ -199,6 +215,8 @@ def renotify_unpaid(member): # Get member infos name, numero, email = get_member_infos(member) + amount = gestion_get_amount(member) + print(amount) BUF.append("* {} (numero {}), {}".format(member, numero, name)) BUF.append(" RENOTIFICATION MEMBRE")