diff --git a/gestaoRaul/comandas/__pycache__/htmx_views.cpython-313.pyc b/gestaoRaul/comandas/__pycache__/htmx_views.cpython-313.pyc index defa748..b9f030f 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__/views.cpython-313.pyc b/gestaoRaul/comandas/__pycache__/views.cpython-313.pyc index 9a4be23..b702c5a 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 92d6858..8bf6db5 100644 --- a/gestaoRaul/comandas/htmx_views.py +++ b/gestaoRaul/comandas/htmx_views.py @@ -21,7 +21,9 @@ def somar(consumo:ProductComanda, comanda:Comanda): valores = { 'total':total, 'parcial':totalParcial, - 'taxaTotal': round(total * Decimal(0.1), 2) + 'taxa': round(total * Decimal(0.1), 2), + 'totalSemTaxa':total - totalParcial, + 'totalComTaxa': round((total - totalParcial)+(total * Decimal(0.1)),2) } return valores @@ -47,8 +49,8 @@ def addProduct(request, product_id, comanda_id): order.save() consumo = ProductComanda.objects.filter(comanda=comanda_id) 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}) + + return render(request, "htmx_components/comandas/htmx_list_products_in_comanda.html",{'valores':valores,'parcials':parcial,'consumo': consumo,'comanda':comanda}) @group_required(groupName='Garçom') def editOrders(request, productComanda_id, obs): @@ -66,8 +68,7 @@ def removeProductComanda(request, productComanda_id): consumo = ProductComanda.objects.filter(comanda=comanda) product_comanda.delete() 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}) + return render(request, "htmx_components/comandas/htmx_list_products_in_comanda.html",{'valores': valores,'parcials':parcial,'consumo': consumo, 'comanda':comanda}) @group_required(groupName='Garçom') def closeComanda(request, comanda_id): @@ -87,13 +88,18 @@ def reopenComanda(request, comanda_id): @group_required(groupName='Gerente') def paymentComanda(request, comanda_id): + taxa = request.POST.get('taxa',False) typePayment = TypePay.objects.get(id=1) consumo = ProductComanda.objects.filter(comanda=comanda_id) comanda = Comanda.objects.get(id=comanda_id) 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() + if taxa == 'True': + pagamento = Payments(value=valores['totalComTaxa'], comanda=comanda, type_pay=typePayment,description='tipo de pagamento mokado') + pagamento.save() + else: + pagamento = Payments(value=valores['totalSemTaxa'], comanda=comanda, type_pay=typePayment,description='tipo de pagamento mokado') + pagamento.save() + comanda.status = 'CLOSED' comanda.save() return redirect('/comandas') @@ -103,7 +109,6 @@ 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() diff --git a/gestaoRaul/comandas/templates/viewcomanda.html b/gestaoRaul/comandas/templates/viewcomanda.html index ad5f841..02d60ef 100644 --- a/gestaoRaul/comandas/templates/viewcomanda.html +++ b/gestaoRaul/comandas/templates/viewcomanda.html @@ -117,6 +117,14 @@ Detalhes {{comanda.name}} {% endif %} {% endfor %} + + + Taxa de serviço 10% + + + R$ {{valores.taxa}} + + {% if parcials%} Pagamentos parciais {% endif %} @@ -132,7 +140,7 @@ Detalhes {{comanda.name}} - Total R$ {{total}} - Taxa de serviso {{taxa}} + Total R$ {{valores.totalComTaxa}} @@ -178,8 +186,19 @@ Detalhes {{comanda.name}} diff --git a/gestaoRaul/comandas/views.py b/gestaoRaul/comandas/views.py index 6f19940..3ac9f3c 100644 --- a/gestaoRaul/comandas/views.py +++ b/gestaoRaul/comandas/views.py @@ -32,7 +32,9 @@ def somar(consumo:ProductComanda, comanda:Comanda): valores = { 'total':total, 'parcial':totalParcial, - 'taxaTotal': round(total * Decimal(0.1), 2) + 'taxa': round(total * Decimal(0.1), 2), + 'totalSemTaxa':total - totalParcial, + 'totalComTaxa': round((total - totalParcial)+(total * Decimal(0.1)),2) } return valores @@ -57,8 +59,7 @@ def viewComanda(request): if p.name == produto['nome'] and p.active == True: products_ordenados.append(p) 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}) + return render(request, 'viewcomanda.html', {'valores':valores,'parcials':parcial,'clients':clients,'comanda': comanda, 'consumo': consumo, 'products': products_ordenados,'mesas':mesas}) @group_required(groupName='Garçom') @@ -96,7 +97,7 @@ def addContaCliente(request): return redirect('comandas') def notificacao(request): - fifteen_hours_ago = timezone.now() - timezone.timedelta(hours=15) + fifteen_hours_ago = timezone.now() - timezone.timedelta(hours=12) ordersPronto = Order.objects.filter(queue__gte=fifteen_hours_ago, finished__isnull=False) grupoGarcom = request.user.groups.filter(name='Garçom').exists() diff --git a/gestaoRaul/db.sqlite3 b/gestaoRaul/db.sqlite3 index 7c6cc53..05cd144 100644 Binary files a/gestaoRaul/db.sqlite3 and b/gestaoRaul/db.sqlite3 differ diff --git a/gestaoRaul/templates/htmx_components/comandas/htmx_list_products_in_comanda.html b/gestaoRaul/templates/htmx_components/comandas/htmx_list_products_in_comanda.html index 5a08512..6a747eb 100644 --- a/gestaoRaul/templates/htmx_components/comandas/htmx_list_products_in_comanda.html +++ b/gestaoRaul/templates/htmx_components/comandas/htmx_list_products_in_comanda.html @@ -1,58 +1,71 @@ {% load static %} - Produto - Preço - + Produto + Preço + {% for item in consumo%} - - {{item.product.name}} - {% if item.product.cuisine == True %} - + + {{item.product.name}} + {% if item.product.cuisine == True %} + - - {% endif %} + + {% endif %} - - R$ {{item.product.price}} + +R$ {{item.product.price}} - {% if comanda.status != 'OPEN'%} - {% else %} - - - - + +{% if comanda.status != 'OPEN'%} +{% else %} + + + + {% endif %} -{% endfor %} -{% if parcials%} -Pagamentos parciais -{% endif %} -{% for parcial in parcials %} - - {{parcial.description}} ás {{parcial.datetime|date:"H:i"}} - R$ -{{parcial.value}} - -{% endfor %} + {% endfor %} + + + Taxa de serviço 10% + + + R$ {{valores.taxa}} + + + {% if parcials%} + Pagamentos parciais + {% endif %} + {% for parcial in parcials %} + + {{parcial.description}} ás {{parcial.datetime|date:"H:i"}} + R$ -{{parcial.value}} + + {% endfor %} + + + + - - Total R$ {{total}} - - - + + Total R$ {{valores.totalComTaxa}} + + + diff --git a/gestaoRaul/templates/static/comandas/js/viewcomanda.js b/gestaoRaul/templates/static/comandas/js/viewcomanda.js index f41da52..4890495 100644 --- a/gestaoRaul/templates/static/comandas/js/viewcomanda.js +++ b/gestaoRaul/templates/static/comandas/js/viewcomanda.js @@ -247,9 +247,20 @@ function addProductComanda(productId,comandaId, cuisine) { } +function taxa(){ + var taxa = document.getElementById('taxa') + var total = document.getElementById('first-total') + var totalComTaxa = document.getElementById('totalComTaxa').innerHTML + var totalSemTaxa = document.getElementById('totalSemTaxa').innerHTML + if (taxa.checked){ + total.innerHTML = totalComTaxa + }else{ + total.innerHTML = totalSemTaxa + } +} -// document.getElementById('openModal').addEventListener('click', openModal); +document.getElementById('taxa').addEventListener("change", taxa); // document.getElementById('productForm').addEventListener('submit', function(event) { // event.preventDefault();