from django.contrib.admin.helpers import ActionForm
from django import forms
+
class PeriodListFilter(SimpleListFilter):
title = _('period')
model = Discount
extra = 1
+class PaybackInline(admin.StackedInline):
+ model = Payback
+ extra = 1
+
class StudentInline(admin.StackedInline):
model = Student
extra = 1
model = Student
exclude = ['options']
filter_horizontal = ['trainings']
- inlines = [PaymentInline, OptionalFeeInline, DiscountInline]
+ inlines = [PaymentInline, OptionalFeeInline, DiscountInline, PaybackInline]
search_fields = ['user__first_name', 'user__last_name', 'user__username']
list_filter = ['user__is_active', 'is_subscribed', 'platform_only', PeriodListFilter,
'trainings', 'iej', 'procedure', 'written_speciality', 'oral_speciality',
amount -= discount.value
return amount
+ @property
+ def total_paybacks(self):
+ amount = 0
+ for payback in self.paybacks.all():
+ amount -= payback.value
+ return amount
+
@property
def balance(self):
return round(self.total_payments - self.total_fees, 2)
db_table = app_label + '_' + 'optional_fees'
verbose_name = _("Optional fees")
verbose_name_plural = _("Optional fees")
+
+
+class Payback(models.Model):
+ "an payback for a student subscription"
+
+ student = models.ForeignKey(Student, related_name='paybacks', verbose_name=_('student'))
+ value = models.FloatField(_('amount'), help_text='€')
+ description = models.CharField(_('description'), max_length=255, blank=True)
+
+ class Meta(MetaCore):
+ db_table = app_label + '_' + 'paybacks'
+ verbose_name = _("Payback")
+ verbose_name_plural = _("Paybacks")
row.write(18, student.total_payments)
row.write(19, student.total_fees)
row.write(20, student.balance)
+ row.write(21, student.total_paybacks)
payments = student.payments.all()
- i = 21
+ i = 22
for month in months_choices:
payment = payments.filter(month=month[0])
if payment:
{'name':"Total paiements", 'width':4000},
{'name':"Prix formation net", 'width':4000},
{'name':"Balance", 'width':4000},
+ {'name':"Total remboursement", 'width':4000},
]
for month in months_choices: