From 37d4511d03dbcbd2f823924757ae25f571a3df1e Mon Sep 17 00:00:00 2001 From: umsangdon Date: Wed, 18 Nov 2026 03:35:24 +0900 Subject: [PATCH] =?UTF-8?q?refactor(855-F=20B9-5):=20B09=20=EC=82=B0?= =?UTF-8?q?=EA=B7=BC=20=EB=AA=A9=EB=A1=9D=EC=9D=B4=20=EC=82=AC=EB=B3=B8=20?= =?UTF-8?q?=EB=8B=A8=EA=B0=80=EC=82=B0=EC=B6=9C=20=EC=88=98=EC=8B=9D=20?= =?UTF-8?q?=EC=82=AC=EB=B3=B8=EC=97=90=EC=84=9C=20=ED=95=98=EC=9C=84=20?= =?UTF-8?q?=EC=82=B0=EA=B7=BC=EC=9D=84=20=EC=9D=BD=EC=9D=8C=20=C2=B7=20?= =?UTF-8?q?=EC=82=AC=EB=B3=B8=20=EB=AC=B6=EC=9D=8C=20=EA=B0=92=20=EC=82=AC?= =?UTF-8?q?=EB=B3=B8=20=3D=20skc.held?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - B09_Estimation_Sangeun.rows_of: 사본 SK 갈래 = 굳힌 줄(굳힌줄 · GX9) 대신 수식 사본 문서 셈(Linked.sk_answer)의 줄이 부른 하위 단가산출 → 산근 줄(대가 블록 산근 줄 키와 같음) · B9-4 합친 뒤(브레인 알림) - M02_Item_Source.copy_rows: 값 사본을 skc.held 로(층 파일 사본 칸 없음 · 사본 SK = 수식 값 몫 · sub4 2-D 맞물림) · 옛 굳힌 SK 원본 갈래 걷음 - 시험: test_719_2 하위 단가산출 줄 산근 하나 더함(GF000206 → GF000160 · 옛 코드 실패 · 새 코드 통과) · test_795_4 둘 = 새 꼴 견본(값 사본 없는 문서 = 사본 · 수식 둘 다 뺌 · SK 값 사본 = 수식 몫) - 검증: 받은 뒤 관련 + 핵심 418 — 통과 417 · test_848_1 ㉦ 하나 = sub4 2-D 굳힘 표지 읽기 두 줄 뒤 통과(브레인 정함) · test_855_b09_golden 같음 Co-Authored-By: Claude Opus 5.5 --- B09_Estimation/B09_Estimation_Sangeun.py | 19 +++++++++---------- M02_MasterTemplete/M02_Item_Source.py | 10 +++++----- resources/tester/test_719_2_sk_project.py | 11 +++++++++++ resources/tester/test_795_4_b09_copy.py | 8 +++++--- 4 files changed, 30 insertions(+), 18 deletions(-) diff --git a/B09_Estimation/B09_Estimation_Sangeun.py b/B09_Estimation/B09_Estimation_Sangeun.py index 09a09420e..4de233051 100644 --- a/B09_Estimation/B09_Estimation_Sangeun.py +++ b/B09_Estimation/B09_Estimation_Sangeun.py @@ -141,16 +141,15 @@ def rows_of(folder: Path, whole: Any = None, docs: dict | None = None) -> list[d doc = copies.get(refs.ref_id(ref)) if not isinstance(doc, dict) or depth >= refs.DEPTH: continue - if refs.kind_of(ref.get("키")) == "sangeun": # 굳힌 SK(719-2) = 대가 · 하위 = 산근 - base = str((doc.get("바탕") or {}).get("로직") or "") - if base and "굳힌줄" in doc: - logic_line(base, doc.get("입력값"), doc.get("켜쌓기율"), None, True) - inner_refs = [ - {"참조": x["참조"]} - for x in doc["굳힌줄"].get("호표") or [] - if isinstance(x.get("참조"), dict) - ] - walk(inner_refs, True, depth + 1) # 단가산출 속 일위대가 · SK + if refs.kind_of(ref.get("키")) == "sangeun": # 사본 SK(719-2) = 대가 · 하위 = 산근 + from B09_Estimation.B09_Estimation_Linked import sk_answer + + got = sk_answer(doc) # 수식 사본 문서 셈(855-F B9-5) — 줄이 부른 하위 단가산출 + for x in got.lines if got else []: + call = x.get("부름") or {} + if call.get("code"): + out.append({"code": call["code"], "given": call.get("given") or {}, + "rate": None, "picks": None}) # fmt: skip continue if refs.kind_of(ref.get("키")) == "promote": # 옛 SP = 일위대가화 first = (doc.get("담은로직") or [None])[0] diff --git a/M02_MasterTemplete/M02_Item_Source.py b/M02_MasterTemplete/M02_Item_Source.py index 3e4dcf009..a148afee1 100644 --- a/M02_MasterTemplete/M02_Item_Source.py +++ b/M02_MasterTemplete/M02_Item_Source.py @@ -196,13 +196,13 @@ def price_bundle(labor: dict[str, Any] | None, root: Path) -> dict[str, Any]: def copy_rows(docs: list[Any]) -> list[dict[str, Any]]: - """문서 · 굳힌 참조사본(SK 는 `원본`)의 로직 사본 줄(795-4) — 키 겹침 = 앞 문서 것.""" + """문서 · 굳힌 참조사본의 로직 사본 줄(795-4 · 값 사본 = `skc.held` · 855 2-D) — + 키 겹침 = 앞 문서 것.""" from M02_MasterTemplete import M02_Sangeun_Copy as skc out: dict[str, dict] = {} for doc in docs: - for one in (doc, doc.get("원본") if isinstance(doc, dict) else None): - if skc.has(one): - for row in [*one[skc.KEY]["로직"], *(one[skc.KEY].get("단가") or [])]: - out.setdefault(str(row.get("키")), row) + held = skc.held(doc) + for row in [*(held or {}).get("로직", []), *((held or {}).get("단가") or [])]: + out.setdefault(str(row.get("키")), row) return list(out.values()) diff --git a/resources/tester/test_719_2_sk_project.py b/resources/tester/test_719_2_sk_project.py index 4d304fe6d..c4edfbd4b 100644 --- a/resources/tester/test_719_2_sk_project.py +++ b/resources/tester/test_719_2_sk_project.py @@ -166,3 +166,14 @@ def test_서고_SK_업데이트_미리보기_다시_굳힘(world, tmp_path): after = daega_inputs(root) block = next(b for b in after["blocks"] if b["id"] == after["libs"][folder]) assert block["cover"] == cover_key and block["lines"][0]["qty"] == pytest.approx(0.108) + + +def test_SK_하위_단가산출_줄_산근(world, tmp_path): + """사본 SK 문서 줄이 부른 하위 단가산출 = 대가 블록 산근 줄 · B09 산근 목록에 그 키(855-F B9-5).""" + key = _sk(world["personal"], 바탕={"로직": "GF000206"}) # 합판거푸집 → GF000160 부름 + root, folder = _lib(world, tmp_path, key) + daega, done, sg_rows = _b09(root) + lines = done[daega["libs"][folder]]["lines"] + subs = [ln for ln in lines if ln["kind"] == "sangeun"] + assert subs and all(ln["key"] in sg_rows for ln in subs) + assert {ln["key"].split(":")[1] for ln in subs} == {"GF000160"} diff --git a/resources/tester/test_795_4_b09_copy.py b/resources/tester/test_795_4_b09_copy.py index c800ffc25..58259b3b6 100644 --- a/resources/tester/test_795_4_b09_copy.py +++ b/resources/tester/test_795_4_b09_copy.py @@ -64,7 +64,9 @@ def test_bundle_is_m02_copy_then_frozen(world, monkeypatch): assert _amount(rows, bundle) == was # 굳힌 묶음 = M01 안 읽음 late = source.price_bundle(source.labor_doc_rows(doc), me) # 구조물 지정이 M01 바뀐 뒤 assert _amount(rows, late) == was # M02 사본 = 만든 때 - old = {k: v for k, v in doc.items() if k != skc.KEY} # ② 사본 없는 옛 문서 = 지금 M01 + old = { + k: v for k, v in doc.items() if k not in (skc.KEY, skc.FORM) + } # ② 값 사본 없음 = 지금 M01 old_rows = source.labor_doc_rows(old) assert _amount(old_rows, source.price_bundle(old_rows, me)) != was @@ -82,9 +84,9 @@ def test_deleted_m01_key_kept_in_copy(world, monkeypatch): def test_copy_rows_order_and_sk_origin(): - """사본 줄 모음 — 앞 문서 먼저 · 굳힌 SK 는 `원본` 사본.""" + """사본 줄 모음 — 앞 문서 먼저 · 값 사본 = `skc.held`(사본 SK = 수식 값 몫 · 855-F B9-5).""" a = {skc.KEY: {"로직": [{"키": "GC1", "v": 1}], "단가": [{"키": "LB1", "v": 1}]}} - b = {"원본": {skc.KEY: {"로직": [{"키": "GC1", "v": 2}, {"키": "GC2"}], "단가": []}}} + b = {skc.FORM: {"로직": [{"키": "GC1", "v": 2}, {"키": "GC2"}], "단가": [], "따로": True}} got = source.copy_rows([a, b, {"x": 1}, None]) assert [(r["키"], r.get("v")) for r in got] == [("GC1", 1), ("LB1", 1), ("GC2", None)] assert item_prices.collect(["GF000219"], over=[]) == item_prices.collect(["GF000219"])