mirror of
https://github.com/i701/sarlink-portal-api.git
synced 2025-07-09 23:16:31 +00:00
refactor(billing): enhance SMS message formatting for expired topups with improved date handling ✨
This commit is contained in:
@ -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
|
||||
|
@ -13,9 +13,9 @@ class PaymentAdmin(admin.ModelAdmin):
|
||||
"paid",
|
||||
"paid_at",
|
||||
"method",
|
||||
"is_expired",
|
||||
"expires_at",
|
||||
"created_at",
|
||||
"expires_at",
|
||||
"is_expired",
|
||||
"updated_at",
|
||||
)
|
||||
|
||||
|
@ -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)
|
||||
|
Reference in New Issue
Block a user