feat: a few shipping products in box
This commit is contained in:
@@ -26,16 +26,6 @@ class ShippingService(BaseService):
|
||||
await self.session.commit()
|
||||
return DeletePalletResponse(ok=True, message="Паллет успешно удален")
|
||||
|
||||
async def _update_box(self, data: UpdateBoxSchema) -> tuple[bool, str]:
|
||||
box = await self.session.get(Box, data.box_id)
|
||||
if not box:
|
||||
return False, f"Короб с ID:{data.box_id} не найден"
|
||||
|
||||
box.quantity = data.quantity
|
||||
box.product_id = data.product_id
|
||||
await self.session.commit()
|
||||
return True, "Короб обновлен"
|
||||
|
||||
async def _create_box(self, data: CreateBoxInCardSchema | CreateBoxInPalletSchema):
|
||||
box = Box(**data.model_dump())
|
||||
self.session.add(box)
|
||||
@@ -59,16 +49,14 @@ class ShippingService(BaseService):
|
||||
|
||||
return True, f"Короб добавлен в паллет"
|
||||
|
||||
async def update_box(self, request: UpdateBoxRequest) -> UpdateBoxResponse:
|
||||
async def create_box(self, request: CreateBoxRequest) -> CreateBoxResponse:
|
||||
data_keys = request.data.model_dump().keys()
|
||||
if "box_id" in data_keys:
|
||||
ok, message = await self._update_box(request.data)
|
||||
elif "pallet_id" in data_keys:
|
||||
if "pallet_id" in data_keys:
|
||||
ok, message = await self._create_box_in_pallet(CreateBoxInPalletSchema.model_validate(request.data))
|
||||
else:
|
||||
ok, message = await self._create_box_in_card(CreateBoxInCardSchema.model_validate(request.data))
|
||||
|
||||
return UpdateBoxResponse(ok=ok, message=message)
|
||||
return CreateBoxResponse(ok=ok, message=message)
|
||||
|
||||
async def delete_box(self, deal_id: int) -> DeleteBoxResponse:
|
||||
box = await self.session.get(Box, deal_id)
|
||||
@@ -94,13 +82,13 @@ class ShippingService(BaseService):
|
||||
shipping_product.product_id = data.product_id
|
||||
shipping_product.quantity = data.quantity
|
||||
await self.session.commit()
|
||||
return True, "Запись о товаре на паллете успешно изменена"
|
||||
return True, "Запись о товаре успешно изменена"
|
||||
|
||||
async def _create_shipping_product(self, data: CreateShippingProductSchema) -> tuple[bool, str]:
|
||||
shipping_product = ShippingProduct(**data.model_dump())
|
||||
self.session.add(shipping_product)
|
||||
await self.session.commit()
|
||||
return True, "Запись о товаре на паллете успешно добавлена"
|
||||
return True, "Запись о товаре успешно добавлена"
|
||||
|
||||
async def update_shipping_product(self, request: UpdateShippingProductRequest) -> UpdateShippingProductResponse:
|
||||
data_keys = request.data.model_dump().keys()
|
||||
|
||||
Reference in New Issue
Block a user