Keep consolidated costs out of local estimates and group public updates
This commit is contained in:
+17
-14
@@ -51,7 +51,6 @@ class DraftMeta(BaseModel):
|
||||
zone: str = ""
|
||||
price_level: str = ""
|
||||
norm_base: str = "ФСНБ-2022"
|
||||
vat_pct: float = 22.0
|
||||
|
||||
|
||||
class EstimateDraft(BaseModel):
|
||||
@@ -59,11 +58,13 @@ class EstimateDraft(BaseModel):
|
||||
positions: list[DraftPosition] = Field(default_factory=list)
|
||||
|
||||
|
||||
# Лимитированные затраты движка (временные здания, зимнее удорожание) и цены перевозок пока
|
||||
# вшиты под Приморский край — решение владельца 14.09.2026: называть это, пока нет своей правки.
|
||||
PRIMORSKY = "Приморский край"
|
||||
LIMITS_NOTE = ("Лимитированные затраты (временные здания, зимнее удорожание, резерв) и цены "
|
||||
"перевозок посчитаны по Приморскому краю — для другого региона их надо уточнить.")
|
||||
LIMITS_NOTE = ("В локальную смету не включены временные здания, зимние затраты, резерв и НДС. "
|
||||
"Нужен ли отдельный расчёт этих затрат для объектной или сводной сметы? "
|
||||
"Если да, уточните вид объекта, регион и сроки строительства, данные ПОС "
|
||||
"и налоговые условия.")
|
||||
TRANSPORT_NOTE = ("Цены перевозок посчитаны по Приморскому краю — для другого региона "
|
||||
"их надо уточнить.")
|
||||
|
||||
|
||||
def recalc_meta(applied: dict) -> dict:
|
||||
@@ -86,7 +87,7 @@ def _applied(basis: dict | None) -> dict:
|
||||
|
||||
def build_and_calc(draft: EstimateDraft, resources: dict, fgis, basis: dict | None = None) -> dict:
|
||||
"""EstimateDraft → расчёт движком (strict) → verify. Возвращает
|
||||
{ok, grand_total, grand_total_with_limits, missing, unpriced, incomplete, applied, verify, …}.
|
||||
{ok, grand_total, missing, unpriced, incomplete, applied, verify, …}.
|
||||
|
||||
Договор двух признаков (не путать, зайка 17.09.2026): `status` отвечает «дошли ли до чисел»
|
||||
— «ok» значит, что движок посчитал и панель можно показать; отказы до чисел говорят причину
|
||||
@@ -95,17 +96,20 @@ def build_and_calc(draft: EstimateDraft, resources: dict, fgis, basis: dict | No
|
||||
не выдавать. Поэтому пара {"status": "ok", "ok": false} законна: числа есть, но смета неполная.
|
||||
incomplete → итог посчитан без ресурсов, которых нет в форме зоны (список в unpriced)."""
|
||||
from smeta_railway.calc.estimate import EstimateCalculator
|
||||
from smeta_railway.config import Section, Subsection, WorkItem
|
||||
from smeta_railway.config import LimitedCostsConfig, Section, Subsection, WorkItem
|
||||
|
||||
items = [WorkItem(code=p.code, name=p.name or p.code, unit=p.unit, qty=p.qty)
|
||||
for p in draft.positions]
|
||||
section = Section(name="Смета", subsections=[Subsection(name="", items=items)])
|
||||
calc = EstimateCalculator(fgis=fgis, resources=resources, strict=True)
|
||||
# Это ЛСР: дополнительные затраты и НДС относятся к отдельному расчёту.
|
||||
# Нулевой конфиг не даёт движку подставить его региональные проценты по умолчанию.
|
||||
calc = EstimateCalculator(
|
||||
fgis=fgis, resources=resources, strict=True,
|
||||
limited_costs_config=LimitedCostsConfig(
|
||||
temp_buildings_pct=0, winter_pct=0, contingency_pct=0))
|
||||
result = calc.calculate([section])
|
||||
|
||||
vp = draft.meta.vat_pct
|
||||
gt = result.grand_total
|
||||
vat = round(gt * vp / 100, 2)
|
||||
# Что прислал агент — по порядку внутри шифра: один шифр может стоять в смете дважды.
|
||||
entered: dict[str, list] = {}
|
||||
for d in draft.positions:
|
||||
@@ -121,8 +125,7 @@ def build_and_calc(draft: EstimateDraft, resources: dict, fgis, basis: dict | No
|
||||
"positions": [{"code": p.gesn_code, "name": p.name, "unit": p.unit,
|
||||
"qty": p.qty, "total": p.total, "norm_base": draft.meta.norm_base, **inp}
|
||||
for p, inp in rows if not p.unresolved],
|
||||
"totals": {"grand_total": gt, "vat_pct": vp, "vat": vat,
|
||||
"total_with_vat": round(gt + vat, 2)},
|
||||
"totals": {"grand_total": gt},
|
||||
}
|
||||
v = estimate_verify.verify(norm)
|
||||
unpriced = list(getattr(result, "unpriced", []) or [])
|
||||
@@ -132,9 +135,9 @@ def build_and_calc(draft: EstimateDraft, resources: dict, fgis, basis: dict | No
|
||||
"applied": _applied(basis),
|
||||
"incomplete": bool(unpriced),
|
||||
"unpriced": unpriced,
|
||||
"limits_note": "" if _applied(basis).get("subject") == PRIMORSKY else LIMITS_NOTE,
|
||||
"limits_note": (LIMITS_NOTE + (" " + TRANSPORT_NOTE
|
||||
if _applied(basis).get("subject") != PRIMORSKY else "")),
|
||||
"grand_total": gt,
|
||||
"grand_total_with_limits": result.grand_total_with_limits,
|
||||
"missing": result.missing,
|
||||
"verify": v,
|
||||
"positions_count": len(result.positions),
|
||||
|
||||
Reference in New Issue
Block a user