Adds a transaction record when salary is paid.

This commit is contained in:
MrEisbear 2025-07-24 22:43:36 -05:00
parent ed256b8e6e
commit 7c9656e4d9

View file

@ -61,6 +61,8 @@ def collect():
with db.cursor(dictionary=True) as cur: with db.cursor(dictionary=True) as cur:
cur.execute("UPDATE users SET balance = balance + %s WHERE bid = %s", (amount, bid,)) cur.execute("UPDATE users SET balance = balance + %s WHERE bid = %s", (amount, bid,))
cur.execute("UPDATE user_jobs SET collected = %s WHERE bid = %s", (datetime.now(timezone.utc), bid,)) cur.execute("UPDATE user_jobs SET collected = %s WHERE bid = %s", (datetime.now(timezone.utc), bid,))
cur.execute("INSERT INTO transactions (source, target, amount, type, timestamp, status) VALUES (%s, %s, "
"%s, %s, %s, %s)", "NULL", bid, amount, "salary", datetime.now(timezone.utc), "completed",)
cur.execute("SELECT balance FROM users WHERE bid = %s", (bid,)) cur.execute("SELECT balance FROM users WHERE bid = %s", (bid,))
new_bal2 = cur.fetchone() new_bal2 = cur.fetchone()
new_bal = new_bal2["balance"] new_bal = new_bal2["balance"]