Show norm cost breakdown and reference rates in finder
This commit is contained in:
+17
-1
@@ -86,6 +86,21 @@ def catalog() -> list[dict]:
|
||||
con.close()
|
||||
|
||||
|
||||
def rate_catalog() -> list[dict]:
|
||||
"""НР/СП by explicit work type from the project's loaded source tables."""
|
||||
try:
|
||||
import estimate_contract # noqa: F401 — registers the sibling package path
|
||||
from smeta_railway.data.nr_sp_tables import NR_TABLE, SP_TABLE
|
||||
except ImportError:
|
||||
return []
|
||||
shared = sorted(NR_TABLE.keys() & SP_TABLE.keys(),
|
||||
key=lambda key: (tuple(int(part) for part in re.findall(r"\d+", key)), key))
|
||||
return [{"id": key, "name": NR_TABLE[key][0],
|
||||
"nr_code": f"812/пр, п.{key}", "nr_pct": NR_TABLE[key][1],
|
||||
"sp_code": f"774/пр, п.{key}", "sp_pct": SP_TABLE[key][1]}
|
||||
for key in shared]
|
||||
|
||||
|
||||
@lru_cache(maxsize=32)
|
||||
def _section_paths(db_key: tuple[str, int, int], base: str, base_type: str) -> tuple[tuple[str, str], ...]:
|
||||
"""Cache section paths and their first norm codes; a rebuilt DB gets a new key."""
|
||||
@@ -140,7 +155,8 @@ def browse(base: str, base_type: str, path: str = "", limit: int = 40,
|
||||
clause = ""
|
||||
params = (BASES[base], base_type)
|
||||
rows = con.execute(
|
||||
"SELECT code,name,unit,cost,price_level,section_path FROM works "
|
||||
"SELECT code,name,unit,cost,salary,machines,salary_mach,materials,"
|
||||
"price_level,section_path FROM works "
|
||||
f"WHERE base=? AND base_type=? {clause} ORDER BY code,name LIMIT ? OFFSET ?",
|
||||
(*params, limit + 1, offset)).fetchall()
|
||||
finally:
|
||||
|
||||
Reference in New Issue
Block a user