Browse Source

Add remaining amount to pay on invoice

Fabs 10 years ago
parent
commit
9197f2e650

+ 7 - 0
coin/billing/models.py

@@ -55,6 +55,13 @@ class Invoice(models.Model):
         return total.quantize(Decimal('0.01'))
     amount_paid.short_description = 'Montant payé'
 
+    def amount_remaining_to_pay(self):
+        """
+        Calcul le montant restant à payer
+        """
+        return self.amount() - self.amount_paid()
+    amount_remaining_to_pay.short_description = 'Reste à payer'
+
     def has_owner(self, uid):
         "Check if passed uid (ex gmajax) is owner of the invoice"
         return (self.member and self.member.ldap_cn and

+ 2 - 0
coin/members/templates/members/invoices.html

@@ -9,6 +9,7 @@
             <th>Numéro</th>
             <th>Date</th>
             <th>Montant</th>
+            <th>Reste à payer</th>
             <th></th>
         </tr>
     </thead>
@@ -18,6 +19,7 @@
             <td><a href="{% url 'billing:invoice' id=invoice.number %}">{{ invoice.number }}</a></td>
             <td>{{ invoice.date }}</td>
             <td>{{ invoice.amount }}</td>
+            <td{% if invoice.amount_remaining_to_pay > 0 %} class="unpaid"{% endif %}>{{ invoice.amount_remaining_to_pay }}</td>
             <td><a href="{% url 'billing:invoice_pdf' id=invoice.number %}">PDF</a></td>
         </tr>
         {% endfor %}

+ 5 - 1
coin/static/css/illyse.css

@@ -136,7 +136,7 @@ table.full-width {
 }
 
 
-/* Invoice */
+/* Invoices */
 #invoice_details .period {
     color:#999;
 }
@@ -145,3 +145,7 @@ table.full-width {
     font-weight:bold;
     border-top:2px solid #DDD;
 }
+
+#member_invoices td.unpaid {
+    color:red;
+}