diff --git a/gestaoRaul/balcao/templates/viewBalcao.html b/gestaoRaul/balcao/templates/viewBalcao.html
index 10afa09..7dd83b1 100644
--- a/gestaoRaul/balcao/templates/viewBalcao.html
+++ b/gestaoRaul/balcao/templates/viewBalcao.html
@@ -43,7 +43,7 @@
| {{item.product.name}} |
- R$ {{item.product.price}} |
+ R$ {{item.product.price}} |
|
diff --git a/gestaoRaul/comandas/__pycache__/htmx_views.cpython-310.pyc b/gestaoRaul/comandas/__pycache__/htmx_views.cpython-310.pyc
index c2cd271..c2f15ee 100644
Binary files a/gestaoRaul/comandas/__pycache__/htmx_views.cpython-310.pyc and b/gestaoRaul/comandas/__pycache__/htmx_views.cpython-310.pyc differ
diff --git a/gestaoRaul/comandas/__pycache__/urls.cpython-310.pyc b/gestaoRaul/comandas/__pycache__/urls.cpython-310.pyc
index 5962582..dd2bf1b 100644
Binary files a/gestaoRaul/comandas/__pycache__/urls.cpython-310.pyc and b/gestaoRaul/comandas/__pycache__/urls.cpython-310.pyc differ
diff --git a/gestaoRaul/comandas/__pycache__/views.cpython-310.pyc b/gestaoRaul/comandas/__pycache__/views.cpython-310.pyc
index 2064891..d3dacc0 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/htmx_views.py b/gestaoRaul/comandas/htmx_views.py
index 2204efc..849a4f6 100644
--- a/gestaoRaul/comandas/htmx_views.py
+++ b/gestaoRaul/comandas/htmx_views.py
@@ -1,3 +1,4 @@
+from decimal import Decimal
from django.http import JsonResponse
from django.shortcuts import render, redirect
@@ -9,6 +10,16 @@ from typePay.models import TypePay
from gestaoRaul.decorators import group_required
+def somar(consumo:ProductComanda, comanda:Comanda):
+ parcial = Payments.objects.filter(comanda=comanda)
+ totalParcial = Decimal(0)
+ total:Decimal = Decimal(0)
+ for p in parcial:
+ totalParcial += p.value
+ for produto in consumo:
+ total += Decimal(produto.product.price)
+ return total - totalParcial
+
def listProduct(request, comanda_id):
product = request.GET.get("search-product")
allProducts = Product.objects.filter(name__icontains=product)
@@ -25,21 +36,16 @@ def addProduct(request, product_id, comanda_id):
product_comanda.save()
product = Product.objects.get(id=product_id)
comanda = Comanda.objects.get(id=comanda_id)
- print(product.cuisine)
-
if product.cuisine == True:
order = Order(id_comanda=comanda, id_product=product, productComanda=product_comanda, obs='')
order.save()
consumo = ProductComanda.objects.filter(comanda=comanda_id)
- total = 0
- for produto in consumo:
- total += produto.product.price
+ total = somar(consumo,comanda)
return render(request, "htmx_components/htmx_list_products_in_comanda.html",{'consumo': consumo, 'total': total, 'comanda':comanda})
@group_required(groupName='Garçom')
def editOrders(request, productComanda_id, obs):
order = Order.objects.get(productComanda=productComanda_id)
- print(obs)
order.obs = obs
order.save()
return JsonResponse({'status': 'ok'})
@@ -50,11 +56,8 @@ def removeProductComanda(request, productComanda_id):
product_comanda = ProductComanda.objects.get(id=productComanda_id)
comanda = Comanda.objects.get(id= product_comanda.comanda.id)
consumo = ProductComanda.objects.filter(comanda=comanda)
-
product_comanda.delete()
- total = 0
- for produto in consumo:
- total += produto.product.price
+ total = somar(consumo, comanda)
return render(request, "htmx_components/htmx_list_products_in_comanda.html",{'consumo': consumo, 'total': total, 'comanda':comanda})
@group_required(groupName='Garçom')
@@ -78,11 +81,20 @@ def paymentComanda(request, comanda_id):
typePayment = TypePay.objects.get(id=1)
consumo = ProductComanda.objects.filter(comanda=comanda_id)
comanda = Comanda.objects.get(id=comanda_id)
- total = 0
- for produto in consumo:
- total += produto.product.price
+ total = somar(consumo, comanda)
pagamento = Payments(value=total, comanda=comanda, type_pay=typePayment,description='tipo de pagamento mokado')
pagamento.save()
comanda.status = 'CLOSED'
comanda.save()
return redirect('/comandas')
+
+@group_required(groupName='Gerente')
+def paymentParcial(request, comanda_id):
+ typePayment = TypePay.objects.get(id=1)
+ comanda = Comanda.objects.get(id=comanda_id)
+ value = Decimal(request.POST.get('value-parcial'))
+ print(value)
+ description = request.POST.get('name-parcial')
+ pagamento = Payments(value=value, comanda=comanda, type_pay=typePayment,description=description)
+ pagamento.save()
+ return redirect('/comandas')
diff --git a/gestaoRaul/comandas/templates/viewcomanda.html b/gestaoRaul/comandas/templates/viewcomanda.html
index cf001d4..0d01c21 100644
--- a/gestaoRaul/comandas/templates/viewcomanda.html
+++ b/gestaoRaul/comandas/templates/viewcomanda.html
@@ -117,14 +117,24 @@ Detalhes {{comanda.name}}
{% endif %}
{% endfor %}
+ {% for parcial in parcials %}
+
+ | {{parcial.datetime}} |
+ R$ -{{parcial.value}} |
+ {{parcial.description}} |
+
+ {% endfor %}
+
+
+
+
| Total R$ {{total}} |
-
-
+
@@ -186,6 +196,24 @@ Detalhes {{comanda.name}}
+
+
+