refactor(855-E 2-E4): 단가산출 옛 칸 수식고침 · 연결 끊기 = 받으면 400 — 엔진 수식 고침 얹기 걷음
- 저장본 확인: 층 SK 14 · 문서 `수식고침` · 더한줄 `끊음` · `수식고침` 0 - M02_Sangeun_Equation: `apply` · `on`(M01 Equation edit_row 엔진 고침) · `strict` · `added_inputs` · 메모 지움 → `clean` = 옛 칸 있으면 400(WHY) - M02_Sangeun_Block: `own` · `row_of`(끊은 기초 `mine.logic`) · `strict` · `is_block` 지움 → `clean` = 끊음 · 수식고침 400 - M02_Sangeun_Calc.clean_doc: eqm · blk strict 부름 걷음(바탕 머리 = `_head_of`) · M02_Sangeun_Doc: 고침 더한 입력 거름 걷음 - 시험 test_796_2b: 옛 칸 고침 = 「수식고침」 400 · 화면 TS 파일 글자 보는 시험 걷음(소스 글자 시험 금지) - 검증: 관련 43 파일 + 지킴 + 관문 356 통과 · 빌더 --check 같음 · typecheck 0 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,88 +1,21 @@
|
||||
"""M02 단가산출(SK) 더한 기초 블록 [연결 끊기] · [다시 잇기](PLAN 796-2e · 요구 659-3 · 656-1).
|
||||
"""M02 단가산출(SK) 더한 기초 옛 [연결 끊기](PLAN 796-2e) — 받지 않음(855-E 2-E4).
|
||||
|
||||
더한 기초 = 더한줄 로직(`종류: 로직`). 기본 = 연결 — 이 SK 의 로직 사본(`M02_Sangeun_Copy`)이 닿는 그 기초
|
||||
(원본 바뀜은 [재생성]·[다시 잇기]에서 따라옴 · 자동 아님 · 보기만).
|
||||
끊음 = 더한줄 칸 `끊음` {시점, 로직 [M01 줄]} — 끊는 때 그 기초가 닿는 닫힌 묶음(하위 로직 · 찾기 표 ·
|
||||
요율 · 사본 줄 그대로 = 금액 그대로)을 이 SK 안 자기 사본으로 굳힘 → 그 줄만 고침:
|
||||
칸 `수식고침`(796-2b 와 같은 꼴 · 같은 `eqm.apply`)을 그 기초 줄에 얹어 셈(`Calc.sub_run`).
|
||||
[재생성] = 끊은 기초의 줄은 안 바꿈(자원 단가만 — 단가는 SK 사본 `단가` · [단가 갱신] 한 길).
|
||||
다시 잇기 = `끊음` · `수식고침` 뗌 + 표지 `다시잇기`(서버만 · 셈·저장 첫머리 `Copy.settle` 이 그 기초가 닿는
|
||||
닫힌 묶음을 지금 M01 줄로 갈음하고 표지 뗌 — 고친 것 버림).
|
||||
화면 길(끊기 · 다시 잇기 · 끊은 기초 수식 탭)은 걷음(894) — 남은 것 = 저장 문서의 `끊음` · `수식고침` 꼴 · 셈.
|
||||
저장 = SK [저장](서버가 다시 얹어 검사 · 셈 · 브라우저 값 안 받음 — 끊음 줄은 사본과 같은 `taken` 꼴 검사).
|
||||
옛 끊음 = 더한줄 로직 칸 `끊음` {시점, 로직 [M01 줄]} + 그 줄 `수식고침` — 굳힌 로직 줄에 엔진 수식 고침을
|
||||
얹던 길 · 화면 길은 894 에서 걷음 · 저장본 0 — 받으면 400.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from M02_MasterTemplete import M02_Sangeun_Copy as skc
|
||||
from M02_MasterTemplete import M02_Sangeun_Doc as sd
|
||||
from M02_MasterTemplete import M02_Sangeun_Equation as eqm
|
||||
|
||||
CUT, EDIT = "끊음", eqm.KEY
|
||||
MANY = 400 # 끊은 기초가 닿는 줄 상한
|
||||
_OWN: dict[int, tuple[Any, Any, Any]] = {}
|
||||
|
||||
|
||||
def is_block(one: Any) -> bool:
|
||||
"""더한 기초 = 더한줄 로직(참조 · 고정 · 자원 줄 아님)."""
|
||||
return isinstance(one, dict) and one.get("종류") == "로직" and bool(one.get("로직"))
|
||||
|
||||
|
||||
def clean(raw: dict, where: str) -> dict:
|
||||
"""`sd._added` 가 부름 — 끊음 · 수식고침 꼴만(뜻 검사는 셈 · 저장 `strict`)."""
|
||||
cut = raw.get(CUT)
|
||||
if not cut:
|
||||
if raw.get(EDIT):
|
||||
raise sd.DocError(f"{where} · 수식 고침은 연결을 끊은 기초만")
|
||||
return {}
|
||||
rows = cut.get("로직") if isinstance(cut, dict) else None
|
||||
code = str(raw.get("로직"))
|
||||
if any(raw.get(k) not in (None, {}, []) for k in sd.BODY):
|
||||
raise sd.DocError(f"{where} · 넣은 SK 몸은 이미 이 SK 안 사본 — 연결 끊기 없음")
|
||||
if (
|
||||
not isinstance(rows, list)
|
||||
or len(rows) > MANY
|
||||
or not all(isinstance(r, dict) and r.get("키") for r in rows)
|
||||
):
|
||||
raise sd.DocError(f"{where} · 끊은 기초 사본 꼴이 틀림")
|
||||
rows = [r for r in rows if str(r["키"])[:2] not in skc.RES] # 단가 = SK 사본 한 곳
|
||||
if code not in {str(r["키"]) for r in rows}:
|
||||
raise sd.DocError(f"{where} · 끊은 기초 사본에 「{code}」 줄 없음")
|
||||
return {CUT: {"시점": str(cut.get("시점") or ""), "로직": rows}} | eqm.clean(raw, {})
|
||||
|
||||
|
||||
def own(one: dict, whole: Any) -> Any:
|
||||
"""끊은 기초의 셈 색인 — `whole` 위에 자기 사본 줄(끊음 아님 = `whole` 그대로)."""
|
||||
cut = one.get(CUT)
|
||||
if not isinstance(cut, dict):
|
||||
return whole
|
||||
hit = _OWN.get(id(cut))
|
||||
if hit and hit[0] is cut and hit[1] is whole:
|
||||
return hit[2]
|
||||
if len(_OWN) > 32: # ponytail: 통째 비움 · 끊은 기초가 많아 느려지면 LRU 로
|
||||
_OWN.clear()
|
||||
got = skc.Copy(whole, skc._rows(cut))
|
||||
_OWN[id(cut)] = (cut, whole, got)
|
||||
return got
|
||||
|
||||
|
||||
def row_of(whole: Any, one: dict, edits: list | None = None) -> tuple[dict, list[str], Any]:
|
||||
"""(끊은 기초 줄 + 수식 고침, 못 얹은 까닭, 그 기초 셈 색인) — `edits` None = 그 기초 자기 고침."""
|
||||
mine = own(one, whole)
|
||||
row = mine.logic(str(one["로직"]))
|
||||
use = one.get(EDIT) if edits is None else edits
|
||||
if not use:
|
||||
return row, [], mine
|
||||
new, why = eqm.apply(row, use, mine)
|
||||
return new, why, mine
|
||||
|
||||
|
||||
def strict(doc: dict, whole: Any) -> None:
|
||||
"""저장 — 끊은 기초 고침이 못 얹히면 400."""
|
||||
for at, one in enumerate(doc.get("더한줄") or [], 1):
|
||||
if is_block(one) and one.get(EDIT):
|
||||
why = row_of(whole, one)[1]
|
||||
if why:
|
||||
raise sd.DocError(f"더한줄 {at}째 수식 고침 못 얹음 — " + " · ".join(why))
|
||||
"""`sd._added` 가 부름 — 옛 칸 `끊음` · `수식고침` 이 있으면 400."""
|
||||
if raw.get(CUT) or raw.get(EDIT):
|
||||
raise sd.DocError(
|
||||
f"{where} · 연결 끊기 · 수식고침(옛 칸) — 받지 않음 · 단가산출 수식 문서로 고침"
|
||||
)
|
||||
return {}
|
||||
|
||||
Reference in New Issue
Block a user