refactor(billing): Simplify topup seeding by removing payment status and date logic 🔨

This commit is contained in:
2025-07-04 16:32:45 +05:00
parent 5db71edc2c
commit 212ea2541f

View File

@ -4,9 +4,6 @@ import random
from django.core.management.base import BaseCommand from django.core.management.base import BaseCommand
from django.utils import timezone from django.utils import timezone
from faker import Faker from faker import Faker
from billing.models import (
Payment,
)
from billing.models import Topup from billing.models import Topup
from api.models import User from api.models import User
@ -40,12 +37,12 @@ class Command(BaseCommand):
for _ in range(number): for _ in range(number):
random_user = random.choice(users) random_user = random.choice(users)
paid_status = fake.boolean(chance_of_getting_true=80) expires_at_date = timezone.now() + timezone.timedelta(
paid_at_date = fake.date_time_this_year() if paid_status else None minutes=10,
)
if paid_at_date and timezone.is_naive(paid_at_date): print(
paid_at_date = timezone.make_aware(paid_at_date) f"Creating topup for user {getattr(random_user, 'id', None)} expires at: {expires_at_date}"
)
Topup.objects.create( Topup.objects.create(
amount=fake.pydecimal( amount=fake.pydecimal(
left_digits=4, left_digits=4,
@ -54,10 +51,9 @@ class Command(BaseCommand):
min_value=100.00, min_value=100.00,
max_value=5000.00, max_value=5000.00,
), ),
paid=paid_status,
user=random_user, user=random_user,
paid_at=paid_at_date,
updated_at=timezone.now(), updated_at=timezone.now(),
expires_at=expires_at_date,
) )
self.stdout.write(self.style.SUCCESS(f"Successfully seeded {number} topups.")) self.stdout.write(self.style.SUCCESS(f"Successfully seeded {number} topups."))