diff --git a/gestaoRaul/balcao/__pycache__/htmx_views.cpython-312.pyc b/gestaoRaul/balcao/__pycache__/htmx_views.cpython-312.pyc
index 539cf43..2762430 100644
Binary files a/gestaoRaul/balcao/__pycache__/htmx_views.cpython-312.pyc and b/gestaoRaul/balcao/__pycache__/htmx_views.cpython-312.pyc differ
diff --git a/gestaoRaul/balcao/__pycache__/views.cpython-312.pyc b/gestaoRaul/balcao/__pycache__/views.cpython-312.pyc
index 82fab5a..e5fe050 100644
Binary files a/gestaoRaul/balcao/__pycache__/views.cpython-312.pyc and b/gestaoRaul/balcao/__pycache__/views.cpython-312.pyc differ
diff --git a/gestaoRaul/balcao/htmx_views.py b/gestaoRaul/balcao/htmx_views.py
index 567e7ac..9b608e0 100644
--- a/gestaoRaul/balcao/htmx_views.py
+++ b/gestaoRaul/balcao/htmx_views.py
@@ -16,23 +16,13 @@ from gestaoRaul.decorators import group_required
def listProductBalcao(request, comanda_id, search_product):
comanda_id = request.GET.get("id-comanda-balcao")
if search_product == '*':
- produtos_mais_vendidos = list(ProductComanda.objects.values('product').annotate(
- quantidade=Count('product'),
- nome=F('product__name') ).order_by('-quantidade'))
- products = Product.objects.all()
- products_ordenados = []
-
- for produto in produtos_mais_vendidos:
- for p in products:
- if p.active == True and p.name == produto['nome']:
- products_ordenados.append(p)
-
+ products_ordenados = ProductComanda.maisVendidos()
return render(request, "htmx_components/htmx_list_products_balcao.html", {"products": products_ordenados,'comanda_id':comanda_id})
else:
product = search_product
products = Product.objects.filter(name__icontains=product, active=True)
- return render(request, "htmx_components/htmx_list_products_balcao.html", {"products": products,'comanda_id':comanda_id})
+ return render(request, "htmx_components/htmx_list_products_balcao.html", {"products": products[:15],'comanda_id':comanda_id})
@group_required(groupName='Garçom')
diff --git a/gestaoRaul/balcao/templates/viewBalcao.html b/gestaoRaul/balcao/templates/viewBalcao.html
index 5d1958e..7682493 100644
--- a/gestaoRaul/balcao/templates/viewBalcao.html
+++ b/gestaoRaul/balcao/templates/viewBalcao.html
@@ -72,30 +72,32 @@
{% for product in products %}
{% if forloop.counter0 == 0 %}
-
- {{product.id}}
- {{comanda.id}}
- {{product.name}}
-
- R$ {{product.price}}
-
+
+ {{product.id}}
+ {{comanda.id}}
+ {{product.name}}
+
+ R$ {{product.price}}
+
- {% else %}
+ {% else %}
-
- {{product.name}}
- R$ {{product.price}}
-
+
+ {{product.name}}
+ R$ {{product.price}}
+
{% endif %}
diff --git a/gestaoRaul/balcao/views.py b/gestaoRaul/balcao/views.py
index 7d6c6f7..13b02ad 100644
--- a/gestaoRaul/balcao/views.py
+++ b/gestaoRaul/balcao/views.py
@@ -20,17 +20,7 @@ def viewBalcao(request):
comanda.save()
consumo = ProductComanda.objects.filter(comanda=comanda.id)
- produtos_mais_vendidos = list(ProductComanda.objects.values('product').annotate(
- quantidade=Count('product'),
- nome=F('product__name') ).order_by('-quantidade'))
- products = Product.objects.all()
- products_ordenados = []
-
- for produto in produtos_mais_vendidos:
- for p in products:
- if p.name == produto['nome'] and p.active == True:
- products_ordenados.append(p)
-
+ products_ordenados = ProductComanda.maisVendidos()
total = 0
for produto in consumo:
total += produto.product.price
diff --git a/gestaoRaul/comandas/__pycache__/models.cpython-312.pyc b/gestaoRaul/comandas/__pycache__/models.cpython-312.pyc
index ccdf436..f02c04a 100644
Binary files a/gestaoRaul/comandas/__pycache__/models.cpython-312.pyc and b/gestaoRaul/comandas/__pycache__/models.cpython-312.pyc differ
diff --git a/gestaoRaul/comandas/__pycache__/views.cpython-312.pyc b/gestaoRaul/comandas/__pycache__/views.cpython-312.pyc
index 7480791..b055aa7 100644
Binary files a/gestaoRaul/comandas/__pycache__/views.cpython-312.pyc and b/gestaoRaul/comandas/__pycache__/views.cpython-312.pyc differ
diff --git a/gestaoRaul/comandas/models.py b/gestaoRaul/comandas/models.py
index 4b853c0..6e6bf59 100644
--- a/gestaoRaul/comandas/models.py
+++ b/gestaoRaul/comandas/models.py
@@ -1,5 +1,6 @@
from django.db import models
from django.contrib.auth.models import User
+from django.db.models import Count, F
@@ -7,7 +8,6 @@ from clients.models import Client
from products.models import Product
from mesas.models import Mesa
from typePay.models import TypePay
-# from payments.models import Payments
class Comanda(models.Model):
id = models.AutoField(primary_key=True)
@@ -32,3 +32,15 @@ class ProductComanda(models.Model):
return self.comanda.name + " - " + self.product.name
+ def maisVendidos():
+ produtos_mais_vendidos = list(ProductComanda.objects.values('product').annotate(
+ quantidade=Count('product'),
+ nome=F('product__name') ).order_by('-quantidade'))
+
+ products = Product.objects.all()
+ products_ordenados = []
+ for produto in produtos_mais_vendidos:
+ for p in products:
+ if p.name == produto['nome'] and p.active == True:
+ products_ordenados.append(p)
+ return products_ordenados[:15]
\ No newline at end of file
diff --git a/gestaoRaul/comandas/templates/viewcomanda.html b/gestaoRaul/comandas/templates/viewcomanda.html
index c13ab05..8d6ff2b 100644
--- a/gestaoRaul/comandas/templates/viewcomanda.html
+++ b/gestaoRaul/comandas/templates/viewcomanda.html
@@ -203,9 +203,12 @@ Detalhes {{comanda.name}}
{% for product in products %}
-
- {{product.name}}
- R$ {{product.price}}
+
+
{{product.name}}
+
R$ {{product.price}}
{% endfor %}
diff --git a/gestaoRaul/comandas/views.py b/gestaoRaul/comandas/views.py
index 7e36336..0720dbf 100644
--- a/gestaoRaul/comandas/views.py
+++ b/gestaoRaul/comandas/views.py
@@ -32,24 +32,12 @@ def viewComanda(request):
comanda_id = int(id)
comanda = Comanda.objects.get(id=comanda_id)
consumo = ProductComanda.objects.filter(comanda=comanda_id)
- # consumo[0].product.
parcial = Payments.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'),
- nome=F('product__name') ).order_by('-quantidade'))
-
- products = Product.objects.all()
- products_ordenados = []
- for produto in produtos_mais_vendidos:
- for p in products:
- if p.name == produto['nome'] and p.active == True:
- products_ordenados.append(p)
+ products_ordenados = ProductComanda.maisVendidos()
valores = somar(consumo,comanda)
-
- return render(request, 'viewcomanda.html', {'config':config, 'valores':valores,'parcials':parcial,'clients':clients,'comanda': comanda, 'consumo': consumo, 'products': products_ordenados,'mesas':mesas})
+ return render(request, 'viewcomanda.html', {'config':config, 'valores':valores,'parcials':parcial,'clients':clients,'comanda': comanda, 'consumo': consumo, 'products': products_ordenados[:15],'mesas':mesas})
@group_required(groupName='Garçom')
@@ -153,6 +141,7 @@ def closeComanda(request, comanda_id):
@group_required(groupName='Garçom')
def addProduct(request, product_id, comanda_id):
+ print('chamouuuuuuuuuuu')
config = {
'taxa': False
}
@@ -202,9 +191,12 @@ def addProduct(request, product_id, comanda_id):
def listProduct(request, comanda_id, product):
- allProducts = Product.objects.filter(name__icontains=product)
+ if product == '*':
+ allProducts = ProductComanda.maisVendidos()
+ else:
+ allProducts = Product.objects.filter(name__icontains=product)
products = []
for p in allProducts:
if p.active == True:
products.append(p)
- return render(request, "htmx_components/comandas/htmx_list_products.html", {"products": products,'comanda_id':comanda_id})
\ No newline at end of file
+ return render(request, "htmx_components/comandas/htmx_list_products.html", {"products": products[:15],'comanda_id':comanda_id})
\ No newline at end of file
diff --git a/gestaoRaul/db.sqlite3 b/gestaoRaul/db.sqlite3
index c60fbf7..8aac7fd 100644
Binary files a/gestaoRaul/db.sqlite3 and b/gestaoRaul/db.sqlite3 differ
diff --git a/gestaoRaul/gestaoRaul/__pycache__/settings.cpython-312.pyc b/gestaoRaul/gestaoRaul/__pycache__/settings.cpython-312.pyc
index 09a277c..15b452e 100644
Binary files a/gestaoRaul/gestaoRaul/__pycache__/settings.cpython-312.pyc and b/gestaoRaul/gestaoRaul/__pycache__/settings.cpython-312.pyc differ
diff --git a/gestaoRaul/products/__pycache__/models.cpython-312.pyc b/gestaoRaul/products/__pycache__/models.cpython-312.pyc
index c9fe22e..08d5592 100644
Binary files a/gestaoRaul/products/__pycache__/models.cpython-312.pyc and b/gestaoRaul/products/__pycache__/models.cpython-312.pyc differ
diff --git a/gestaoRaul/products/__pycache__/urls.cpython-312.pyc b/gestaoRaul/products/__pycache__/urls.cpython-312.pyc
index 065ea79..d068639 100644
Binary files a/gestaoRaul/products/__pycache__/urls.cpython-312.pyc and b/gestaoRaul/products/__pycache__/urls.cpython-312.pyc differ
diff --git a/gestaoRaul/products/__pycache__/views.cpython-312.pyc b/gestaoRaul/products/__pycache__/views.cpython-312.pyc
index 00c27ce..b9caa9a 100644
Binary files a/gestaoRaul/products/__pycache__/views.cpython-312.pyc and b/gestaoRaul/products/__pycache__/views.cpython-312.pyc differ
diff --git a/gestaoRaul/products/models.py b/gestaoRaul/products/models.py
index aee417e..eaa822f 100644
--- a/gestaoRaul/products/models.py
+++ b/gestaoRaul/products/models.py
@@ -2,6 +2,7 @@ from django.db import models
from categories.models import Categories
+
# Create your models here.
class Product(models.Model):
id = models.AutoField(primary_key=True)
@@ -15,4 +16,4 @@ class Product(models.Model):
active = models.BooleanField(default=True)
def __str__(self) -> str:
- return self.name
\ No newline at end of file
+ return f"{self.id} - {self.name} - {self.price} - {self.category} - {self.cuisine} - {self.active} "
diff --git a/gestaoRaul/products/templates/products.html b/gestaoRaul/products/templates/products.html
index c15ba14..faae47f 100644
--- a/gestaoRaul/products/templates/products.html
+++ b/gestaoRaul/products/templates/products.html
@@ -19,6 +19,7 @@ Produtos
+
Cardápio Digital
@@ -36,6 +37,8 @@ Produtos
| {{product.name}} |
R$ {{product.price}} |
{{product.quantity}} |
+ {{product.image}} |
+
{{product.category.name}} |
@@ -86,15 +89,20 @@ Produtos
|