From c9df064389e978f0ec1c9b5311307b35cb235f17 Mon Sep 17 00:00:00 2001 From: umsangdon Date: Tue, 17 Nov 2026 01:11:01 +0900 Subject: [PATCH] =?UTF-8?q?fix(848-7):=20=EC=97=91=EC=85=80=20=ED=8C=90=20?= =?UTF-8?q?=EC=A0=9C=EC=96=B4=20=EA=B5=AC=EC=97=AD=20=EC=97=B0=EA=B2=B0=20?= =?UTF-8?q?=EB=AC=B8=EC=84=9C=20=C2=B7=20=EA=B0=92=20=ED=99=94=EB=A9=B4=20?= =?UTF-8?q?=EC=BA=90=EC=8B=9C=EC=97=90=20=C2=B7=20=EB=B0=A9=EC=8B=9D=20?= =?UTF-8?q?=EC=97=86=EB=8A=94=20=EC=9C=84=20=EC=B8=B5(=EA=B0=80=EC=A0=B8?= =?UTF-8?q?=EC=98=A8=20=EA=B0=92)=20=EB=B3=80=EC=88=98=20=EB=AC=BC?= =?UTF-8?q?=EB=A0=A4=EB=B0=9B=EC=9D=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - M02_Doc_Import.record — 엑셀 판도 기계 식 문서 · 값을 기록(없으면 제어 구역이 안 열림 · ORCA 에서 찾음) - prune_work_layer ↔ pruneWorkLayer — 위 층에 방식 없이 식 · 변수만 있어도 같은 식이면 물려받음 (저장 뒤 손대지 않은 경쟁사 값이 내 고침 · 파랑으로 남던 것) - 시험 test_848_7 방식 없는 위 층 거울 · 관련 시험 442 통과 Co-Authored-By: Claude Opus 5.5 --- M02_MasterTemplete/M02_Doc_Import.py | 3 ++ common_util/common_util_formula_doc_cover.ts | 3 +- .../master_data/scripts/master_doc_cover.py | 5 ++- resources/tester/test_848_7_import_carry.py | 41 +++++++++++++++++++ 4 files changed, 50 insertions(+), 2 deletions(-) diff --git a/M02_MasterTemplete/M02_Doc_Import.py b/M02_MasterTemplete/M02_Doc_Import.py index d74b21182..de85a7876 100644 --- a/M02_MasterTemplete/M02_Doc_Import.py +++ b/M02_MasterTemplete/M02_Doc_Import.py @@ -570,6 +570,9 @@ def record(doc: dict, sk: dict) -> dict[str, Any]: links.learn(mine) rec.prefetch(mine) dc.mc.calc(mine, rec) + if mine is not doc: # 848-7 엑셀 판 기계 줄 제어 구역 = 연결 문서 · 값도 화면 캐시에 + rec.prefetch(doc) + dc.mc.calc(doc, rec) except Exception: # noqa: BLE001 — 셈 틀림 = 셈 답 표지 · 기록은 모은 데까지 pass return rec.out() diff --git a/common_util/common_util_formula_doc_cover.ts b/common_util/common_util_formula_doc_cover.ts index 23fb406f8..1442c472e 100644 --- a/common_util/common_util_formula_doc_cover.ts +++ b/common_util/common_util_formula_doc_cover.ts @@ -297,7 +297,8 @@ export function pruneWorkLayer( const upForm = upWay === HOURLY ? String(up.식 ?? "") : ""; const form = String(want.식 ?? "") || upForm; if (form !== upForm) out.식 = form; - const held = { ...(base ?? {}), ...(form === upForm ? (up.변수 ?? {}) : {}) }; + const same = form === String(up.식 ?? ""); // 848-7 방식 없는 위 층(가져온 값)도 같은 식이면 변수 물려받음 + const held = { ...(base ?? {}), ...(same ? (up.변수 ?? {}) : {}) }; const got = Object.entries(want.변수 ?? {}).filter( ([k, v]) => v !== null && v !== undefined && v !== "" && !(k in held && sameNum(v, held[k])), ); diff --git a/resources/master_data/scripts/master_doc_cover.py b/resources/master_data/scripts/master_doc_cover.py index 4b0617331..60c27ce37 100644 --- a/resources/master_data/scripts/master_doc_cover.py +++ b/resources/master_data/scripts/master_doc_cover.py @@ -239,7 +239,10 @@ def prune_work_layer(want, base: dict | None = None, upper: dict | None = None) form = str(want.get("식") or "") or up_form if form != up_form: out["식"] = form - held = {**(base or {}), **((up.get("변수") or {}) if form == up_form else {})} + same = form == str( + up.get("식") or "" + ) # 848-7 방식 없는 위 층(가져온 값)도 같은 식이면 변수 물려받음 + held = {**(base or {}), **((up.get("변수") or {}) if same else {})} got = { k: v for k, v in (want.get("변수") or {}).items() diff --git a/resources/tester/test_848_7_import_carry.py b/resources/tester/test_848_7_import_carry.py index aee5ecbed..52b800fe1 100644 --- a/resources/tester/test_848_7_import_carry.py +++ b/resources/tester/test_848_7_import_carry.py @@ -360,3 +360,44 @@ def test_세_줄_OH_나누기_꼴도_한_줄_금액_같음(links): shape.machines(doc, {}, {}) assert len(doc["금액"]) == 1 and doc["금액"][0]["비목곱"] == {"재료비": "0.5"} assert _money(mc.calc(dim.view(doc, "엑셀"), links)) == _money(before) + + +# ── ⑦ 방식 없는 위 층(가져온 값) — 내 고침엔 바꾼 칸만 남음(파이썬 = TS) ───────────── +_JS_PRUNE = r""" +const fs = require("fs"), path = require("path"); +const ts = require(path.join(process.argv[1], "config", "node_modules", "typescript")); +const cache = new Map(); +function load(at) { + if (cache.has(at)) return cache.get(at); + const js = ts.transpileModule(fs.readFileSync(at, "utf8"), { + compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020 }, + }).outputText; + const box = { exports: {} }; + cache.set(at, box.exports); + const need = (p) => (p.startsWith(".") ? load(path.resolve(path.dirname(at), `${p}.ts`)) : require(p)); + new Function("exports", "module", "require", js)(box.exports, box, need); + return box.exports; +} +const cov = load(path.join(process.argv[1], "common_util", "common_util_formula_doc_cover.ts")); +const xs = JSON.parse(fs.readFileSync(0, "utf8")); +process.stdout.write(JSON.stringify(xs.map((x) => cov.pruneWorkLayer(x[0], x[1], x[2]) ?? null))); +""" + + +def test_방식_없는_위_층_변수_물려받음_거울(): + mcv = importlib.import_module("master_doc_cover") + up = {"식": "GC001155", "변수": {"운반거리": 0.185, "f": 0.85}} + cases = [ + [{"방식": "시간당", "식": "GC001155", "변수": {"운반거리": 0.3, "f": 0.85}}, {}, up], + [{"방식": "시간당", "식": "GC001155", "변수": {"운반거리": 0.185, "f": 0.85}}, {}, up], + [{"방식": "시간당", "식": "GC001173", "변수": {"f": 0.85}}, {}, up], + ] + want = [mcv.prune_work_layer(*c) for c in cases] + assert want == [ + {"방식": "시간당", "식": "GC001155", "변수": {"운반거리": 0.3}}, + {"방식": "시간당", "식": "GC001155"}, # 시간당만 켬 = 경쟁사 값 그대로 + {"방식": "시간당", "식": "GC001173", "변수": {"f": 0.85}}, # 다른 식 = 안 물려받음 + ] + proc = subprocess.run(["node", "-e", _JS_PRUNE, str(ROOT)], input=json.dumps(cases), capture_output=True, + text=True, encoding="utf-8", check=True) # fmt: skip + assert json.loads(proc.stdout) == want