def update_balance(self):
old = self.balance
- new = round(self.total_payments - self.total_fees, 2)
+ new = round(self.total_payments - self.total_fees + self.total_paybacks, 2)
if old != new:
self.balance = new
self.save()
def update_balance_signal(sender, instance, *args, **kwargs):
if sender is Student:
instance.update_balance()
- elif sender in (Discount, OptionalFee, Payment):
+ elif sender in (Discount, OptionalFee, Payment, Payback):
instance.student.update_balance()
signals.post_save.connect(update_balance_signal)
row.write(11, profile.city)
row.write(12, profile.telephone)
if profile.birthday:
- row.write(13, profile.birthday.strftime("%d/%m/%Y"))
+ try:
+ row.write(13, profile.birthday.strftime("%d/%m/%Y"))
+ except ValueError:
+ row.write(13, 'erreur')
row.write(14, student.level)
row.write(20, student.balance)
row.write(21, student.total_paybacks)
- row.write(22, student.fascicule)
+ row.write(22, student.subscription_fees)
+ row.write(23, student.fascicule)
- i = 23
+ i = 24
for month in months_choices:
row.write(i, payment_per_month[month[0]])
i += 1
{'name':"Prix formation net", 'width':4000},
{'name':"Balance", 'width':4000},
{'name':"Total remboursement", 'width':4000},
+ {'name': "Frais d'inscription", 'width': 4000},
{'name':"Envoi des fascicules", 'width':3500},
]