|
|
@@ -370,9 +370,14 @@ def informe_categoria(request):
|
|
|
fecha__range=(fecha_inicio_dt, fecha_fin_dt)
|
|
|
).order_by('fecha').aggregate(total=Sum('monto'))
|
|
|
|
|
|
+ saldo_inicial = Movimiento.objects.filter(
|
|
|
+ categoria=categoria,
|
|
|
+ usuario=request.user,
|
|
|
+ fecha__lt=fecha_inicio_dt
|
|
|
+ ).aggregate(total=Sum('monto'))['total'] or Decimal('0.00')
|
|
|
|
|
|
movimientos_con_saldo = []
|
|
|
- saldo_acumulado = Decimal('0.00')
|
|
|
+ saldo_acumulado = saldo_inicial
|
|
|
for mov in movimientos:
|
|
|
if mov.tipo == 'Ingreso':
|
|
|
saldo_acumulado += mov.monto
|
|
|
@@ -393,6 +398,7 @@ def informe_categoria(request):
|
|
|
'movimientos_con_saldo': movimientos_con_saldo,
|
|
|
'fecha_inicio': fecha_inicio_str,
|
|
|
'fecha_fin': fecha_fin_str,
|
|
|
+ 'saldo_inicial': saldo_inicial
|
|
|
}
|
|
|
|
|
|
return render(request, 'informe_categoria.html', context)
|