Fix stove material matching for site bill

This commit is contained in:
anor
2026-11-26 21:23:03 +10:00
parent 68f9a77c03
commit dd93361276
3 changed files with 62 additions and 5 deletions
+4 -3
View File
@@ -18,7 +18,6 @@ RATES = {
"bread": ("08-08-003-09", "8-31-9"),
}
BRICK_QUERY = {"ceramic": "кирпич керамический", "fireclay": "кирпич шамотный"}
_BRICK_WORDS = ("кирпич", "шамот", "огнеупор")
_ROMAN = ("I", "II", "III", "IV")
@@ -120,7 +119,8 @@ def load(stove: c.StoveRequest) -> dict:
zone = zones[0]["zone_name"] if zones else s.zone
periods = [r.get("period") for r in probe.get("results", []) if r.get("period")]
out = {"valid_at": _period(periods[0]) if periods else "период не указан", "region": region,
"zone": s.zone and zone, "notes": notes, "lines": [], "brick_lines_skipped": []}
"zone": s.zone and zone, "notes": notes, "lines": [], "brick_lines_skipped": [],
"search_results": {}}
if s.kind in RATES:
code = RATES[s.kind][0]
rate = rim_calc.calc_rim_rate(code=code, region=region, zone=zone)
@@ -149,9 +149,10 @@ def load(stove: c.StoveRequest) -> dict:
out["lines"].append(_line(query, qty, "шт", _choose(got, "шт", query), bricks=True))
for item in s.materials or []:
name = item.name
if any(word in name.lower() for word in _BRICK_WORDS):
if re.search(r"\bкирпич(?:и|а|ей|ом|у)?\b", name.lower()):
out["brick_lines_skipped"].append(name)
continue
got = fgis_ref.find_resource_price(query=name, region=region, zone=zone, limit=12)
out["search_results"][len(out["lines"])] = got
out["lines"].append(_line(name, item.qty, item.unit, _choose(got, item.unit, name)))
return out