feat: taxa de serviso part1

This commit is contained in:
2025-02-17 17:10:43 -03:00
parent e6beb6f4b5
commit aac7f57fbe
9 changed files with 22 additions and 8 deletions

View File

@@ -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'

View File

@@ -132,7 +132,7 @@ Detalhes {{comanda.name}}
<tfoot>
<tr>
<td colspan="2" style="text-align: center;"><b>Total R$ {{total}}</b></td>
<td colspan="2" style="text-align: center;"><b>Total R$ {{total}} - Taxa de serviso {{taxa}}</b></td>
</tr>
</tfoot>
</table>

View File

@@ -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')

Binary file not shown.