From 3cb38e2e9fb08e07664caa7daa9aa651262bd213 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elisi=C3=A1rio=20Couto?= Date: Fri, 7 Jun 2024 20:46:45 +0100 Subject: [PATCH] feat(sync): Correctly calculate days left, based on the default 90 days period. --- leggen/commands/sync.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/leggen/commands/sync.py b/leggen/commands/sync.py index ed801bc..09d2415 100644 --- a/leggen/commands/sync.py +++ b/leggen/commands/sync.py @@ -27,13 +27,14 @@ def sync(ctx: click.Context): if account_status != "LINKED": created_at = datetime.datetime.fromisoformat(r["created"]) now = datetime.datetime.now(tz=datetime.timezone.utc) - if (created_at - now).days <= 15: + days_left = 90 - (created_at - now).days + if days_left <= 15: n = { "bank": r["institution_id"], "status": REQUISITION_STATUS.get(r["status"], "UNKNOWN"), "created_at": created_at.timestamp(), "requisition_id": r["id"], - "days_left": (created_at - now).days, + "days_left": days_left, } send_expire_notification(ctx, n)