mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-29 07:53:23 +00:00
chore: Ajout d'un mode test au lancement du serveur pour ajouter des
datas de test
This commit is contained in:
87
Back-End/School/management/commands/init_school_fees.py
Normal file
87
Back-End/School/management/commands/init_school_fees.py
Normal file
@ -0,0 +1,87 @@
|
||||
from django.core.management.base import BaseCommand
|
||||
from Auth.models import Profile
|
||||
from School.models import Fee, Discount, FeeType, DiscountType
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = 'Initialize or update Fees and Discounts'
|
||||
|
||||
def handle(self, *args, **kwargs):
|
||||
self.create_or_update_fees()
|
||||
self.create_or_update_discounts()
|
||||
|
||||
def create_or_update_fees(self):
|
||||
fees_data = [
|
||||
{
|
||||
"name": "Frais d'inscription",
|
||||
"base_amount": "150.00",
|
||||
"description": "Montant de base",
|
||||
"is_active": True,
|
||||
"type": FeeType.REGISTRATION_FEE
|
||||
},
|
||||
{
|
||||
"name": "Matériel",
|
||||
"base_amount": "85.00",
|
||||
"description": "Livres / jouets",
|
||||
"is_active": True,
|
||||
"type": FeeType.REGISTRATION_FEE
|
||||
},
|
||||
{
|
||||
"name": "Sorties périscolaires",
|
||||
"base_amount": "120.00",
|
||||
"description": "Sorties",
|
||||
"is_active": True,
|
||||
"type": FeeType.REGISTRATION_FEE
|
||||
},
|
||||
{
|
||||
"name": "Les colibris",
|
||||
"base_amount": "4500.00",
|
||||
"description": "TPS / PS / MS / GS",
|
||||
"is_active": True,
|
||||
"type": FeeType.TUITION_FEE
|
||||
},
|
||||
{
|
||||
"name": "Les butterflies",
|
||||
"base_amount": "5000.00",
|
||||
"description": "CP / CE1 / CE2 / CM1 / CM2",
|
||||
"is_active": True,
|
||||
"type": FeeType.TUITION_FEE
|
||||
}
|
||||
]
|
||||
|
||||
for fee_data in fees_data:
|
||||
Fee.objects.update_or_create(
|
||||
name=fee_data["name"],
|
||||
type=fee_data["type"],
|
||||
defaults=fee_data
|
||||
)
|
||||
|
||||
self.stdout.write(self.style.SUCCESS('Fees initialized or updated successfully'))
|
||||
|
||||
def create_or_update_discounts(self):
|
||||
discounts_data = [
|
||||
{
|
||||
"name": "Parrainage",
|
||||
"amount": "10.00",
|
||||
"description": "Réduction pour parrainage",
|
||||
"discount_type": DiscountType.PERCENT,
|
||||
"type": FeeType.TUITION_FEE
|
||||
},
|
||||
{
|
||||
"name": "Réinscription",
|
||||
"amount": "100.00",
|
||||
"description": "Réduction pour Réinscription",
|
||||
"discount_type": DiscountType.PERCENT,
|
||||
"type": FeeType.REGISTRATION_FEE
|
||||
}
|
||||
]
|
||||
|
||||
for discount_data in discounts_data:
|
||||
Discount.objects.update_or_create(
|
||||
name=discount_data["name"],
|
||||
type=discount_data["type"],
|
||||
discount_type=discount_data["discount_type"],
|
||||
defaults=discount_data
|
||||
)
|
||||
|
||||
self.stdout.write(self.style.SUCCESS('Discounts initialized or updated successfully'))
|
||||
|
||||
Reference in New Issue
Block a user