feat: valor total divida cliente

This commit is contained in:
2025-02-19 17:08:11 -03:00
parent d2ab8212b9
commit 46f0900763
4 changed files with 18 additions and 5 deletions

View File

@@ -16,6 +16,7 @@ Comandas
<body>
<div style="justify-self: center;">
<h4>{{client.name}}</h4>
<h4>R$ {{total}}</h4>
</div>
<div class=" ">

View File

@@ -1,9 +1,11 @@
from decimal import Decimal
from django.shortcuts import render, redirect
from django.contrib.auth.models import User
from comandas.models import Comanda
from comandas.models import Comanda, ProductComanda
from gestaoRaul.decorators import group_required
from clients.models import Client
from payments.models import Payments
@@ -13,11 +15,21 @@ def clients(request):
return render(request, 'clients.html', {'clients': clients})
def viewClient(request,clientId):
id = int(clientId)
print(id)
client = Client.objects.get(id=id)
client = Client.objects.get(id=int(clientId))
comandas = Comanda.objects.filter(client = client).filter(status = 'FIADO')
return render(request, 'viewclient.html', {'client': client, 'comandas': comandas})
total = Decimal(0)
for comanda in comandas:
totalConsumo = 0
totalParcial = 0
consumo = ProductComanda.objects.filter(comanda=comanda)
parcial = Payments.objects.filter(comanda=comanda)
for p in parcial:
totalParcial += p.value
for produto in consumo:
totalConsumo += produto.product.price
total+= (totalConsumo - totalParcial)
total+= round(total * Decimal(0.1), 2)
return render(request, 'viewclient.html', {'total': total, 'client': client, 'comandas': comandas})
@group_required(groupName='Gerente')

Binary file not shown.