From 86912c69de49d3222c694b76bc557bc1c83c6de7 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 31 Mar 2002 17:12:17 +0000 Subject: [PATCH] vin skripte verfeinert --- scripts/register/unpaid.sql | 4 ++-- scripts/register/warn.py | 46 ++++++++++++++++++++++++------------- scripts/register/zat.py | 2 +- 3 files changed, 33 insertions(+), 19 deletions(-) diff --git a/scripts/register/unpaid.sql b/scripts/register/unpaid.sql index 7103ecfa3..e7c80b5d2 100644 --- a/scripts/register/unpaid.sql +++ b/scripts/register/unpaid.sql @@ -1,6 +1,6 @@ -select distinct u.id ID, s.faction Partei, left(concat(firstname,' ',lastname, ' <',email,'>'),43) Name, sum(t.balance) Kontostand +select distinct u.id ID, concat(s.game, '/', s.faction) Partei, left(concat(firstname,' ',lastname, ' <',email,'>'),43) Name, sum(t.balance) Kontostand from users u, transactions t, subscriptions s where u.id=t.user and u.id=s.user and s.status='ACTIVE' GROUP BY s.faction - HAVING Kontostand<2.5; + HAVING Kontostand<5; diff --git a/scripts/register/warn.py b/scripts/register/warn.py index 83e4d77cd..e367b6287 100755 --- a/scripts/register/warn.py +++ b/scripts/register/warn.py @@ -9,7 +9,8 @@ dryrun=0 if len(sys.argv)>2: dryrun=1 price=1.25 -warnahead=2 +warnahead=4 +cancelafter=1 db=MySQLdb.connect(db=dbname) cursor=db.cursor() @@ -18,28 +19,41 @@ server=smtplib.SMTP('localhost') while users > 0: users=users-1 email, uid, games = cursor.fetchone() + if games==0: + continue c2 = db.cursor() t = c2.execute("select sum(balance) from transactions where user="+str(int(uid))) if t==0: balance=0.0 else: balance = c2.fetchone()[0] - if balance < games*warnahead*price: - print "Warning "+email+", uid="+str(int(uid))+", balance="+str(balance)+", games="+str(int(games)) - Msg = ("From: Vinyambar Buchhaltung <"+From+">\nTo: "+email+"\nSubject: Vinyambar Kontostand, Warnung.\n\n"+ - "Dein Vinyambar Kontostand reicht nicht mehr aus, um die kommenden "+str(warnahead)+"\n"+ - "Wochen zu bezahlen. Bitte mache baldmöglichst eine neue Überweisung\n" - "auf das Vinyambar-Konto.\n\n"+ - "Kundennummer: "+str(uid)+"\n"+ - "Kontostand: "+str(balance)+" EUR\n"+ - "\n"+ - "Unser Konto: Katja Zedel\n"+ - "Kontonummer 1251 886 106\n"+ - "BLZ 500 502 01 (Frankfurter Sparkasse)\n") - try: - # print Msg + Msg=None + if balance <= games*warnahead*price: + Msg = ("From: Vinyambar Buchhaltung <"+From+">\nTo: "+email+"\n") + if balance <= -games*cancelafter*price: + Msg=Msg+"Subject: Vinyambar Abmeldung Kunde "+str(int(uid))+".\n\n" + Msg = Msg+("Nachdem Dein Konto bei uns im Minus ist, haben wir deine\n"+ + "Anmeldung bei Vinyambar gekündigt, und die Partei(en) der Parteibörse\n"+ + "zugeführt.\n") + print "CANCEL: "+email+", uid="+str(int(uid))+", balance="+str(balance)+", games="+str(int(games)) if dryrun==0: - server.sendmail(From, email, Msg) + c2.execute("UPDATE subscriptions set user=0, status='CANCELLED' where user="+str(int(uid))) + else: + print "WARNING: "+email+", uid="+str(int(uid))+", balance="+str(balance)+", games="+str(int(games)) + Msg = Msg+"Subject: WARNUNG - Vinyambar Kontostand Kunde "+str(int(uid))+"\n\n" + Msg = Msg+("Dein Vinyambar Kontostand reicht nicht mehr aus, um die kommenden "+str(warnahead)+"\n"+ + "Wochen zu bezahlen. Bitte mache baldmöglichst eine neue Überweisung\n" + "auf das Vinyambar-Konto.\n\n"+ + "Kundennummer: "+str(uid)+"\n"+ + "Kontostand: "+str(balance)+" EUR\n"+ + "\n"+ + "Unser Konto: Katja Zedel\n"+ + "Kontonummer 1251 886 106\n"+ + "BLZ 500 502 01 (Frankfurter Sparkasse)\n") + + if (Msg!=None) and dryrun==0: + try: + server.sendmail(From, email, Msg) except: print "Could not send confirmation to "+email print "Exception is:", sys.exc_type, ":", sys.exc_value diff --git a/scripts/register/zat.py b/scripts/register/zat.py index 1344ddac2..b7df75aa3 100755 --- a/scripts/register/zat.py +++ b/scripts/register/zat.py @@ -36,7 +36,7 @@ print "Removing "+str(int(k))+" transfered subscriptions." k = cursor.execute("UPDATE subscriptions SET user=0 where game="+str(int(game))+" and status='CANCELLED' and updated<'"+date+"'") print "Removing "+str(int(k))+" cancelled subscriptions." -k = cursor.execute("UPDATE subscriptions SET user=0 where game="+str(int(game))+" and status='DEAD' and updated<'"+date+"'") +k = cursor.execute("UPDATE subscriptions SET user=0 where game="+str(int(game))+" and status='DEAD'") print "Removing "+str(int(k))+" dead subscriptions." k = cursor.execute("UPDATE subscriptions SET status='CANCELLED' where game="+str(int(game))+" and status='ACTIVE' and lastturn+3<="+str(lastturn))