diff --git a/gestaoRaul/balcao/__pycache__/htmx_views.cpython-310.pyc b/gestaoRaul/balcao/__pycache__/htmx_views.cpython-310.pyc index b1f4518..408ff84 100644 Binary files a/gestaoRaul/balcao/__pycache__/htmx_views.cpython-310.pyc and b/gestaoRaul/balcao/__pycache__/htmx_views.cpython-310.pyc differ diff --git a/gestaoRaul/balcao/__pycache__/views.cpython-310.pyc b/gestaoRaul/balcao/__pycache__/views.cpython-310.pyc index 20f1b17..ce1761e 100644 Binary files a/gestaoRaul/balcao/__pycache__/views.cpython-310.pyc and b/gestaoRaul/balcao/__pycache__/views.cpython-310.pyc differ diff --git a/gestaoRaul/balcao/htmx_views.py b/gestaoRaul/balcao/htmx_views.py index c718c30..e5ae67d 100644 --- a/gestaoRaul/balcao/htmx_views.py +++ b/gestaoRaul/balcao/htmx_views.py @@ -5,6 +5,7 @@ from django.db.models import Count, F from comandas.models import Comanda, ProductComanda +from mesas.models import Mesa from products.models import Product from payments.models import Payments from typePay.models import TypePay @@ -66,7 +67,12 @@ def removeProductBalcao(request, productComanda_id): def paymentBalcao(request, comanda_id): typePayment = TypePay.objects.get(id=1) consumo = ProductComanda.objects.filter(comanda=comanda_id) - vendasBalcao = Comanda.objects.get(name='VENDAS BALCAO') + try: + vendasBalcao = Comanda.objects.get(name='VENDAS BALCAO') + except: + mesa = Mesa.objects.get(id=1) + vendasBalcao = Comanda(name='VENDAS BALCAO', mesa=mesa, user=request.user, status='CLOSED') + vendasBalcao.save() comanda = Comanda.objects.get(name='VENDA BALCÃO') total = 0 for produto in consumo: @@ -77,3 +83,7 @@ def paymentBalcao(request, comanda_id): pagamento.save() return redirect('viewBalcao') + + +#"GET /balcao/addProductBalcaoTeclado83/1/1/ HTTP/1.1" 200 747 +#"GET /balcao/addProductBalcaoTeclado83/13/1/ HTTP/1.1" 500 133103 \ No newline at end of file diff --git a/gestaoRaul/balcao/templates/viewBalcao.html b/gestaoRaul/balcao/templates/viewBalcao.html index f9b3e89..238fee7 100644 --- a/gestaoRaul/balcao/templates/viewBalcao.html +++ b/gestaoRaul/balcao/templates/viewBalcao.html @@ -71,8 +71,11 @@ {% for product in products %} {% if forloop.counter0 == 0 %} -
+
{{product.name}}
@@ -82,8 +85,11 @@ {% else %} -
+
{{product.name}}
R$ {{product.price}}
diff --git a/gestaoRaul/balcao/views.py b/gestaoRaul/balcao/views.py index e3856f1..4a22a76 100644 --- a/gestaoRaul/balcao/views.py +++ b/gestaoRaul/balcao/views.py @@ -2,13 +2,22 @@ from django.shortcuts import render from comandas.models import Comanda, ProductComanda from products.models import Product +from mesas.models import Mesa from django.db.models import Count, F +from django.contrib.auth.models import User + def viewBalcao(request): + try: + comanda = Comanda.objects.get(name='VENDA BALCÃO') + except: + user = User.objects.get(id=request.user.id) + mesa = Mesa.objects.get(id=1) + comanda = Comanda(name='VENDA BALCÃO', mesa=mesa, user=user,status='CLOSED') + comanda.save() - comanda = Comanda.objects.get(name='VENDA BALCÃO') consumo = ProductComanda.objects.filter(comanda=comanda.id) produtos_mais_vendidos = list(ProductComanda.objects.values('product').annotate( quantidade=Count('product'), diff --git a/gestaoRaul/comandas/__pycache__/models.cpython-310.pyc b/gestaoRaul/comandas/__pycache__/models.cpython-310.pyc index 429c867..0bc7c4a 100644 Binary files a/gestaoRaul/comandas/__pycache__/models.cpython-310.pyc and b/gestaoRaul/comandas/__pycache__/models.cpython-310.pyc differ diff --git a/gestaoRaul/comandas/__pycache__/views.cpython-310.pyc b/gestaoRaul/comandas/__pycache__/views.cpython-310.pyc index 8419fad..2d275c6 100644 Binary files a/gestaoRaul/comandas/__pycache__/views.cpython-310.pyc and b/gestaoRaul/comandas/__pycache__/views.cpython-310.pyc differ diff --git a/gestaoRaul/comandas/migrations/0004_comanda_user.py b/gestaoRaul/comandas/migrations/0004_comanda_user.py new file mode 100644 index 0000000..8f2d86b --- /dev/null +++ b/gestaoRaul/comandas/migrations/0004_comanda_user.py @@ -0,0 +1,22 @@ +# Generated by Django 5.1.4 on 2025-01-15 12:43 + +import django.db.models.deletion +from django.conf import settings +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('comandas', '0003_comanda_status_alter_productcomanda_product'), + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ] + + operations = [ + migrations.AddField( + model_name='comanda', + name='user', + field=models.ForeignKey(blank=True, default=1, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL), + preserve_default=False, + ), + ] diff --git a/gestaoRaul/comandas/migrations/__pycache__/0004_comanda_user.cpython-310.pyc b/gestaoRaul/comandas/migrations/__pycache__/0004_comanda_user.cpython-310.pyc new file mode 100644 index 0000000..c238195 Binary files /dev/null and b/gestaoRaul/comandas/migrations/__pycache__/0004_comanda_user.cpython-310.pyc differ diff --git a/gestaoRaul/comandas/models.py b/gestaoRaul/comandas/models.py index f626245..ee79a2d 100644 --- a/gestaoRaul/comandas/models.py +++ b/gestaoRaul/comandas/models.py @@ -1,4 +1,6 @@ from django.db import models +from django.contrib.auth.models import User + from clients.models import Client from products.models import Product @@ -8,6 +10,7 @@ from typePay.models import TypePay class Comanda(models.Model): id = models.AutoField(primary_key=True) mesa = models.ForeignKey(Mesa, on_delete=models.CASCADE) + user = models.ForeignKey(User, on_delete=models.CASCADE, null=False, blank=True) type_pay = models.ForeignKey(TypePay, on_delete=models.SET_NULL, null=True) dt_open = models.DateTimeField(auto_now_add=True) dt_close = models.DateTimeField(null=True, blank=True) diff --git a/gestaoRaul/comandas/views.py b/gestaoRaul/comandas/views.py index 81838d3..c96de85 100644 --- a/gestaoRaul/comandas/views.py +++ b/gestaoRaul/comandas/views.py @@ -40,7 +40,7 @@ def createComanda(request): name = request.POST.get('name-comanda') mesa_id = int(request.POST.get('select-mesa')[0]) mesa = Mesa.objects.get(id=mesa_id) - comanda = Comanda(name=name, mesa=mesa) + comanda = Comanda(name=name, mesa=mesa, user=request.user) comanda.save() return redirect('comandas') diff --git a/gestaoRaul/db - Copia (2).sqlite3 b/gestaoRaul/db - Copia (2).sqlite3 new file mode 100644 index 0000000..cf57560 Binary files /dev/null and b/gestaoRaul/db - Copia (2).sqlite3 differ diff --git a/gestaoRaul/db - Copia.sqlite3 b/gestaoRaul/db - Copia.sqlite3 new file mode 100644 index 0000000..81b0fd0 Binary files /dev/null and b/gestaoRaul/db - Copia.sqlite3 differ diff --git a/gestaoRaul/db.sqlite3 b/gestaoRaul/db.sqlite3 index dced9fa..0015b85 100644 Binary files a/gestaoRaul/db.sqlite3 and b/gestaoRaul/db.sqlite3 differ diff --git a/gestaoRaul/home/__pycache__/views.cpython-310.pyc b/gestaoRaul/home/__pycache__/views.cpython-310.pyc index 1f92df8..d42a3bd 100644 Binary files a/gestaoRaul/home/__pycache__/views.cpython-310.pyc and b/gestaoRaul/home/__pycache__/views.cpython-310.pyc differ diff --git a/gestaoRaul/home/views.py b/gestaoRaul/home/views.py index c47f3f1..71e97c1 100644 --- a/gestaoRaul/home/views.py +++ b/gestaoRaul/home/views.py @@ -14,15 +14,19 @@ from gestaoRaul.decorators import group_required @group_required(groupName='Gerente') def home(request): - total_pagamentos = Payments.objects.aggregate(total=Sum('value'))['total'] - qdt_pagamentos = Payments.objects.aggregate(total=Count('value'))['total'] - pagamentos = Payments.objects.all() - ticekMedio = total_pagamentos / qdt_pagamentos + try: + total_pagamentos = Payments.objects.aggregate(total=Sum('value'))['total'] + qdt_pagamentos = Payments.objects.aggregate(total=Count('value'))['total'] + pagamentos = Payments.objects.all() + ticekMedio = total_pagamentos / qdt_pagamentos + + produtos_mais_vendidos = ProductComanda.objects.values('product').annotate( + quantidade=Count('product'), + nome=F('product__name') ).order_by('-quantidade')[:5] + return render(request, 'home.html', {'total_pagamentos': total_pagamentos, 'pagamentos': pagamentos, 'qdt_pagamentos': qdt_pagamentos, 'produtos_mais_vendidos': produtos_mais_vendidos, 'ticekMedio': ticekMedio, }) + except: + return render(request, 'home.html') - produtos_mais_vendidos = ProductComanda.objects.values('product').annotate( - quantidade=Count('product'), - nome=F('product__name') ).order_by('-quantidade')[:5] - return render(request, 'home.html', {'total_pagamentos': total_pagamentos, 'pagamentos': pagamentos, 'qdt_pagamentos': qdt_pagamentos, 'produtos_mais_vendidos': produtos_mais_vendidos, 'ticekMedio': ticekMedio, }) @group_required(groupName='Gerente') def chartCuisine(request): diff --git a/gestaoRaul/orders/templates/orders.html b/gestaoRaul/orders/templates/orders.html index fc627ab..d079b1e 100644 --- a/gestaoRaul/orders/templates/orders.html +++ b/gestaoRaul/orders/templates/orders.html @@ -48,6 +48,7 @@

{{order.id_product.name}}

{{order.obs}}

{{order.id_comanda.name}} - {{order.id_comanda.mesa.name}}

+

Atendente: {{order.id_comanda.user.first_name}}

{{order.queue|date:"D"}} {{order.queue|date:"d/m/Y - H:i"}}