diff --git a/M02_MasterTemplete/M02_Labor_Ref.py b/M02_MasterTemplete/M02_Labor_Ref.py index ae47ac4be..f8ede9600 100644 --- a/M02_MasterTemplete/M02_Labor_Ref.py +++ b/M02_MasterTemplete/M02_Labor_Ref.py @@ -299,6 +299,19 @@ def summary(folder: Path, kind: str, key: str, expand: Expand | None = None) -> layer, owner = where(folder) base = expand({"층": layer, "주인": owner, "키": key}).get("기준") or {} out["기준금액"] = float(base["계"]) if "계" in base else None + # 717-2a 목록 열 — 바탕(로직 「키 이름」 | 참조 키 | None) · 고친 줄 수 · 쓰는 곳 수 + if kind == "sangeun": + top, (layer, owner) = doc.get("바탕") or {}, where(folder) + logic = top.get("로직") + out["바탕"] = logic or (top.get("참조") or {}).get("키") + if logic and expand is not None: + try: + out["바탕"] = f"{logic} {expand.whole.logic(logic).get('이름') or ''}".strip() + except Exception: # noqa: BLE001 — 없는 로직 = 키만(셈 때 까닭) + pass + out["고친줄수"] = sum(len(doc.get(k) or ()) for k in ("덮개", "더한줄", "뺀줄")) + # ponytail: SK 마다 모든 층 훑음(users) — 목록이 느려지면 층 훑기 한 번 셈으로 + out["쓰는곳수"] = len(users({"층": layer, "주인": owner, "키": key})) return out diff --git a/resources/tester/test_717_2a_sangeun_list.py b/resources/tester/test_717_2a_sangeun_list.py new file mode 100644 index 000000000..ac19b209a --- /dev/null +++ b/resources/tester/test_717_2a_sangeun_list.py @@ -0,0 +1,54 @@ +"""M02 단가산출 칸 목록 줄(PLAN 717-2a · `M02_Labor_Ref.summary` sangeun 갈래) — 임시 storage. + +바탕 = 로직 「키 이름」 · 참조 = SK 키 · 없음 = None · 고친 줄 수 = 덮개 + 더한줄 + 뺀줄 · +쓰는 곳 수 = 그 SK 를 바탕 · 더한줄로 담은 문서 수 · 일위대가(precombo) 줄엔 안 붙음. +""" + +from M01_MasterData import M01_MasterData_Store as m01 +from M02_MasterTemplete import M02_Labor_Ref as refs +from M02_MasterTemplete import M02_MasterTemplete_Store as store +from M02_MasterTemplete.M02_Labor_Expand import Expand +from resources.tester.test_m02_labor_ref import MINE, world # noqa: F401 — 같은 임시 층 + +PCT = "GC001109" + + +def _sk(folder, **doc): + with store.at(folder): + return refs.create("sangeun", {"이름": "목록 시험", "단위": "㎡", "더한줄": [], **doc})[ + "이름" + ] + + +def _row(folder, kind, key): + return refs.summary(folder, kind, key, Expand(m01.loaded()[1])) + + +def test_sangeun_row_base_edits_users(world): + mine = world["personal"] + a = _sk(mine, 바탕={"로직": PCT}, 덮개={"labor:LB000036#0": {"qty": 0.5}}, 뺀줄=["pct:x#0"]) + name = m01.loaded()[1].logic(PCT)["이름"] + row = _row(mine, "sangeun", a) + assert row["바탕"] == f"{PCT} {name}".strip() + assert row["고친줄수"] == 2 and row["쓰는곳수"] == 0 + assert row["제목"] == "목록 시험" and row["단위"] == "㎡" + # 바탕 참조 SK · 더한줄 하나 → 그 SK 쓰는 곳 1 + b = _sk( + mine, + 바탕={"참조": {**MINE, "키": a}}, + 더한줄=[{"종류": "인력", "요소": "LB000036", "이름": "보통인부", "단위": "인", "수량": 1}], + ) + row_b = _row(mine, "sangeun", b) + assert row_b["바탕"] == a and row_b["고친줄수"] == 1 + assert _row(mine, "sangeun", a)["쓰는곳수"] == 1 + # 바탕 없음 + c = _sk(mine) + row_c = _row(mine, "sangeun", c) + assert row_c["바탕"] is None and row_c["고친줄수"] == 0 + + +def test_precombo_row_has_no_sangeun_fields(world): + with store.at(world["personal"]): + sc = refs.create("precombo", {"이름": "조합", "담은로직": []})["이름"] + row = _row(world["personal"], "precombo", sc) + assert not {"바탕", "고친줄수", "쓰는곳수"} & set(row)