]> git.parisson.com Git - teleforma.git/commitdiff
Fix balance & fix crash when exporting user with birthdate < 1900, and add a subscrip...
authorYoan Le Clanche <yoan@ellington.pilotsystems.net>
Tue, 28 May 2019 16:02:33 +0000 (18:02 +0200)
committerYoan Le Clanche <yoan@ellington.pilotsystems.net>
Tue, 28 May 2019 16:02:33 +0000 (18:02 +0200)
teleforma/models/crfpa.py
teleforma/views/crfpa.py

index 34ca3260afedfffc1ad574119f87a2917403b841..cccd91abb5047c245304357585452c6bd0a0b0d5 100755 (executable)
@@ -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)
index e3f93a5c4494212d324bfa894f469ffe45549df5..104b47a471e5fc8bef11a14bc26325c885031a8f 100644 (file)
@@ -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},
                 ]