mirror of
https://github.com/welton89/RRBEC.git
synced 2026-04-05 13:35:42 +00:00
ordem add produtos na comanda
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -8,7 +8,11 @@ from typePay.models import TypePay
|
||||
|
||||
def listProduct(request, comanda_id):
|
||||
product = request.GET.get("search-product")
|
||||
products = Product.objects.filter(name__icontains=product)
|
||||
allProducts = Product.objects.filter(name__icontains=product)
|
||||
products = []
|
||||
for p in allProducts:
|
||||
if p.active == True:
|
||||
products.append(p)
|
||||
return render(request, "htmx_components/htmx_list_products.html", {"products": products,'comanda_id':comanda_id})
|
||||
|
||||
def addProduct(request, product_id, comanda_id):
|
||||
|
||||
@@ -21,7 +21,7 @@ Detalhes {{comanda.name}}
|
||||
<body>
|
||||
<div class="grid-container" >
|
||||
<div>
|
||||
<button class="primary" id="openModal"
|
||||
<button class="primary" id="openModal" onclick="openModal()"
|
||||
{% if comanda.status != 'OPEN'%}
|
||||
disabled
|
||||
{% endif %}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
from django.shortcuts import render, redirect
|
||||
from django.db.models import Count, F
|
||||
|
||||
from comandas.models import Comanda, ProductComanda
|
||||
from products.models import Product
|
||||
@@ -17,12 +18,23 @@ def viewComanda(request):
|
||||
comanda_id = int(id)
|
||||
comanda = Comanda.objects.get(id=comanda_id)
|
||||
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)
|
||||
total = 0
|
||||
|
||||
for produto in consumo:
|
||||
total += produto.product.price
|
||||
|
||||
return render(request, 'viewcomanda.html', {'comanda': comanda, 'consumo': consumo, 'total': total, 'products': products})
|
||||
return render(request, 'viewcomanda.html', {'comanda': comanda, 'consumo': consumo, 'total': total, 'products': products_ordenados})
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user