mirror of
https://github.com/welton89/RRBEC.git
synced 2026-04-05 13:35:42 +00:00
Feat: instacia do balcão diferente para cada usuario
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -1,6 +1,8 @@
|
||||
from django.shortcuts import render, redirect
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
from django.db.models import Count, F
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -70,19 +72,20 @@ def removeProductBalcao(request, productComanda_id):
|
||||
def paymentBalcao(request, comanda_id):
|
||||
typePayment = TypePay.objects.get(id=1)
|
||||
consumo = ProductComanda.objects.filter(comanda=comanda_id)
|
||||
user = User.objects.get(id=request.user.id)
|
||||
try:
|
||||
vendasBalcao = Comanda.objects.get(name='VENDAS BALCAO')
|
||||
except:
|
||||
mesa = Mesa.objects.get(id=1)
|
||||
vendasBalcao = Comanda(name='VENDAS BALCAO', mesa=mesa, user=request.user, status='CLOSED')
|
||||
vendasBalcao.save()
|
||||
comanda = Comanda.objects.get(name='VENDA BALCÃO')
|
||||
comanda = Comanda.objects.get(name=f'{user.id} - BALCÃO - {user.first_name}')
|
||||
total = 0
|
||||
for produto in consumo:
|
||||
total += produto.product.price
|
||||
produto.comanda = vendasBalcao
|
||||
produto.save()
|
||||
pagamento = Payments(value=total, comanda=comanda, type_pay=typePayment,description='VENDA BALCÃO')
|
||||
pagamento = Payments(value=total, comanda=comanda, type_pay=typePayment,description=f'{user.id} - BALCÃO - {user.first_name}')
|
||||
pagamento.save()
|
||||
return redirect('viewBalcao')
|
||||
|
||||
|
||||
@@ -12,11 +12,11 @@ from gestaoRaul.decorators import group_required
|
||||
@group_required(groupName='Garçom')
|
||||
def viewBalcao(request):
|
||||
try:
|
||||
comanda = Comanda.objects.get(name='VENDA BALCÃO')
|
||||
comanda = Comanda.objects.get(name=f'{user.id} - BALCÃO - {user.first_name}')
|
||||
except:
|
||||
user = User.objects.get(id=request.user.id)
|
||||
mesa = Mesa.objects.get(id=1)
|
||||
comanda = Comanda(name='VENDA BALCÃO', mesa=mesa, user=user,status='CLOSED')
|
||||
comanda = Comanda(name=f'{user.id} - BALCÃO - {user.first_name}', mesa=mesa, user=user,status='CLOSED')
|
||||
comanda.save()
|
||||
|
||||
consumo = ProductComanda.objects.filter(comanda=comanda.id)
|
||||
|
||||
Reference in New Issue
Block a user