fix: коэффициенты к нормам ресурсов (демонтаж/условия 571/421пр) — норма была сырой

Проверка опровергла мою оценку «редкий кейс»: коэф на отдельных ресурсах в 11%
позиций (446 расценок). Сверка со справочником (Приказы Минстроя 571/пр демонтаж,
421/пр условия работ) подтвердила: в .gge лежит БАЗОВАЯ норма ГЭСН, коэф к ней
обязателен (53.6 × 0.7 = 5.96568 точно). Раньше я хранил норму без коэф —
искажение для демонтажных работ. Теперь к каждому ресурсу прикреплён coef
{factors по Target, reason}; позиционные коэф получили target. Цены не затронуты
(они из вычисленных Totals, уже с коэф). Юнит-тест на арифметику применения.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
anor
2026-06-09 01:37:55 +10:00
co-authored by Claude Opus 4.8
parent 6f78d9a32c
commit ae157bc309
4 changed files with 48 additions and 5 deletions
+29 -2
View File
@@ -53,6 +53,28 @@ def _index(node) -> dict | None:
return {"value": val, "reason": reason}
def _res_coef(node) -> dict | None:
"""Поправочный коэффициент НА РЕСУРС (Coefficients/Final по Target).
Норма Consumption — БАЗОВАЯ (ГЭСН); эффективная = норма × factors[Target].
Target: «Расход» (к норме расхода труда/машин/материалов), «Стоимость».
Reason — обоснование Приказом Минстроя (571/пр — демонтаж/разборка,
421/пр — условия производства работ). Встречается в ~11% позиций."""
cs = node.find("Coefficients")
if cs is None:
return None
factors = {}
fin = cs.find("Final")
if fin is not None:
for v in fin.findall(".//Values/Value"):
tg = _t(v, "Target")
if tg:
factors[tg] = _f(_t(v, "CoefValue"))
reasons = [r for r in (_t(c, "Reason") for c in cs.findall("Coefficient")) if r]
if not factors and not reasons:
return None
return {"factors": factors, "reason": "; ".join(dict.fromkeys(reasons))}
def _material(mat, external=False) -> dict:
d = {
"code": _t(mat, "Code"),
@@ -62,6 +84,7 @@ def _material(mat, external=False) -> dict:
"price_base": _f(_t(mat, "PricePerUnitBase")),
"price_cur": _f(_t(mat, "PricePerUnitCur")),
"index": _index(mat),
"coef": _res_coef(mat),
}
if external:
d["external"] = True
@@ -81,6 +104,7 @@ def _resources(cost) -> dict:
"consumption": _f(_t(w, "Consumption")),
"unit": _t(w, "Unit"),
"price_cur": _f(_t(w, "PricePerUnitCur")),
"coef": _res_coef(w),
})
for m in ri.findall("Machine"):
mach = m.find("Machinist")
@@ -92,10 +116,12 @@ def _resources(cost) -> dict:
"price_base": _f(_t(m, "PricePerUnitBase")),
"price_cur": _f(_t(m, "PricePerUnitCur")),
"index": _index(m),
"coef": _res_coef(m),
"machinist": {
"consumption": _f(_t(mach, "Consumption")),
"price_cur": _f(_t(mach, "PricePerUnitCur")),
"grade": _t(mach, "Grade"),
"coef": _res_coef(mach),
} if mach is not None else None,
})
for mat in ri.findall("Material"):
@@ -114,11 +140,12 @@ def _coefficients(cost) -> list[dict]:
if cs is None:
return out
for c in cs.findall("Coefficient"):
val = c.find(".//Values/Value/CoefValue")
v = c.find(".//Values/Value")
out.append({
"name": _t(c, "Name"),
"reason": _t(c, "Reason"),
"value": (val.text or "").strip() if val is not None and val.text else "",
"value": _t(v, "CoefValue") if v is not None else "",
"target": _t(v, "Target") if v is not None else "",
})
return out