diff --git a/M02_MasterTemplete/M02_Labor_Copy.py b/M02_MasterTemplete/M02_Labor_Copy.py index 8dbedbf8f..d4a9992c3 100644 --- a/M02_MasterTemplete/M02_Labor_Copy.py +++ b/M02_MasterTemplete/M02_Labor_Copy.py @@ -151,11 +151,8 @@ def line(whole: Any, doc: dict, one: dict) -> dict[str, Any]: docs = dc.closure(whole, dc.calls(base), None) if base else {} if base is None: return {"기준": None, "줄": [], "재료": [], "까닭": f"수식 문서 없음 「{code}」"} - row = whole.logic(code) - mats = [] if isinstance(row.get("흐름"), dict) else row.get("호표") or [] - apart = dc.apart_of( - one.get("자재표시"), [{"차례": n} for n, x in enumerate(mats) if x.get("종류") == "재료"] - ) + mats = dc.prices._mat_lines(base) # 재료 금액 줄(855 L2 ⓑ-3 — 로직 줄 호표 안 읽음) + apart = dc.apart_of(one.get("자재표시"), [{"차례": n} for n, _, _ in mats]) given = dc.given_of(whole, code, one.get("입력값")) body = dc.line_doc(base, rate, picks, apart) ans = _traced(body, whole, docs, given, copy) @@ -185,12 +182,12 @@ def _traced(doc: dict, whole: Any, docs: dict, given: dict, copy: dict) -> dict: } -def _mats(items: list, ans: dict, picks: Any) -> list[dict[str, Any]]: - """로직 자재(103-1) — 맨 위 재료 줄(호표 차례 = 문서 금액 줄 차례)마다 셈 기록이 읽은 품목 키 · - 수량 · 단가 · 금액(별도계상 · 같은 품목 400 · 호표 들이기 `_inside` 가 읽음).""" +def _mats(mats: list, ans: dict, picks: Any) -> list[dict[str, Any]]: + """로직 자재(103-1) — 재료 금액 줄(`_mat_lines` · 단위 = 연결 단위 = 로직 원문 표기)마다 + 셈 기록이 읽은 품목 키 · 수량 · 단가 · 금액(별도계상 · 같은 품목 400 · `_inside` 가 읽음).""" calls, lines, out = ans.get("부름") or [], ans.get("줄") or [], [] - for n, item in enumerate(items): - if item.get("종류") != "재료" or n >= len(lines): + for n, line, link in mats: + if n >= len(lines): continue read = [calls[j] for j in lines[n].get("부름") or [] if j < len(calls)] keys = [c.get("품목") for c in read] + [ @@ -199,7 +196,12 @@ def _mats(items: list, ans: dict, picks: Any) -> list[dict[str, Any]]: key = next((k for k in keys if k), None) head = {k: lines[n].get(k) for k in ("수량", "단가", "금액", "까닭")} out.append( - {"차례": n, "이름": item.get("이름") or "", "단위": item.get("단위") or "", **head} + { + "차례": n, + "이름": line.get("이름") or "", + "단위": link.get("단위") or line.get("단위") or "", + } + | head | {"품목": {"키": key} if key else None, "고름": str(n) in (picks or {})} ) return out