mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-29 07:53:23 +00:00
27 lines
975 B
Python
27 lines
975 B
Python
from django.core.management.base import BaseCommand
|
|
from School.models import PaymentMode, PaymentModeType, FeeType, Establishment
|
|
|
|
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):
|
|
establishment = Establishment.objects.get(name="N3WT")
|
|
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,
|
|
'establishment': establishment
|
|
}
|
|
)
|
|
|
|
self.stdout.write(self.style.SUCCESS('Payment Modes initialized or updated successfully')) |