idk
This commit is contained in:
parent
c7686fb239
commit
aa1cdc2fb3
@ -45,7 +45,7 @@ class BoxService:
|
|||||||
|
|
||||||
def add_products_to_open_box(self, open_box: OpenBox, product_data: Dict[Product, int]) -> None:
|
def add_products_to_open_box(self, open_box: OpenBox, product_data: Dict[Product, int]) -> None:
|
||||||
"""Add products to an open box."""
|
"""Add products to an open box."""
|
||||||
for product, quantity in product_data.items():
|
for product, quantity in product_data.items(): # TODO BATCH THIS
|
||||||
open_box_card = OpenBoxCard(
|
open_box_card = OpenBoxCard(
|
||||||
id=str(uuid4()),
|
id=str(uuid4()),
|
||||||
open_box_id=open_box.id,
|
open_box_id=open_box.id,
|
||||||
@ -94,7 +94,6 @@ class BoxService:
|
|||||||
num_cards_expected=create_box_data.num_cards_expected
|
num_cards_expected=create_box_data.num_cards_expected
|
||||||
)
|
)
|
||||||
self.db.add(product)
|
self.db.add(product)
|
||||||
self.db.flush()
|
|
||||||
self.db.add(box)
|
self.db.add(box)
|
||||||
|
|
||||||
return box, True
|
return box, True
|
||||||
@ -150,7 +149,6 @@ class BoxService:
|
|||||||
date_opened=datetime.strptime(box_data.date_opened, "%Y-%m-%d") if box_data.date_opened else datetime.now()
|
date_opened=datetime.strptime(box_data.date_opened, "%Y-%m-%d") if box_data.date_opened else datetime.now()
|
||||||
)
|
)
|
||||||
self.db.add(open_box)
|
self.db.add(open_box)
|
||||||
self.db.flush()
|
|
||||||
|
|
||||||
staged_product_data = self.get_staged_product_data(box_data.file_ids)
|
staged_product_data = self.get_staged_product_data(box_data.file_ids)
|
||||||
product_data = self.aggregate_staged_product_data(staged_product_data)
|
product_data = self.aggregate_staged_product_data(staged_product_data)
|
||||||
|
@ -38,7 +38,8 @@ class InventoryService:
|
|||||||
if inventory is None:
|
if inventory is None:
|
||||||
inventory = Inventory(
|
inventory = Inventory(
|
||||||
product_id=product.id,
|
product_id=product.id,
|
||||||
quantity=quantity
|
quantity=quantity,
|
||||||
|
warehouse_id="0f0d01b1-97ba-4ab2-9082-22062bca9b06" # TODO FIX
|
||||||
)
|
)
|
||||||
self.db.add(inventory)
|
self.db.add(inventory)
|
||||||
else:
|
else:
|
||||||
@ -61,7 +62,7 @@ class InventoryService:
|
|||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
with db_transaction(self.db):
|
with db_transaction(self.db):
|
||||||
for product, quantity in product_data.items():
|
for product, quantity in product_data.items(): # TODO BATCH THIS
|
||||||
self.add_inventory(product, quantity)
|
self.add_inventory(product, quantity)
|
||||||
return UpdateInventoryResponse(success=True)
|
return UpdateInventoryResponse(success=True)
|
||||||
except SQLAlchemyError:
|
except SQLAlchemyError:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user