mirror of
https://github.com/welton89/RRBEC.git
synced 2026-04-05 21:45:41 +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.shortcuts import render, redirect
|
||||||
from django.views.decorators.csrf import csrf_exempt
|
from django.views.decorators.csrf import csrf_exempt
|
||||||
from django.db.models import Count, F
|
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):
|
def paymentBalcao(request, comanda_id):
|
||||||
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)
|
||||||
|
user = User.objects.get(id=request.user.id)
|
||||||
try:
|
try:
|
||||||
vendasBalcao = Comanda.objects.get(name='VENDAS BALCAO')
|
vendasBalcao = Comanda.objects.get(name='VENDAS BALCAO')
|
||||||
except:
|
except:
|
||||||
mesa = Mesa.objects.get(id=1)
|
mesa = Mesa.objects.get(id=1)
|
||||||
vendasBalcao = Comanda(name='VENDAS BALCAO', mesa=mesa, user=request.user, status='CLOSED')
|
vendasBalcao = Comanda(name='VENDAS BALCAO', mesa=mesa, user=request.user, status='CLOSED')
|
||||||
vendasBalcao.save()
|
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
|
total = 0
|
||||||
for produto in consumo:
|
for produto in consumo:
|
||||||
total += produto.product.price
|
total += produto.product.price
|
||||||
produto.comanda = vendasBalcao
|
produto.comanda = vendasBalcao
|
||||||
produto.save()
|
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()
|
pagamento.save()
|
||||||
return redirect('viewBalcao')
|
return redirect('viewBalcao')
|
||||||
|
|
||||||
|
|||||||
@@ -12,11 +12,11 @@ from gestaoRaul.decorators import group_required
|
|||||||
@group_required(groupName='Garçom')
|
@group_required(groupName='Garçom')
|
||||||
def viewBalcao(request):
|
def viewBalcao(request):
|
||||||
try:
|
try:
|
||||||
comanda = Comanda.objects.get(name='VENDA BALCÃO')
|
comanda = Comanda.objects.get(name=f'{user.id} - BALCÃO - {user.first_name}')
|
||||||
except:
|
except:
|
||||||
user = User.objects.get(id=request.user.id)
|
user = User.objects.get(id=request.user.id)
|
||||||
mesa = Mesa.objects.get(id=1)
|
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()
|
comanda.save()
|
||||||
|
|
||||||
consumo = ProductComanda.objects.filter(comanda=comanda.id)
|
consumo = ProductComanda.objects.filter(comanda=comanda.id)
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user