feat: Ajout des modes de paiements + création d'une commande dans le

back permettant d'initialiser des données de test (pour les tarifs)
This commit is contained in:
N3WT DE COMPET
2025-02-12 15:13:15 +01:00
parent 23203c0397
commit 0c5e3aa098
12 changed files with 299 additions and 44 deletions

View File

@ -0,0 +1,25 @@
from django.core.management.base import BaseCommand
from School.models import PaymentMode, PaymentModeType, FeeType
class Command(BaseCommand):
help = 'Initialize or update Payment Modes'
def handle(self, *args, **kwargs):
self.create_or_update_payment_modes()
def create_or_update_payment_modes(self):
for fee_type in FeeType.choices:
fee_type_value = fee_type[0]
for mode in PaymentModeType.choices:
mode_value = mode[0]
PaymentMode.objects.update_or_create(
mode=mode_value,
type=fee_type_value,
defaults={
'is_active': False
}
)
self.stdout.write(self.style.SUCCESS('Payment Modes initialized or updated successfully'))