diff --git a/M02_MasterTemplete/M02_Sangeun_Const.py b/M02_MasterTemplete/M02_Sangeun_Const.py index 4229f4311..5c90e5ea3 100644 --- a/M02_MasterTemplete/M02_Sangeun_Const.py +++ b/M02_MasterTemplete/M02_Sangeun_Const.py @@ -267,21 +267,6 @@ def _top_add(key: str) -> bool: return bool(hit) and not hit[2] -def kinds(doc: dict, spot: str) -> list[str]: - """자리의 덮개 갈래 — 품 · 단가 · 상수 · 표값 · 뺌(차례 그대로).""" - cover, out = (doc.get("덮개") or {}).get(spot) or {}, [] - if "qty" in cover or "배율" in cover: - out.append("품") - if any(k in cover for k in sd.PARTS): - out.append("단가") - out += [ - n - for n, k in (("상수", "상수덮개"), ("표값", "표값덮개"), ("식", "식덮개")) - if spot in (doc.get(k) or {}) - ] - return out + (["뺌"] if spot in (doc.get("뺀줄") or []) else []) - - # ── 셈 답 ────────────────────────────────────────────────────────── def answer(got: dict, clean: dict) -> dict: """`M02_Sangeun_Calc.calc_doc` 답 — 셈 답(1 단위 몫) + 가져온 식 원본 보기(옛 `원래` · `시트` · 머리 걷음).""" diff --git a/M02_MasterTemplete/M02_Sangeun_Copy.py b/M02_MasterTemplete/M02_Sangeun_Copy.py index f425d0a77..58a792271 100644 --- a/M02_MasterTemplete/M02_Sangeun_Copy.py +++ b/M02_MasterTemplete/M02_Sangeun_Copy.py @@ -16,9 +16,7 @@ 재생성 = 지금 M01 로 새로 찍음 — 덮개 · 식덮개 · 변수줄 · 상수 · 표값 · 까닭은 cid 열쇠라 새 사본에 그대로 얹힘 · 못 얹은 칸 = 짝잃음. 저장 때 = 사본에 없는 새 줄(더한줄 로직 더함 · 기초 바꿈)만 지금 M01 에서 더함. -길(`M02_Sangeun_Router`): POST …/sangeun/copy/{price|regen} 몸 {문서, 입력값?} → - {문서(사본할일), 전, 후, 바뀐자원 [{키, 이름, 전, 후, 지워짐?}] · 못얹은 [{cid, 까닭}]} - (저장 없음). +미리 셈 = `M02_Doc_Sk_Path.preview`(몸 `할일` · 옛 `preview` 는 걷음 · 855 2-E2). 셈 답 덧칸 `사본` = {시점, 단가시점, M01새판, 지운키, 단가새값} · 같은 내용 지문 몫 = `same_part`. """ @@ -386,43 +384,3 @@ def same_part(doc: Any) -> str | None: seen = state(copy, whole_()) fresh = not (seen["M01새판"] or seen["지운키"] or seen["단가새값"]) return None if fresh else f"{copy.get('판')}:{copy.get('단가판')}" - - -# ── [단가 갱신] · [재생성] 미리 셈(저장 없음) ────────────────────────── -def _money(ans: dict) -> dict | None: - base = ans.get("기준") - return {k: base.get(k) for k in ("노무비", "재료비", "경비", "계")} if base else None - - -def _lost(ans: dict) -> dict[str, dict]: - rows = [*(ans.get("짝잃음") or []), *((ans.get("시트") or {}).get("짝잃음") or [])] - return {str(x.get("cid")): x for x in rows if isinstance(x, dict)} - - -def preview(doc: Any, job: str, given: dict | None = None) -> dict[str, Any]: - """{문서(할일 얹음), 전, 후, 바뀐자원 · 못얹은} — 재생성은 단가갱신을 품음.""" - from M02_MasterTemplete import M02_Sangeun_Calc as calc - - if not isinstance(doc, dict): - raise sd.DocError("단가산출 문서가 묶음 아님") - old = doc.get(JOB) - new = REGEN if REGEN in (old, job) else job - after_doc = {**doc, JOB: new} - before = calc.calc_doc(doc, given) - after = calc.calc_doc(after_doc, given) - out: dict[str, Any] = {"문서": after_doc, "전": _money(before), "후": _money(after)} - if cut := [ - str(x.get("이름") or x.get("로직")) for x in doc.get("더한줄") or [] if x.get("끊음") - ]: - out["끊은기초"] = cut # 줄은 그대로 · 자원 단가만(요구 656-1) - if job == PRICE: - copy = _stored(doc.get("키")) or taken(held(doc)) - out["바뀐자원"] = refresh(copy, whole_())[1] if copy else [] - else: - was = _lost(before) - out["못얹은"] = [ - {"cid": c, "까닭": x.get("까닭") or "새 사본에 그 줄 없음"} - for c, x in _lost(after).items() - if c not in was - ] - return out diff --git a/M02_MasterTemplete/M02_Sangeun_Formula.py b/M02_MasterTemplete/M02_Sangeun_Formula.py index 117e9981b..9d74ef16b 100644 --- a/M02_MasterTemplete/M02_Sangeun_Formula.py +++ b/M02_MasterTemplete/M02_Sangeun_Formula.py @@ -456,74 +456,3 @@ def _path(deps: dict, start: str, goal: str) -> list[str] | None: seen.add(nxt) todo.append([*path, nxt]) return None - - -# ── 셈 답 덧칸(790-2 `시트`) ───────────────────────────────────────── -def sheet_more(spots: dict, base: dict, clean: dict, mids: dict) -> list[dict]: - """790-2 시트 자리에 덧칸 — 식글(지금 식 이름 꼴) · 원식글 · 식덮개 · 식틀림 · 변수 줄 · - 더한줄 식글 · 돌려줌 = 틀린 식 · 짝 잃은 식 칸(시트 `짝잃음` 에 더함).""" - from M02_MasterTemplete import M02_Sangeun_Const as const - - row, bad, fixed = settle(base, clean) - eff, covers = const._swapped(row, clean), fixed.get("식덮개") or {} - now, why = _places(eff), clean.get("까닭") or {} - wrong: dict[str, list[str]] = {} - for b in bad: - wrong.setdefault(b["cid"], []).append(b["까닭"]) - for spot, one in spots.items(): - if spot in now and one.get("갈래") != "더한줄": - part, at = now[spot] - one["원식글"] = to_name(str(one.get("식")), base) - one["식글"] = to_name(str(eff[part][at].get(FIELD[part])), base) - one["식덮개"] = spot in covers - hit = _ADD.match(spot) - adds = fixed.get("더한줄") or [] - if hit and int(hit[1]) < len(adds) and adds[int(hit[1])].get("수량식"): - one["식"] = adds[int(hit[1])]["수량식"] - one["식글"] = to_name(one["식"], base) - if spot in wrong: - one["식틀림"] = wrong[spot] - good = {x["이름"]: x["식"] for x in fixed.get("변수줄") or []} - for line in clean.get("변수줄") or []: - spot, text = f"mid:{line['이름']}", good.get(line["이름"], line["식"]) - spots[spot] = { - "갈래": "변수", - "이름": line["이름"], - "식": text, - "식글": to_name(text, base), - "표시": line.get("표시"), - "자리": line["자리"], - "원래": None, - "지금": mids.get(line["이름"]) if line["이름"] in good else None, - "덮개": [], - "까닭": why.get(spot), - "M01바뀜": False, - **({"식틀림": wrong[spot]} if spot in wrong else {}), - } - return bad - - -def name_table(base: dict, clean: dict) -> list[dict]: - """식 칸에서 부를 이름 — 입력 · 중간 · 변수 · 덧줄 · 비목 · 별칭 · 자원 · 번지 · 단계.""" - mf = _eng() - out = [{"글": str(x.get("이름")), "갈래": "입력"} for x in base.get("입력") or []] - out += [{"글": str(x.get("이름")), "갈래": "중간"} for x in base.get("중간") or []] - out += [{"글": x["이름"], "갈래": "변수"} for x in clean.get("변수줄") or []] - out += [{"글": str(x.get("이름")), "갈래": "덧줄"} for x in base.get("덧줄") or []] - out += [{"글": k, "갈래": "비목"} for k in mf.COST_ITEMS] - out += [{"글": f"[{k}]", "갈래": "별칭"} for k in aliases(base)] - label_of, seen = _labels(_whole())[0], set() - for part in FIELD: - for x in base.get(part) or []: - texts = [ - str(x.get(FIELD[part])), - *([x["요소"]] if isinstance(x.get("요소"), str) else []), - ] - for key in (k for t in texts for k in mf.mk.KEY.findall(t)): - if key in label_of and key not in seen: - seen.add(key) - out.append({"글": f"[{label_of[key]}]", "갈래": "자원"}) - lines = [*(base.get("호표") or []), *(base.get("덧줄") or [])] - out += [{"글": f"번지.{x['번지']}", "갈래": "번지"} for x in lines if x.get("번지")] - out += [{"글": f"단계.'{x.get('이름')}'", "갈래": "단계"} for x in base.get("단계") or []] - return out diff --git a/resources/tester/test_792_1_sangeun_formula.py b/resources/tester/test_792_1_sangeun_formula.py index 4955671ac..183f63dc7 100644 --- a/resources/tester/test_792_1_sangeun_formula.py +++ b/resources/tester/test_792_1_sangeun_formula.py @@ -142,7 +142,7 @@ def test_펼침_막음_초기화_걷음(world): doc, n = flat.reset("sangeun", {**_plus(), "까닭": {MAN: "할증"}}) assert n == 1 and "식덮개" not in doc and "까닭" not in doc and doc["변수줄"] assert const.restore(_plus(), MAN).get("식덮개") is None - assert const.kinds(_plus(), MAN) == ["식"] and const.covers_n(_plus()) == 1 + assert const.covers_n(_plus()) == 1 # ── B09 사본 굳힘 ───────────────────────────────────────────────────── diff --git a/resources/tester/test_795_1_sk_copy.py b/resources/tester/test_795_1_sk_copy.py index 3f1d826ad..1a28585d6 100644 --- a/resources/tester/test_795_1_sk_copy.py +++ b/resources/tester/test_795_1_sk_copy.py @@ -14,6 +14,7 @@ import json import pytest from M01_MasterData import M01_MasterData_Store as m01 +from M02_MasterTemplete import M02_Doc_Sk_Path as path from M02_MasterTemplete import M02_Labor_Doc as labor from M02_MasterTemplete import M02_Labor_Ref as refs from M02_MasterTemplete import M02_Library_Same as same @@ -118,12 +119,11 @@ def test_price_refresh_only_on_press(world, monkeypatch): assert _sum(me, key) == was # 누르기 전 = 단가 기준 시점 값 fresh = _sum(me, _sk(me, 바탕={"로직": PCT})) # 지금 M01 로 새로 찍은 SK assert fresh != was - with store.at(me): - got = skc.preview(_doc(me, key), skc.PRICE) + with store.at(me): # 화면 [단가 갱신] 미리 셈 = 수식 길(옛 `skc.preview` 걷음 · 855 2-E2) + got = path.preview(key, {"할일": skc.PRICE}) assert got["전"]["계"] == was and got["후"]["계"] == fresh assert [x["키"] for x in got["바뀐자원"]] == [lb] - assert got["문서"][skc.JOB] == skc.PRICE - _save(me, key, got["문서"]) # [저장] = 서버가 할일 적용 + _save(me, key, {**_doc(me, key), skc.JOB: skc.PRICE}) # [저장] = 서버가 할일 적용 saved = _doc(me, key) assert skc.JOB not in saved and _sum(me, key) == fresh assert skc.held(saved)["단가시점"] >= skc.held(saved)["시점"] @@ -142,7 +142,7 @@ def test_deleted_keys_keep_last_value(world, monkeypatch): assert now["기준"]["계"] == was assert {PCT, lb} <= set(now["사본"]["지운키"]) with store.at(me): - got = skc.preview(_doc(me, key), skc.PRICE) + got = path.preview(key, {"할일": skc.PRICE}) assert {"키": lb, "이름": got["바뀐자원"][0]["이름"], "지워짐": True} in got["바뀐자원"] assert got["후"]["계"] == was @@ -195,7 +195,7 @@ def test_imported_same_rule(world, monkeypatch): row["값"] = row["값"] * 2 _fake(monkeypatch, [row]) assert _sum(me, key) == was - with store.at(me): - got = skc.preview(_doc(me, key), skc.PRICE) - assert [x["키"] for x in got["바뀐자원"]] == [MAN] - assert got["후"]["노무비"] == pytest.approx(got["전"]["노무비"] * 2, abs=1) + before = _calc(me, _doc(me, key))["기준"]["노무비"] + _save(me, key, {**_doc(me, key), skc.JOB: skc.PRICE}) # [단가 갱신] 뒤 [저장] = 할일 적용 + after = _calc(me, _doc(me, key))["기준"]["노무비"] + assert after == pytest.approx(before * 2, abs=1) diff --git a/resources/tester/test_821_1_my_machine.py b/resources/tester/test_821_1_my_machine.py index 561810eb7..afa99fe9e 100644 --- a/resources/tester/test_821_1_my_machine.py +++ b/resources/tester/test_821_1_my_machine.py @@ -15,6 +15,7 @@ import pytest from fastapi import HTTPException from M01_MasterData import M01_MasterData_Store as m01 +from M02_MasterTemplete import M02_Doc_Sk_Path as path from M02_MasterTemplete import M02_Labor_Ref as refs from M02_MasterTemplete import M02_Machine_Find as mfind from M02_MasterTemplete import M02_Machine_Hourly as mh @@ -147,11 +148,12 @@ def test_sk_copy_edit_refresh_delete(world): assert now["기준"]["계"] == was and now["사본"]["단가새값"] is True assert now["사본"]["지운키"] == [] new = _at(me, mh.hourly, key)["계"] - look = _at(me, skc.preview, _doc(me, sk), skc.PRICE) + look = _at(me, path.preview, sk, {"할일": skc.PRICE}) # 화면 [단가 갱신] 미리 셈(수식 길) assert float(look["전"]["계"]) == float(was) and float(look["후"]["계"]) == new assert [x["키"] for x in look["바뀐자원"]] == [key] with store.at(me): # [저장] = 할일 적용 - store.write("sangeun", sk, store.read("sangeun", sk)["판"], look["문서"]) + got = store.read("sangeun", sk) + store.write("sangeun", sk, got["판"], {**got["문서"], skc.JOB: skc.PRICE}) assert float(_sum(me, sk)) == new assert _calc(me, _doc(me, sk))["사본"]["단가새값"] is False # 층 사이 복사 — 사본이 따라감(받은 층에 그 내 기계 없음 · 마지막 값) @@ -162,7 +164,7 @@ def test_sk_copy_edit_refresh_delete(world): assert gone["쓰는곳"] == [{"키": sk, "이름": "sub3임시 내기계"}] after = _calc(me, _doc(me, sk)) assert float(after["기준"]["계"]) == new and after["사본"]["지운키"] == [key] - look = _at(me, skc.preview, _doc(me, sk), skc.PRICE) + look = _at(me, path.preview, sk, {"할일": skc.PRICE}) assert look["바뀐자원"] == [{"키": key, "이름": NAME, "지워짐": True}] assert float(look["후"]["계"]) == new diff --git a/resources/tester/test_822_1_copy_gap.py b/resources/tester/test_822_1_copy_gap.py index 2e09d9028..73a80f6e7 100644 --- a/resources/tester/test_822_1_copy_gap.py +++ b/resources/tester/test_822_1_copy_gap.py @@ -207,9 +207,9 @@ def test_imported_ours(world, monkeypatch): was = _sum(me, key) _move(monkeypatch, MAN) assert _sum(me, key) == was - doc = _at(me, lambda: store.read("sangeun", key)["문서"]) - got = _at(me, skc.preview, doc, skc.PRICE) - assert [x["키"] for x in got["바뀐자원"]] == [MAN] and got["후"]["계"] > was + doc = _at(me, lambda: store.read("sangeun", key)) # [단가 갱신] 뒤 [저장] = 할일 적용 + _at(me, lambda: store.write("sangeun", key, doc["판"], {**doc["문서"], skc.JOB: skc.PRICE})) + assert _sum(me, key) > was def test_layer_copy_keeps_copy(world, monkeypatch): diff --git a/ui_template/ui_template_locale_m2.ts b/ui_template/ui_template_locale_m2.ts index 76d522701..d33768375 100644 --- a/ui_template/ui_template_locale_m2.ts +++ b/ui_template/ui_template_locale_m2.ts @@ -170,10 +170,6 @@ export const ui_locales_m2 = { "바탕 단가산출 기초가 저장 뒤 바뀜 — 고친 칸의 바탕 값을 확인하고 [저장]하면 새 판으로 맞춤", "The base M01 logic changed since saving — check edited cells, then Save to adopt the new version", ], - M02_SangeunLost: [ - "바탕에서 짝을 잃은 고침 — 지우지 않고 남겨 둠", - "Edits that lost their base row — kept, not deleted", - ], M02_SangeunGap: [ "못 셈 줄 — 금액 빼고 나머지로 셈 · 줄을 빼거나 입력을 채움", "Lines not priced — total uses the rest · drop the line or fill its input",