Интегрирован wesp в сайт
CI / quality (push) Canceled after 0s

This commit is contained in:
влад
2026-07-17 12:57:18 +03:00
parent 5dfa06ddbe
commit 355c0ef9f1
883 changed files with 194576 additions and 177 deletions
@@ -0,0 +1,30 @@
"""Рецепт для экрана оператора загрузки (весы / дублёр) — с overlay «План на день»."""
from __future__ import annotations
from datetime import date as date_cls
from typing import Any
from app.models import Recipe
def plan_ingredients_for_loading(
recipe: Recipe, *, plan_date: str | None = None
) -> list[dict[str, Any]]:
"""Ингредиенты с весами плана на день, как на киоске тракториста (без пропущенных)."""
from app.routes.recipes import _serialize_recipe
resolved = (plan_date or date_cls.today().isoformat())[:10]
payload = _serialize_recipe(recipe, plan_date=resolved, exclude_skipped=True)
rows: list[dict[str, Any]] = []
for ing in payload.get("ingredients") or []:
rows.append(
{
"id": ing.get("id"),
"name": (ing.get("name") or "").strip() or "",
"amount": float(ing.get("amount") or 0),
"order": int(ing.get("order") or 0),
}
)
rows.sort(key=lambda row: (row["order"], str(row.get("id") or "")))
return rows