From 27293255bfaa418cd6e6031f77493a78a10a18bc Mon Sep 17 00:00:00 2001 From: Frederick Yin Date: Tue, 23 Nov 2021 16:37:18 +0800 Subject: Keep track of overdue umbrellas Also keep an admin log entry --- jimbrella/routine.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'jimbrella') diff --git a/jimbrella/routine.py b/jimbrella/routine.py index a4ad638..33c48dc 100644 --- a/jimbrella/routine.py +++ b/jimbrella/routine.py @@ -112,7 +112,7 @@ def sync_database(takeaway: JForm, giveback: JForm, db: Database, admin: AdminLo ) -def process_overdue(db: Database): +def process_overdue(db: Database, admin: AdminLog): overdue = Database.find_overdue(db.read()) # mark and log umbrellas that were not, but just became overdue for umb in filter(lambda u: u["status"] == "lent", overdue): @@ -124,6 +124,16 @@ def process_overdue(db: Database): umb["tenant_id"], umb["tenant_phone"], ) + admin.log( + "OVERDUE", + { + "key": umb["serial"], + "name": umb["tenant_name"], + "phone": umb["tenant_phone"], + "id": umb["tenant_id"], + "email": "", + }, + ) if __name__ == "__main__": @@ -132,3 +142,4 @@ if __name__ == "__main__": db = Database(DATABASE_PATH) admin_log = AdminLog(ADMIN_LOG_PATH) sync_database(takeaway, giveback, db, admin_log) + process_overdue(db, admin_log) -- cgit v1.2.3