feat(796-2e-1): 더한 기초 블록 [연결 끊기] · [다시 잇기] 서버 — 끊음 = 이 SK 안 자기 사본 줄 · 수식 고침 · 재생성 때 줄 안 바꿈
- M02_Sangeun_Block 신설: 끊기(닫힌 묶음 굳힘 · 금액 그대로) · 다시 잇기(고침 버림 + 원본 갈음) · 끊은 기초 수식 읽기 · 미리 셈 · 저장 검사 - Calc.sub_run 이 끊은 기초 자기 줄 + 수식 고침을 얹어 셈 · Copy.settle 이 다시 잇기 표지 처리 · [단가 갱신] · [재생성] 응답 끊은기초 한 줄 - Router: block/unlink · relink · equation 몸 블록 · 새 시험 test_796_2e_unlink_basis 6 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -209,6 +209,19 @@ def grow(copy: dict, fresh: dict | None) -> dict:
|
||||
return {**copy, "로직": logic, "판": _fp(logic), "단가": cost, "단가판": _fp(cost)}
|
||||
|
||||
|
||||
def rejoin(copy: dict, adds: list) -> dict:
|
||||
"""[다시 잇기](796-2e) — 표지 낀 더한 기초가 닿는 닫힌 묶음을 지금 M01 줄로 갈음(단가 줄은 더하기만)."""
|
||||
keys = [
|
||||
str(x["로직"]) for x in adds if isinstance(x, dict) and x.get("다시잇기") and x.get("로직")
|
||||
]
|
||||
fresh = snap(keys, [])
|
||||
if not fresh:
|
||||
return copy
|
||||
new = {str(r.get("키")): r for r in fresh["로직"]}
|
||||
logic = [new.pop(str(r.get("키")), r) for r in copy["로직"]] + list(new.values())
|
||||
return grow({**copy, "로직": logic, "판": _fp(logic)}, fresh)
|
||||
|
||||
|
||||
def taken(raw: Any) -> dict | None:
|
||||
"""받은 사본(층 복사 · 새로) — 줄 꼴만 보고 판은 서버가 다시 셈."""
|
||||
if not has({KEY: raw}):
|
||||
@@ -244,6 +257,8 @@ def settle(doc: Any, save: bool = False) -> Any:
|
||||
copy = stamp(out)
|
||||
elif job == PRICE and copy:
|
||||
copy = refresh(copy, whole_())[0]
|
||||
if copy and any(isinstance(x, dict) and x.get("다시잇기") for x in out.get("더한줄") or []):
|
||||
copy = rejoin(copy, out["더한줄"])
|
||||
if save and copy:
|
||||
copy = grow(copy, stamp(out))
|
||||
return {**out, KEY: copy} if copy else out
|
||||
@@ -311,6 +326,10 @@ def preview(doc: Any, job: str, given: dict | None = None) -> dict[str, Any]:
|
||||
before = calc.calc_doc(doc, given, False)
|
||||
after = calc.calc_doc(after_doc, given, False)
|
||||
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(doc.get(KEY))
|
||||
out["바뀐자원"] = refresh(copy, whole_())[1] if copy else []
|
||||
|
||||
Reference in New Issue
Block a user