fiz um monte de coisa e criei um bug

This commit is contained in:
2025-01-15 11:04:27 -03:00
parent a2fd5d12e3
commit 43d9cd9c5b
20 changed files with 83 additions and 19 deletions

View File

@@ -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

View File

@@ -71,8 +71,11 @@
{% for product in products %}
{% if forloop.counter0 == 0 %}
<article name="productBox" id="productId-{{ product.id }}"
onclick="addProductClick({{product.id}} , {{comanda.id}})" style="background-color: #293552;">
<article
name="productBox"
id="productId-{{ product.id }}"
onclick="addProductClick({{product.id}} , {{comanda.id}})"
style="background-color: #293552;">
<p hidden id="{{forloop.counter0}}">{{product.id}}</p>
<p hidden id="comanda{{forloop.counter0}}">{{comanda.id}}</p>
{{product.name}} <br>
@@ -82,8 +85,11 @@
{% else %}
<article name="productBox" id="productId-{{ product.id }}"
onclick="addProductClick({{product.id}} , {{comanda.id}})" style="background-color: #293552;">
<article
name="productBox"
id="productId-{{ product.id }}"
onclick="addProductClick({{product.id}} , {{comanda.id}})"
style="background-color: #293552;">
{{product.name}} <br>
R$ {{product.price}}
</article>

View File

@@ -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'),