mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-28 23:43:22 +00:00
feat: Mise à jour du modèle (possibilité d'associer une réduciton à un
frais d'inscription [#18]
This commit is contained in:
@ -68,6 +68,11 @@ class Planning(models.Model):
|
||||
def __str__(self):
|
||||
return f'Planning for {self.level} of {self.school_class.atmosphere_name}'
|
||||
|
||||
class PaymentOptions(models.IntegerChoices):
|
||||
SINGLE_PAYMENT = 0, _('Paiement en une seule fois')
|
||||
FOUR_TIME_PAYMENT = 1, _('Paiement en 4 fois')
|
||||
TEN_TIME_PAYMENT = 2, _('Paiement en 10 fois')
|
||||
|
||||
class Discount(models.Model):
|
||||
name = models.CharField(max_length=255, unique=True)
|
||||
amount = models.DecimalField(max_digits=10, decimal_places=2)
|
||||
@ -78,25 +83,23 @@ class Discount(models.Model):
|
||||
|
||||
class Fee(models.Model):
|
||||
name = models.CharField(max_length=255, unique=True)
|
||||
amount = models.DecimalField(max_digits=10, decimal_places=2)
|
||||
description = models.TextField(blank=True)
|
||||
base_amount = models.DecimalField(max_digits=10, decimal_places=2, default=0)
|
||||
currency = models.CharField(max_length=3, default='EUR')
|
||||
discounts = models.ManyToManyField('Discount', blank=True)
|
||||
payment_option = models.IntegerField(choices=PaymentOptions, default=PaymentOptions.SINGLE_PAYMENT)
|
||||
is_active = models.BooleanField(default=True)
|
||||
updated_at = models.DateTimeField(auto_now=True)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
class TuitionFee(models.Model):
|
||||
class PaymentOptions(models.IntegerChoices):
|
||||
SINGLE_PAYMENT = 0, _('Paiement en une seule fois')
|
||||
FOUR_TIME_PAYMENT = 1, _('Paiement en 4 fois')
|
||||
TEN_TIME_PAYMENT = 2, _('Paiement en 10 fois')
|
||||
|
||||
name = models.CharField(max_length=255, unique=True)
|
||||
description = models.TextField(blank=True)
|
||||
base_amount = models.DecimalField(max_digits=10, decimal_places=2)
|
||||
base_amount = models.DecimalField(max_digits=10, decimal_places=2, default=0)
|
||||
currency = models.CharField(max_length=3, default='EUR')
|
||||
discounts = models.ManyToManyField('Discount', blank=True)
|
||||
validity_start_date = models.DateField()
|
||||
validity_end_date = models.DateField()
|
||||
payment_option = models.IntegerField(choices=PaymentOptions, default=PaymentOptions.SINGLE_PAYMENT)
|
||||
is_active = models.BooleanField(default=True)
|
||||
updated_at = models.DateTimeField(auto_now=True)
|
||||
@ -107,16 +110,3 @@ class TuitionFee(models.Model):
|
||||
def clean(self):
|
||||
if self.validity_end_date <= self.validity_start_date:
|
||||
raise ValidationError(_('La date de fin de validité doit être après la date de début de validité.'))
|
||||
|
||||
def calculate_final_amount(self):
|
||||
amount = self.base_amount
|
||||
|
||||
# Apply fees (supplements and taxes)
|
||||
# for fee in self.fees.all():
|
||||
# amount += fee.amount
|
||||
|
||||
# Apply discounts
|
||||
for discount in self.discounts.all():
|
||||
amount -= discount.amount
|
||||
|
||||
return amount
|
||||
|
||||
Reference in New Issue
Block a user