소스 검색

Negativos para los gastos en informe.

Celestino Rey 1 년 전
부모
커밋
8ec591da27
3개의 변경된 파일25개의 추가작업 그리고 4개의 파일을 삭제
  1. 9 2
      src/finanzas/views.py
  2. 8 0
      src/templates/informe_cuenta.html
  3. 8 2
      src/templates/informe_cuenta_pdf.html

+ 9 - 2
src/finanzas/views.py

@@ -523,13 +523,18 @@ def informe_cuenta(request):
         for mov in movimientos:
             if mov.cuenta_origen == cuenta:
                 saldo -= mov.monto
+                tipo = 'Gasto'
             elif mov.cuenta_destino == cuenta:
                 saldo += mov.monto
+                tipo = 'Ingreso'
 
             movimientos_con_saldo.append({
                 'fecha': mov.fecha,
                 'descripcion': mov.descripcion,
                 'monto': mov.monto,
+                'tipo': tipo,
+                'desde': mov.cuenta_origen.nombre if mov.cuenta_origen else 'N/A',
+                'hasta': mov.cuenta_destino.nombre if mov.cuenta_destino else 'N/A',
                 'saldo_despues': saldo,
             })
 
@@ -596,15 +601,17 @@ def informe_cuenta_pdf(request):
     for mov in movimientos:
         if mov.cuenta_origen == cuenta:
             saldo -= mov.monto
-            tipo = 'Salida'
+            tipo = 'Gasto'
         elif mov.cuenta_destino == cuenta:
             saldo += mov.monto
-            tipo = 'Entrada'
+            tipo = 'Ingreso'
         else:
             tipo = 'Otro'
 
         historial.append({
             'fecha': mov.fecha,
+            'desde': mov.cuenta_origen.nombre if mov.cuenta_origen else 'N/A',
+            'hasta': mov.cuenta_destino.nombre if mov.cuenta_destino else 'N/A',
             'descripcion': mov.descripcion,
             'monto': mov.monto,
             'tipo': tipo,

+ 8 - 0
src/templates/informe_cuenta.html

@@ -35,6 +35,8 @@
             <thead>
                 <tr>
                     <th>Fecha</th>
+                    <th>Desde</th>
+                    <th>Hasta</th>
                     <th>Descripción</th>
                     <th class="text-end">Monto (€)</th>
                     <th class="text-end">Saldo después (€)</th>
@@ -44,8 +46,14 @@
                 {% for item in movimientos_con_saldo %}
                 <tr>
                     <td>{{ item.fecha|date:"Y-m-d H:i" }}</td>
+                    <td>{{ item.desde }}</td>
+                    <td>{{ item.hasta }}</td>
                     <td>{{ item.descripcion }}</td>
+                    {% if item.tipo == 'Ingreso' %}
                     <td class="text-end">{{ item.monto|floatformat:2 }}</td>
+                    {% else %}
+                    <td class="text-end">-{{ item.monto|floatformat:2 }}</td>
+                    {% endif %}
                     <td class="text-end">{{ item.saldo_despues|floatformat:2 }}</td>
                 </tr>
                 {% endfor %}

+ 8 - 2
src/templates/informe_cuenta_pdf.html

@@ -19,8 +19,9 @@
         <thead>
             <tr>
                 <th class="text-left">Fecha</th>
+                <th class="text-left">Desde</th>
+                <th class="text-left">Hasta</th>
                 <th class="text-left">Descripción</th>
-                <th class="text-left">Tipo</th>
                 <th>Monto (€)</th>
                 <th>Saldo después (€)</th>
             </tr>
@@ -29,9 +30,14 @@
             {% for item in historial %}
             <tr>
                 <td class="text-left">{{ item.fecha|date:"Y-m-d H:i" }}</td>
+                <td class="text-left">{{ item.desde }}</td>
+                <td class="text-left">{{ item.hasta }}</td>
                 <td class="text-left">{{ item.descripcion }}</td>
-                <td class="text-left">{{ item.tipo }}</td>
+                {% if item.tipo == 'Ingreso' %}
                 <td>{{ item.monto|floatformat:2 }}</td>
+                {% else %}
+                <td>-{{ item.monto|floatformat:2 }}</td>
+                {% endif %}
                 <td>{{ item.saldo_despues|floatformat:2 }}</td>
             </tr>
             {% endfor %}