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:
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
| Файл | Что | Источник |
|
| Файл | Что | Источник |
|
||||||
|------|-----|----------|
|
|------|-----|----------|
|
||||||
| `estimates_index.json` (~11 МБ) | 3097 расценок с ПОЛНЫМ составом: работа→код ГЭСН→ед→**ресурсы** (рабочие/машины/материалы + нормы + цены база/тек + **индекс пересчёта с обоснованием** + машинисты)→цена/ед→**структура стоимости** (машины/материалы/зарплата)→трудозатраты→накладные/прибыль (с обоснованием+руб)→коэффициенты→comment→Transport-позиции→freq→объём. + 6796 прямых материалов (цена, возвратный-флаг) | 2519 `.gge` ЛСР/ОСР (67 256 позиций) |
|
| `estimates_index.json` (~12 МБ) | 3097 расценок с ПОЛНЫМ составом: работа→код ГЭСН→ед→**ресурсы** (рабочие/машины/материалы + нормы + цены база/тек + индекс пересчёта + **коэф к норме**: демонтаж/условия 571/421пр, Target+обоснование, эфф.норма = норма×коэф + машинисты)→цена/ед→**структура стоимости**→трудозатраты→накладные/прибыль (обоснование+руб)→коэффициенты позиции (с Target)→comment→Transport→freq→объём. + 6796 прямых материалов | 2519 `.gge` ЛСР/ОСР (67 256 позиций) |
|
||||||
| `ka_index.json` (~5.3 МБ) | 3922 материала: **сметная цена** (EstimateWithoutVAT) min/median/max/**winner** + рыночная + склад + перевозка→обезличенные офферы→регион→квартал | 181 zip КА |
|
| `ka_index.json` (~5.3 МБ) | 3922 материала: **сметная цена** (EstimateWithoutVAT) min/median/max/**winner** + рыночная + склад + перевозка→обезличенные офферы→регион→квартал | 181 zip КА |
|
||||||
| `vor_index.json` (~8.5 МБ) | 25 834 работы: ед→объём (min/median/max)→**формула расчёта**→ссылка на лист (с номером) | 1951 `.gge` ВОР, схема QuantityTakeoff |
|
| `vor_index.json` (~8.5 МБ) | 25 834 работы: ед→объём (min/median/max)→**формула расчёта**→ссылка на лист (с номером) | 1951 `.gge` ВОР, схема QuantityTakeoff |
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
+29
-2
@@ -53,6 +53,28 @@ def _index(node) -> dict | None:
|
|||||||
return {"value": val, "reason": reason}
|
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:
|
def _material(mat, external=False) -> dict:
|
||||||
d = {
|
d = {
|
||||||
"code": _t(mat, "Code"),
|
"code": _t(mat, "Code"),
|
||||||
@@ -62,6 +84,7 @@ def _material(mat, external=False) -> dict:
|
|||||||
"price_base": _f(_t(mat, "PricePerUnitBase")),
|
"price_base": _f(_t(mat, "PricePerUnitBase")),
|
||||||
"price_cur": _f(_t(mat, "PricePerUnitCur")),
|
"price_cur": _f(_t(mat, "PricePerUnitCur")),
|
||||||
"index": _index(mat),
|
"index": _index(mat),
|
||||||
|
"coef": _res_coef(mat),
|
||||||
}
|
}
|
||||||
if external:
|
if external:
|
||||||
d["external"] = True
|
d["external"] = True
|
||||||
@@ -81,6 +104,7 @@ def _resources(cost) -> dict:
|
|||||||
"consumption": _f(_t(w, "Consumption")),
|
"consumption": _f(_t(w, "Consumption")),
|
||||||
"unit": _t(w, "Unit"),
|
"unit": _t(w, "Unit"),
|
||||||
"price_cur": _f(_t(w, "PricePerUnitCur")),
|
"price_cur": _f(_t(w, "PricePerUnitCur")),
|
||||||
|
"coef": _res_coef(w),
|
||||||
})
|
})
|
||||||
for m in ri.findall("Machine"):
|
for m in ri.findall("Machine"):
|
||||||
mach = m.find("Machinist")
|
mach = m.find("Machinist")
|
||||||
@@ -92,10 +116,12 @@ def _resources(cost) -> dict:
|
|||||||
"price_base": _f(_t(m, "PricePerUnitBase")),
|
"price_base": _f(_t(m, "PricePerUnitBase")),
|
||||||
"price_cur": _f(_t(m, "PricePerUnitCur")),
|
"price_cur": _f(_t(m, "PricePerUnitCur")),
|
||||||
"index": _index(m),
|
"index": _index(m),
|
||||||
|
"coef": _res_coef(m),
|
||||||
"machinist": {
|
"machinist": {
|
||||||
"consumption": _f(_t(mach, "Consumption")),
|
"consumption": _f(_t(mach, "Consumption")),
|
||||||
"price_cur": _f(_t(mach, "PricePerUnitCur")),
|
"price_cur": _f(_t(mach, "PricePerUnitCur")),
|
||||||
"grade": _t(mach, "Grade"),
|
"grade": _t(mach, "Grade"),
|
||||||
|
"coef": _res_coef(mach),
|
||||||
} if mach is not None else None,
|
} if mach is not None else None,
|
||||||
})
|
})
|
||||||
for mat in ri.findall("Material"):
|
for mat in ri.findall("Material"):
|
||||||
@@ -114,11 +140,12 @@ def _coefficients(cost) -> list[dict]:
|
|||||||
if cs is None:
|
if cs is None:
|
||||||
return out
|
return out
|
||||||
for c in cs.findall("Coefficient"):
|
for c in cs.findall("Coefficient"):
|
||||||
val = c.find(".//Values/Value/CoefValue")
|
v = c.find(".//Values/Value")
|
||||||
out.append({
|
out.append({
|
||||||
"name": _t(c, "Name"),
|
"name": _t(c, "Name"),
|
||||||
"reason": _t(c, "Reason"),
|
"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
|
return out
|
||||||
|
|
||||||
|
|||||||
+17
-1
@@ -26,12 +26,21 @@ LSR_XML = """<?xml version="1.0" encoding="UTF-8"?>
|
|||||||
<Unit>1000 м3</Unit><QuantityTotal>6.751</QuantityTotal>
|
<Unit>1000 м3</Unit><QuantityTotal>6.751</QuantityTotal>
|
||||||
<Comment>(тестовый комментарий)</Comment>
|
<Comment>(тестовый комментарий)</Comment>
|
||||||
<PerUnit><LaborCosts>0</LaborCosts><MachinistLaborCosts>5.5</MachinistLaborCosts></PerUnit>
|
<PerUnit><LaborCosts>0</LaborCosts><MachinistLaborCosts>5.5</MachinistLaborCosts></PerUnit>
|
||||||
|
<Coefficients>
|
||||||
|
<Coefficient><Name>Стесненные условия</Name><Reason>421/пр_2022_прил.10</Reason>
|
||||||
|
<Values><Value><CoefValue>1.15</CoefValue><Target>ОТ</Target></Value></Values></Coefficient>
|
||||||
|
</Coefficients>
|
||||||
<ResourcesInternal>
|
<ResourcesInternal>
|
||||||
<Machine>
|
<Machine>
|
||||||
<Code>91.01.01-035</Code><Name>Бульдозеры 79 кВт</Name>
|
<Code>91.01.01-035</Code><Name>Бульдозеры 79 кВт</Name>
|
||||||
<Consumption>5.5</Consumption><Unit>маш.-ч</Unit>
|
<Consumption>5.5</Consumption><Unit>маш.-ч</Unit>
|
||||||
<PricePerUnitBase>900</PricePerUnitBase><PricePerUnitCur>1224.81</PricePerUnitCur>
|
<PricePerUnitBase>900</PricePerUnitBase><PricePerUnitCur>1224.81</PricePerUnitCur>
|
||||||
<Index><Reason>1030</Reason><Value><IndexValue>1.38</IndexValue></Value></Index>
|
<Index><Reason>1030</Reason><Value><IndexValue>1.38</IndexValue></Value></Index>
|
||||||
|
<Coefficients>
|
||||||
|
<Coefficient><Reason>571/пр_2022_п.83_т.2</Reason>
|
||||||
|
<Values><Value><CoefValue>0.7</CoefValue><Target>Расход</Target></Value></Values></Coefficient>
|
||||||
|
<Final><Values><Value><CoefValue>0.7</CoefValue><Target>Расход</Target></Value></Values></Final>
|
||||||
|
</Coefficients>
|
||||||
<Machinist><Grade>6</Grade><Consumption>5.5</Consumption><PricePerUnitCur>541.85</PricePerUnitCur></Machinist>
|
<Machinist><Grade>6</Grade><Consumption>5.5</Consumption><PricePerUnitCur>541.85</PricePerUnitCur></Machinist>
|
||||||
</Machine>
|
</Machine>
|
||||||
</ResourcesInternal>
|
</ResourcesInternal>
|
||||||
@@ -111,10 +120,17 @@ def test_parse_estimate_full(tmp_path):
|
|||||||
assert p["overhead"] == {"value": "92", "target": "ФОТ",
|
assert p["overhead"] == {"value": "92", "target": "ФОТ",
|
||||||
"reason": "Пр/812-001.1-1", "price_cur": 18509.0}
|
"reason": "Пр/812-001.1-1", "price_cur": 18509.0}
|
||||||
assert p["profit"]["value"] == "46"
|
assert p["profit"]["value"] == "46"
|
||||||
|
# позиционный коэффициент с Target
|
||||||
|
assert p["coefficients"][0] == {"name": "Стесненные условия",
|
||||||
|
"reason": "421/пр_2022_прил.10",
|
||||||
|
"value": "1.15", "target": "ОТ"}
|
||||||
m = p["resources"]["machines"][0]
|
m = p["resources"]["machines"][0]
|
||||||
assert m["code"] == "91.01.01-035" and m["price_cur"] == 1224.81
|
assert m["code"] == "91.01.01-035" and m["price_cur"] == 1224.81
|
||||||
assert m["index"] == {"value": 1.38, "reason": "1030"}
|
assert m["index"] == {"value": 1.38, "reason": "1030"}
|
||||||
assert m["machinist"] == {"consumption": 5.5, "price_cur": 541.85, "grade": "6"}
|
assert m["machinist"]["grade"] == "6"
|
||||||
|
# коэф НА РЕСУРС: норма 5.5 базовая, эффективная = 5.5 × 0.7 (демонтаж 571/пр)
|
||||||
|
assert m["coef"] == {"factors": {"Расход": 0.7}, "reason": "571/пр_2022_п.83_т.2"}
|
||||||
|
assert round(m["consumption"] * m["coef"]["factors"]["Расход"], 3) == 3.85
|
||||||
# прямой материал + Transport
|
# прямой материал + Transport
|
||||||
assert d["direct_materials"][0]["name"] == "Песок природный"
|
assert d["direct_materials"][0]["name"] == "Песок природный"
|
||||||
assert d["direct_materials"][0]["is_return"] is False
|
assert d["direct_materials"][0]["is_return"] is False
|
||||||
|
|||||||
Reference in New Issue
Block a user