mirror of
https://github.com/welton89/RRBEC.git
synced 2026-04-05 05:25:40 +00:00
feat: taxa de serviço conticionado a configuração (que ainda não existe rs)
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -1,5 +1,7 @@
|
||||
{% extends "base.html" %}
|
||||
{% load static %}
|
||||
{% load custom_filter_tag %}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -34,7 +36,7 @@ Clientes
|
||||
|
||||
<tr>
|
||||
<td ><a id="name-{{client.id}}" href="{% url 'viewClient' client.id %}">{{client.name}}</a></td>
|
||||
<td id="debt-{{client.id}}" >R$ {{client.debt}}</td>
|
||||
<td id="debt-{{client.id}}" >R$ {{client.id | totalFiado}}</td>
|
||||
<td class="hide-on-mobile" id="contact-{{client.id}}" >{{client.contact}}</td>
|
||||
<td hidden id="active-{{client.id}}" >{{client.active}}</td>
|
||||
<td>
|
||||
|
||||
@@ -16,7 +16,7 @@ Comandas
|
||||
<body>
|
||||
<div style="justify-self: center;">
|
||||
<h4>{{client.name}}</h4>
|
||||
<h4>R$ {{total}}</h4>
|
||||
<h4>R$ {{client.id | totalFiado}}</h4>
|
||||
</div>
|
||||
|
||||
<div class=" ">
|
||||
|
||||
@@ -15,21 +15,24 @@ def clients(request):
|
||||
return render(request, 'clients.html', {'clients': clients})
|
||||
|
||||
def viewClient(request,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+= round(total * Decimal(0.1), 2)
|
||||
return render(request, 'viewclient.html', {'total': total, 'client': client, 'comandas': comandas})
|
||||
# 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 render(request, 'viewclient.html', {'client': client, 'comandas': comandas})
|
||||
|
||||
|
||||
@group_required(groupName='Gerente')
|
||||
|
||||
Binary file not shown.
@@ -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 }}">
|
||||
|
||||
Binary file not shown.
@@ -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):
|
||||
|
||||
@@ -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')
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user