feat: Harmonisation des fees / ajout de type de réduction / mise à jour

du calcul [#18]
This commit is contained in:
N3WT DE COMPET
2025-01-21 20:39:36 +01:00
parent 8d1a41e269
commit 5462306a60
11 changed files with 169 additions and 194 deletions

View File

@ -73,40 +73,33 @@ class PaymentOptions(models.IntegerChoices):
FOUR_TIME_PAYMENT = 1, _('Paiement en 4 fois')
TEN_TIME_PAYMENT = 2, _('Paiement en 10 fois')
class DiscountType(models.IntegerChoices):
CURRENCY = 0, 'Currency'
PERCENT = 1, 'Percent'
class FeeType(models.IntegerChoices):
REGISTRATION_FEE = 0, 'Registration Fee'
TUITION_FEE = 1, 'Tuition Fee'
class Discount(models.Model):
name = models.CharField(max_length=255, unique=True)
amount = models.DecimalField(max_digits=10, decimal_places=2)
amount = models.DecimalField(max_digits=10, decimal_places=2, default=0)
description = models.TextField(blank=True)
discount_type = models.IntegerField(choices=DiscountType.choices, default=DiscountType.CURRENCY)
def __str__(self):
return self.name
class Fee(models.Model):
name = models.CharField(max_length=255, unique=True)
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')
description = models.TextField(blank=True)
payment_option = models.IntegerField(choices=PaymentOptions.choices, default=PaymentOptions.SINGLE_PAYMENT)
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)
currency = models.CharField(max_length=3, default='EUR')
type = models.IntegerField(choices=FeeType.choices, default=FeeType.REGISTRATION_FEE)
def __str__(self):
return self.name
class TuitionFee(models.Model):
name = models.CharField(max_length=255, unique=True)
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
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é.'))