diff --git a/gestaoRaul/comandas/__pycache__/htmx_views.cpython-313.pyc b/gestaoRaul/comandas/__pycache__/htmx_views.cpython-313.pyc index 26337a7..defa748 100644 Binary files a/gestaoRaul/comandas/__pycache__/htmx_views.cpython-313.pyc and b/gestaoRaul/comandas/__pycache__/htmx_views.cpython-313.pyc differ diff --git a/gestaoRaul/comandas/__pycache__/urls.cpython-313.pyc b/gestaoRaul/comandas/__pycache__/urls.cpython-313.pyc index c980ac8..499be1b 100644 Binary files a/gestaoRaul/comandas/__pycache__/urls.cpython-313.pyc and b/gestaoRaul/comandas/__pycache__/urls.cpython-313.pyc differ diff --git a/gestaoRaul/comandas/__pycache__/views.cpython-313.pyc b/gestaoRaul/comandas/__pycache__/views.cpython-313.pyc index 72e9039..9a4be23 100644 Binary files a/gestaoRaul/comandas/__pycache__/views.cpython-313.pyc and b/gestaoRaul/comandas/__pycache__/views.cpython-313.pyc differ diff --git a/gestaoRaul/comandas/htmx_views.py b/gestaoRaul/comandas/htmx_views.py index 7a4c1b8..92d6858 100644 --- a/gestaoRaul/comandas/htmx_views.py +++ b/gestaoRaul/comandas/htmx_views.py @@ -18,7 +18,12 @@ def somar(consumo:ProductComanda, comanda:Comanda): totalParcial += p.value for produto in consumo: total += Decimal(produto.product.price) - return total - totalParcial + valores = { + 'total':total, + 'parcial':totalParcial, + 'taxaTotal': round(total * Decimal(0.1), 2) + } + return valores def listProduct(request, comanda_id): product = request.GET.get("search-product") @@ -41,7 +46,8 @@ def addProduct(request, product_id, comanda_id): order = Order(id_comanda=comanda, id_product=product, productComanda=product_comanda, obs='') order.save() consumo = ProductComanda.objects.filter(comanda=comanda_id) - total = somar(consumo,comanda) + valores = somar(consumo,comanda) + total = valores['total'] - valores['parcial'] return render(request, "htmx_components/comandas/htmx_list_products_in_comanda.html",{'parcials':parcial,'consumo': consumo, 'total': total, 'comanda':comanda}) @group_required(groupName='Garçom') @@ -59,7 +65,8 @@ def removeProductComanda(request, productComanda_id): parcial = Payments.objects.filter(comanda=comanda) consumo = ProductComanda.objects.filter(comanda=comanda) product_comanda.delete() - total = somar(consumo, comanda) + valores = somar(consumo,comanda) + total = valores['total'] - valores['parcial'] return render(request, "htmx_components/comandas/htmx_list_products_in_comanda.html",{'parcials':parcial,'consumo': consumo, 'total': total, 'comanda':comanda}) @group_required(groupName='Garçom') @@ -83,7 +90,8 @@ 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 = somar(consumo, comanda) + valores = somar(consumo,comanda) + total = valores['total'] - valores['parcial'] pagamento = Payments(value=total, comanda=comanda, type_pay=typePayment,description='tipo de pagamento mokado') pagamento.save() comanda.status = 'CLOSED' diff --git a/gestaoRaul/comandas/templates/viewcomanda.html b/gestaoRaul/comandas/templates/viewcomanda.html index 7d84bdf..ad5f841 100644 --- a/gestaoRaul/comandas/templates/viewcomanda.html +++ b/gestaoRaul/comandas/templates/viewcomanda.html @@ -132,7 +132,7 @@ Detalhes {{comanda.name}} - Total R$ {{total}} + Total R$ {{total}} - Taxa de serviso {{taxa}} diff --git a/gestaoRaul/comandas/views.py b/gestaoRaul/comandas/views.py index fc3b87d..6f19940 100644 --- a/gestaoRaul/comandas/views.py +++ b/gestaoRaul/comandas/views.py @@ -29,7 +29,12 @@ def somar(consumo:ProductComanda, comanda:Comanda): totalParcial += p.value for produto in consumo: total += Decimal(produto.product.price) - return total - totalParcial + valores = { + 'total':total, + 'parcial':totalParcial, + 'taxaTotal': round(total * Decimal(0.1), 2) + } + return valores @group_required(groupName='Garçom') def viewComanda(request): @@ -51,8 +56,9 @@ def viewComanda(request): for p in products: if p.name == produto['nome'] and p.active == True: products_ordenados.append(p) - total = somar(consumo,comanda) - return render(request, 'viewcomanda.html', {'parcials':parcial,'clients':clients,'comanda': comanda, 'consumo': consumo, 'total': total, 'products': products_ordenados,'mesas':mesas}) + valores = somar(consumo,comanda) + total = valores['total'] - valores['parcial'] + return render(request, 'viewcomanda.html', {'taxa': valores['taxaTotal'],'parcials':parcial,'clients':clients,'comanda': comanda, 'consumo': consumo, 'total': total, 'products': products_ordenados,'mesas':mesas}) @group_required(groupName='Garçom') diff --git a/gestaoRaul/db.sqlite3 b/gestaoRaul/db.sqlite3 index a9cfccc..7c6cc53 100644 Binary files a/gestaoRaul/db.sqlite3 and b/gestaoRaul/db.sqlite3 differ diff --git a/gestaoRaul/gestaoRaul/__pycache__/settings.cpython-313.pyc b/gestaoRaul/gestaoRaul/__pycache__/settings.cpython-313.pyc index 6b2bfb0..f853361 100644 Binary files a/gestaoRaul/gestaoRaul/__pycache__/settings.cpython-313.pyc and b/gestaoRaul/gestaoRaul/__pycache__/settings.cpython-313.pyc differ diff --git a/gestaoRaul/gestaoRaul/__pycache__/urls.cpython-313.pyc b/gestaoRaul/gestaoRaul/__pycache__/urls.cpython-313.pyc index 531fc64..670b5e7 100644 Binary files a/gestaoRaul/gestaoRaul/__pycache__/urls.cpython-313.pyc and b/gestaoRaul/gestaoRaul/__pycache__/urls.cpython-313.pyc differ