diff --git a/gestaoRaul/comandas/__pycache__/urls.cpython-313.pyc b/gestaoRaul/comandas/__pycache__/urls.cpython-313.pyc index f14f58b..0486c93 100644 Binary files a/gestaoRaul/comandas/__pycache__/urls.cpython-313.pyc and b/gestaoRaul/comandas/__pycache__/urls.cpython-313.pyc differ diff --git a/gestaoRaul/comandas/__pycache__/views.cpython-313.pyc b/gestaoRaul/comandas/__pycache__/views.cpython-313.pyc index ece44a5..0bdbc2b 100644 Binary files a/gestaoRaul/comandas/__pycache__/views.cpython-313.pyc and b/gestaoRaul/comandas/__pycache__/views.cpython-313.pyc differ diff --git a/gestaoRaul/comandas/templates/comandas.html b/gestaoRaul/comandas/templates/comandas.html index 90a07ae..d9b678a 100644 --- a/gestaoRaul/comandas/templates/comandas.html +++ b/gestaoRaul/comandas/templates/comandas.html @@ -52,7 +52,8 @@ Comandas {% csrf_token %}

Abrir Comanda


- + {% for mesa in mesas %} diff --git a/gestaoRaul/comandas/templates/viewcomanda.html b/gestaoRaul/comandas/templates/viewcomanda.html index 41307cf..55ab4d6 100644 --- a/gestaoRaul/comandas/templates/viewcomanda.html +++ b/gestaoRaul/comandas/templates/viewcomanda.html @@ -38,11 +38,9 @@ Detalhes {{comanda.name}} {% else %} - {% endif %} - {% if comanda.status != 'OPEN'%} - - @@ -185,10 +175,9 @@ Detalhes {{comanda.name}} {% csrf_token %}

Editar Comanda

-
- - + {% for mesa in mesas %} @@ -205,20 +194,29 @@ Detalhes {{comanda.name}} diff --git a/gestaoRaul/comandas/urls.py b/gestaoRaul/comandas/urls.py index 5ba273a..6a05852 100644 --- a/gestaoRaul/comandas/urls.py +++ b/gestaoRaul/comandas/urls.py @@ -9,6 +9,7 @@ urlpatterns = [ path('viewcomanda/', views.viewComanda, name='viewcomanda'), path('createComanda/', views.createComanda, name='createComanda'), path('editComanda/', views.editComanda, name='editComanda'), + path('addContaCliente/', views.addContaCliente, name='addContaCliente'), diff --git a/gestaoRaul/comandas/views.py b/gestaoRaul/comandas/views.py index 8c193ef..74a2304 100644 --- a/gestaoRaul/comandas/views.py +++ b/gestaoRaul/comandas/views.py @@ -1,7 +1,9 @@ +from decimal import Decimal from django.shortcuts import render, redirect from django.db.models import Count, F from comandas.models import Comanda, ProductComanda +from clients.models import Client from products.models import Product from mesas.models import Mesa from gestaoRaul.decorators import group_required @@ -21,6 +23,7 @@ def viewComanda(request): comanda = Comanda.objects.get(id=comanda_id) consumo = ProductComanda.objects.filter(comanda=comanda_id) mesas = Mesa.objects.all() + clients = Client.objects.filter(active=True) produtos_mais_vendidos = list(ProductComanda.objects.values('product').annotate( quantidade=Count('product'), @@ -36,7 +39,7 @@ def viewComanda(request): for produto in consumo: total += produto.product.price - return render(request, 'viewcomanda.html', {'comanda': comanda, 'consumo': consumo, 'total': total, 'products': products_ordenados,'mesas':mesas}) + return render(request, 'viewcomanda.html', {'clients':clients,'comanda': comanda, 'consumo': consumo, 'total': total, 'products': products_ordenados,'mesas':mesas}) @group_required(groupName='Garçom') @@ -58,3 +61,18 @@ def editComanda(request): comanda.save() return redirect('comandas') +@group_required(groupName='Gerente') +def addContaCliente(request): + + comandaId = int(request.POST.get('idComanda')) + clientId = int(request.POST.get('select-client')) + valor = float(request.POST.get('valor-conta').replace(',','.')) + comanda = Comanda.objects.get(id=comandaId) + client = Client.objects.get(id=clientId) + client.debt = client.debt + Decimal(valor) + comanda.client = client + comanda.status = 'CLOSED' + client.save() + comanda.save() + return redirect('comandas') + diff --git a/gestaoRaul/db.sqlite3 b/gestaoRaul/db.sqlite3 index 57a8645..f930d35 100644 Binary files a/gestaoRaul/db.sqlite3 and b/gestaoRaul/db.sqlite3 differ diff --git a/gestaoRaul/templates/static/comandas/js/viewcomanda.js b/gestaoRaul/templates/static/comandas/js/viewcomanda.js index 51959dd..efb632f 100644 --- a/gestaoRaul/templates/static/comandas/js/viewcomanda.js +++ b/gestaoRaul/templates/static/comandas/js/viewcomanda.js @@ -34,6 +34,18 @@ function modal_payment_comanda() { recebido.focus() } + +function modal_conta_client() { + document.getElementById('conta-cliente').style.display = 'block'; + // recebido = document.getElementById('recebido') + // recebido.focus() +} + +function close_modal_conta_client() { + document.getElementById('conta-cliente').style.display = 'none'; +} + + function close_modal_payment_comanda() { document.getElementById('payment-comanda').style.display = 'none'; }