refactor(855-F B9-5): 가져온 식 단가산출도 문서만 — 대가 블록 % 밑 · 줄 자리 · 합밖 · 사본 묶음 줄을 수식 문서에서(가져온.로직 안 읽음)

- B09 Labor_Source.sangeun: 옛 로직 줄 셈법(_law · rule.mark on 가져온.로직 · 바탕 로직 줄) 걷음 →
  % 밑 = 문서 금액 줄 단가 「번지.X.비목 × r%」 · 「단계.'이름'.비목」 을 문서 줄(이름 · 번지 · 비목) · 단계로 푼
  rows: 꼴(_doc_base · Labor_Rule._ref) · 줄 자리 = 문서 금액 줄 자리 · 합밖 = 문서 답 · 밑 이름 없는 % 줄 글 = 문서 식 글
- M02_Item_Sangeun.bundle_keys: 가져온 식 줄 대신 문서 · 부름 문서가 잇는 요소 키(사본 단가 묶음)
- 까닭: sub8 857-3b — 가져온 식 저장본에서 가져온.로직이 없어짐(옛 굳힘은 대가 줄 0 개가 됨)
- 골든 test_855_b09_golden daega_inputs 다시 뜸 — 가져온 식 블록 % 줄 spec 글만(옛 식 글 「번지.A01.재료비 * 11 / 100」
  → 문서 식 글 「번지.A01.재료비 × 11%」) · 밑 rows · 율 · 금액 · 줄 수 같음(6 줄)
- 검증: 관련 + 핵심 455 — 통과 454 · test_848_1 ㉦ 하나 = sub4 굳힘 표지 읽기 뒤 통과(브레인 정함) ·
  test_792_3 실무 가져온 식 대가 둘 · 848_7 통과 · Labor_Source 700 줄

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-18 04:07:26 +09:00
co-authored by Claude Opus 5.5
parent 37d4511d03
commit 8da324551f
5 changed files with 41 additions and 40 deletions
+26 -21
View File
@@ -200,7 +200,6 @@ class Builder:
rid = refs.ref_id(ref)
lines = [{**self._doc_line(got, n, x), "sk": True} for n, x in enumerate(got.lines)]
base = str((doc.get("바탕") or {}).get("로직") or "")
law = _law(doc, base, whole, lines, got.lines) # 새 의미 로직 줄 자리 · 합밖 · % 밑(792-4)
expand = _Loose(whole, lambda r: copies.get(refs.ref_id(r)))
m02 = sk_money(doc, whole, expand, rid)
given = doc.get("입력값") or {}
@@ -216,7 +215,6 @@ class Builder:
"cite": f"단가산출 {ref.get('키')}",
"origin": {"참조": rid, "단가산출": rid, "바탕": base}, # cid 열쇠 = SK 이름표
"lines": lines,
**({"rule": law} if law else {}),
**({"m02": m02} if m02 else {}),
}
return self.put(block, f"P:{_digest({'단가산출': rid})}")
@@ -226,21 +224,20 @@ class Builder:
head = {"name": x.get("이름") or "", "spec": "", "unit": x.get("단위") or ""}
qty, key, call = _f(x.get("수량")), str(x.get("키") or ""), x.get("부름") or {}
out = {"out": True} if x.get("합밖") else {}
if place := ((got.doc.get("금액") or [])[n : n + 1] or [{}])[0].get("자리"):
out["place"] = dict(place) # 줄 자리(792-4) = 문서 금액 줄 칸
if pct := got.pct(n):
word = pct[1].removesuffix("의 %")
base = {"노무비": "part:labor", "재료비": "part:material", "경비": "part:expense",
"인건비": "lines:labor"}.get(word, f"line:{word}") # fmt: skip
if not word: # 밑을 모르는 덧줄 — 옛 길과 같게 빈 줄
return {
**head,
**out,
"kind": "blank",
"qty": qty,
"why": "덧줄 — 대가 단가로 못 셈",
}
part = PART.get(str((got.doc.get("금액") or [])[n].get("비목")), "expense")
base = base if word else _doc_base(got.doc, n) # 번지 · 단계 밑(792-4)
if base is None: # 밑을 모르는 덧줄 — 옛 길과 같게 빈 줄
why = "덧줄 — 대가 단가로 못 셈"
return {**head, **out, "kind": "blank", "qty": qty, "why": why}
dl = (got.doc.get("금액") or [])[n] # 밑 이름 모름 = 문서 식 글
part, spec = PART.get(str(dl.get("비목")), "expense"), pct[1] or str(dl.get("단가"))
return {**head, **out, "kind": "pct", "part": part, "base": base,
"spec": pct[1], "unit": "%", "qty": float(pct[0])} # fmt: skip
"spec": spec, "unit": "%", "qty": float(pct[0])} # fmt: skip
own = _own(x, qty)
if call.get("machine") or key[:2] == "EQ":
key = call.get("machine") or key
@@ -521,18 +518,26 @@ def _row(whole: Any, key: str) -> dict[str, Any]:
return {}
def _law(doc: dict, base: str, whole: Any, lines: list, engine: list) -> dict | None:
"""SK 블록 셈법(792-4) — 줄이 기초 줄(가져온 식 = 가져온 줄 · 그 밖 = 바탕 로직)과 하나하나
맞을 때만 `rule.mark`(새 의미 로직 = 줄 자리 · 합밖 · % 밑) · 안 맞음(따로 고친 문서) = None."""
from M02_MasterTemplete import M02_Doc_Import as dim
def _doc_base(doc: dict, n: int) -> str | None:
"""% 줄 밑(792-4 `rows:`) — 단가 「번지.X.비목 × r%」 · 「단계.'이름'.비목 …」 = 문서 금액 줄 ·
단계로 푼 앞 줄 차례(`Labor_Rule._ref`) · 모름 = None."""
lines = doc.get("금액") or []
try:
row = (doc.get("가져온") or {}).get("로직") if dim.is_imported(doc) else whole.logic(base)
except Exception: # noqa: BLE001 — 바탕 없음 · 없는 로직
node = rule.md.parse(str(lines[n].get("단가") or ""))
except Exception: # noqa: BLE001 — 못 읽는 식 = 밑 모름
return None
if not isinstance(row, dict) or len(rule.ms.items(row)) != len(lines):
if node[0] == "bin" and node[1] == "*" and node[3][0] == "pct":
node = node[2]
elif node[0] == "bin" and node[1] == "/" and node[2][0] == "bin" and node[2][1] == "*":
node = node[2][2]
else:
return None
return rule.mark(row, lines, engine)
keep = ("이름", "번지", "비목", "합밖")
row = {"호표": [{k: x.get(k) for k in keep if k in x} for x in lines], "덧줄": []}
got = rule._ref({**row, "단계": doc.get("단계") or []}, node, n)
if not got or len(set(got)) != len(got):
return None
return "rows:" + ",".join(str(i) if part is None else f"{i}@{part}" for i, part in got)
def fixed_line(fx: dict, qty: Any, where: dict | None = None, whole: Any = None) -> dict[str, Any]: