fix(848-7): 엑셀 판 제어 구역 연결 문서 · 값 화면 캐시에 · 방식 없는 위 층(가져온 값) 변수 물려받음

- M02_Doc_Import.record — 엑셀 판도 기계 식 문서 · 값을 기록(없으면 제어 구역이 안 열림 · ORCA 에서 찾음)
- prune_work_layer ↔ pruneWorkLayer — 위 층에 방식 없이 식 · 변수만 있어도 같은 식이면 물려받음
  (저장 뒤 손대지 않은 경쟁사 값이 내 고침 · 파랑으로 남던 것)
- 시험 test_848_7 방식 없는 위 층 거울 · 관련 시험 442 통과

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 01:11:01 +09:00
co-authored by Claude Opus 5.5
parent a4a7d80885
commit c9df064389
4 changed files with 50 additions and 2 deletions
+3
View File
@@ -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()
+2 -1
View File
@@ -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])),
);
@@ -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()
@@ -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