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}"