mirror of
https://github.com/welton89/RRBEC.git
synced 2026-04-05 21:45:41 +00:00
feat: acossiar comandas fiados a conta client
This commit is contained in:
Binary file not shown.
@@ -34,7 +34,7 @@ Detalhes {{comanda.name}}
|
||||
{% endif %}
|
||||
>Fechar Conta</button>
|
||||
|
||||
{% if comanda.status == 'PAYING' %}
|
||||
{% if comanda.status == 'PAYING' or comanda.status == 'FIADO'%}
|
||||
<button class="btn-secondary" id="pagarComanda" onclick="modal_payment_comanda()">Receber</button>
|
||||
{% else %}
|
||||
|
||||
@@ -207,9 +207,11 @@ Detalhes {{comanda.name}}
|
||||
<div style="display: flex;gap: 10px;">
|
||||
|
||||
<button type="submit" class="btn-secondary" onclick="backPage()">Receber</button>
|
||||
{% if comanda.status != 'FIADO' %}
|
||||
<button type="button" class="btn-primary" onclick=" modal_conta_client()">
|
||||
Conta
|
||||
</button>
|
||||
{% endif %}
|
||||
<button type="button" class="btn-cancel" onclick="close_modal_payment_comanda()">Cancelar</button>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
Binary file not shown.
@@ -1,6 +1,8 @@
|
||||
from decimal import Decimal
|
||||
from django import template
|
||||
|
||||
from comandas.models import Comanda, ProductComanda
|
||||
from payments.models import Payments
|
||||
|
||||
register = template.Library()
|
||||
|
||||
@@ -8,10 +10,18 @@ register = template.Library()
|
||||
def filter_total(value):
|
||||
id = value
|
||||
comanda_id = int(id)
|
||||
totalParcial = Decimal(0)
|
||||
comanda = Comanda.objects.get(id=comanda_id)
|
||||
consumo = ProductComanda.objects.filter(comanda=comanda_id)
|
||||
total = 0
|
||||
parcial = Payments.objects.filter(comanda=comanda)
|
||||
for p in parcial:
|
||||
totalParcial += p.value
|
||||
|
||||
total = Decimal(0)
|
||||
for produto in consumo:
|
||||
total += produto.product.price
|
||||
taxa = round(total * Decimal(0.1), 2)
|
||||
total = (total + taxa) - totalParcial
|
||||
return f'R$ {total}'
|
||||
|
||||
|
||||
|
||||
@@ -87,12 +87,12 @@ def addContaCliente(request):
|
||||
|
||||
comandaId = int(request.POST.get('idComanda'))
|
||||
clientId = int(request.POST.get('select-client'))
|
||||
valor = float(request.POST.get('valor-conta').replace(',','.'))
|
||||
comanda = Comanda.objects.get(id=comandaId)
|
||||
client = Client.objects.get(id=clientId)
|
||||
client.debt = client.debt + Decimal(valor)
|
||||
# client.debt = Decimal(0)
|
||||
comanda.client = client
|
||||
comanda.status = 'CLOSED'
|
||||
comanda.dt_close = timezone.now()
|
||||
comanda.status = 'FIADO'
|
||||
client.save()
|
||||
comanda.save()
|
||||
return redirect('comandas')
|
||||
|
||||
Reference in New Issue
Block a user