Fix stove material matching for site bill
This commit is contained in:
+4
-3
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user