From 950f42ae3f337ecc963418fb3cafd1c53ea4cf1d Mon Sep 17 00:00:00 2001 From: i701 Date: Sun, 6 Jul 2025 21:22:56 +0500 Subject: [PATCH] =?UTF-8?q?feat(payment):=20add=20status=20field=20and=20i?= =?UTF-8?q?s=5Fexpired=20property=20to=20Payment=20model=20for=20enhanced?= =?UTF-8?q?=20payment=20tracking=20=E2=9C=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- billing/migrations/0012_payment_status.py | 25 +++++++++++++++++++++++ billing/models.py | 15 ++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 billing/migrations/0012_payment_status.py diff --git a/billing/migrations/0012_payment_status.py b/billing/migrations/0012_payment_status.py new file mode 100644 index 0000000..0f0e65b --- /dev/null +++ b/billing/migrations/0012_payment_status.py @@ -0,0 +1,25 @@ +# Generated by Django 5.2 on 2025-07-06 15:42 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("billing", "0011_topup_status"), + ] + + operations = [ + migrations.AddField( + model_name="payment", + name="status", + field=models.CharField( + choices=[ + ("PENDING", "Pending"), + ("PAID", "Paid"), + ("CANCELLED", "Cancelled"), + ], + default="PENDING", + max_length=20, + ), + ), + ] diff --git a/billing/models.py b/billing/models.py index 814365a..8ddddbb 100644 --- a/billing/models.py +++ b/billing/models.py @@ -27,6 +27,21 @@ class Payment(models.Model): created_at = models.DateTimeField(default=timezone.now) updated_at = models.DateTimeField(auto_now=True) devices = models.ManyToManyField(Device, related_name="payments") + status = models.CharField( + max_length=20, + choices=[ + ("PENDING", "Pending"), + ("PAID", "Paid"), + ("CANCELLED", "Cancelled"), + ], + default="PENDING", + ) + + @property + def is_expired(self): + if self.expires_at is None: + return False + return timezone.now() > self.expires_at def __str__(self): return f"Payment by {self.user}"