From beb133ab971fa7344721988c8b0f5159ff3f7666 Mon Sep 17 00:00:00 2001 From: Yoan Le Clanche Date: Tue, 28 May 2019 18:02:33 +0200 Subject: [PATCH] Fix balance & fix crash when exporting user with birthdate < 1900, and add a subscription_fees field --- teleforma/models/crfpa.py | 4 ++-- teleforma/views/crfpa.py | 11 ++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/teleforma/models/crfpa.py b/teleforma/models/crfpa.py index 34ca3260..cccd91ab 100755 --- a/teleforma/models/crfpa.py +++ b/teleforma/models/crfpa.py @@ -223,7 +223,7 @@ class Student(Model): 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() @@ -240,7 +240,7 @@ class Student(Model): 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) diff --git a/teleforma/views/crfpa.py b/teleforma/views/crfpa.py index e3f93a5c..104b47a4 100644 --- a/teleforma/views/crfpa.py +++ b/teleforma/views/crfpa.py @@ -273,7 +273,10 @@ class UserXLSBook(object): 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) @@ -302,10 +305,11 @@ class UserXLSBook(object): 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 @@ -337,6 +341,7 @@ class UserXLSBook(object): {'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}, ] -- 2.39.5