Masse salariale: sous-total et arrondis
authorJean-Philippe Caissy <jpcaissy@piji.ca>
Wed, 21 Mar 2012 22:22:28 +0000 (17:22 -0500)
committerJean-Philippe Caissy <jpcaissy@piji.ca>
Wed, 21 Mar 2012 22:22:28 +0000 (17:22 -0500)
project/rh/masse_salariale.py
project/rh/templates/rh/rapports/masse_salariale.html
project/rh/views.py

index 2fcb9e7..fd50a20 100644 (file)
@@ -147,6 +147,9 @@ class MasseSalariale():
                         self.annee),
         )
 
+        grand_total = 0.0
+        grand_total_euro = 0.0
+
         for item in self.employes.values():
             dossiers = item['dossiers']
             remuns = item['remunerations']
@@ -399,8 +402,18 @@ class MasseSalariale():
                             ),
             }
 
+            for key in item_rapport.keys():
+                if type(item_rapport[key]) in (type(float()), type(long())):
+                    item_rapport[key] = round(item_rapport[key], 2)
+            grand_total += masse_salariale
+            grand_total_euro += masse_salariale_euro.montant * regime * (
+                                    date_delta.days / rapport_date_delta.days
+                            )
+
             self.rapport.append(item_rapport)
 
+        self.grand_totaux = (grand_total, grand_total_euro)
+
     def build_qs(self, prefix, date_debut, date_fin):
         date_debut_null = \
                 Q(**{"%s%s__isnull" % (prefix, KEY_DATE_DEBUT): True})
index c4515ca..737b41f 100644 (file)
         {% endfor %}
     </tr>
 {% endfor %}{% endspaceless %}
+    <tr>
+        <td colspan="{{ colspan }}" style="text-align:right;font-weight:bold;">
+            TOTAL : 
+        </td>
+        <td>{{ total }}</td>
+        <td>{{ total_euro }}</td>
+    </tr>
 </table>
-
 {% endblock %}
index 07c68a8..6553732 100644 (file)
@@ -222,6 +222,9 @@ def rapports_masse_salariale(request):
             h = SortHeaders(request, headers, order_field_type="ot",
                     not_sortable=c['header_keys'], order_field="o")
             c['headers'] = list(h.headers())
+            c['total'] = masse.grand_totaux[0]
+            c['total_euro'] = masse.grand_totaux[1]
+            c['colspan'] = len(c['header_keys']) - 2
 
     return render_to_response('rh/rapports/masse_salariale.html', c, RequestContext(request))