diff --git a/api/tasks.py b/api/tasks.py index aa06175..343f858 100644 --- a/api/tasks.py +++ b/api/tasks.py @@ -5,7 +5,8 @@ from api.notifications import send_sms import os import logging from django.utils import timezone -from api.notifications import send_clean_telegram_markdown + +# from api.notifications import send_clean_telegram_markdown from api.omada import Omada from apibase.env import env, BASE_DIR from procrastinate.contrib.django import app diff --git a/billing/admin.py b/billing/admin.py index b5ba0e2..62d120d 100644 --- a/billing/admin.py +++ b/billing/admin.py @@ -13,9 +13,9 @@ class PaymentAdmin(admin.ModelAdmin): "paid", "paid_at", "method", - "is_expired", - "expires_at", "created_at", + "expires_at", + "is_expired", "updated_at", ) diff --git a/billing/tasks.py b/billing/tasks.py index 1df796f..104d6fb 100644 --- a/billing/tasks.py +++ b/billing/tasks.py @@ -6,6 +6,7 @@ from procrastinate.contrib.django import app from api.notifications import send_sms from billing.models import Topup from django.utils.timezone import localtime +from datetime import datetime logger = logging.getLogger(__name__) @@ -56,8 +57,15 @@ def update_expired_topups(timestamp: int): def send_sms_task( user: str, mobile: str, amount: float, topup_id: str, created_at: str ): + # Parse the ISO formatted date string + try: + dt = datetime.fromisoformat(created_at) + formatted_date = dt.strftime("%d %b %Y, %I:%M %p") + except Exception: + formatted_date = created_at # fallback to original if parsing fails + message = ( - f"Dear {user}, \n\nYour topup of {amount} MVR [created at {created_at}] has expired. " + f"Dear {user}, \n\nYour topup of {amount} MVR [created at {formatted_date}] has expired. " "Please make a new topup to update your wallet. \n\n- SAR Link" ) send_sms(mobile, message)