diff --git a/app.py b/app.py index 98a9c79..6cd0635 100644 --- a/app.py +++ b/app.py @@ -33,6 +33,7 @@ def initialize_database(): user_id INTEGER NOT NULL, entrytype TEXT NOT NULL CHECK(entrytype IN ('in', 'out')), ts TEXT NOT NULL, + paid BOOLEAN NOT NULL DEFAULT FALSE, FOREIGN KEY(user_id) REFERENCES users(id) ) """) @@ -64,9 +65,9 @@ def create_entry(user_id, entry_type, client_timestamp=None): else: timestamp = utc_now() cursor.execute(""" - INSERT INTO entries (user_id, entrytype, ts) - VALUES (?, ?, ?) - """, (user_id, entry_type, timestamp.isoformat())) + INSERT INTO entries (user_id, entrytype, ts, paid) + VALUES (?, ?, ?, ?) + """, (user_id, entry_type, timestamp.isoformat(), False)) conn.commit() conn.close() @@ -202,7 +203,7 @@ def api_get_users(): def api_get_entries(): conn = get_db_connection() entries = conn.execute(""" - SELECT id, user_id, entrytype, ts + SELECT id, user_id, entrytype, ts, paid FROM entries ORDER BY ts DESC """).fetchall() @@ -215,6 +216,7 @@ def api_create_entry(): user_id = data.get("user_id") entry_type = data.get("entrytype") client_timestamp = data.get("timestamp") + paid = data.get("paid", False) if entry_type not in ("in", "out"): return jsonify({ "error": "Invalid entrytype" @@ -222,7 +224,8 @@ def api_create_entry(): create_entry( user_id, entry_type, - client_timestamp + client_timestamp, + paid ) return jsonify({ "status": "success"