feat: taxa de serviço conticionado a configuração (que ainda não existe rs)

This commit is contained in:
2025-02-21 10:33:03 -03:00
parent 46f0900763
commit fdb9d9e453
11 changed files with 63 additions and 18 deletions

View File

@@ -117,6 +117,7 @@ Detalhes {{comanda.name}}
{% endif %}
</tr>
{% endfor %}
{% if config.taxa %}
<tr>
<td>
Taxa de serviço 10%
@@ -125,6 +126,8 @@ Detalhes {{comanda.name}}
R$ {{valores.taxa}}
</td>
</tr>
{% endif %}
{% if parcials%}
<td colspan="2" style="text-align: center;"><b>Pagamentos parciais</b></td>
{% endif %}
@@ -140,7 +143,11 @@ Detalhes {{comanda.name}}
<tfoot>
<tr>
{% if config.taxa %}
<td colspan="2" style="text-align: center;"><b>Total R$ {{valores.totalComTaxa}}</b></td>
{% else %}
<td colspan="2" style="text-align: center;"><b>Total R$ {{valores.totalSemTaxa}}</b></td>
{% endif %}
</tr>
</tfoot>
</table>
@@ -191,12 +198,16 @@ Detalhes {{comanda.name}}
<h2>Pagamento</h2>
<div style="display: flex; align-content: space-around; align-items: center; justify-self: center;gap: 50px;">
{% if config.taxa %}
<h1 id="first-total">R$ {{ valores.totalComTaxa }}</h1>
<h1 hidden id="totalComTaxa">R$ {{ valores.totalComTaxa }}</h1>
<h1 hidden id="totalSemTaxa">R$ {{ valores.totalSemTaxa }}</h1>
<div>
<input id="taxa" name="taxa" type="checkbox" value="True" label="Taxa de serviço" checked >Taxa de serviço
{% else %}
<h1 id="first-total">R$ {{ valores.totalSemTaxa }}</h1>
{% endif %}
</div>
</div>
<div>
@@ -268,7 +279,7 @@ Detalhes {{comanda.name}}
<form id="form-comanda" method="post" action="{% url 'addContaCliente' %}">
{% csrf_token %}
<h2>Adicionar na Conta</h2>
<h1>R$ {{ total }}</h1>
<h1>R$ {{ valores.totalSemTaxa }}</h1>
<div>
<input hidden type="text" name="valor-conta" value="{{ total }}">
<input hidden type="text" name="idComanda" value="{{ comanda.id }}">

View File

@@ -2,12 +2,16 @@ from decimal import Decimal
from django import template
from comandas.models import Comanda, ProductComanda
from clients.models import Client
from payments.models import Payments
register = template.Library()
@register.filter(name='total')
def filter_total(value):
config = {
'taxa': False
}
id = value
comanda_id = int(id)
totalParcial = Decimal(0)
@@ -21,9 +25,31 @@ def filter_total(value):
for produto in consumo:
total += produto.product.price
taxa = round(total * Decimal(0.1), 2)
total = (total + taxa) - totalParcial
total = (total + taxa) - totalParcial if config['taxa'] else total - totalParcial
return f'R$ {total}'
@register.filter(name='totalFiado')
def viewClient(clientId):
config = {
'taxa': False
}
client = Client.objects.get(id=int(clientId))
comandas = Comanda.objects.filter(client = client).filter(status = 'FIADO')
total = Decimal(0)
for comanda in comandas:
totalConsumo = 0
totalParcial = 0
consumo = ProductComanda.objects.filter(comanda=comanda)
parcial = Payments.objects.filter(comanda=comanda)
for p in parcial:
totalParcial += p.value
for produto in consumo:
totalConsumo += produto.product.price
total+= (totalConsumo - totalParcial)
total = total + round(total * Decimal(0.1), 2) if config['taxa'] else total
return total
@register.filter(name='groupUser')
def has_group(user, group_name):

View File

@@ -41,6 +41,9 @@ def somar(consumo:ProductComanda, comanda:Comanda):
@group_required(groupName='Garçom')
def viewComanda(request):
config = {
'taxa': False
}
id = request.GET.get('parametro')
comanda_id = int(id)
comanda = Comanda.objects.get(id=comanda_id)
@@ -60,7 +63,7 @@ def viewComanda(request):
if p.name == produto['nome'] and p.active == True:
products_ordenados.append(p)
valores = somar(consumo,comanda)
return render(request, 'viewcomanda.html', {'valores':valores,'parcials':parcial,'clients':clients,'comanda': comanda, 'consumo': consumo, 'products': products_ordenados,'mesas':mesas})
return render(request, 'viewcomanda.html', {'config':config, 'valores':valores,'parcials':parcial,'clients':clients,'comanda': comanda, 'consumo': consumo, 'products': products_ordenados,'mesas':mesas})
@group_required(groupName='Garçom')