diff --git a/gestaoRaul/clients/__pycache__/views.cpython-313.pyc b/gestaoRaul/clients/__pycache__/views.cpython-313.pyc index 0355210..8e07ad0 100644 Binary files a/gestaoRaul/clients/__pycache__/views.cpython-313.pyc and b/gestaoRaul/clients/__pycache__/views.cpython-313.pyc differ diff --git a/gestaoRaul/clients/templates/viewclient.html b/gestaoRaul/clients/templates/viewclient.html index 454df85..12dddc5 100644 --- a/gestaoRaul/clients/templates/viewclient.html +++ b/gestaoRaul/clients/templates/viewclient.html @@ -16,6 +16,7 @@ Comandas

{{client.name}}

+

R$ {{total}}

diff --git a/gestaoRaul/clients/views.py b/gestaoRaul/clients/views.py index eace8f2..a597eb9 100644 --- a/gestaoRaul/clients/views.py +++ b/gestaoRaul/clients/views.py @@ -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') diff --git a/gestaoRaul/db.sqlite3 b/gestaoRaul/db.sqlite3 index 89c6f9e..fddbf6b 100644 Binary files a/gestaoRaul/db.sqlite3 and b/gestaoRaul/db.sqlite3 differ