mirror of
https://github.com/welton89/RRBEC.git
synced 2026-04-05 13:35:42 +00:00
feat: criado funcções de movimentação de estoque
This commit is contained in:
@@ -6,7 +6,7 @@ from django.contrib.auth.models import User
|
||||
|
||||
|
||||
|
||||
from comandas.models import Comanda, ProductComanda
|
||||
from comandas.models import Comanda, ProductComanda, StockMovementType, StockMovement
|
||||
from mesas.models import Mesa
|
||||
from products.models import Product
|
||||
from payments.models import Payments
|
||||
@@ -30,7 +30,19 @@ def addProductBalcao(request, product_id, comanda_id, qtd):
|
||||
for i in range(qtd):
|
||||
product_comanda = ProductComanda(comanda_id=comanda_id, product_id=product_id)
|
||||
product_comanda.save()
|
||||
Product.subStock(Product.objects.get(id=product_id), qtd)
|
||||
product = Product.objects.get(id=product_id)
|
||||
comanda = Comanda.objects.get(id=comanda_id)
|
||||
user = User.objects.get(id=request.user.id)
|
||||
typeMovement = StockMovementType.objects.get(name="Venda - Balcao")
|
||||
|
||||
StockMovement.subTransactionStock(
|
||||
product=product,
|
||||
movement_type=typeMovement,
|
||||
comanda=comanda,
|
||||
user=user,
|
||||
qtd=1,
|
||||
obs= "Vendido no balcão"
|
||||
)
|
||||
|
||||
consumo = ProductComanda.objects.filter(comanda=comanda_id)
|
||||
total = 0
|
||||
@@ -44,7 +56,20 @@ def addProductBalcaoTeclado(request, product_id, comanda_id, qtd):
|
||||
for i in range(qtd):
|
||||
product_comanda = ProductComanda(comanda_id=comanda_id, product_id=product_id)
|
||||
product_comanda.save()
|
||||
Product.subStock(Product.objects.get(id=product_id), qtd)
|
||||
product = Product.objects.get(id=product_id)
|
||||
comanda = Comanda.objects.get(id=comanda_id)
|
||||
user = User.objects.get(id=request.user.id)
|
||||
typeMovement = StockMovementType.objects.get(name="Venda - Balcao")
|
||||
|
||||
StockMovement.subTransactionStock(
|
||||
product=product,
|
||||
movement_type=typeMovement,
|
||||
comanda=comanda,
|
||||
user=user,
|
||||
qtd=1,
|
||||
obs= "Vendido no balcão"
|
||||
)
|
||||
|
||||
consumo = ProductComanda.objects.filter(comanda=comanda_id)
|
||||
total = 0
|
||||
for produto in consumo:
|
||||
@@ -54,9 +79,23 @@ def addProductBalcaoTeclado(request, product_id, comanda_id, qtd):
|
||||
@group_required(groupName='Garçom')
|
||||
def removeProductBalcao(request, productComanda_id):
|
||||
product_comanda = ProductComanda.objects.get(id=productComanda_id)
|
||||
comanda = product_comanda.comanda
|
||||
product = product_comanda.product
|
||||
user = User.objects.get(id=request.user.id)
|
||||
typeMovement = StockMovementType.objects.get(name="Estorno")
|
||||
|
||||
consumo = ProductComanda.objects.filter(comanda=product_comanda.comanda)
|
||||
StockMovement.sumTransactionStock(
|
||||
product=product,
|
||||
movement_type=typeMovement,
|
||||
comanda=comanda,
|
||||
user=user,
|
||||
qtd=1,
|
||||
obs= "Excluido do balcão"
|
||||
)
|
||||
|
||||
|
||||
product_comanda.delete()
|
||||
Product.addStock(Product.objects.get(id=product_comanda.product.id), 1)
|
||||
|
||||
total = 0
|
||||
for produto in consumo:
|
||||
|
||||
Reference in New Issue
Block a user