Получение со склада через карточку инструмента
This commit is contained in:
Binary file not shown.
Binary file not shown.
+11
-4
@@ -49,14 +49,20 @@ async def post_requests(
|
||||
action = request_data.get("body").get("action").get("operation")
|
||||
logger.info(f"Получение запроса на перемещение ({action}) инструмента")
|
||||
userId = request_data.get("body").get("userData").get("id")
|
||||
sourceTollboxId = (
|
||||
sourceTollboxId = int(
|
||||
request_data.get("body").get("action").get("selectedItem").get("toolboxId")
|
||||
)
|
||||
toolkitId = request_data.get("body").get("action").get("selectedItem").get("id")
|
||||
toolkitId = int(
|
||||
request_data.get("body").get("action").get("selectedItem").get("id")
|
||||
)
|
||||
quantity = request_data.get("body").get("action").get("quantity")
|
||||
price = round(
|
||||
request_data.get("body").get("action").get("selectedItem").get("totalCost")
|
||||
/ request_data.get("body").get("action").get("selectedItem").get("available"),
|
||||
float(
|
||||
request_data.get("body").get("action").get("selectedItem").get("totalCost")
|
||||
)
|
||||
/ int(
|
||||
request_data.get("body").get("action").get("selectedItem").get("available")
|
||||
),
|
||||
2,
|
||||
)
|
||||
reason = request_data.get("body").get("action").get("comment")
|
||||
@@ -78,6 +84,7 @@ async def post_requests(
|
||||
if result:
|
||||
resonse["status"] = "ok"
|
||||
case "get":
|
||||
logger.info(f"Получение инструмента {toolkitId} из ящика {sourceTollboxId}")
|
||||
targetTollboxId = await ToolboxHandler.getIdByOwner(userId)
|
||||
result = await StocksActions.takeToolkit(
|
||||
sourceTollboxId,
|
||||
|
||||
@@ -28,6 +28,7 @@ async def toolkit_request(
|
||||
if not toolboxes:
|
||||
return response
|
||||
toolboxesTitles = {toolbox["id"]: toolbox["title"] for toolbox in toolboxes}
|
||||
toolboxesOwners = {toolbox["id"]: toolbox["owner_id"] for toolbox in toolboxes}
|
||||
stocksData = {"count": 0, "toolboxes": {}}
|
||||
for stock in stocks:
|
||||
toolboxTitle = toolboxesTitles.get(stock["toolbox_id"], None)
|
||||
@@ -39,8 +40,18 @@ async def toolkit_request(
|
||||
"count": stock["quantity"],
|
||||
"placement": stock["placement"],
|
||||
}
|
||||
logger.info(stock.keys())
|
||||
if not toolboxesOwners.get(stock["toolbox_id"]):
|
||||
stocksData["toolboxes"][toolboxTitle]["id"] = stock["toolbox_id"]
|
||||
stocksData["toolboxes"][toolboxTitle]["totalCost"] = (
|
||||
stock["price"] * stock["quantity"]
|
||||
)
|
||||
else:
|
||||
stocksData["toolboxes"][toolboxTitle]["count"] += stock["quantity"]
|
||||
if not toolboxesOwners.get(stock["toolbox_id"]):
|
||||
stocksData["toolboxes"][toolboxTitle]["totalCost"] += (
|
||||
stock["price"] * stock["quantity"]
|
||||
)
|
||||
response["status"] = "ok"
|
||||
response["data"] = stocksData
|
||||
return response
|
||||
|
||||
Reference in New Issue
Block a user