feat(stove-api): expose estimate and operator controls
This commit is contained in:
+7
-2
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user