mirror of
https://github.com/i701/sarlink-portal-api.git
synced 2025-07-07 12:16:30 +00:00
feat(payment): add status field and is_expired property to Payment model for enhanced payment tracking ✨
This commit is contained in:
25
billing/migrations/0012_payment_status.py
Normal file
25
billing/migrations/0012_payment_status.py
Normal file
@ -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,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
@ -27,6 +27,21 @@ class Payment(models.Model):
|
|||||||
created_at = models.DateTimeField(default=timezone.now)
|
created_at = models.DateTimeField(default=timezone.now)
|
||||||
updated_at = models.DateTimeField(auto_now=True)
|
updated_at = models.DateTimeField(auto_now=True)
|
||||||
devices = models.ManyToManyField(Device, related_name="payments")
|
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):
|
def __str__(self):
|
||||||
return f"Payment by {self.user}"
|
return f"Payment by {self.user}"
|
||||||
|
Reference in New Issue
Block a user