mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-28 23:43:22 +00:00
96 lines
3.4 KiB
Python
96 lines
3.4 KiB
Python
from django.core.management.base import BaseCommand
|
|
from Auth.models import Profile
|
|
from School.models import Fee, Discount, FeeType, DiscountType, Establishment
|
|
|
|
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):
|
|
establishment = Establishment.objects.get(name="N3WT")
|
|
fees_data = [
|
|
{
|
|
"name": "Frais d'inscription",
|
|
"base_amount": "150.00",
|
|
"description": "Montant de base",
|
|
"is_active": True,
|
|
"type": FeeType.REGISTRATION_FEE,
|
|
"establishment": establishment
|
|
},
|
|
{
|
|
"name": "Matériel",
|
|
"base_amount": "85.00",
|
|
"description": "Livres / jouets",
|
|
"is_active": True,
|
|
"type": FeeType.REGISTRATION_FEE,
|
|
"establishment": establishment
|
|
},
|
|
{
|
|
"name": "Sorties périscolaires",
|
|
"base_amount": "120.00",
|
|
"description": "Sorties",
|
|
"is_active": True,
|
|
"type": FeeType.REGISTRATION_FEE,
|
|
"establishment": establishment
|
|
},
|
|
{
|
|
"name": "Les colibris",
|
|
"base_amount": "4500.00",
|
|
"description": "TPS / PS / MS / GS",
|
|
"is_active": True,
|
|
"type": FeeType.TUITION_FEE,
|
|
"establishment": establishment
|
|
},
|
|
{
|
|
"name": "Les butterflies",
|
|
"base_amount": "5000.00",
|
|
"description": "CP / CE1 / CE2 / CM1 / CM2",
|
|
"is_active": True,
|
|
"type": FeeType.TUITION_FEE,
|
|
"establishment": establishment
|
|
}
|
|
]
|
|
|
|
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):
|
|
establishment = Establishment.objects.get(name="N3WT")
|
|
discounts_data = [
|
|
{
|
|
"name": "Parrainage",
|
|
"amount": "10.00",
|
|
"description": "Réduction pour parrainage",
|
|
"discount_type": DiscountType.PERCENT,
|
|
"type": FeeType.TUITION_FEE,
|
|
"establishment": establishment
|
|
},
|
|
{
|
|
"name": "Réinscription",
|
|
"amount": "100.00",
|
|
"description": "Réduction pour Réinscription",
|
|
"discount_type": DiscountType.PERCENT,
|
|
"type": FeeType.REGISTRATION_FEE,
|
|
"establishment": establishment
|
|
}
|
|
]
|
|
|
|
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'))
|
|
|