склади и инструмент готовы
This commit is contained in:
+16
-31
@@ -21,9 +21,7 @@ class StocksActions:
|
||||
placement: str,
|
||||
reason: str,
|
||||
):
|
||||
logger.info(
|
||||
f"Оприходование инструмента {toolkit_id} на складе {toolbox_id} ..."
|
||||
)
|
||||
logger.info(f"Приход инструмента {toolkit_id} на складе {toolbox_id} ...")
|
||||
newStocks = await StockHandler.add(
|
||||
toolkit_id=toolkit_id,
|
||||
toolbox_id=toolbox_id,
|
||||
@@ -33,12 +31,12 @@ class StocksActions:
|
||||
)
|
||||
if newStocks is None:
|
||||
logger.error(
|
||||
f"Оприходование инструмента {toolkit_id} на складе {toolbox_id} не удалось"
|
||||
f"Приход инструмента {toolkit_id} на складе {toolbox_id} не удалось"
|
||||
)
|
||||
return False
|
||||
|
||||
recorded = await StocksRecordsHandler.add(
|
||||
action="Оприходование",
|
||||
action="Приход",
|
||||
source_stock_id=None,
|
||||
target_stock_id=newStocks.get("id"),
|
||||
source_toolbox_id=None,
|
||||
@@ -51,7 +49,7 @@ class StocksActions:
|
||||
return_record=True,
|
||||
)
|
||||
logger.info(
|
||||
f"Оприходование инструмента {toolkit_id} на складе {toolbox_id} прошло {'успешно' if recorded else 'не успешно'}"
|
||||
f"Приход инструмента {toolkit_id} на складе {toolbox_id} прошло {'успешно' if recorded else 'не успешно'}"
|
||||
)
|
||||
if recorded:
|
||||
accepted = await StocksRecordsHandler.decide(
|
||||
@@ -61,6 +59,11 @@ class StocksActions:
|
||||
logger.error(
|
||||
f"Принятие записи о оприходовании инструмента {toolkit_id} на складе {toolbox_id} не удалось"
|
||||
)
|
||||
refillUpdated = await ToolkitHandler.updateRefillDate(toolkit_id)
|
||||
if not refillUpdated:
|
||||
logger.error(
|
||||
f"Обновление даты последнего заполнения инструмента {toolkit_id} не удалось"
|
||||
)
|
||||
return accepted
|
||||
return False
|
||||
|
||||
@@ -70,8 +73,6 @@ class StocksActions:
|
||||
target_toolbox_id: int,
|
||||
toolkit_id: int,
|
||||
quantity: int,
|
||||
user_id: int,
|
||||
reason: str,
|
||||
target_placement: str = None,
|
||||
):
|
||||
logger.info(
|
||||
@@ -169,27 +170,13 @@ class StocksActions:
|
||||
f"Изменение остатков инструмента {toolkit_id} на склад {target_toolbox_id} по цене {stock['price']} успешно завершено"
|
||||
)
|
||||
|
||||
# recorded = await StocksRecordsHandler.add(
|
||||
# action=action,
|
||||
# source_stock_id=stock["id"],
|
||||
# target_stock_id=targetStock.get("id"),
|
||||
# source_toolbox_id=source_toolbox_id,
|
||||
# target_toolbox_id=target_toolbox_id,
|
||||
# toolkit_id=toolkit_id,
|
||||
# init_user_id=user_id,
|
||||
# reason=reason,
|
||||
# quantity=quantity,
|
||||
# price=stock["price"],
|
||||
# )
|
||||
# if not recorded:
|
||||
# logger.error(
|
||||
# f"Ошибка создания записи о {action} инструмента {toolkit_id} со склада {source_toolbox_id} на склад {target_toolbox_id}"
|
||||
# )
|
||||
# return False
|
||||
|
||||
logger.info(
|
||||
f"{action} инструмента {toolkit_id} со склада {source_toolbox_id} на склад {target_toolbox_id} прошло успешно"
|
||||
)
|
||||
moveUpdated = await ToolkitHandler.updateMovindDate(toolkit_id)
|
||||
if not moveUpdated:
|
||||
logger.error(f"Ошибка обновления даты движения инструмента {toolkit_id}")
|
||||
return False
|
||||
return movementsList
|
||||
|
||||
async def movingRequest(
|
||||
@@ -220,7 +207,7 @@ class StocksActions:
|
||||
return_record=return_record,
|
||||
)
|
||||
logger.info(
|
||||
f"Запрос на {action} инструмента {toolkit_id} со склада {source_toolbox_id} в количестве {quantity} по цене {price} {'успешно завершен' if recorded else 'завершен с ошибкой'}"
|
||||
f"Запрос на {action} инструмента {toolkit_id} со склада {source_toolbox_id} в количестве {quantity} по цене {price} {'успешно создан' if recorded else 'завершен с ошибкой'}"
|
||||
)
|
||||
return recorded
|
||||
|
||||
@@ -270,8 +257,6 @@ class StocksActions:
|
||||
target_toolbox_id=target_toolbox_id,
|
||||
toolkit_id=movingRecord.toolkit_id,
|
||||
quantity=movingRecord.quantity,
|
||||
user_id=user_id,
|
||||
reason=movingRecord.reason,
|
||||
)
|
||||
if not stocksMovements:
|
||||
logger.error(f"Ошибка при {movingRecord.action} инструмента")
|
||||
@@ -388,10 +373,10 @@ class StocksActions:
|
||||
for toolkit in toolkits:
|
||||
if "Сверло" in toolkit.get("title"):
|
||||
toolboxId = toolboxesDict.get("Шкаф")
|
||||
placement = None
|
||||
else:
|
||||
toolboxId = toolboxesDict.get("Стеллаж")
|
||||
|
||||
placement = chr(65 + random.randint(0, 25)) + str(random.randint(1, 19))
|
||||
placement = chr(65 + random.randint(0, 25)) + str(random.randint(1, 19))
|
||||
|
||||
registryCount = 5
|
||||
|
||||
|
||||
Reference in New Issue
Block a user