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")