mirror of
https://github.com/welton89/RRBEC.git
synced 2026-04-05 13:35:42 +00:00
feat: taxa de serviço part2
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -21,7 +21,9 @@ def somar(consumo:ProductComanda, comanda:Comanda):
|
|||||||
valores = {
|
valores = {
|
||||||
'total':total,
|
'total':total,
|
||||||
'parcial':totalParcial,
|
'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
|
return valores
|
||||||
|
|
||||||
@@ -47,8 +49,8 @@ def addProduct(request, product_id, comanda_id):
|
|||||||
order.save()
|
order.save()
|
||||||
consumo = ProductComanda.objects.filter(comanda=comanda_id)
|
consumo = ProductComanda.objects.filter(comanda=comanda_id)
|
||||||
valores = 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})
|
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')
|
@group_required(groupName='Garçom')
|
||||||
def editOrders(request, productComanda_id, obs):
|
def editOrders(request, productComanda_id, obs):
|
||||||
@@ -66,8 +68,7 @@ def removeProductComanda(request, productComanda_id):
|
|||||||
consumo = ProductComanda.objects.filter(comanda=comanda)
|
consumo = ProductComanda.objects.filter(comanda=comanda)
|
||||||
product_comanda.delete()
|
product_comanda.delete()
|
||||||
valores = somar(consumo,comanda)
|
valores = somar(consumo,comanda)
|
||||||
total = valores['total'] - valores['parcial']
|
return render(request, "htmx_components/comandas/htmx_list_products_in_comanda.html",{'valores': valores,'parcials':parcial,'consumo': consumo, 'comanda':comanda})
|
||||||
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')
|
@group_required(groupName='Garçom')
|
||||||
def closeComanda(request, comanda_id):
|
def closeComanda(request, comanda_id):
|
||||||
@@ -87,13 +88,18 @@ def reopenComanda(request, comanda_id):
|
|||||||
|
|
||||||
@group_required(groupName='Gerente')
|
@group_required(groupName='Gerente')
|
||||||
def paymentComanda(request, comanda_id):
|
def paymentComanda(request, comanda_id):
|
||||||
|
taxa = request.POST.get('taxa',False)
|
||||||
typePayment = TypePay.objects.get(id=1)
|
typePayment = TypePay.objects.get(id=1)
|
||||||
consumo = ProductComanda.objects.filter(comanda=comanda_id)
|
consumo = ProductComanda.objects.filter(comanda=comanda_id)
|
||||||
comanda = Comanda.objects.get(id=comanda_id)
|
comanda = Comanda.objects.get(id=comanda_id)
|
||||||
valores = somar(consumo,comanda)
|
valores = somar(consumo,comanda)
|
||||||
total = valores['total'] - valores['parcial']
|
if taxa == 'True':
|
||||||
pagamento = Payments(value=total, comanda=comanda, type_pay=typePayment,description='tipo de pagamento mokado')
|
pagamento = Payments(value=valores['totalComTaxa'], comanda=comanda, type_pay=typePayment,description='tipo de pagamento mokado')
|
||||||
pagamento.save()
|
pagamento.save()
|
||||||
|
else:
|
||||||
|
pagamento = Payments(value=valores['totalSemTaxa'], comanda=comanda, type_pay=typePayment,description='tipo de pagamento mokado')
|
||||||
|
pagamento.save()
|
||||||
|
|
||||||
comanda.status = 'CLOSED'
|
comanda.status = 'CLOSED'
|
||||||
comanda.save()
|
comanda.save()
|
||||||
return redirect('/comandas')
|
return redirect('/comandas')
|
||||||
@@ -103,7 +109,6 @@ def paymentParcial(request, comanda_id):
|
|||||||
typePayment = TypePay.objects.get(id=1)
|
typePayment = TypePay.objects.get(id=1)
|
||||||
comanda = Comanda.objects.get(id=comanda_id)
|
comanda = Comanda.objects.get(id=comanda_id)
|
||||||
value = Decimal(request.POST.get('value-parcial'))
|
value = Decimal(request.POST.get('value-parcial'))
|
||||||
print(value)
|
|
||||||
description = request.POST.get('name-parcial')
|
description = request.POST.get('name-parcial')
|
||||||
pagamento = Payments(value=value, comanda=comanda, type_pay=typePayment,description=description)
|
pagamento = Payments(value=value, comanda=comanda, type_pay=typePayment,description=description)
|
||||||
pagamento.save()
|
pagamento.save()
|
||||||
|
|||||||
@@ -117,6 +117,14 @@ Detalhes {{comanda.name}}
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
Taxa de serviço 10%
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
R$ {{valores.taxa}}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
{% if parcials%}
|
{% if parcials%}
|
||||||
<td colspan="2" style="text-align: center;"><b>Pagamentos parciais</b></td>
|
<td colspan="2" style="text-align: center;"><b>Pagamentos parciais</b></td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@@ -132,7 +140,7 @@ Detalhes {{comanda.name}}
|
|||||||
|
|
||||||
<tfoot>
|
<tfoot>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2" style="text-align: center;"><b>Total R$ {{total}} - Taxa de serviso {{taxa}}</b></td>
|
<td colspan="2" style="text-align: center;"><b>Total R$ {{valores.totalComTaxa}}</b></td>
|
||||||
</tr>
|
</tr>
|
||||||
</tfoot>
|
</tfoot>
|
||||||
</table>
|
</table>
|
||||||
@@ -178,8 +186,19 @@ Detalhes {{comanda.name}}
|
|||||||
|
|
||||||
<dialog id="payment-comanda" style="display: none;" >
|
<dialog id="payment-comanda" style="display: none;" >
|
||||||
<article>
|
<article>
|
||||||
|
<form action="{% url 'paymentComanda' comanda.id %}" method="post">
|
||||||
|
{% csrf_token %}
|
||||||
<h2>Pagamento</h2>
|
<h2>Pagamento</h2>
|
||||||
<h1 id="first-total">R$ {{ total }}</h1>
|
<div style="display: flex; align-content: space-around; align-items: center; justify-self: center;gap: 50px;">
|
||||||
|
|
||||||
|
<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
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<p>Recebido:</p> <input id="recebido" type="number">
|
<p>Recebido:</p> <input id="recebido" type="number">
|
||||||
<h4 id="troco">Troco: </h4>
|
<h4 id="troco">Troco: </h4>
|
||||||
@@ -187,13 +206,14 @@ Detalhes {{comanda.name}}
|
|||||||
<footer>
|
<footer>
|
||||||
<div style="display: flex;gap: 10px;">
|
<div style="display: flex;gap: 10px;">
|
||||||
|
|
||||||
<button type="submit" class="btn-secondary" hx-get="{% url 'paymentComanda' comanda.id %} " hx-trigger="click" hx-swap="none" onclick="backPage()">Receber</button>
|
<button type="submit" class="btn-secondary" onclick="backPage()">Receber</button>
|
||||||
<button type="button" class="btn-primary" onclick=" modal_conta_client()">
|
<button type="button" class="btn-primary" onclick=" modal_conta_client()">
|
||||||
Conta
|
Conta
|
||||||
</button>
|
</button>
|
||||||
<button type="button" class="btn-cancel" onclick="close_modal_payment_comanda()">Cancelar</button>
|
<button type="button" class="btn-cancel" onclick="close_modal_payment_comanda()">Cancelar</button>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
</form>
|
||||||
</article>
|
</article>
|
||||||
</dialog>
|
</dialog>
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,9 @@ def somar(consumo:ProductComanda, comanda:Comanda):
|
|||||||
valores = {
|
valores = {
|
||||||
'total':total,
|
'total':total,
|
||||||
'parcial':totalParcial,
|
'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
|
return valores
|
||||||
|
|
||||||
@@ -57,8 +59,7 @@ def viewComanda(request):
|
|||||||
if p.name == produto['nome'] and p.active == True:
|
if p.name == produto['nome'] and p.active == True:
|
||||||
products_ordenados.append(p)
|
products_ordenados.append(p)
|
||||||
valores = somar(consumo,comanda)
|
valores = somar(consumo,comanda)
|
||||||
total = valores['total'] - valores['parcial']
|
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', {'taxa': valores['taxaTotal'],'parcials':parcial,'clients':clients,'comanda': comanda, 'consumo': consumo, 'total': total, 'products': products_ordenados,'mesas':mesas})
|
|
||||||
|
|
||||||
|
|
||||||
@group_required(groupName='Garçom')
|
@group_required(groupName='Garçom')
|
||||||
@@ -96,7 +97,7 @@ def addContaCliente(request):
|
|||||||
return redirect('comandas')
|
return redirect('comandas')
|
||||||
|
|
||||||
def notificacao(request):
|
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)
|
ordersPronto = Order.objects.filter(queue__gte=fifteen_hours_ago, finished__isnull=False)
|
||||||
|
|
||||||
grupoGarcom = request.user.groups.filter(name='Garçom').exists()
|
grupoGarcom = request.user.groups.filter(name='Garçom').exists()
|
||||||
|
|||||||
Binary file not shown.
@@ -18,7 +18,7 @@
|
|||||||
src="{% static 'midia/icons/note.svg' %}"
|
src="{% static 'midia/icons/note.svg' %}"
|
||||||
style="width: 25px; height: 35px; cursor: pointer;">
|
style="width: 25px; height: 35px; cursor: pointer;">
|
||||||
</img>
|
</img>
|
||||||
<span>
|
</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
@@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{% if comanda.status != 'OPEN'%}
|
{% if comanda.status != 'OPEN'%}
|
||||||
{% else %}
|
{% else %}
|
||||||
<td>
|
<td>
|
||||||
@@ -41,6 +42,14 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
Taxa de serviço 10%
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
R$ {{valores.taxa}}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
{% if parcials%}
|
{% if parcials%}
|
||||||
<td colspan="2" style="text-align: center;"><b>Pagamentos parciais</b></td>
|
<td colspan="2" style="text-align: center;"><b>Pagamentos parciais</b></td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@@ -50,9 +59,13 @@
|
|||||||
<td>R$ -{{parcial.value}}</td>
|
<td>R$ -{{parcial.value}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<tfoot>
|
<tfoot>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2" style="text-align: center;">Total R$ {{total}}</td>
|
<td colspan="2" style="text-align: center;"><b>Total R$ {{valores.totalComTaxa}}</b></td>
|
||||||
</tr>
|
</tr>
|
||||||
</tfoot>
|
</tfoot>
|
||||||
</table>
|
|
||||||
|
|||||||
@@ -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) {
|
// document.getElementById('productForm').addEventListener('submit', function(event) {
|
||||||
// event.preventDefault();
|
// event.preventDefault();
|
||||||
|
|||||||
Reference in New Issue
Block a user