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:
@@ -2,8 +2,10 @@ from datetime import date
|
||||
from decimal import Decimal
|
||||
from django.http import JsonResponse
|
||||
from django.shortcuts import render, redirect
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
from comandas.models import Comanda, ProductComanda
|
||||
|
||||
from comandas.models import Comanda, ProductComanda, StockMovementType, StockMovement
|
||||
from orders.models import Order
|
||||
from products.models import Product
|
||||
from payments.models import Payments, somar
|
||||
@@ -37,15 +39,27 @@ def removeProductComanda(request, productComanda_id):
|
||||
'taxa': False
|
||||
}
|
||||
product_comanda = ProductComanda.objects.get(id=productComanda_id)
|
||||
comanda = Comanda.objects.get(id= product_comanda.comanda.id)
|
||||
comanda = product_comanda.comanda
|
||||
product = product_comanda.product
|
||||
user = User.objects.get(id=request.user.id)
|
||||
typeMovement = StockMovementType.objects.get(name="Estorno")
|
||||
|
||||
if comanda.status == 'OPEN':
|
||||
parcial = Payments.objects.filter(comanda=comanda)
|
||||
consumo = ProductComanda.objects.filter(comanda=comanda)
|
||||
valores = somar(consumo,comanda)
|
||||
if product_comanda.product.cuisine == True:
|
||||
order = Order.objects.get(productComanda=product_comanda)
|
||||
|
||||
StockMovement.sumTransactionStock(
|
||||
product=product,
|
||||
movement_type=typeMovement,
|
||||
comanda=comanda,
|
||||
user=user,
|
||||
qtd=1,
|
||||
obs= "Excluido da comanda"
|
||||
)
|
||||
product_comanda.delete()
|
||||
Product.addStock(Product.objects.get(id=product_comanda.product.id), 1)
|
||||
|
||||
msg = JsonResponse({
|
||||
'type': 'broadcast',
|
||||
@@ -60,8 +74,15 @@ def removeProductComanda(request, productComanda_id):
|
||||
consumo = ProductComanda.objects.filter(comanda=comanda)
|
||||
valores = somar(consumo,comanda)
|
||||
else:
|
||||
StockMovement.sumTransactionStock(
|
||||
product=product,
|
||||
movement_type=typeMovement,
|
||||
comanda=comanda,
|
||||
user=user,
|
||||
qtd=1,
|
||||
obs= "Excluido da comanda"
|
||||
)
|
||||
product_comanda.delete()
|
||||
Product.addStock(Product.objects.get(id=product_comanda.product.id), 1)
|
||||
consumo = ProductComanda.objects.filter(comanda=comanda)
|
||||
valores = somar(consumo,comanda)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user