From: Guillaume Pellerin Date: Mon, 11 May 2015 22:58:44 +0000 (+0200) Subject: add payements to XLS export X-Git-Tag: 1.1~253 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=1156b2dc2715b65643c7b4bb72a23d844303f001;p=teleforma.git add payements to XLS export --- diff --git a/teleforma/admin.py b/teleforma/admin.py index 2fa3d4cb..bd7f5c00 100644 --- a/teleforma/admin.py +++ b/teleforma/admin.py @@ -72,9 +72,6 @@ class StudentAdmin(admin.ModelAdmin): def student_name(self, instance): return instance.user.last_name + ' ' + instance.user.first_name - def balance(self, instance): - return round(instance.total_payments - instance.total_fees, 2) - # def queryset(self, request): # qs = super(StudentAdmin, self).queryset(request) # qs = qs.annotate(models.Count('warehouse__amount')) diff --git a/teleforma/models/crfpa.py b/teleforma/models/crfpa.py index ccab7610..98f6e95a 100644 --- a/teleforma/models/crfpa.py +++ b/teleforma/models/crfpa.py @@ -162,6 +162,10 @@ class Student(Model): amount += payment.value return amount + @property + def balance(self): + return round(self.total_payments - self.total_fees, 2) + class Meta(MetaCore): db_table = app_label + '_' + 'student' verbose_name = _('Student') diff --git a/teleforma/views/crfpa.py b/teleforma/views/crfpa.py index 6c5b396b..bb6824cd 100644 --- a/teleforma/views/crfpa.py +++ b/teleforma/views/crfpa.py @@ -244,6 +244,11 @@ class UserXLSBook(object): row.write(12, profile.city) row.write(13, profile.telephone) row.write(14, user.date_joined.strftime("%d/%m/%Y")) + + row.write(15, student.total_payments) + row.write(16, student.total_fees) + row.write(17, student.balance) + return counter + 1 else: return counter @@ -264,7 +269,10 @@ class UserXLSBook(object): {'name':'CP', 'width':2500}, {'name':'VILLE', 'width':5000}, {'name':'TEL', 'width':5000}, - {'name':"Date d'inscription", 'width':5000} + {'name':"Date d'inscription", 'width':5000}, + {'name':"Total paiements", 'width':4000}, + {'name':"Total reductions", 'width':4000}, + {'name':"Balance", 'width':4000}, ] i = 0 for col in cols: