feat(stove-api): expose estimate and operator controls

This commit is contained in:
anor
2026-11-26 20:22:55 +10:00
parent de624297ed
commit a98aa460d4
19 changed files with 1074 additions and 12 deletions
+7 -2
View File
@@ -102,6 +102,8 @@ def build_answer(stove: c.StoveRequest, prices: dict) -> dict:
answer["total"] = _fork([work + amount for _, work in ways])
if ways and ways[0][1] is not None:
answer["works"] = _fork([work for _, work in ways])
if answer["total"] is None:
answer["total"] = dict(answer["works"])
return answer
@@ -148,12 +150,15 @@ def _volumes(stove: c.StoveRequest, prices: dict, notes: list):
body, ways, gaps = stove.stove, [], []
norms = prices.get("norms") or {}
kinds = [k for k in c.BRICK_KINDS if getattr(body.bricks, k) > 0]
absent = [k for k in kinds if not norms.get(k)]
aggregate = norms.get("aggregate")
absent = [] if aggregate else [k for k in kinds if not norms.get(k)]
if aggregate:
notes.append("объём по суммарной норме кирпича ГЭСН; раздельной нормы на шамотный кирпич нет")
if absent:
names = " и ".join(c.BRICK_NAMES[k] for k in absent)
notes.append(f"в составе расценки нет нормы на {names} — объём по кирпичу не посчитан")
else:
per_m3 = sum(_fraction(norms[k]) for k in kinds) * 1000
per_m3 = (_fraction(aggregate) if aggregate else sum(_fraction(norms[k]) for k in kinds)) * 1000
pieces = sum(getattr(body.bricks, k) for k in kinds)
ways.append((f"по кирпичу ({_bricks_label(body.bricks)})", Fraction(pieces) / per_m3))
if body.mass_kg is not None: