mirror of
https://github.com/elisiariocouto/leggen.git
synced 2025-12-14 13:12:22 +00:00
feat(sync): Correctly calculate days left, based on the default 90 days period.
This commit is contained in:
@@ -27,13 +27,14 @@ def sync(ctx: click.Context):
|
|||||||
if account_status != "LINKED":
|
if account_status != "LINKED":
|
||||||
created_at = datetime.datetime.fromisoformat(r["created"])
|
created_at = datetime.datetime.fromisoformat(r["created"])
|
||||||
now = datetime.datetime.now(tz=datetime.timezone.utc)
|
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 = {
|
n = {
|
||||||
"bank": r["institution_id"],
|
"bank": r["institution_id"],
|
||||||
"status": REQUISITION_STATUS.get(r["status"], "UNKNOWN"),
|
"status": REQUISITION_STATUS.get(r["status"], "UNKNOWN"),
|
||||||
"created_at": created_at.timestamp(),
|
"created_at": created_at.timestamp(),
|
||||||
"requisition_id": r["id"],
|
"requisition_id": r["id"],
|
||||||
"days_left": (created_at - now).days,
|
"days_left": days_left,
|
||||||
}
|
}
|
||||||
send_expire_notification(ctx, n)
|
send_expire_notification(ctx, n)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user