Merge branch 'sub_laptop_4' of C:/Aislo_wt/sub_laptop_4 into main_laptop_1
This commit is contained in:
@@ -107,7 +107,7 @@ def doc_of(whole: Any, key: str) -> dict | None:
|
||||
if live and (_live(key) is None or skc._fp(_live(key)) == skc._fp(prices.to_json(row))):
|
||||
return cp.deepcopy(live)
|
||||
try:
|
||||
return cv.convert(whole, row)[0]
|
||||
return md.tag(cv.convert(whole, row)[0], row) # 855 L1 이름표 = 빌더와 같게
|
||||
except _ERR:
|
||||
return cp.deepcopy(live) if live else None
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ def _index(sk: dict, master: Any = None, doc: Any = None) -> Any:
|
||||
|
||||
# ── 엑셀 단가 그대로 고친 줄(가져온 로직 줄 + SK 고침 · 엔진 셈 없음) ─────────
|
||||
def _engine_adds(doc: dict) -> bool:
|
||||
"""값을 엔진 셈으로만 얻는 더한줄(형제 SK · 율 · 세부 고친 둘째 기초)이 있음 — 옛 길(`_old_ctx`)."""
|
||||
"""값을 엔진 셈으로만 얻는 더한줄(형제 SK · 율 · 세부 고친 둘째 기초)이 있음 — 못 셈(옛 셈 은퇴)."""
|
||||
return any(
|
||||
one.get("참조") or sd.is_rate(one) or sd.sub_patched(one) for one in doc.get("더한줄") or []
|
||||
)
|
||||
@@ -84,7 +84,7 @@ def _ctx(sk: dict, whole: Any) -> tuple:
|
||||
"""엑셀 단가 기준 고친 줄(855 2-C2) — 가져온 로직 줄(`row_of`) + 수식 고침 · SK 고침(`sd.patched`) ·
|
||||
더한줄 고정 값(`fixed.line`) → (색인, 키, 입력, {정체, 고친 줄(`ROW`)}, None) · 옛 엔진 안 돎.
|
||||
안쪽 산근(형제 SK) 줄 값 = 0 자리값(`_attach` 가 형제 SK 연결 + 엑셀 값으로 갈음).
|
||||
`_engine_adds` 인 SK 만 옛 셈 길(그 더한줄 값이 엔진 답 — 2-C1 · 2-C5 몫)."""
|
||||
`_engine_adds` 인 SK = 못 셈(그 더한줄 값이 옛 엔진 답 — 옛 셈 은퇴 · 855 2-C1)."""
|
||||
from M02_MasterTemplete import M02_Sangeun_Calc as calc
|
||||
from M02_MasterTemplete import M02_Sangeun_Copy as skc
|
||||
from M02_MasterTemplete import M02_Sangeun_Equation as eqm
|
||||
@@ -92,7 +92,7 @@ def _ctx(sk: dict, whole: Any) -> tuple:
|
||||
raw = {**sk, imp.KEY: {**sk[imp.KEY], "단가기준": "엑셀"}}
|
||||
doc = sd.clean(raw, None, whole)
|
||||
if _engine_adds(doc):
|
||||
return _old_ctx(raw, whole)
|
||||
raise ValueError("형제 SK · 율 · 고친 둘째 기초 더한줄 — 옛 엔진 셈 은퇴 · 못 셈")
|
||||
w = skc.over(doc, whole)
|
||||
base = sd.empty_row(doc)
|
||||
base = {**base, "호표": [dict(x) for x in base.get("호표") or []]}
|
||||
@@ -118,20 +118,6 @@ def _ctx(sk: dict, whole: Any) -> tuple:
|
||||
ROW = "고친줄" # `_ctx` 가 넘기는 엑셀 단가 기준 고친 줄(857-3a — 색인 `.logic` 안 부름)
|
||||
|
||||
|
||||
def _old_ctx(raw: dict, whole: Any) -> tuple:
|
||||
"""옛 셈 길(`OLD`)로 돌려 엔진에 넣은 (색인, 키, 입력, 답, 재료) — `_engine_adds` SK 만."""
|
||||
from M02_MasterTemplete import M02_Doc_Sk as dsk
|
||||
from M02_MasterTemplete import M02_Sangeun_Calc as calc
|
||||
|
||||
box: list = []
|
||||
token = dsk.OLD.set(True)
|
||||
try:
|
||||
calc.run(sd.clean(raw, None, whole), whole, catch=box)
|
||||
finally:
|
||||
dsk.OLD.reset(token)
|
||||
return box[-1]
|
||||
|
||||
|
||||
# ── 소요량 · 계수 고른 칸 → 수 자리에 기호 ──────────────────────────────
|
||||
CMP = ("<=", ">=", "==", "!=", "<", ">") # 비교 글자 — 수 세기에서 뺌(`QtyLinks._literals`)
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
SK `수식`(꼴 = `M02_Doc_Copy`) — `문서` = 이 SK 문서(키 = SK 키 · 옵션 값 · 줄 규칙까지 든 정본) ·
|
||||
`부름` = 부르는 단가산출 닫힌 묶음 · `끊음` = 이 사본에 굳힌 부름(고칠 수 있음) · 값 사본.
|
||||
두 갈래:
|
||||
파생(따로 없음) — 옛 칸(바탕 · 덮개 · 뺀줄 · 더한줄 · 수식고침 …)이 정함: 셈마다 옛 칸이 낸 줄
|
||||
(`M02_Sangeun_Calc.run` 이 엔진에 넣는 고친 줄)을 문서로 옮겨(덮개 없는 바탕 = M01 문서 사본 ·
|
||||
고친 줄 = `master_doc_convert`) 문서 셈 · 지금 화면(옛 칸 고침)이 그대로 돎.
|
||||
파생(따로 없음) — 셈마다 바탕 로직의 기초 문서 사본 + 줄 규칙(입력값 · 켜쌓기율 · 고름 · 자재표시)으로
|
||||
다시 지음(`derive` · 옛 엔진 안 돎 · 855 2-C1) · 옛 칸 고침(덮개 · 뺀줄 · 더한줄 · 수식고침 …) =
|
||||
못 셈(올림 없음).
|
||||
따로 — 수식 길(`M02_Doc_Router`)로 문서를 고침: 저장한 문서가 정본 · 옛 칸 고침 저장 = 409 ·
|
||||
[재생성] = 지금 M01 로 다시 찍어 파생으로 돌아감(고친 문서 버림).
|
||||
SK 금액(기준 · 1 단위 = 기준 ÷ 배) = 문서 셈 — 일위대가 · 사전조합 · 구조물 조합이 이 값을 씀.
|
||||
@@ -24,7 +24,6 @@ from __future__ import annotations
|
||||
import copy as cp
|
||||
import json
|
||||
from contextvars import ContextVar
|
||||
from decimal import Decimal
|
||||
from typing import Any
|
||||
|
||||
from M02_MasterTemplete import M02_Doc_Copy as dc
|
||||
@@ -83,6 +82,10 @@ def _set_values(doc: dict, given: dict) -> None:
|
||||
link = var.get("연결") or {}
|
||||
if link.get("갈래") in ("선택", "입력") and var.get("열쇠") in given:
|
||||
link["값"] = given[var["열쇠"]]
|
||||
have = list(link.get("목록") or [])
|
||||
mine = str(link["값"]).startswith("개인 ") # 내 기계 원문번호(821-1)
|
||||
if link["갈래"] == "선택" and link["값"] not in have and (mine or not have):
|
||||
link["목록"] = [*have, link["값"]] # 열린 목록 · 내 기계 = 고른 값을 목록에
|
||||
|
||||
|
||||
def base_doc(sk: dict, whole: Any, key: str) -> tuple[dict | None, bool]:
|
||||
@@ -115,35 +118,58 @@ def _bare_doc(doc: dict) -> dict:
|
||||
return {k: v for k, v in doc.items() if k not in (mcv.COVER, mcv.HAND)}
|
||||
|
||||
|
||||
def derive(sk: dict, ctx: tuple) -> dict:
|
||||
"""옛 칸이 낸 고친 줄(`ctx` = run 이 엔진에 넣은 (색인, 키, 입력, 바탕 답)) → 이 SK 문서.
|
||||
덮개 없는 바탕(고친 줄 = 바탕 줄) = 기초 문서(`base_doc`) 사본 · 아니면 고친 줄 변환 ·
|
||||
옵션 = 기초 문서 기본 위에 내가 고른 값(848-10 · 옛 로직 줄 자동값이 기초 고침을 안 이김)."""
|
||||
whole, key, values, got, mats = ctx
|
||||
row = whole.logic(key)
|
||||
given = dc.given_of(whole, key, values)
|
||||
mine = {k: v for k, v in given.items() if k in (values or {})} # 내가 고른 값
|
||||
OLD_PATCH = (*_PATCH, "변수줄", "식덮개") # 옛 칸 고침(덮개 · 더한줄 · 식 칸 …) — 셈 은퇴(855 2-C1)
|
||||
OLD_WHY = "옛 칸(덮개 · 뺀줄 · 더한줄 · 수식고침 …)으로 고친 단가산출 — 옛 칸 셈 은퇴 · 수식 문서로 다시 만들어야 셈"
|
||||
REF_WHY = "바탕 참조 단가산출 — 수식 문서 없음 · 못 셈"
|
||||
|
||||
|
||||
def frozen(sk: dict) -> bool:
|
||||
"""굳힌 사본 SK(B09 · 구조물 사본 `GX9…` 굳힌 줄 · 수식 사본 없음) — 바탕 로직에 M01 수식 문서
|
||||
없음 · 셈 = 옛 길(B9 걸음 몫 · 855 2-C1 은 안 건드림)."""
|
||||
key = str((sk.get("바탕") or {}).get("로직") or "")
|
||||
return bool(key) and not dc.has(sk) and key not in dc.folder()
|
||||
|
||||
|
||||
def old_only(sk: dict) -> bool:
|
||||
"""옛 칸 고침이 든 파생 SK(가져온 식 빼고 — 그 문서는 `M02_Doc_Import` 가 지음) — 셈 안 함."""
|
||||
return not dim.is_imported(sk) and any(sk.get(k) not in (None, {}, []) for k in OLD_PATCH)
|
||||
|
||||
|
||||
def derive(sk: dict, whole: Any) -> dict:
|
||||
"""이 SK 문서(855 2-C1 · 옛 엔진 안 돎) — 바탕 로직 = 기초 문서(`base_doc`) 사본 · 바탕 없음 = 빈 문서 ·
|
||||
옵션 = 기초 문서 기본 위에 내가 고른 값(848-10 · 손고침 · 프로젝트 층 = 옛 로직 줄 자동값) ·
|
||||
줄 규칙(켜쌓기율 · 고름 · 자재표시 · 일위대가 [+ 줄] 사본 811-1) = 문서 규칙(`dc.line_doc` ·
|
||||
SK 재료 빈 칸 = 직접계산 747-1). `whole` = 값 사본 색인. 옛 칸 고침 SK 는 부르는 쪽이 먼저 막음."""
|
||||
key = str(sk.get("키") or "")
|
||||
base_key = str((sk.get("바탕") or {}).get("로직") or "")
|
||||
plain, real = None, False
|
||||
if base_key:
|
||||
try:
|
||||
frozen = whole.logic(base_key)
|
||||
same = {**row, "키": base_key} == frozen
|
||||
except dc._ERR:
|
||||
same = False
|
||||
plain, real = base_doc(sk, whole, base_key) if same else (None, False)
|
||||
if plain is not None:
|
||||
doc = cp.deepcopy(_bare_doc(plain)) # ① = `위덮음`(848-1)
|
||||
_set_values(doc, mine if real else given)
|
||||
elif not (row.get("호표") or row.get("덧줄") or row.get("결과")):
|
||||
doc = dc.md.blank(str(sk.get("키") or ""), str(sk.get("이름") or ""))
|
||||
else:
|
||||
live = dc.folder().get(base_key) if base_key and renew.on() else None
|
||||
given = {**given, **renew._opts(live), **mine} if live else given
|
||||
doc = dc.cv.convert(whole, row, given)[0]
|
||||
apart = dc.apart_of(got.get("자재표시"), mats)
|
||||
doc = dc.line_doc(doc, got.get("켜쌓기율"), got.get("고름") or None, apart)
|
||||
return {**doc, "키": str(sk.get("키") or key), "이름": str(sk.get("이름") or doc.get("이름"))}
|
||||
if not base_key:
|
||||
return {**dc.md.blank(key, str(sk.get("이름") or "")), "키": key}
|
||||
plain, real = base_doc(sk, whole, base_key)
|
||||
if plain is None:
|
||||
raise ValueError(f"기초 문서 없음 「{base_key}」")
|
||||
row = whole.logic(base_key)
|
||||
got = sd.patched(row, sk) # 줄 규칙 칸 cid → 차례(옛 칸 고침 없음 = 바탕 줄 그대로)
|
||||
names = {str(i.get("이름")) for i in row.get("입력") or []}
|
||||
values = {k: v for k, v in (sk.get("입력값") or {}).items() if k in names}
|
||||
given = dc.given_of(whole, base_key, values) if values or not real else {}
|
||||
doc = cp.deepcopy(_bare_doc(plain)) # ① = `위덮음`(848-1)
|
||||
_set_values(doc, {k: v for k, v in given.items() if k in values} if real else given)
|
||||
apart = [] if isinstance(row.get("흐름"), dict) else _apart(got)
|
||||
doc = dc.line_doc(doc, sk.get("켜쌓기율"), got["고름"] or None, apart)
|
||||
return {**doc, "키": key or base_key, "이름": str(sk.get("이름") or doc.get("이름"))}
|
||||
|
||||
|
||||
def _apart(got: dict) -> list[int]:
|
||||
"""별도계상 재료 줄 차례 — SK 빈 칸 = 직접계산(747-1) · 「별도계상」 고른 줄만."""
|
||||
from M02_MasterTemplete import M02_Labor_Doc as labor # 늦게 — 일위대가 셈이 이 파일을 부름
|
||||
|
||||
marks = got["자재표시"]
|
||||
return [
|
||||
n
|
||||
for n, item in enumerate(got["줄"].get("호표") or [])
|
||||
if item.get("종류") == "재료"
|
||||
and labor.apart({"별도계상": "직접계산", **labor.marks(marks.get(str(n)))})
|
||||
]
|
||||
|
||||
|
||||
def seed(sk: dict) -> dict | None:
|
||||
@@ -188,26 +214,30 @@ def upper(sk: dict, got: Any) -> Any:
|
||||
return with_upper(sk, got)
|
||||
|
||||
|
||||
def copy_of(sk: dict, ctx: tuple | None) -> dict | None:
|
||||
"""셈에 쓸 수식 사본 — 따로 = 저장본 · 파생 = 지금 옛 칸으로 다시 지은 문서(부름은 있던 것 먼저) ·
|
||||
`OLD` 켬(옮기기 대조 · 시험) = 옛 길."""
|
||||
if OLD.get() or not own(sk):
|
||||
def copy_of(sk: dict, whole: Any = None) -> dict | None:
|
||||
"""셈에 쓸 수식 사본 — 따로 = 저장본 · 파생 = 지금 다시 지은 문서(부름은 있던 것 먼저 · 옛 엔진 안 돎) ·
|
||||
사본 없음(바탕 참조) · 옛 칸 고침 파생 SK = None(못 셈 · 855 2-C1). `whole` = 셈 색인(없으면 SK 값 사본)."""
|
||||
if not own(sk):
|
||||
return None
|
||||
got = sk.get(KEY) if dc.has(sk) else seed(sk)
|
||||
if got is None and "로직" in (sk.get("바탕") or {}) and not frozen(sk):
|
||||
got = {"부름": {}} # 저장 전 새 SK = 지금 M01 값(값 사본은 [저장] 때 찍음)
|
||||
if got is None:
|
||||
return None
|
||||
got = upper(sk, renew.form(sk, got)) # M01 자동 따라옴(836-2) · ① 위 층 덮음(848-1)
|
||||
if got.get("따로") or ctx is None:
|
||||
if got.get("따로"):
|
||||
return carry.carry(sk, got) # 848-7 가져온 식 ① = 가져온 값
|
||||
if dim.is_imported(sk): # 가져온 식 — 엑셀 단가 기준 줄에서 지음(우리 = 한 번 더 돎)
|
||||
if old_only(sk):
|
||||
return None
|
||||
whole = whole if whole is not None else skc.over(sk, skc.whole_())
|
||||
if dim.is_imported(sk): # 가져온 식 — 엑셀 단가 기준 줄에서 지음(`Doc_Import._ctx`)
|
||||
try:
|
||||
same = dim.basis_of(sk) == "엑셀"
|
||||
root = dim.derive(sk, ctx if same else None, dc.base(ctx[0]))
|
||||
root = dim.derive(sk, None, dc.base(whole))
|
||||
except dc._ERR as e:
|
||||
root = {**dc.md.blank(str(sk.get("키"))), "_틀림": str(e)}
|
||||
return carry.carry(sk, {**got, "문서": root, "부름": {}})
|
||||
try:
|
||||
root = renew.carry(got, derive(sk, ctx)) # 맡긴 기계 덮음(836-2)
|
||||
root = renew.carry(got, derive(sk, whole)) # 맡긴 기계 덮음(836-2)
|
||||
except dc._ERR as e:
|
||||
root = {**dc.md.blank(str(sk.get("키"))), "_틀림": str(e)}
|
||||
values = dc.values_of(sk[skc.KEY]) if skc.has(sk) else dc.values_of(got) # 서버가 정한 값
|
||||
@@ -220,22 +250,6 @@ def copy_of(sk: dict, ctx: tuple | None) -> dict | None:
|
||||
return {**got, **values, "문서": root, "부름": calls, **origin}
|
||||
|
||||
|
||||
def on_run(sk: dict, ans: dict, ctx: tuple | None) -> dict:
|
||||
"""`M02_Sangeun_Calc.run` 끝 — 수식 사본 있는 SK 금액 = 문서 셈(기준 · 1 단위) + 덧칸 `수식셈`."""
|
||||
copy = copy_of(sk, ctx)
|
||||
if copy is None:
|
||||
return ans
|
||||
got = run(sk, copy, ctx[0] if ctx else None)
|
||||
money = dc.money(got)
|
||||
base = {k: Decimal(str(v)) for k, v in money.items()} if money else None
|
||||
times = Decimal(str(ans.get("배") or 1))
|
||||
unit = {k: v / times for k, v in base.items()} if base else None
|
||||
mark = {"셈됨": bool(base), "따로": bool(copy.get("따로"))}
|
||||
if not base:
|
||||
mark["까닭"] = copy["문서"].get("_틀림") or dc.why(got) or "돈 아닌 문서"
|
||||
return {**ans, "기준": base, "1단위": unit, "수식셈": mark}
|
||||
|
||||
|
||||
def run(sk: dict, copy: dict, master: Any = None) -> dict:
|
||||
"""문서 셈 — 가져온 식 = 단가기준 · 형제 SK(`dim.run`) · 그 밖 = 값 사본(`dc.run`)."""
|
||||
if dim.is_imported(sk):
|
||||
@@ -256,9 +270,8 @@ def norm(copy: dict) -> dict:
|
||||
|
||||
def settle(out: dict, whole: Any, job: Any, raw: Any) -> dict:
|
||||
"""저장 꼴에 `수식` 을 정함 — 수식 길 저장(`NEW`) = 그 사본 · 따로 = 저장본(옛 칸 고침 409 ·
|
||||
단가갱신 = 값만 · 재생성 = 파생으로) · 그 밖 = 옛 칸으로 다시 지음(부름 = 있던 것 · 재생성 = 새로)."""
|
||||
from M02_MasterTemplete import M02_Sangeun_Calc as calc
|
||||
|
||||
단가갱신 = 값만 · 재생성 = 파생으로) · 그 밖 = 다시 지음(부름 = 있던 것 · 재생성 = 새로 · 옛 엔진 안 돎) ·
|
||||
옛 칸 고침 파생 SK = 문서 없이 값 사본 · 부름만(못 셈)."""
|
||||
out = {k: v for k, v in out.items() if k != KEY}
|
||||
if not own(out):
|
||||
return out
|
||||
@@ -290,8 +303,6 @@ def settle(out: dict, whole: Any, job: Any, raw: Any) -> dict:
|
||||
if not skc.has(out) and not dim.is_imported(out):
|
||||
empty = seed(out)
|
||||
return {**out, KEY: norm(empty)} if empty else out
|
||||
box: list = []
|
||||
calc.run(out, whole, catch=box)
|
||||
calls = {} if job == skc.REGEN else (have or {}).get("부름") or {}
|
||||
first = {**(dc.values_of(out[skc.KEY]) if skc.has(out) else {}), "부름": calls}
|
||||
if job != skc.REGEN and (have or {}).get("끊음"): # 안 바뀐 항목 고침 = 그대로(836-2)
|
||||
@@ -302,7 +313,17 @@ def settle(out: dict, whole: Any, job: Any, raw: Any) -> dict:
|
||||
UPPER
|
||||
): # ① = 저장본(프로젝트 층) · 밖은 `copy_of` 가 지금 기초 것으로(848-1)
|
||||
first[UPPER] = have[UPPER]
|
||||
copy = copy_of({**out, KEY: first}, box[-1] if box else None)
|
||||
copy = copy_of({**out, KEY: first}, whole)
|
||||
if (
|
||||
copy and skc.READS.get() is not None
|
||||
): # 저장 관문 — 문서 셈 · 부름 줄이 읽은 줄을 적음(826-3)
|
||||
run({**out, KEY: copy}, copy, whole)
|
||||
index = dc.over(copy)
|
||||
for key in copy.get("부름") or {}: # 부름 문서를 가른 값 사본 줄(`dc.doc_of`)도 둠
|
||||
try:
|
||||
index.logic(key)
|
||||
except dc._ERR:
|
||||
pass
|
||||
if (
|
||||
copy and skc.has(out) and skc.READS.get() is None and (keys := gap.gaps(copy))
|
||||
): # 파생 — 옛 로직 사본에 박음(822-1)
|
||||
|
||||
@@ -60,24 +60,20 @@ def _settled(doc: dict, job: Any = None) -> tuple[dict, Any]:
|
||||
|
||||
|
||||
def current(doc: dict, job: Any = None) -> dict:
|
||||
"""그 SK 의 지금 수식 사본(할일 적용 · 저장 없음) — 따로 = 저장한 문서 · 파생 = 옛 칸으로 지음."""
|
||||
from M02_MasterTemplete import M02_Sangeun_Calc as calc
|
||||
|
||||
"""그 SK 의 지금 수식 사본(할일 적용 · 저장 없음) — 따로 = 저장한 문서 · 파생 = 다시 지음(옛 엔진 안 돎) ·
|
||||
옛 칸 고침 파생 SK = 400(못 셈 · 855 2-C1)."""
|
||||
if not dsk.own(doc):
|
||||
raise _bad("바탕 참조 단가산출 — 수식 사본 없음")
|
||||
raise _bad(dsk.REF_WHY)
|
||||
clean, whole = _settled(doc, job)
|
||||
if not dc.has(clean): # 옮기기 전 · 새 SK — 저장 때 지을 사본을 미리
|
||||
seed = dsk.settle(clean, whole, job, doc).get(dsk.KEY)
|
||||
if seed is None:
|
||||
raise _bad("수식 사본을 지을 수 없음 — 바탕 로직 · 줄 없음")
|
||||
clean = {**clean, dsk.KEY: seed}
|
||||
box: list = []
|
||||
try:
|
||||
calc.run(clean, whole, catch=box)
|
||||
except sd.DocError as e:
|
||||
raise calc._fail(e) from e
|
||||
got = dsk.copy_of(clean, box[-1] if box else None)
|
||||
return got if got is not None else clean[dsk.KEY]
|
||||
got = dsk.copy_of(clean, whole)
|
||||
if got is None:
|
||||
raise _bad(dsk.OLD_WHY)
|
||||
return got
|
||||
|
||||
|
||||
def answer(copy: dict, sk: dict) -> dict[str, Any]:
|
||||
|
||||
@@ -132,28 +132,32 @@ def _formula_of(doc: dict) -> dict | None:
|
||||
|
||||
|
||||
def line(whole: Any, doc: dict, one: dict) -> dict[str, Any]:
|
||||
"""로직 줄 기준 — 수식 사본 있는 층 셈 = 문서 셈(줄 옵션 = 문서 규칙 · `dc.line_doc`) ·
|
||||
상세 줄 · 재료 = 옛 엔진(화면 그대로 · 802-4b) · 프로젝트 층 · B09(단가 책) · 사본 없음 = 옛 길."""
|
||||
"""로직 줄 기준 — 수식 사본 있는 층 셈 = 문서 셈 한 길(줄 옵션 = 문서 규칙 · `dc.line_doc` · 줄 = 문서
|
||||
답 줄 · 옛 엔진 안 돎 · 855 2-C1) · 프로젝트 층 · B09(단가 책) · 사본 없음 = 옛 길(옛 로직 줄 ·
|
||||
저장소 0 · B9 · 2-E 걸음 몫)."""
|
||||
from M02_MasterTemplete import M02_Labor_Doc as labor
|
||||
|
||||
code, rate, picks = one["로직"], one.get("켜쌓기율"), one.get("고름")
|
||||
old = labor.drop_apart(
|
||||
labor.run_line(whole, code, one.get("입력값"), rate, picks), one.get("자재표시")
|
||||
)
|
||||
copy = None if _project() or dsk.OLD.get() else _formula_of(doc)
|
||||
if not copy or getattr(whole, "_tag", None) != (copy.get("판"), copy.get("단가판")):
|
||||
return old
|
||||
got = labor.run_line(whole, code, one.get("입력값"), rate, picks)
|
||||
return labor.drop_apart(got, one.get("자재표시"))
|
||||
base = copy["부름"].get(code)
|
||||
if base is None:
|
||||
return {**old, "기준": None, "까닭": f"수식 문서 없음 「{code}」"}
|
||||
apart = dc.apart_of(one.get("자재표시"), old.get("재료"))
|
||||
return {"기준": None, "줄": [], "재료": [], "까닭": f"수식 문서 없음 「{code}」"}
|
||||
row = whole.logic(code)
|
||||
mats = [] if isinstance(row.get("흐름"), dict) else row.get("호표") or []
|
||||
apart = dc.apart_of(
|
||||
one.get("자재표시"), [{"차례": n} for n, x in enumerate(mats) if x.get("종류") == "재료"]
|
||||
)
|
||||
given = dc.given_of(whole, code, one.get("입력값"))
|
||||
ans = dc.run(dc.line_doc(base, rate, picks, apart), copy, given, whole)
|
||||
if "결과" in ans:
|
||||
return old
|
||||
return {"결과": ans["결과"], "기준": None, "까닭": None}
|
||||
money = dc.money(ans)
|
||||
got = {k: Decimal(str(v)) for k, v in money.items()} if money else None
|
||||
return {**old, "기준": got, "까닭": None if got else dc.why(ans)}
|
||||
lines = ans.get("줄") or []
|
||||
return {"기준": got, "줄": lines, "재료": [], "까닭": None if got else dc.why(ans)}
|
||||
|
||||
|
||||
def combo(expand: Any, doc: dict, trail: tuple[str, ...]) -> dict[str, Any]:
|
||||
|
||||
@@ -1,27 +1,15 @@
|
||||
"""M02 단가산출(SK) 셈 — 바탕 사슬 → 고친 줄 → M01 엔진 한 벌(PLAN 715-1b · 715-2).
|
||||
"""M02 단가산출(SK) 셈 — 수식 사본 문서 셈 한 길(PLAN 855 2-C1 · 715-1b · 715-2).
|
||||
|
||||
셈 = ① 바탕(M01 로직 · 바탕 SK 의 고친 줄 · 없음) ② `M02_Sangeun_Doc.patched` ③ 더한줄 참조 ·
|
||||
(SK · SC) · 고정 줄 = 먼저 셈한 1 단위 노 · 재 · 경 → `값묶음`
|
||||
④ M01 색인 위에 고친 줄을 SK 키로 얹어
|
||||
(M01 시험 계산 `_swap` 과 같은 꼴 · 메모리만 · 정본 · 캐시 안 고침) `labor.run_line` — 자동값 ·
|
||||
켜쌓기율 · 고름 · % 덧줄을 엔진이 다시 셈. 1 단위 = 기준 ÷ 배(바탕 로직 결과단위 앞 수).
|
||||
셈(`run`) = 수식 사본(`M02_Doc_Sk.copy_of` — 따로 = 저장 문서 · 파생 = 기초 문서 + 줄 규칙)을 문서 계산기로 ·
|
||||
기준 · 1 단위 · 줄 · 비목 · 끝수 = 문서 답 · 옛 엔진 안 돎 · 수식 사본 없음(바탕 참조) · 옛 칸 고침(덮개 ·
|
||||
뺀줄 · 더한줄 · 수식고침 · 식 칸) = 못 셈 + 까닭 하나 · 굳힌 사본(B09 · 구조물 사본 GX9) = 옛 길(`_frozen` ·
|
||||
`resolve` 바탕 사슬 · `_bundles` · `_rated` 율 더한줄 — B9 걸음 몫 · `Doc_Import._ctx` 도 고친 줄 도구를 씀).
|
||||
계산 자리(CLAUDE.md 5장 ③) = 서버 단독 · 화면은 셈 길(저장 안 함 · 최신 응답만).
|
||||
저장(`clean_doc`) = 꼴 검사 + 참조 위 층 · 있는 문서 · 순환 422 + 서버가 `원값` · `바탕판` 적음.
|
||||
둘째 기초(727-2 · 더한줄 로직) = 세부 덮개 · 뺀줄 있으면 고친 기초 줄을 엔진으로 셈한 `값묶음` 줄
|
||||
(B09 굳힘도 그 값) · 화면 셈 길(`calc_doc`) = 그 줄 덧칸 `펼침`(세부 줄 × 수량) · `뺀세부` ·
|
||||
`바탕판` ·
|
||||
`꼬리표`(원문번호) · 답 `꼬리표` = 바탕 원문번호.
|
||||
저장(`clean_doc`) = 꼴 검사 + 참조 위 층 · 있는 문서 · 순환 422 + 서버가 `바탕판` · `M01판` 적음.
|
||||
SK 단위 환산(728-2) = 배 = 바탕 기준단위(「100본」) → SK 단위(`master_unit.swap` ·
|
||||
「식」 · 빈 단위 = 앞 수 뗀 바탕 단위 = 옛 셈) ·
|
||||
다른 성격 = 문서 `환산` {계수 | 단위중량 {종별, 형상}} · 없으면 셈 막음(까닭) ·
|
||||
화면 셈 길 줄 · 계 = SK 1 단위 몫(`per_unit`).
|
||||
바탕 재료(747-1) = 별도계상 빈 칸 = 직접계산(M01 기초처럼 재료비에 듦 · 「별도계상」 고른 줄만 밖) ·
|
||||
일위대가 덮개 줄(`line` · `M02_Labor_Patch.run`)은 일위대가 기본(222-1 · 162-1) 그대로.
|
||||
보기 넷 한 답(750-1) = 화면 셈 길 답에 `글`(읽는 식) · `중간`(`M02_Sangeun_Views`) · 일위대가 줄
|
||||
모달 = 문서 `줄모드` true → `line`(일위대가 그 줄 셈과 같은 값).
|
||||
율 더한줄(778-4 · `_rated`) = 엔진 한 번 돈 줄로 밑(`M02_Labor_Fixed.rate_base` · 짝 화면
|
||||
`M02_MasterTemplete_Labor_Calc.ts` `rateBase` · 거울 시험 `test_778_4_rate_line.py`) → 율 줄 `값묶음` =
|
||||
{비목: 밑 ÷ 100} → 엔진 다시(율 줄 없는 문서 = 한 번만 · 값 그대로) · 줄 덧칸 `율` · `규격`.
|
||||
「식」 · 빈 단위 = 앞 수 뗀 바탕 단위) · 다른 성격 = 문서 `환산` {계수 | 단위중량 {종별, 형상}} ·
|
||||
없으면 셈 막음(까닭) · 화면 셈 길 줄 · 계 = SK 1 단위 몫(`per_unit`).
|
||||
바탕 재료(747-1) = 별도계상 빈 칸 = 직접계산(「별도계상」 고른 줄만 문서 금액 줄 `합밖`).
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -39,7 +27,6 @@ from M02_MasterTemplete import M02_MasterTemplete_Store as store
|
||||
from M02_MasterTemplete import M02_Sangeun_Block as blk
|
||||
from M02_MasterTemplete import M02_Sangeun_Const as const, M02_Sangeun_Copy as skc
|
||||
from M02_MasterTemplete import M02_Sangeun_Doc as sd, M02_Sangeun_Equation as eqm
|
||||
from M02_MasterTemplete import M02_Sangeun_Views as views
|
||||
|
||||
COSTS = labor.COSTS
|
||||
Ref = dict[str, Any]
|
||||
@@ -245,29 +232,8 @@ def _gap(item: dict, why: str) -> dict:
|
||||
|
||||
# ── 둘째 기초 세부(727-2) ─────────────────────────────────────────────────
|
||||
def sub_run(one: dict, whole: Any, patched: bool = True) -> dict[str, Any]:
|
||||
"""더한줄 로직 하나 = 그 기초 줄(+ 세부 덮개 · 뺀줄)을 엔진으로 — `run_line` 답 + 정체 ·
|
||||
짝잃음 ·
|
||||
바탕판(덮기 전 기초 지문) · 입력 = 채운 줄 값(`_fill`). `patched` False = 덮기 전."""
|
||||
code = str(one["로직"])
|
||||
mine = blk.own(one, whole) # 끊은 기초(796-2e) = 자기 사본 줄 위
|
||||
try:
|
||||
row = mine.logic(code)
|
||||
except Exception as e: # noqa: BLE001 — 엔진 FormulaError
|
||||
return {"기준": None, "까닭": str(e), "정체": [], "짝잃음": [], "바탕판": ""}
|
||||
if any(one.get(k) not in (None, {}, []) for k in sd.BODY): # 넣은 SK 몸(740-1) = 이름 없는 SK
|
||||
keep = ("입력값", *sd.BODY, *(("덮개", "뺀줄") if patched else ()))
|
||||
doc = {"키": "SK-000000", "이름": "줄", "단위": "식", "바탕": {"로직": code}}
|
||||
doc |= {"덮개": {}, "뺀줄": [], "더한줄": [], **{k: one[k] for k in keep if k in one}}
|
||||
try:
|
||||
return {**run(doc, mine), "바탕판": fingerprint(row)}
|
||||
except sd.DocError as e:
|
||||
return {"기준": None, "까닭": str(e), "정체": [], "짝잃음": [], "바탕판": ""}
|
||||
edited, lost = blk.row_of(whole, one)[0:2] if patched else (row, []) # 수식 고침(796-2e)
|
||||
got = sd.patched(edited, one if patched else {})
|
||||
over = _Over(mine, code, {**got["줄"], "키": code})
|
||||
out = labor.run_line(over, code, one.get("입력값"), None, got["고름"] or None)
|
||||
miss = [{"cid": eqm.LOST, "까닭": "수식 고침 못 얹음 — " + " · ".join(lost)}] if lost else []
|
||||
return {**out, "정체": got["정체"], "짝잃음": got["짝잃음"] + miss, "바탕판": fingerprint(row)}
|
||||
"""더한줄 로직 하나(둘째 기초 · 옛 칸) — 수식 사본 없음 = 못 셈 + 까닭(855 2-C1 · 옛 엔진 안 돎)."""
|
||||
return {"기준": None, "까닭": dsk.OLD_WHY, "정체": [], "짝잃음": [], "바탕판": ""}
|
||||
|
||||
|
||||
def _bundled(item: dict, sub: dict) -> dict:
|
||||
@@ -288,46 +254,6 @@ def tag_of(whole: Any, code: str) -> str:
|
||||
return code
|
||||
|
||||
|
||||
def _detail(one: dict, at: int, whole: Any) -> dict[str, Any]:
|
||||
"""둘째 기초 세부 줄(화면) — 수량 · 금액 · 비목 = 세부 × 더한줄 수량(상자 합 몫) · `원문` =
|
||||
그 기초 1 기준단위 몫(M01 원문 품 · 744-1 화면 품 칸) · cid `add:#k/세부 cid` ·
|
||||
`바탕값` = 덮기 전 1 기준단위 품 · 단가 · `뺀세부` = 뺀 줄 이름."""
|
||||
sub = sub_run(one, whole)
|
||||
plain = sub_run(one, whole, False) if sd.sub_patched(one) else sub
|
||||
was = dict(zip(plain["정체"], plain.get("줄") or []))
|
||||
covers, times = one.get("덮개") or {}, Decimal(str(one.get("수량") or 0))
|
||||
rows = []
|
||||
for cid, line in zip(sub["정체"], sub.get("줄") or []):
|
||||
mine = covers.get(cid) or {}
|
||||
scaled = {
|
||||
k: None if line.get(k) is None else Decimal(str(line[k])) * times
|
||||
for k in ("수량", "금액")
|
||||
}
|
||||
parts = {
|
||||
k: None if v is None else Decimal(str(v)) * times
|
||||
for k, v in (line.get("비목") or {}).items()
|
||||
}
|
||||
rows.append(
|
||||
{
|
||||
**line,
|
||||
**scaled,
|
||||
"비목": parts,
|
||||
"cid": f"add:#{at}/{cid}",
|
||||
"원문": {k: line.get(k) for k in ("수량", "금액", "비목")},
|
||||
"바탕값": _was(was[cid]) if cid in was else None,
|
||||
**({"덮개": [k for k in sd.COVER_KEYS if k in mine]} if mine else {}),
|
||||
**({"원값": mine["원값"]} if "원값" in mine else {}),
|
||||
}
|
||||
)
|
||||
gone = [
|
||||
{"cid": f"add:#{at}/{c}", "이름": was[c].get("이름") or ""}
|
||||
for c in one.get("뺀줄") or []
|
||||
if c in was
|
||||
]
|
||||
tag = tag_of(whole, str(one["로직"]))
|
||||
return {"펼침": rows, "뺀세부": gone, "바탕판": sub["바탕판"], "꼬리표": tag}
|
||||
|
||||
|
||||
def _bundles(row: dict, whole: Any, expand: Any, trail: tuple) -> None:
|
||||
"""더한줄 참조 · 고정 줄 `값묶음` = 1 단위 노 · 재 · 경 — 못 셈 줄 = `_gap`(나머지 셈 계속)."""
|
||||
for at, item in enumerate(row["호표"]):
|
||||
@@ -352,6 +278,15 @@ def _bundles(row: dict, whole: Any, expand: Any, trail: tuple) -> None:
|
||||
}
|
||||
|
||||
|
||||
def _row_of(doc: dict, whole: Any) -> dict:
|
||||
"""배 · 바탕판이 읽는 바탕 줄(셈 아님) — 바탕 로직 = 그 줄 · 없음 = 빈 줄(가져온 식 = 그 줄)."""
|
||||
key = (doc.get("바탕") or {}).get("로직")
|
||||
try:
|
||||
return whole.logic(key) if key else sd.empty_row(doc)
|
||||
except Exception as e: # noqa: BLE001 — 없는 로직
|
||||
raise sd.DocError(f"바탕 로직 · {e}") from e
|
||||
|
||||
|
||||
def run(
|
||||
doc: dict,
|
||||
whole: Any,
|
||||
@@ -359,64 +294,90 @@ def run(
|
||||
read: Any = refs.read_ref,
|
||||
expand: Any = None,
|
||||
trail: tuple = (),
|
||||
detail: bool = False,
|
||||
line: bool = False,
|
||||
seen: bool = True,
|
||||
catch: list | None = None,
|
||||
**_opts: Any,
|
||||
) -> dict[str, Any]:
|
||||
"""SK 셈(저장 안 함) — `run_line` 답 + `{1단위, 배, 정체, 짝잃음, 바탕판}` · 줄마다 `cid` ·
|
||||
고친 칸 `덮개`(칸 이름) · `원값`. 틀린 문서 · 순환 = `sd.DocError` ·
|
||||
`detail` = 둘째 기초 세부 펼침(`_detail` · 화면 셈 길만) · 그때 `seen` = 보기 덧칸(750-1) ·
|
||||
`line` = 일위대가 덮개 줄."""
|
||||
"""SK 셈(저장 안 함 · 855 2-C1) = 수식 사본 문서 셈 한 길 — 기준 · 1 단위 · 줄 · 비목 · 끝수 모두
|
||||
문서 답(`M02_Doc_Sk.run`) · 줄 `cid` = 「금액#n」(문서 금액 줄 차례) · 줄 `단위` = 문서 금액 줄 단위 ·
|
||||
수식 사본 없음(바탕 참조 · 옛 칸 덮개 · 더한줄 …) = 못 셈 + 까닭 하나(옛 엔진 안 돎 · 올림 없음) ·
|
||||
굳힌 사본(`M02_Doc_Sk.frozen` — B09 · 구조물 사본) = 옛 길(`_frozen` · B9 걸음 몫).
|
||||
`given` · `_opts`(detail · line · seen) = 옛 길 손님 꼴 — 문서 셈은 안 씀(옛 길도 금액은 문서 답 ·
|
||||
2-E2 에서 부르는 쪽과 같이 걷음). 틀린 단위 환산 = `sd.DocError`."""
|
||||
if dsk.frozen(doc):
|
||||
return _frozen(doc, whole, given, read, expand, trail)
|
||||
whole = skc.over(doc, whole)
|
||||
base = doc.get("바탕") or {}
|
||||
tag = tag_of(whole, base["로직"]) if "로직" in base else (base.get("참조") or {}).get("키")
|
||||
head = {"짝잃음": [], "빠진줄": [], "꼬리표": tag}
|
||||
copy = dsk.copy_of(doc, whole)
|
||||
if copy is None:
|
||||
why = dsk.OLD_WHY if dsk.own(doc) else dsk.REF_WHY
|
||||
none = {"기준": None, "1단위": None, "배": Decimal(1), "바탕판": "", "줄": [], "정체": []}
|
||||
return {**head, **none, "까닭": why, "수식셈": {"셈됨": False, "따로": False, "까닭": why}}
|
||||
row = _row_of(doc, whole)
|
||||
times = ratio_of(doc, row, whole)
|
||||
got = dsk.run(doc, copy, whole)
|
||||
money = dsk.dc.money(got)
|
||||
total = {k: Decimal(str(v)) for k, v in money.items()} if money else None
|
||||
mark = {"셈됨": bool(total), "따로": bool(copy.get("따로"))}
|
||||
if not total:
|
||||
mark["까닭"] = copy["문서"].get("_틀림") or dsk.dc.why(got) or "돈 아닌 문서"
|
||||
src = copy["문서"].get("금액") or []
|
||||
lines = [
|
||||
{**x, "단위": str((src[n] if n < len(src) else {}).get("단위") or ""), "cid": f"금액#{n}"}
|
||||
for n, x in enumerate(got.get("줄") or [])
|
||||
]
|
||||
out = {
|
||||
**head,
|
||||
"기준": total,
|
||||
"1단위": {k: v / times for k, v in total.items()} if total else None,
|
||||
"배": times,
|
||||
"바탕판": fingerprint(row),
|
||||
"줄": lines,
|
||||
"정체": [x["cid"] for x in lines],
|
||||
"끝수": got.get("끝수"),
|
||||
"까닭": None if total or "결과" in got else mark["까닭"],
|
||||
"수식셈": mark,
|
||||
}
|
||||
return out | ({"결과": got["결과"]} if "결과" in got else {})
|
||||
|
||||
|
||||
def _frozen(doc: dict, whole: Any, given: Any, read: Any, expand: Any, trail: tuple) -> dict:
|
||||
"""굳힌 사본 SK(수식 없음) 옛 엔진 셈 — 2-C1 전 `run` 그대로(굳힌 줄 = 덮개 · 더한줄 없음) · B9 몫."""
|
||||
from M02_MasterTemplete.M02_Labor_Expand import Expand
|
||||
|
||||
got = resolve(doc, whole := skc.over(doc, whole), read, trail, given, line)
|
||||
got = resolve(doc, whole := skc.over(doc, whole), read, trail, given)
|
||||
row = {**got["줄"], "호표": [dict(x) for x in got["줄"]["호표"]]}
|
||||
_bundles(row, whole, expand or Expand(whole, read), trail)
|
||||
head = {k: got[k] for k in ("정체", "짝잃음", "바탕판")} | {"배": got["배"]}
|
||||
gaps = {at: x for at, x in enumerate(row["호표"]) if x.get("빠짐")}
|
||||
key = str(doc.get("키") or "SK-000000")
|
||||
over = _Over(whole, key, {**row, "키": key})
|
||||
# 이 SK 줄의 입력만 — 더한줄 로직 입력은 `_fill` 이 따로 채움
|
||||
names = {str(i.get("이름")) for i in row.get("입력") or []}
|
||||
values = {k: v for k, v in {**got["입력값"], **(given or {})}.items() if k in names}
|
||||
out = labor.run_line(over, key, values, got["켜쌓기율"], got["고름"] or None)
|
||||
rates = _rated(row, out.get("줄") or [], got["정체"], got["자재표시"], got["켜쌓기율"])
|
||||
if rates is not None: # 율 더한줄(778-4) — 밑을 넣고 다시
|
||||
head["짝잃음"] = head["짝잃음"] + rates
|
||||
out = labor.run_line(over, key, values, got["켜쌓기율"], got["고름"] or None)
|
||||
eng, ctx = out.get("줄") or [], (over, key, values, got, out.get("재료")) # 802-4a 고친 줄
|
||||
catch is None or catch.append(ctx)
|
||||
seen = (
|
||||
views.text_of(over, key, values, got["고름"], got["정체"], eng) if detail and seen else {}
|
||||
args = (
|
||||
_Over(whole, key, {**row, "키": key}),
|
||||
key,
|
||||
values,
|
||||
got["켜쌓기율"],
|
||||
got["고름"] or None,
|
||||
)
|
||||
covers = doc.get("덮개") or {}
|
||||
lines = []
|
||||
for at, (cid, line) in enumerate(zip(got["정체"], out.get("줄") or [])):
|
||||
mine = covers.get(cid) or {}
|
||||
mark = {"덮개": [k for k in sd.COVER_KEYS if k in mine]} if mine else {}
|
||||
if at in gaps: # 못 셈 줄 = 금액 — · 까닭(725)
|
||||
mark |= {"단가": None, "금액": None, "비목": {}, "까닭": gaps[at]["빠짐"]}
|
||||
hit = re.match(r"^add:#(\d+)$", cid)
|
||||
one = got["채운더한줄"][int(hit[1])] if hit else {}
|
||||
if detail and one.get("종류") == "로직" and at not in gaps:
|
||||
mark |= _detail(one, int(hit[1]), whole)
|
||||
if sd.is_rate(one): # 율 줄 = 율 · 「기준의 %」(화면 % 줄 · `per_unit` 수량 그대로)
|
||||
mark |= {"율": Decimal(str(one["수량"])), "규격": _rate_text(one["고정"]["비율"])}
|
||||
lines.append(
|
||||
{**line, "cid": cid, **mark, **({"원값": mine["원값"]} if "원값" in mine else {})}
|
||||
)
|
||||
out = labor.run_line(*args)
|
||||
lost = _rated(row, out.get("줄") or [], got["정체"], got["자재표시"], got["켜쌓기율"])
|
||||
if lost is not None: # 율 더한줄(778-4) — 밑을 넣고 다시
|
||||
out = labor.run_line(*args)
|
||||
gap = {"단가": None, "금액": None, "비목": {}}
|
||||
lines = [
|
||||
{**line, "cid": cid, **({**gap, "까닭": gaps[at]["빠짐"]} if at in gaps else {})}
|
||||
for at, (cid, line) in enumerate(zip(got["정체"], out.get("줄") or []))
|
||||
]
|
||||
out = labor.drop_apart({**out, "줄": lines}, got["자재표시"])
|
||||
base = out.get("기준")
|
||||
unit = {k: Decimal(str(v)) / got["배"] for k, v in base.items()} if base else None
|
||||
gone = [
|
||||
{"cid": got["정체"][at], "이름": x.get("이름") or "", "까닭": x["빠짐"]}
|
||||
for at, x in gaps.items()
|
||||
]
|
||||
base = doc.get("바탕") or {}
|
||||
tag = tag_of(whole, base["로직"]) if "로직" in base else (base.get("참조") or {}).get("키")
|
||||
ans = {**out, **head, **seen, "1단위": unit, "빠진줄": gone, "꼬리표": tag}
|
||||
return dsk.on_run(doc, ans, ctx) # 수식 사본 SK = 문서 셈 금액(802-4a)
|
||||
head = {k: got[k] for k in ("정체", "바탕판", "배")} | {"짝잃음": got["짝잃음"] + (lost or [])}
|
||||
unit = {k: Decimal(str(v)) / got["배"] for k, v in base.items()} if base else None
|
||||
tag = tag_of(whole, str((doc.get("바탕") or {}).get("로직") or ""))
|
||||
return {**out, **head, "1단위": unit, "빠진줄": gone, "꼬리표": tag}
|
||||
|
||||
|
||||
def _group(item: dict, line: dict) -> str | None:
|
||||
@@ -465,20 +426,14 @@ def _rated(row: dict, eng: list, ids: list, marks: dict, stack: Any = None) -> l
|
||||
return lost
|
||||
|
||||
|
||||
def _rate_text(rate: dict) -> str:
|
||||
"""율 줄 규격 — 「인력의 %」 · 목록 = 「줄 n 개의 %」."""
|
||||
basis = rate["기준"]
|
||||
return f"줄 {len(basis)} 개의 %" if isinstance(basis, list) else f"{basis}의 %"
|
||||
|
||||
|
||||
def unit(doc: dict, whole: Any, expand: Any, trail: tuple) -> dict[str, Any]:
|
||||
"""펼침(`Expand`) 한 칸 — `{이름, 단위, 기준(1 단위), 까닭, 줄, 짝잃음}` · 못 셈 = 까닭."""
|
||||
head = {"이름": doc.get("이름"), "단위": doc.get("단위")}
|
||||
try:
|
||||
got = run(doc, whole, None, expand.read, expand, trail)
|
||||
got = run(doc, whole, None, getattr(expand, "read", refs.read_ref), expand, trail)
|
||||
except sd.DocError as e:
|
||||
return {**head, "기준": None, "까닭": str(e)}
|
||||
gone = got.get("빠진줄") or [] # 쓰는 자리 = 빠진 줄 있으면 통째 기준 없음(부분 값 안 넘김)
|
||||
gone = got.get("빠진줄") or [] # 굳힌 사본 옛 길 — 빠진 줄 있으면 통째 기준 없음
|
||||
why = got.get("까닭") or next((f"「{x['이름']}」 {x['까닭']}" for x in gone), None)
|
||||
why = why or (None if got.get("1단위") else "돈 아닌 로직")
|
||||
times = got["배"]
|
||||
@@ -548,7 +503,8 @@ def _check_refs(doc: dict, here_: refs.Here) -> None:
|
||||
|
||||
|
||||
def clean_doc(doc: Any, here_: refs.Here) -> dict[str, Any]:
|
||||
"""저장 꼴(`Labor_Ref.clean_doc` 가 부름) — 검사 · 참조 · 순환 · 서버가 `원값` · `바탕판`."""
|
||||
"""저장 꼴(`Labor_Ref.clean_doc` 가 부름) — 검사 · 참조 · 순환 · 서버가 `바탕판` · `M01판` ·
|
||||
옛 칸 덮개 · 둘째 기초 `원값` 적기는 걷음(옛 칸 셈 은퇴 · 855 2-C1)."""
|
||||
raw, job = doc, doc.get(skc.JOB) if isinstance(doc, dict) else None # 수식 사본(802-4a)
|
||||
whole = skc.over(doc := skc.settle(doc, True), skc.whole_()) # 사본(795-1) · 내 기계(821-1)
|
||||
try:
|
||||
@@ -560,45 +516,17 @@ def clean_doc(doc: Any, here_: refs.Here) -> dict[str, Any]:
|
||||
out["바탕"], out["더한줄"] = rough["바탕"], rough["더한줄"]
|
||||
for one in out["더한줄"]: # 처음수량(744-1) = 넣을 때 수량 · 없으면 지금 수량
|
||||
one.setdefault("처음수량", one["수량"])
|
||||
if out["덮개"]:
|
||||
bare = run({**out, "덮개": {}}, whole) # 덮기 전 값 = 원값(그때 M01)
|
||||
was = {x["cid"]: x for x in bare.get("줄") or []}
|
||||
for cid, one in out["덮개"].items():
|
||||
if cid in was:
|
||||
one["원값"] = _was(was[cid])
|
||||
out |= const.stamp(base["줄"], out) # 바탕판 · M01판(790-2) · 식 칸 엔진 식(792-1)
|
||||
ratio_of(out, base["줄"], whole) # 단위 못 바꿈(계수 없음) = 저장 막음(728-2)
|
||||
_stamp_adds(out, base, whole)
|
||||
out = dsk.settle(out, whole, job, raw)
|
||||
except sd.DocError as e:
|
||||
raise _fail(e) from e
|
||||
return out
|
||||
|
||||
|
||||
def _stamp_adds(out: dict, base: dict, whole: Any) -> None:
|
||||
"""둘째 기초 저장 칸(727-2) — `바탕판` = 그 기초 지문 · 세부 덮개 `원값` = 덮기 전
|
||||
1 기준단위 값."""
|
||||
filled, _ = _fill(out, whole, {**base["입력값"], **out["입력값"]})
|
||||
for one, mine in zip(filled["더한줄"], out["더한줄"]):
|
||||
if one.get("종류") != "로직":
|
||||
continue
|
||||
plain = sub_run(one, whole, False)
|
||||
if plain["바탕판"]:
|
||||
mine["바탕판"] = plain["바탕판"]
|
||||
was = dict(zip(plain["정체"], plain.get("줄") or []))
|
||||
for cid, cover in (mine.get("덮개") or {}).items():
|
||||
if cid in was:
|
||||
cover["원값"] = _was(was[cid])
|
||||
|
||||
|
||||
def _was(line: dict) -> dict[str, Any]:
|
||||
keep = {"qty": line.get("율", line.get("수량")), "단가": line.get("단가")}
|
||||
return {k: sd.plain(Decimal(str(v))) for k, v in keep.items() if v is not None}
|
||||
|
||||
|
||||
def calc_doc(doc: Any, given: dict | None = None, seen: bool = True) -> dict[str, Any]:
|
||||
"""셈 길(`M02_Sangeun_Router`) — 지금 층 문서 · 저장 전 화면 문서 · 틀림 400 · 순환 422 ·
|
||||
`seen` = 보기 덧칸(`글` · `중간`) 지음."""
|
||||
`seen` = 옛 보기 덧칸 자리(856-1 뒤 안 지음 · 길 꼴만 · 2-E2 에서 걷음)."""
|
||||
from M01_MasterData import M01_MasterData_Store as m01
|
||||
|
||||
with m01.cache.steady(): # 한 셈 동안 M01 파일 자국 한 번(792-2)
|
||||
@@ -607,8 +535,7 @@ def calc_doc(doc: Any, given: dict | None = None, seen: bool = True) -> dict[str
|
||||
clean = sd.clean(doc, None, whole)
|
||||
_check_refs(clean, refs.here()) # 저장 전 문서도 위 층만 · 있는 문서 · 순환 422
|
||||
me = refs.ref_id({"층": refs.here()[0], "주인": refs.here()[1], "키": clean["키"]})
|
||||
line = isinstance(doc, dict) and doc.get("줄모드") is True # 일위대가 줄 모달(750-1)
|
||||
got = run(clean, whole, given, trail=(me,), detail=True, line=line, seen=seen)
|
||||
got = run(clean, whole, given, trail=(me,))
|
||||
except sd.DocError as e:
|
||||
raise _fail(e) from e
|
||||
return skc.mark(const.answer(got, clean, doc, given, (me,)), clean) # 790-2 · 795-1
|
||||
return skc.mark(const.answer(got, clean), clean) # 795-1
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
"""M02 단가산출(SK) 숫자 넓힘(PLAN 790-2 · 요구서_652 · _분석_650-H3 E2) — 새 덮개 갈래 · 시트 답.
|
||||
"""M02 단가산출(SK) 숫자 넓힘(PLAN 790-2 · 요구서_652 · _분석_650-H3 E2) — 새 덮개 갈래.
|
||||
|
||||
시험 `resources/tester/test_790_2_sangeun_const.py` · 799-2 — 화면 짝(`Const_Model.ts` · 시트 탭)은 걷음, 서버만 남음.
|
||||
|
||||
@@ -15,8 +15,7 @@
|
||||
셈 = `M02_Sangeun_Doc.patched` 첫머리 `formulas`(바탕 줄 식을 바꾼 사본) → 모든 셈 길(화면 · 저장
|
||||
원값 · B09 · 펼침 겹침) 한 벌 · 펼침(`M02_Library_Flat._read`) = 새 덮개 SK 는 안 펼침
|
||||
(옛 참조 그대로) · [초기화](`M02_Library_Flat.reset`) = `restore` 전체.
|
||||
화면 셈 답(`answer`) 덧칸 `원래` {노무비, 재료비, 경비, 계}(1 단위) + `시트` {자리, 글줄, 짝잃음} ·
|
||||
M01 원래 = 같은 옵션 · 덮개 · 뺀줄 · 더한줄 · 새 덮개 없는 셈.
|
||||
화면 셈 답(`answer`) = 문서 셈 답 + 머리(옛 `원래` · `시트` 덧칸은 855 2-C1 에서 걷음 · 상세 몸 856-1).
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -25,7 +24,6 @@ import functools
|
||||
import hashlib
|
||||
import json
|
||||
import re
|
||||
from decimal import Decimal
|
||||
from typing import Any
|
||||
|
||||
from M02_MasterTemplete import M02_Sangeun_Doc as sd
|
||||
@@ -139,24 +137,6 @@ def _swapped(row: dict, doc: dict) -> dict:
|
||||
return out
|
||||
|
||||
|
||||
def lost(row: dict, doc: dict) -> list[dict]:
|
||||
"""짝 잃은 새 덮개 — 바탕에 없는 자리 · 없는 n 번째."""
|
||||
where, out = places(row), []
|
||||
for name, kind in (("상수덮개", "num"), ("표값덮개", "find")):
|
||||
for spot, cover in (doc.get(name) or {}).items():
|
||||
if spot not in where:
|
||||
out.append({"cid": spot, "까닭": f"{name} — 바탕에 없는 줄"})
|
||||
continue
|
||||
part, at = where[spot]
|
||||
have = len(scan(str((row[part][at] or {}).get(FIELD[part])))[kind])
|
||||
out += [
|
||||
{"cid": spot, "까닭": f"{name} — {int(n) + 1} 번째 없음"}
|
||||
for n in cover
|
||||
if int(n) >= have
|
||||
]
|
||||
return out
|
||||
|
||||
|
||||
def no_flat(doc: Any) -> None:
|
||||
"""펼침 막음 — 상수 · 표값 덮개 SK(펼친 줄에 못 옮김 · 옛 참조 그대로 = 값 그대로)."""
|
||||
keys = ("상수덮개", "표값덮개", eqm.KEY) # 수식 고침(796-2b)
|
||||
@@ -313,105 +293,9 @@ def kinds(doc: dict, spot: str) -> list[str]:
|
||||
|
||||
|
||||
# ── 화면 셈 답 ────────────────────────────────────────────────────────
|
||||
def answer(got: dict, clean: dict, raw: Any, given: dict | None, trail: tuple) -> dict:
|
||||
"""`M02_Sangeun_Calc.calc_doc` 답 — 옛 답 + `원래` · `시트`."""
|
||||
def answer(got: dict, clean: dict) -> dict:
|
||||
"""`M02_Sangeun_Calc.calc_doc` 답 — 셈 답(1 단위 몫) + 머리 · 가져온 식 원본 보기(옛 `원래` · `시트` 걷음 · 855 2-C1)."""
|
||||
from M02_MasterTemplete import M02_Sangeun_Calc as calc
|
||||
|
||||
out = {**calc.views.finish(calc.per_unit(got, clean)), "머리": calc.head_of(clean)}
|
||||
return calc.labor._json(imp.more(out | sheet(out, clean, raw, given, trail), clean))
|
||||
|
||||
|
||||
def _bare(doc: dict) -> dict:
|
||||
out = {k: v for k, v in doc.items() if k not in (*NEW, *fx.FIELDS, "뺀더한줄", eqm.KEY)}
|
||||
return out | {"덮개": {}, "뺀줄": [], "더한줄": []}
|
||||
|
||||
|
||||
def _mids(whole: Any, key: str, row: dict, values: dict) -> tuple[dict, dict]:
|
||||
"""(중간 값, 엔진 입력) — 시험 계산과 같은 길(`M02_Sangeun_Views.text_of`) · 못 셈 = 빈."""
|
||||
from M02_MasterTemplete import M02_Sangeun_Calc as calc
|
||||
|
||||
over = calc._Over(whole, key, {**row, "키": key})
|
||||
m01 = calc.labor.m01
|
||||
auto = {k: v for k, v in m01.mau.values(over, over.logic(key)).items() if v is not None}
|
||||
given = {**auto, **m01._dec(values or {})}
|
||||
try:
|
||||
mid = calc.labor.mcut.engine(over, key, m01.cm.mf.run(over, key, given)).get("중간") or {}
|
||||
except Exception: # noqa: BLE001 — 엔진 FormulaError · 셈 틀림 = 값 없음
|
||||
return {}, given
|
||||
return mid, given
|
||||
|
||||
|
||||
def _finds(whole: Any, text: str, env: dict) -> list[dict]:
|
||||
from M02_MasterTemplete import M02_Labor_Doc as labor
|
||||
|
||||
mf, out = labor.m01.cm.mf, []
|
||||
for n, (a, b) in enumerate(scan(text)["find"]):
|
||||
try:
|
||||
value = mf.evaluate(mf.parse(text[a:b]), dict(env), whole)
|
||||
except Exception: # noqa: BLE001
|
||||
value = None
|
||||
out.append({"n": n, "글": text[a:b], "값": value})
|
||||
return out
|
||||
|
||||
|
||||
def sheet(ans: dict, clean: dict, raw: Any, given: dict | None, trail: tuple) -> dict:
|
||||
"""`원래` · `시트` — 자리마다 원래 · 지금 · 덮개 갈래 · 까닭 · M01바뀜 · 상수 · 표값."""
|
||||
from M02_MasterTemplete import M02_Labor_Ref as refs
|
||||
from M02_MasterTemplete import M02_Sangeun_Calc as calc
|
||||
|
||||
whole = calc.skc.over(clean, calc.labor.m01.loaded()[1]) # 사본(795-1) — 중간 · 표값도
|
||||
try:
|
||||
base = calc._base_of(clean, whole, refs.read_ref, trail)["줄"]
|
||||
bare = calc.per_unit(calc.run(_bare(clean), whole, given, trail=trail), clean)
|
||||
except sd.DocError:
|
||||
return {"원래": None, "시트": {"자리": {}, "글줄": clean.get("글줄") or [], "짝잃음": []}}
|
||||
was = {x["cid"]: x for x in bare.get("줄") or [] if x.get("cid")}
|
||||
now = {x["cid"]: x for x in ans.get("줄") or [] if x.get("cid")}
|
||||
key = str(clean.get("키") or "SK-000000")
|
||||
values = {**(clean.get("입력값") or {}), **(given or {})}
|
||||
mids0, env0 = _mids(whole, key, base, values)
|
||||
mids1, _ = _mids(whole, key, formulas(base, clean), values)
|
||||
stamps = (raw.get("M01판") if isinstance(raw, dict) else None) or {}
|
||||
stamps = {} if imp.is_imported(clean) else stamps # 가져온 식 = M01 짝 없음(793-3b)
|
||||
fresh = stamp(base)["M01판"]
|
||||
why = clean.get("까닭") or {}
|
||||
nums, finds = clean.get("상수덮개") or {}, clean.get("표값덮개") or {}
|
||||
spots: dict[str, dict] = {}
|
||||
for spot, (part, at) in places(base).items():
|
||||
line = base[part][at]
|
||||
text = str(line.get(FIELD[part]))
|
||||
consts = [
|
||||
{"n": n, "값": nums.get(spot, {}).get(str(n), v), "원값": v}
|
||||
for n, v in enumerate(Decimal(text[a:b]) for a, b in scan(text)["num"])
|
||||
]
|
||||
tables = [
|
||||
{**t, "원값": t["값"], "값": finds.get(spot, {}).get(str(t["n"]), t["값"])}
|
||||
for t in _finds(whole, text, {**env0, **mids0})
|
||||
]
|
||||
if part == "중간":
|
||||
name = str(line.get("이름"))
|
||||
old, cur = mids0.get(name), mids1.get(name)
|
||||
else:
|
||||
old, cur = (was.get(spot) or {}).get("금액"), (now.get(spot) or {}).get("금액")
|
||||
spots[spot] = {
|
||||
"갈래": part,
|
||||
"이름": line.get("이름") or "",
|
||||
"식": text,
|
||||
"상수": consts,
|
||||
"표값": tables,
|
||||
"원래": old,
|
||||
"지금": cur,
|
||||
"덮개": kinds(clean, spot),
|
||||
"까닭": why.get(spot),
|
||||
"M01바뀜": spot in stamps and stamps[spot] != fresh.get(spot),
|
||||
}
|
||||
for cid, line in now.items():
|
||||
if _ADD.match(cid) and cid not in spots:
|
||||
spots[cid] = {"갈래": "더한줄", "이름": line.get("이름") or "", "원래": None}
|
||||
spots[cid] |= {"지금": line.get("금액"), "덮개": [], "까닭": why.get(cid)}
|
||||
gone = lost(base, clean) + [
|
||||
{"cid": s, "까닭": "M01 바뀜 — 바탕에 없는 줄"} for s in stamps if s not in fresh
|
||||
]
|
||||
gone += fx.sheet_more(spots, base, clean, mids1) # 식 칸(792-1) 덧칸 · 변수 줄 · 틀린 식
|
||||
top = {"글줄": clean.get("글줄") or [], "짝잃음": gone, "이름표": fx.name_table(base, clean)}
|
||||
return {"원래": bare.get("기준"), "시트": {"자리": spots, **top}}
|
||||
out = {**calc.per_unit(got, clean), "머리": calc.head_of(clean)}
|
||||
return calc.labor._json(imp.more(out, clean))
|
||||
|
||||
@@ -1,83 +0,0 @@
|
||||
"""M02 단가산출(SK) 보기 넷 = 셈 답 하나(PLAN 750-1 · 요구 588-1) — 화면 셈 길 답 덧칸.
|
||||
|
||||
- `글` = 읽는 식(M01 `/text` 와 같은 꼴 · `master_text.lines` + `master_sheet_line.annotate`) ·
|
||||
SK 고친 줄(`_Over`) · 같은 입력(자동값 + 입력값) · 같은 고름(`choosing`) 위에서 지음.
|
||||
줄마다 `cid` = SK 줄 cid(`annotate` 와 같은 차례 — 호표 줄 × `_shares` 비목 · 뒤 덧줄).
|
||||
금액 · 소계 · 계 = SK `줄` · `기준` 그대로(`finish` — 별도계상 뺌 · 켜쌓기율 · 단위 환산 ÷배 ·
|
||||
못 셈 줄 까닭) · 식 글(`글` · `이름글`)은 바탕 단위 셈 그대로 + 머리 `나눔`(배 ≠ 1).
|
||||
- `중간` = 시험 계산 중간값(수 · 글만) — 시험 계산 = {lines: `줄`, sums: `기준`, middle: `중간`}.
|
||||
계산 자리 = 서버 단독(CLAUDE.md 5장 ③) · 화면은 그리기만.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from decimal import Decimal
|
||||
from typing import Any
|
||||
|
||||
from M02_MasterTemplete import M02_Labor_Doc as labor
|
||||
|
||||
mf = labor.m01.cm.mf
|
||||
import master_sheet_line as msl # noqa: E402 — scripts 길은 `m01` 이 둠
|
||||
import master_text as mtx # noqa: E402
|
||||
|
||||
_ERRORS = (mf.FormulaError, ArithmeticError, KeyError, TypeError, ValueError)
|
||||
|
||||
|
||||
def text_of(over: Any, key: str, values: dict, picks: Any, ids: list, eng: list) -> dict:
|
||||
"""`{글, 중간}` — `eng` = `run_line` 줄(별도계상 빼기 전 · 차례 맞춤용) · 못 지음 = 까닭."""
|
||||
row = over.logic(key)
|
||||
auto = {k: v for k, v in labor.m01.mau.values(over, row).items() if v is not None}
|
||||
given = {**auto, **labor.m01._dec(values or {})}
|
||||
try:
|
||||
with mf.mp.choosing(picks or None):
|
||||
text = msl.annotate(over, key, given, mtx.lines(over, key, given))
|
||||
mid = labor.mcut.engine(over, key, mf.run(over, key, given)).get("중간") or {} # 751-3
|
||||
except _ERRORS as e:
|
||||
return {"글": {"ok": False, "reason": str(e) or type(e).__name__}, "중간": {}}
|
||||
if text.get("ok") and "groups" in text and "결과" not in row:
|
||||
_tag(row, ids, eng, text)
|
||||
keep = (Decimal, int, float, str, bool)
|
||||
return {"글": text, "중간": {k: v for k, v in mid.items() if isinstance(v, keep)}}
|
||||
|
||||
|
||||
def _tag(row: dict, ids: list, eng: list, text: dict) -> None:
|
||||
"""글 줄마다 `cid` — `annotate` 와 같은 차례(호표 줄 × 몫 비목 → 덧줄)."""
|
||||
slots = {g["비목"]: iter(g["줄"]) for g in text["groups"]}
|
||||
items, adds = row.get("호표") or [], row.get("덧줄") or []
|
||||
for n, line in enumerate(eng):
|
||||
if n < len(items):
|
||||
parts = [p for p, _ in mtx._shares(line)] if line.get("비목") else []
|
||||
else:
|
||||
parts = [adds[n - len(items)]["비목"]] if n - len(items) < len(adds) else []
|
||||
for part in parts:
|
||||
one = next(slots.get(part, iter(())), None)
|
||||
if one is not None and n < len(ids):
|
||||
one["cid"] = ids[n]
|
||||
|
||||
|
||||
def finish(ans: dict) -> dict:
|
||||
"""화면 답(`per_unit` 뒤) — 글 금액 · 소계 · 계 = SK 줄 · 기준 · SK 에 없는 줄(별도계상) 뺌."""
|
||||
text = ans.get("글") or {}
|
||||
base = ans.get("기준")
|
||||
if not text.get("ok") or "groups" not in text or not base:
|
||||
return ans
|
||||
sk = {x["cid"]: x for x in ans.get("줄") or [] if x.get("cid")}
|
||||
groups = []
|
||||
for g in text["groups"]:
|
||||
kept = []
|
||||
for one in g["줄"]:
|
||||
line = sk.get(one.get("cid"))
|
||||
if line is None and one.get("cid"):
|
||||
continue # SK 에서 빠진 줄(별도계상)
|
||||
if line is not None:
|
||||
parts = line.get("비목") or {}
|
||||
money = parts.get(g["비목"]) if len(parts) > 1 else line.get("금액")
|
||||
one = {**one, "금액": money}
|
||||
if line.get("까닭"):
|
||||
one["까닭"] = line["까닭"]
|
||||
kept.append(one)
|
||||
if kept:
|
||||
groups.append({**g, "줄": kept, "소계": base.get(g["비목"])})
|
||||
times = ans.get("화면배")
|
||||
head = {"나눔": times} if times not in (None, 1) else {}
|
||||
return {**ans, "글": {**text, "groups": groups, "계": base.get("계"), **head}}
|
||||
@@ -3,7 +3,7 @@
|
||||
"지문": {
|
||||
"키": "e68369418202e5ee",
|
||||
"calc_user": "6d74551273d6735f",
|
||||
"daega_inputs": "0ef81c80bc45ae0b",
|
||||
"daega_inputs": "d26099b92d7d0a1b",
|
||||
"수요": "f793204cf95c45c4",
|
||||
"산근 값": "c486d041a3246ffb",
|
||||
"산근 글": "a21b34ec13661f0c",
|
||||
|
||||
@@ -6,15 +6,12 @@
|
||||
[단가산출로 저장] = 새 SK + 참조 줄 · 같은 값 · 단위 빈칸 400 · 덮개 없는 줄 = 옛 값.
|
||||
"""
|
||||
|
||||
from decimal import Decimal
|
||||
|
||||
import pytest
|
||||
|
||||
from M01_MasterData import M01_MasterData_Store as m01
|
||||
from M02_MasterTemplete import M02_Labor_Doc as labor
|
||||
from M02_MasterTemplete import M02_Labor_Ref as refs
|
||||
from M02_MasterTemplete import M02_MasterTemplete_Store as store
|
||||
from M02_MasterTemplete import M02_Sangeun_Calc as calc
|
||||
from resources.tester.test_m02_labor_ref import MINE, world # noqa: F401 — 같은 임시 층
|
||||
|
||||
PCT = "GC001109" # 원/㎡ · 인력 둘(LB000036 · LB000002) + 「노무비 * 3 / 100」
|
||||
@@ -40,66 +37,6 @@ def _value(folder, key):
|
||||
return refs.Expand(_whole(), given=given)(ref)
|
||||
|
||||
|
||||
def test_logic_line_cover_in_precombo(world):
|
||||
"""사전조합 로직 줄 덮개 = 같은 덮개 SK 값 · 손셈(품 0.5 × 단가 + 둘째 줄 · 3 % 덧줄)."""
|
||||
bare = labor.run_line(_whole(), PCT, {})
|
||||
sc = _sc(world["personal"], [{"로직": PCT, "패치": COVER}])
|
||||
with store.at(world["personal"]):
|
||||
kept = store.read("precombo", sc)["문서"]["담은로직"][0]
|
||||
assert kept["패치"] == COVER
|
||||
got = _value(world["personal"], sc)["기준"]
|
||||
cut = labor.mcut.down # 751-3 — 줄 0.1 원 · 비목 합 1 원 버림
|
||||
labor_sum = cut(Decimal("0.5") * Decimal(str(bare["줄"][0]["단가"])), 1) + Decimal(
|
||||
str(bare["줄"][1]["금액"])
|
||||
)
|
||||
assert got["노무비"] == pytest.approx(cut(labor_sum, 0))
|
||||
assert got["경비"] == pytest.approx(labor_sum * 3 / 100, abs=1)
|
||||
|
||||
|
||||
def test_line_pick_by_order_stays_after_drop(world):
|
||||
"""줄 고름 = 바탕 호표 차례(2) · 패치 뺀줄로 첫 재료 줄을 빼도 그 자재가 그 줄에."""
|
||||
import master_pick as mp
|
||||
|
||||
whole = _whole()
|
||||
row = whole.logic(TWO_MATS)
|
||||
item = row["호표"][2]
|
||||
want = mp.search(whole, item["요소"], {}, item.get("단위"))[1]
|
||||
one = {
|
||||
"로직": TWO_MATS,
|
||||
"고름": {"2": want},
|
||||
"자재표시": {"2": {"별도계상": "직접계산"}},
|
||||
"패치": {"뺀줄": ["material:" + row["호표"][1]["이름"] + "#0"]},
|
||||
}
|
||||
with store.at(world["personal"]):
|
||||
doc = labor.clean({"담은로직": [one]})
|
||||
got = labor.calc(doc, {})["줄"][0]
|
||||
picked = [x for x in got["줄"] if x.get("품목")]
|
||||
assert [x["품목"]["키"] for x in picked] == [want]
|
||||
|
||||
|
||||
def test_ref_line_cover_only_that_line(world):
|
||||
"""SK 참조 줄 덮개 = 그 줄만 · SK 원본 · 다른 줄 값 그대로."""
|
||||
with store.at(world["personal"]):
|
||||
sk = refs.create(
|
||||
"sangeun", {"이름": "밑", "단위": "㎡", "바탕": {"로직": PCT}, "더한줄": []}
|
||||
)["이름"]
|
||||
before = store.read("sangeun", sk)["판"]
|
||||
ref = {**MINE, "키": sk}
|
||||
sc = _sc(
|
||||
world["personal"],
|
||||
[{"참조": ref, "수량": {"손": 1}, "패치": COVER}, {"로직": "GC001111", "수량": {"손": 1}}],
|
||||
)
|
||||
inner = _value(world["personal"], sc)["안"]
|
||||
plain = _value(world["personal"], _sc(world["personal"], [{"참조": ref}]))["기준"]
|
||||
covered = calc.calc_doc(
|
||||
{"키": "SK-000999", "이름": "x", "단위": "㎡", "바탕": {"로직": PCT}, **COVER}
|
||||
)
|
||||
assert inner[0]["기준"]["계"] == pytest.approx(Decimal(str(covered["1단위"]["계"])))
|
||||
assert inner[0]["기준"]["계"] != plain["계"]
|
||||
with store.at(world["personal"]):
|
||||
assert store.read("sangeun", sk)["판"] == before
|
||||
|
||||
|
||||
def test_refusals(world):
|
||||
with store.at(world["personal"]):
|
||||
with pytest.raises(store.StoreError, match="단위가 빔"):
|
||||
|
||||
@@ -1,101 +0,0 @@
|
||||
# ruff: noqa: F811 — 임시 층 fixture(world)를 test_m02_labor_ref 에서 받아 씀
|
||||
"""M02 단가산출(SK) 엔진 입력 덧칸(PLAN 715-1b · `master_pick`) — 고친 줄 값 = 손셈.
|
||||
|
||||
줄 단가 덮개 = 손 단가 · 로직 줄 노 · 재 · 경 덮개 = 값묶음(일부면 엔진 값 위) ·
|
||||
덧줄 % 가 덮인 값에서 다시 셈 · 더한줄 참조(SK · SC) · 고정 = 1 단위 묶음 · 덧칸 없는 줄 = 엔진 값.
|
||||
"""
|
||||
|
||||
from decimal import Decimal
|
||||
|
||||
import pytest
|
||||
|
||||
from M01_MasterData import M01_MasterData_Store as m01
|
||||
from M02_MasterTemplete import M02_Labor_Doc as labor
|
||||
from M02_MasterTemplete import M02_Labor_Ref as refs
|
||||
from M02_MasterTemplete import M02_MasterTemplete_Store as store
|
||||
from M02_MasterTemplete import M02_Sangeun_Calc as calc
|
||||
from resources.tester.test_m02_labor_ref import MINE, world # noqa: F401 — 같은 임시 층
|
||||
|
||||
PCT = "GC001109" # 원/㎡ · 인력 둘 + 「노무비 * 3 / 100」
|
||||
SUB = "GC000999" # 원/주 · 인력 둘 + 로직 줄(GC000275)
|
||||
|
||||
|
||||
def _whole():
|
||||
return m01.loaded()[1]
|
||||
|
||||
|
||||
def _run(**doc):
|
||||
from M02_MasterTemplete import M02_Sangeun_Doc as sd
|
||||
|
||||
whole = _whole()
|
||||
clean = sd.clean({"키": "SK-000001", "이름": "시험", "단위": "㎡", **doc}, None, whole)
|
||||
return labor._json(calc.run(clean, whole))
|
||||
|
||||
|
||||
def test_price_cover_is_hand_price_and_pct_follows():
|
||||
bare = labor.run_line(_whole(), PCT, {})
|
||||
first, second = bare["줄"][0], bare["줄"][1]
|
||||
got = _run(바탕={"로직": PCT}, 덮개={"labor:LB000036#0": {"labor": 200000}})
|
||||
line = got["줄"][0]
|
||||
assert line["단가"] == 200000 and line["출처"] == "손 단가"
|
||||
cut = labor.mcut.down # 751-3 — 줄 0.1 원 · 비목 합 1 원 버림
|
||||
want = cut(Decimal(str(first["수량"])) * 200000, 1) + Decimal(str(second["금액"]))
|
||||
assert got["기준"]["노무비"] == pytest.approx(float(cut(want, 0)))
|
||||
assert got["기준"]["경비"] == pytest.approx(float(want * 3 / 100), abs=1)
|
||||
|
||||
|
||||
def test_bundle_cover_on_logic_line_partial():
|
||||
bare = labor.run_line(_whole(), SUB, {})
|
||||
sub = bare["줄"][2]
|
||||
got = _run(바탕={"로직": SUB}, 단위="주", 덮개={"logic:GC000275#0": {"expense": 1000}})
|
||||
line = got["줄"][2]
|
||||
qty = Decimal(str(sub["수량"]))
|
||||
assert line["비목"]["경비"] == pytest.approx(float(qty * 1000))
|
||||
assert line["비목"]["노무비"] == pytest.approx(
|
||||
float(sub["비목"]["노무비"])
|
||||
) # 안 덮은 칸 = 엔진 값
|
||||
|
||||
|
||||
def test_untouched_lines_same_as_engine():
|
||||
bare = labor.run_line(_whole(), SUB, {})
|
||||
got = _run(바탕={"로직": SUB}, 단위="주") # 바탕 단위(728-2 — 성격 다르면 계수 칸)
|
||||
assert got["기준"]["계"] == pytest.approx(float(bare["기준"]["계"]))
|
||||
|
||||
|
||||
def test_added_ref_and_fixed_lines(world):
|
||||
"""더한줄 = SK 참조 2 · 고정 줄 1 — 값 = 2 × 그 SK 1 단위 + 고정 단가."""
|
||||
with store.at(world["personal"]):
|
||||
sk = refs.create(
|
||||
"sangeun", {"이름": "밑", "단위": "㎡", "바탕": {"로직": PCT}, "더한줄": []}
|
||||
)["이름"]
|
||||
unit = calc.calc_doc(store.read("sangeun", sk)["문서"])["1단위"]["계"]
|
||||
top = refs.create(
|
||||
"sangeun",
|
||||
{
|
||||
"이름": "위",
|
||||
"단위": "식",
|
||||
"바탕": None,
|
||||
"더한줄": [
|
||||
{"참조": {**MINE, "키": sk}, "수량": 2},
|
||||
{"고정": {"이름": "운반", "단위": "식", "단가": {"경비": 5000}}, "수량": 1},
|
||||
],
|
||||
},
|
||||
)["이름"]
|
||||
got = calc.calc_doc(store.read("sangeun", top)["문서"])
|
||||
assert got["기준"]["계"] == pytest.approx(unit * 2 + 5000, abs=1)
|
||||
expense = labor.run_line(_whole(), PCT, {})["기준"]["경비"]
|
||||
assert got["기준"]["경비"] == pytest.approx(5000 + 2 * float(expense), abs=1)
|
||||
|
||||
|
||||
def test_added_material_counts_unless_apart():
|
||||
"""사용자가 더한 재료 줄 = 기본 계 안(재료비 · 계에 더함) · 줄 「별도계상」 칸만 계 밖(재료 목록만)."""
|
||||
one = {"종류": "재료", "요소": "MT000010", "수량": 3, "단가": 1200}
|
||||
bare = _run(바탕={"로직": PCT})
|
||||
inside = _run(바탕={"로직": PCT}, 더한줄=[one])
|
||||
assert inside["기준"]["재료비"] == pytest.approx(bare["기준"]["재료비"] + 3600)
|
||||
assert inside["기준"]["계"] == pytest.approx(bare["기준"]["계"] + 3600, abs=1)
|
||||
assert any(x["cid"] == "add:#0" for x in inside["줄"])
|
||||
apart = _run(바탕={"로직": PCT}, 더한줄=[{**one, "별도계상": True}])
|
||||
assert apart["기준"]["계"] == pytest.approx(bare["기준"]["계"])
|
||||
assert not any(x["cid"] == "add:#0" for x in apart["줄"])
|
||||
assert any(m["금액"] == pytest.approx(3600) for m in apart["재료"])
|
||||
@@ -5,8 +5,6 @@
|
||||
바탕 · 사전조합에 SK 넣기 = 펼쳐 담음(740-1 · 원본 지워도 그대로) · 층 복사 왕복 같은 값.
|
||||
"""
|
||||
|
||||
from decimal import Decimal
|
||||
|
||||
import pytest
|
||||
|
||||
from M01_MasterData import M01_MasterData_Store as m01
|
||||
@@ -46,109 +44,6 @@ def _bare(code):
|
||||
return labor.run_line(_whole(), code, {})
|
||||
|
||||
|
||||
def test_qty_cover_hand_and_pct_recomputed(world):
|
||||
"""품 덮개 = 손셈 · 「노무비 * 3 / 100」 덧줄 다시 셈 · 원값 = 서버가 셈."""
|
||||
bare = _bare(PCT)
|
||||
first, second = bare["줄"][0], bare["줄"][1]
|
||||
key = _sk(
|
||||
world["personal"], 바탕={"로직": PCT}, 덮개={"labor:LB000036#0": {"qty": 0.5, "원값": 9}}
|
||||
)
|
||||
doc = _doc(world["personal"], key)
|
||||
assert doc["덮개"]["labor:LB000036#0"]["원값"]["qty"] == pytest.approx(float(first["수량"]))
|
||||
assert len(doc["바탕판"]) == 16
|
||||
got = _calc(world["personal"], key)
|
||||
cut = calc.labor.mcut.down # 751-3 — 줄 0.1 원 · 비목 합 1 원 버림
|
||||
labor_sum = cut(Decimal("0.5") * Decimal(str(first["단가"])), 1) + Decimal(str(second["금액"]))
|
||||
assert got["기준"]["노무비"] == pytest.approx(float(cut(labor_sum, 0)))
|
||||
assert got["기준"]["경비"] == pytest.approx(float(labor_sum * 3 / 100), abs=1)
|
||||
assert got["줄"][0]["덮개"] == ["qty"] and got["줄"][0]["cid"] == "labor:LB000036#0"
|
||||
assert got["짝잃음"] == []
|
||||
# 덧줄 율 덮개 = 5 %
|
||||
key = _sk(
|
||||
world["personal"],
|
||||
바탕={"로직": PCT},
|
||||
덮개={"pct:" + bare["줄"][2]["이름"] + "#0": {"qty": 5}},
|
||||
)
|
||||
got = _calc(world["personal"], key)
|
||||
assert got["기준"]["경비"] == pytest.approx(float(bare["기준"]["노무비"]) * 0.05, abs=1)
|
||||
|
||||
|
||||
def test_drop_then_pick_stays_on_its_line(world):
|
||||
"""뺀줄 뒤 고름 제자리 — 둘째 재료 줄을 고른 자재가 첫 재료 줄을 뺀 뒤에도 그 줄 품목."""
|
||||
import master_pick as mp
|
||||
|
||||
whole = _whole()
|
||||
row = whole.logic(TWO_MATS)
|
||||
item = row["호표"][2]
|
||||
picks = mp.search(whole, item["요소"], {}, item.get("단위"))
|
||||
want = picks[1] if len(picks) > 1 else picks[0]
|
||||
first_cid = "material:" + row["호표"][1]["이름"] + "#0"
|
||||
second_cid = "material:" + item["이름"] + "#0"
|
||||
key = _sk(
|
||||
world["personal"],
|
||||
단위="m",
|
||||
바탕={"로직": TWO_MATS},
|
||||
뺀줄=[first_cid],
|
||||
고름={second_cid: want},
|
||||
자재표시={second_cid: {"별도계상": "직접계산"}}, # 기본 = 별도계상(222-1) 줄 빠짐
|
||||
)
|
||||
got = _calc(world["personal"], key)
|
||||
names = [x["이름"] for x in got["줄"]]
|
||||
assert row["호표"][1]["이름"] not in names
|
||||
line = next(x for x in got["줄"] if x["cid"] == second_cid)
|
||||
assert line["품목"]["키"] == want
|
||||
|
||||
|
||||
def test_lost_cover_kept_and_listed(world):
|
||||
key = _sk(world["personal"], 바탕={"로직": PCT}, 덮개={"labor:LB999999#0": {"qty": 1}})
|
||||
got = _calc(world["personal"], key)
|
||||
assert got["짝잃음"][0]["cid"] == "labor:LB999999#0"
|
||||
assert "labor:LB999999#0" in _doc(world["personal"], key)["덮개"]
|
||||
assert got["기준"]["계"] == pytest.approx(float(_bare(PCT)["기준"]["계"]))
|
||||
|
||||
|
||||
def test_chain_base_flattened_delete_free(world):
|
||||
"""바탕 SK 넣기(740-1) = 펼쳐 담음 — 바탕 = M01 기초 · 위 덮개 겹침 · 값 같음 ·
|
||||
원본 지워도 그대로."""
|
||||
a = _sk(world["personal"], 바탕={"로직": PCT})
|
||||
b = _sk(
|
||||
world["personal"], 바탕={"참조": {**MINE, "키": a}}, 덮개={"labor:LB000002#0": {"qty": 0}}
|
||||
)
|
||||
assert _doc(world["personal"], b)["바탕"] == {"로직": PCT}
|
||||
got = _calc(world["personal"], b)
|
||||
bare = _bare(PCT)
|
||||
assert got["기준"]["노무비"] == pytest.approx(
|
||||
float(calc.labor.mcut.down(bare["줄"][0]["금액"], 0))
|
||||
)
|
||||
with store.at(world["personal"]):
|
||||
store.delete("sangeun", a) # 쓰는 곳 없음(서로 독립)
|
||||
assert _calc(world["personal"], b)["기준"] == got["기준"]
|
||||
|
||||
|
||||
def test_precombo_holds_sangeun(world):
|
||||
"""사전조합에 SK 넣기(811-1) = SK 참조 한 행 · 1 단위 값 × 수량 · 쓰는 SK 는 못 지움."""
|
||||
from M02_MasterTemplete import M02_Labor_Doc as labor
|
||||
|
||||
sk = _sk(world["personal"], 바탕={"로직": PCT}, 덮개={"labor:LB000036#0": {"qty": 0.5}})
|
||||
one = _calc(world["personal"], sk)["1단위"]["계"]
|
||||
with store.at(world["personal"]):
|
||||
sc = refs.create(
|
||||
"precombo",
|
||||
{
|
||||
"이름": "조합",
|
||||
"단위": "㎡",
|
||||
"담은로직": [{"참조": {**MINE, "키": sk}, "수량": {"손": 2}}],
|
||||
},
|
||||
)["이름"]
|
||||
line = store.read("precombo", sc)["문서"]["담은로직"][0]
|
||||
assert line["참조"] == {**MINE, "키": sk} # 811-1 SK 줄 = 참조 한 행(안 펼침)
|
||||
with pytest.raises(store.StoreError, match="쓰는 곳"):
|
||||
store.delete("sangeun", sk)
|
||||
pill = {f"{refs.ref_id({**MINE, '키': sc})}#0": 2} # 723-1 안 줄 수량 = 쓰는 쪽 알약
|
||||
got = labor.calc({"담은로직": [{"참조": {**MINE, "키": sc}, "수량": {"손": 1}}]}, pill)
|
||||
assert got["반영합"]["계"] == pytest.approx(one * 2, abs=1)
|
||||
|
||||
|
||||
def test_layer_copy_round_trip(world):
|
||||
"""개인 B(바탕 = 개인 A) → 회사로 복사 = 펼친 몸(바탕 = 기초 · 본뜬) → 개인으로 다시 =
|
||||
같은 값."""
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
"""717-2b M02 단가산출 상세 · 고침 지킴 시험 — 순수 꼴(node) · 글 · 서버 저장 왕복(임시 storage).
|
||||
|
||||
- 공용 상세 고침(724-1 `setLineCover`) → SK 덮개(qty · 배율 · 비목 칸 · 원값 곁 글) ·
|
||||
더한줄 수량 · 단가 · 뺀줄 · 되살림
|
||||
- SK 셈 답 → 공용 상세 줄(`hoView` — 정체 차례 · 바탕 줄 그대로 · 더한줄 · 고침 열쇠) ·
|
||||
계산서 묶음 = 표 줄 그대로
|
||||
- 화면 문서 꼴이 서버 저장(`clean_doc`)을 지나고 서버가 원값 · 바탕판을 다시 적음 · 셈 = 손셈
|
||||
- 상세 = M01 상세 부품(M02 길) · 부품 상자만 · 마스터 이동 단추 = 등록 없으면 숨김
|
||||
"""
|
||||
|
||||
from decimal import Decimal
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from M02_MasterTemplete import M02_Labor_Ref as refs
|
||||
from M02_MasterTemplete import M02_MasterTemplete_Store as store
|
||||
from M02_MasterTemplete import M02_Sangeun_Calc as calc
|
||||
from resources.tester.test_m02_labor_ref import world # noqa: F401 — 같은 임시 층
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
M02 = ROOT / "M02_MasterTemplete"
|
||||
BASE = "GC000278"
|
||||
|
||||
|
||||
def _text(p: Path) -> str:
|
||||
return p.read_text(encoding="utf-8")
|
||||
|
||||
|
||||
def test_화면_문서_꼴_서버_저장_셈(world): # noqa: F811 — 가져온 fixture
|
||||
"""화면 꼴(덮개 + 원값 곁 글 · 로직 줄 나눈 단가 · 더한줄 · 뺀줄) → 저장 · 셈 = 손셈."""
|
||||
mine = world["personal"]
|
||||
with store.at(mine):
|
||||
plain = calc.calc_doc(
|
||||
{"키": "SK-000000", "이름": "t", "단위": "㎥", "바탕": {"로직": BASE}}
|
||||
)
|
||||
lines = {x["cid"]: x for x in plain["줄"]}
|
||||
a, g = lines["labor:LB000018#0"], lines["logic:GC000267#0"]
|
||||
parts = {k: Decimal(str(v)) for k, v in g["비목"].items()}
|
||||
whole_amount = sum(parts.values())
|
||||
split = {
|
||||
{"노무비": "labor", "재료비": "material", "경비": "expense"}[k]: float(
|
||||
round(Decimal(90000) * v / whole_amount, 4)
|
||||
)
|
||||
for k, v in parts.items()
|
||||
}
|
||||
doc = {
|
||||
"이름": "717-2b 시험",
|
||||
"단위": "㎥",
|
||||
"바탕": {"로직": BASE},
|
||||
"덮개": {
|
||||
"labor:LB000018#0": {"qty": 0.02, "원값": {"qty": 1, "단가": 1}}, # 화면 곁 글
|
||||
"logic:GC000267#0": {**split, "원값": {"qty": 9}},
|
||||
},
|
||||
"뺀줄": ["labor:LB000002#1"],
|
||||
"더한줄": [
|
||||
{"종류": "인력", "요소": "LB000002", "이름": "보통인부", "단위": "인", "수량": 0.01}
|
||||
],
|
||||
}
|
||||
key = refs.create("sangeun", doc)["이름"]
|
||||
saved = store.read("sangeun", key)["문서"]
|
||||
got = calc.calc_doc(saved)
|
||||
cover = saved["덮개"]["labor:LB000018#0"]
|
||||
assert cover["원값"]["qty"] == pytest.approx(a["수량"]) # 서버가 다시 적음(화면 값 버림)
|
||||
assert saved["바탕판"] == plain["바탕판"] and saved["뺀줄"] == ["labor:LB000002#1"]
|
||||
by = {x["cid"]: x for x in got["줄"]}
|
||||
assert "labor:LB000002#1" not in by
|
||||
assert by["labor:LB000018#0"]["금액"] == pytest.approx(0.02 * a["단가"])
|
||||
# 751-3 — 비목마다 0.1 원 버림(셋)
|
||||
assert by["logic:GC000267#0"]["금액"] == pytest.approx(g["수량"] * 90000, abs=0.3)
|
||||
added = by["add:#0"] # 더한 보통인부 = 바탕 보통인부 단가 × 0.01
|
||||
assert added["수량"] == pytest.approx(0.01)
|
||||
assert added["단가"] == pytest.approx(lines["labor:LB000002#0"]["단가"])
|
||||
gap = sum(x["금액"] for x in got["줄"]) - got["기준"]["계"] # 751-3 비목마다 1 원 버림
|
||||
assert -1e-6 <= gap < 3
|
||||
@@ -13,7 +13,6 @@ from pathlib import Path
|
||||
import pytest
|
||||
|
||||
from M02_MasterTemplete import M02_Labor_Doc as labor
|
||||
from M02_MasterTemplete import M02_Sangeun_Calc as calc
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
M02 = ROOT / "M02_MasterTemplete"
|
||||
@@ -81,18 +80,6 @@ def _fx(name: str, unit: str, code: str) -> dict:
|
||||
def test_721_2_인력_재료_서버가_받아_셈():
|
||||
whole = labor.m01.loaded()[1]
|
||||
wage = whole.get(LB)["값"]
|
||||
sk = calc.calc_doc(
|
||||
{
|
||||
"키": "SK-000001",
|
||||
"이름": "시험",
|
||||
"단위": "㎡",
|
||||
"바탕": None,
|
||||
"더한줄": [
|
||||
{"종류": "인력", "요소": LB, "이름": "석공", "단위": "인", "수량": 1},
|
||||
{"종류": "재료", "요소": MT, "이름": "합판", "단위": "㎡", "수량": 1},
|
||||
],
|
||||
}
|
||||
)["1단위"]
|
||||
doc = labor.clean(
|
||||
{
|
||||
"담은로직": [
|
||||
@@ -102,8 +89,7 @@ def test_721_2_인력_재료_서버가_받아_셈():
|
||||
}
|
||||
)
|
||||
got = labor.calc(doc, {})
|
||||
assert sk["노무비"] == pytest.approx(wage) and sk["재료비"] > 0
|
||||
assert got["반영합"]["계"] == pytest.approx(sk["계"])
|
||||
assert got["반영합"]["노무비"] == pytest.approx(wage) and got["반영합"]["재료비"] > 0
|
||||
assert [ln["이은"] for ln in got["줄"]] == [["노무비"], ["재료비"]]
|
||||
|
||||
|
||||
@@ -153,17 +139,7 @@ def test_736_3_기계_고정_줄_금액():
|
||||
"단가": {k: got[k] for k in ("노무비", "재료비", "경비")},
|
||||
"이음": {"노임": None, "자재": None, "기계": EQ},
|
||||
}
|
||||
sk = calc.calc_doc(
|
||||
{
|
||||
"키": "SK-000001",
|
||||
"이름": "시험",
|
||||
"단위": "시간",
|
||||
"바탕": None,
|
||||
"더한줄": [{"고정": fx, "이름": got["이름"], "단위": "시간", "수량": 1}],
|
||||
}
|
||||
)["1단위"]
|
||||
doc = labor.clean({"담은로직": [{"로직": "", "고정": fx, "수량": {"손": 1}}]})
|
||||
assert sk["계"] == pytest.approx(got["계"])
|
||||
assert labor.calc(doc, {})["반영합"]["계"] == pytest.approx(got["계"])
|
||||
find = _text(M02 / "M02_MasterTemplete_Find_Pick.ts")
|
||||
assert (
|
||||
|
||||
@@ -1,107 +0,0 @@
|
||||
"""725-1 · 725-2 단가산출 [항목 추가] 못 셈 줄 — 더한줄 로직 입력 = 공통 옵션 › 로직 기본값 ·
|
||||
그래도 빈 입력 · 수량 없는 일위대가 줄 = 그 줄만 금액 없음 + 까닭 · 나머지 셈 계속(임시 storage)."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from M01_MasterData import M01_MasterData_Store as m01
|
||||
from M02_MasterTemplete import M02_Labor_Doc as labor
|
||||
from M02_MasterTemplete import M02_Labor_Ref as refs
|
||||
from M02_MasterTemplete import M02_MasterTemplete_Store as store
|
||||
from M02_MasterTemplete import M02_Sangeun_Calc as calc
|
||||
from resources.tester.test_m02_labor_ref import MINE, world # noqa: F401 — 같은 임시 층
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
GF = "GF000099" # 측구터파기 토사 · 입력 지역 · 보정작업
|
||||
PCT = "GC001109" # 입력 없음 · 인력 둘 + 덧줄 %
|
||||
GF_LINE = {"종류": "로직", "로직": GF, "입력값": {}, "수량": 1}
|
||||
PCT_LINE = {"종류": "로직", "로직": PCT, "입력값": {}, "수량": 1}
|
||||
|
||||
|
||||
def _sk(folder, **doc):
|
||||
with store.at(folder):
|
||||
made = refs.create("sangeun", {"이름": "sub7임시", "단위": "㎥", "더한줄": [], **doc})
|
||||
return store.read("sangeun", made["이름"])["문서"]
|
||||
|
||||
|
||||
def _run(folder, doc, given=None):
|
||||
with store.at(folder):
|
||||
return calc.calc_doc(doc, given)
|
||||
|
||||
|
||||
def _line(got, cid):
|
||||
return next(x for x in got["줄"] if x["cid"] == cid)
|
||||
|
||||
|
||||
def _m01(code, values):
|
||||
return float(labor.run_line(m01.loaded()[1], code, values, None, None)["기준"]["계"])
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("given", "want"),
|
||||
[
|
||||
(None, {"지역": "전국평균", "보정작업": "해당 없음"}), # 로직 기본값
|
||||
({"지역": "서울"}, {"지역": "서울", "보정작업": "해당 없음"}), # 공통 옵션 › 기본값
|
||||
],
|
||||
)
|
||||
def test_added_logic_takes_common_then_default(world, given, want): # noqa: F811
|
||||
"""입력 있는 로직 더한줄(입력값 {}) = 공통 옵션 넣은 M01 셈 · 계 = 바탕 + 그 줄."""
|
||||
doc = _sk(world["personal"], 바탕={"로직": GF}, 더한줄=[GF_LINE])
|
||||
plain = _sk(world["personal"], 바탕={"로직": GF})
|
||||
got, bare = _run(world["personal"], doc, given), _run(world["personal"], plain, given)
|
||||
one = _m01(GF, want)
|
||||
assert got["빠진줄"] == [] and not got.get("까닭")
|
||||
assert _line(got, "add:#0")["금액"] == pytest.approx(one, rel=1e-9)
|
||||
assert got["기준"]["계"] - bare["기준"]["계"] == pytest.approx(one, rel=1e-9)
|
||||
assert doc["더한줄"][0]["입력값"] == {} # 문서에 안 적음 — 공통 옵션을 바꾸면 따라감
|
||||
|
||||
|
||||
def test_line_without_input_only_that_line_drops(world, monkeypatch): # noqa: F811
|
||||
"""기본값도 없는 입력 = 그 줄만 금액 — · 까닭 · 계 = 나머지 · 쓰는 자리 = 기준 없음."""
|
||||
monkeypatch.setattr(calc, "_defaults", lambda whole, code: {})
|
||||
doc = _sk(world["personal"], 더한줄=[GF_LINE, PCT_LINE])
|
||||
rest = _sk(world["personal"], 더한줄=[PCT_LINE])
|
||||
got, want = _run(world["personal"], doc), _run(world["personal"], rest)
|
||||
gap = _line(got, "add:#0")
|
||||
assert gap["금액"] is None and gap["까닭"] == "입력 「지역」 없음"
|
||||
assert got["빠진줄"] == [{"cid": "add:#0", "이름": gap["이름"], "까닭": "입력 「지역」 없음"}]
|
||||
assert gap["이름"] # 이름 남음 — 화면 줄 빼기 자리
|
||||
assert got["기준"]["계"] == pytest.approx(float(want["기준"]["계"]), rel=1e-9)
|
||||
assert _line(got, "add:#1")["금액"] == pytest.approx(float(want["기준"]["계"]), rel=1e-9)
|
||||
with store.at(world["personal"]):
|
||||
up = refs.Expand(m01.loaded()[1])({**MINE, "키": doc["키"]})
|
||||
assert up["기준"] is None and "입력 「지역」 없음" in up["까닭"]
|
||||
|
||||
|
||||
def test_precombo_in_sk_flattened_no_gap(world): # noqa: F811
|
||||
"""740-1 — SK 에 넣은 일위대가 = 줄마다 더한줄로 펼쳐 담음(수량 = 넣은 수 × 1) · 빠진 줄 없음."""
|
||||
with store.at(world["personal"]):
|
||||
sc = refs.create(
|
||||
"precombo", {"이름": "sub7임시SC", "단위": "㎥", "담은로직": [{"로직": PCT}]}
|
||||
)
|
||||
line = {"참조": {**MINE, "키": sc["이름"]}, "수량": 2}
|
||||
doc = _sk(world["personal"], 더한줄=[line, PCT_LINE])
|
||||
rest = _sk(world["personal"], 더한줄=[PCT_LINE])
|
||||
got, want = _run(world["personal"], doc), _run(world["personal"], rest)
|
||||
assert doc["더한줄"][0]["로직"] == PCT and doc["더한줄"][0]["본뜬"]["키"] == sc["이름"]
|
||||
assert got["빠진줄"] == []
|
||||
assert got["기준"]["계"] == pytest.approx(3 * float(want["기준"]["계"]), rel=1e-9)
|
||||
|
||||
|
||||
def test_screen_shows_dropped_lines():
|
||||
"""화면 — 빠진 줄 띠(이름 · 까닭) · 금액 없는 줄 계산서 금액 —."""
|
||||
ts = (ROOT / "M02_MasterTemplete" / "M02_MasterTemplete_Sangeun_Detail.ts").read_text("utf-8")
|
||||
assert "ans?.빠진줄" in ts and 'L("M02_SangeunGap")' in ts
|
||||
|
||||
|
||||
def test_no_base_common_option_seoul(world): # noqa: F811
|
||||
"""725-6 — 바탕 없는 SK 도 공통 옵션(지역 서울) 따라감 = M01 셈."""
|
||||
doc = _sk(world["personal"], 더한줄=[GF_LINE])
|
||||
got = _run(world["personal"], doc, {"지역": "서울"})
|
||||
assert got["빠진줄"] == [], got
|
||||
assert got["기준"], {k: v for k, v in got.items() if k != "줄"}
|
||||
assert got["기준"]["계"] == pytest.approx(_m01(GF, {"지역": "서울", "보정작업": "해당 없음"}))
|
||||
assert float(got["기준"]["계"]) == 5660 # 751-3 끝수 · 840-5 굴착기 조종원 35,412 → 59,020/시간
|
||||
@@ -16,8 +16,6 @@ from pathlib import Path
|
||||
import pytest
|
||||
|
||||
from M01_MasterData import M01_MasterData_Store as m01
|
||||
from M02_MasterTemplete import M02_Item_Prices as prices
|
||||
from M02_MasterTemplete import M02_Item_Source as source
|
||||
from M02_MasterTemplete import M02_Labor_Doc as labor
|
||||
from M02_MasterTemplete import M02_Labor_Ref as refs
|
||||
from M02_MasterTemplete import M02_Logic_Standard as standard
|
||||
@@ -104,83 +102,6 @@ def _m01(code, values=None):
|
||||
return float(labor.run_line(m01.loaded()[1], code, values or {}, None, None)["기준"]["계"])
|
||||
|
||||
|
||||
def test_727_2_첫_기초_바탕_세부_줄(world): # noqa: F811
|
||||
doc = _sk(world["personal"], 바탕={"로직": GF})
|
||||
got = _run(world["personal"], doc)
|
||||
assert _line(got, "labor:LB000002#0")["수량"] == pytest.approx(0.023)
|
||||
assert _line(got, "logic:GC000267#0")["수량"] == pytest.approx(0.01546, abs=1e-5)
|
||||
assert got["꼬리표"] == "9-12-1"
|
||||
|
||||
|
||||
def test_727_2_기초_둘_세부_펼침_계(world): # noqa: F811
|
||||
doc = _sk(world["personal"], 바탕={"로직": GF}, 더한줄=[SECOND])
|
||||
bare = _run(world["personal"], _sk(world["personal"], 바탕={"로직": GF}))
|
||||
got = _run(world["personal"], doc)
|
||||
add = _line(got, "add:#0")
|
||||
assert add["꼬리표"] == "3-2-1" and add["바탕판"] and add["뺀세부"] == []
|
||||
sub = {x["cid"]: x for x in add["펼침"]}
|
||||
assert list(sub) == [
|
||||
"add:#0/labor:LB000036#0",
|
||||
"add:#0/labor:LB000002#0",
|
||||
"add:#0/pct:공구손료 및 경장비#0",
|
||||
]
|
||||
assert sub["add:#0/labor:LB000036#0"]["수량"] == pytest.approx(0.018)
|
||||
# 머리 = 수량 × 기초 끝수 계(751-3 · 비목 1 원 · 줄 0.1 원 버림) — 펼침 합과 비목마다 수량 × 1 원 안
|
||||
q = add["수량"]
|
||||
assert sum(x["금액"] for x in add["펼침"]) == pytest.approx(add["금액"], abs=0.3 + 3 * q)
|
||||
assert add["금액"] == pytest.approx(_m01(PCT), rel=1e-9)
|
||||
assert got["기준"]["계"] == pytest.approx(bare["기준"]["계"] + _m01(PCT), rel=1e-9)
|
||||
with store.at(world["personal"]): # 펼침 없는 셈(쓰는 자리) = 같은 계
|
||||
plain = calc.run(doc, m01.loaded()[1])
|
||||
assert float(plain["기준"]["계"]) == pytest.approx(got["기준"]["계"], rel=1e-9)
|
||||
|
||||
|
||||
def test_727_2_둘째_기초_덮개_뺀줄_저장(world): # noqa: F811
|
||||
one = {**SECOND, "수량": 2, "덮개": COVER, "뺀줄": DROP}
|
||||
doc = _sk(world["personal"], 바탕={"로직": GF}, 더한줄=[one])
|
||||
saved = doc["더한줄"][0]
|
||||
assert saved["덮개"]["labor:LB000036#0"] == {
|
||||
"qty": 0.036,
|
||||
"원값": {"qty": 0.018, "단가": 233250},
|
||||
}
|
||||
assert saved["뺀줄"] == DROP and saved["바탕판"]
|
||||
got = _run(world["personal"], doc)
|
||||
add = _line(got, "add:#0")
|
||||
cut = labor.mcut.down # 751-3 — 기초 줄 0.1 원 · 비목 합 1 원 → × 수량 0.1 원
|
||||
want = cut(2 * cut(cut(0.036 * 233250, 1) + cut(0.012 * 172068, 1), 0), 1)
|
||||
assert add["금액"] == pytest.approx(float(want), rel=1e-9)
|
||||
sub = {x["cid"]: x for x in add["펼침"]}
|
||||
assert sub["add:#0/labor:LB000036#0"]["덮개"] == ["qty"]
|
||||
assert sub["add:#0/labor:LB000036#0"]["수량"] == pytest.approx(0.072)
|
||||
assert add["뺀세부"] == [{"cid": "add:#0/" + DROP[0], "이름": "공구손료 및 경장비"}]
|
||||
lost = {**one, "덮개": {"labor:LB999999#0": {"qty": 1}}}
|
||||
got = _run(world["personal"], {**doc, "더한줄": [lost]})
|
||||
assert any(x["cid"] == "add:#0/labor:LB999999#0" for x in got["짝잃음"])
|
||||
|
||||
|
||||
def test_727_2_굳힘_같은_값(world, monkeypatch): # noqa: F811
|
||||
one = {**SECOND, "덮개": COVER, "뺀줄": DROP}
|
||||
key = _sk(
|
||||
world["personal"],
|
||||
바탕={"로직": GF},
|
||||
더한줄=[one],
|
||||
입력값={"보정작업": "암석작업(연암・보통암・경암)"},
|
||||
)
|
||||
ref = {**MINE, "키": key["키"]}
|
||||
with store.at(world["personal"]):
|
||||
top = labor.clean({"열": "rv", "담은로직": [{"참조": ref, "수량": {"손": 2}}]})
|
||||
live = labor.calc(top, {})["줄"][0]
|
||||
rows = source.labor_doc_rows(top)
|
||||
bundle = source.price_bundle(rows, world["personal"])
|
||||
frozen = rows["참조사본"][refs.ref_id(ref)]
|
||||
assert frozen["굳힌줄"]["호표"][-1]["값묶음"] # 고친 둘째 기초 = 셈한 값묶음 줄
|
||||
got = prices.calc(rows, json.loads(json.dumps(bundle, ensure_ascii=False)), {}, {}, None)
|
||||
line = got["줄"][0]
|
||||
assert not line["까닭"] and not live["까닭"]
|
||||
for part in ("노무비", "재료비", "경비", "계"):
|
||||
assert line["기준"][part] == pytest.approx(live["기준"][part], rel=1e-9)
|
||||
|
||||
|
||||
def test_727_3_옵션_저장_일위대가_그_옵션(world): # noqa: F811
|
||||
rock = {"지역": "전국평균", "보정작업": "암석작업(연암・보통암・경암)"}
|
||||
doc = _sk(
|
||||
@@ -191,14 +112,3 @@ def test_727_3_옵션_저장_일위대가_그_옵션(world): # noqa: F811
|
||||
up = refs.Expand(m01.loaded()[1])({**MINE, "키": doc["키"]})
|
||||
assert float(up["기준"]["계"]) == pytest.approx(_m01(GF, rock), rel=1e-9)
|
||||
assert _m01(GF, rock) > _m01(GF, {"지역": "전국평균", "보정작업": "해당 없음"})
|
||||
# 둘째 기초 입력(바탕에 없는 이름)도 SK 입력값에 남고 그 옵션으로 셈
|
||||
two = _sk( # 단위 = 바탕 단위(728-2 — 성격 다르면 계수 칸)
|
||||
world["personal"],
|
||||
바탕={"로직": PCT},
|
||||
단위="㎡",
|
||||
더한줄=[{**SECOND, "로직": GF}],
|
||||
입력값=rock,
|
||||
)
|
||||
assert two["입력값"] == rock
|
||||
got = _run(world["personal"], two)
|
||||
assert _line(got, "add:#0")["금액"] == pytest.approx(_m01(GF, rock), rel=1e-9)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
"""728-2 지킴 — SK 단위 환산: 바탕 기준단위 → SK 단위 배 · 화면 줄 · 계 = SK 1 단위 몫 ·
|
||||
계수 없으면 셈 막음 · 「식」 = 옛 셈 · 둘째 기초 수량 처음값 · 돈 아닌 기초 고르기 창에서 뺌 ·
|
||||
계수 없으면 셈 막음 · 「식」 = 옛 셈 · 돈 아닌 기초 고르기 창에서 뺌 ·
|
||||
고침 꼴 화면배 되돌림."""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -15,7 +15,6 @@ HERE = Path(__file__).resolve().parent
|
||||
sys.path.insert(0, str(ROOT))
|
||||
sys.path.insert(0, str(ROOT / "resources/master_data/scripts"))
|
||||
|
||||
import master_unit as mu # noqa: E402
|
||||
|
||||
from M01_MasterData import M01_MasterData_Store as m01 # noqa: E402
|
||||
from M02_MasterTemplete import M02_Sangeun_Calc as sc # noqa: E402
|
||||
@@ -38,10 +37,12 @@ def _shown(whole, doc):
|
||||
|
||||
def test_단목베기_100본_제안_본으로_바꾸면_1본_계(whole):
|
||||
full = _shown(whole, _doc("GF000287", "100본"))
|
||||
assert full["배"] == 1 and full["기준"]["계"] == Decimal("153889") # 751-3 1 원 버림
|
||||
assert full["배"] == 1 and full["기준"]["계"] == Decimal(
|
||||
"255186"
|
||||
) # 수식 문서 기본 옵션(흉고직경 14 · 단목 · 855 2-C1)
|
||||
assert sc.head_of({"단위": "100본"}) == "100본 당"
|
||||
one = _shown(whole, _doc("GF000287", "본"))
|
||||
assert one["배"] == 100 and round(one["기준"]["계"], 2) == Decimal("1538.89")
|
||||
assert one["배"] == 100 and round(one["기준"]["계"], 2) == Decimal("2551.86")
|
||||
assert sc.head_of({"단위": "본"}) == "1 본 당"
|
||||
pairs = [(x["수량"], y["수량"]) for x, y in zip(full["줄"], one["줄"], strict=True)]
|
||||
assert all(b == a / 100 for a, b in pairs) and one["화면배"] == 100 # 세부 품 ÷100
|
||||
@@ -71,25 +72,8 @@ def test_성격_다르면_계수_칸_없으면_셈_막음(whole):
|
||||
|
||||
def test_식_빈_단위는_옛_셈(whole):
|
||||
old = _shown(whole, _doc("GF000287", "식"))
|
||||
assert old["배"] == 100 and round(old["1단위"]["계"], 2) == Decimal("1538.89")
|
||||
assert "화면배" not in old and old["기준"]["계"] == Decimal("153889") # 화면 = 바탕 몫 그대로
|
||||
|
||||
|
||||
def test_둘째_기초_수량_처음값_배(whole):
|
||||
"""바탕 10㎡(GC000421) + 둘째 기초 100㎡(GF000041) — 처음값 0.1 = 바탕 기준단위 몫."""
|
||||
qty = mu.swap("10㎡", "100㎡")["배"]
|
||||
assert qty == Decimal("0.1")
|
||||
alone = sc.run(sd.clean(_doc("GF000041", "100㎡"), None, whole), whole)["1단위"]["계"]
|
||||
one = {"종류": "로직", "로직": "GF000041", "입력값": {}, "수량": float(qty)}
|
||||
got = sc.run(sd.clean(_doc("GC000421", "㎡", 더한줄=[one]), None, whole), whole)
|
||||
bare = sc.run(sd.clean(_doc("GC000421", "㎡"), None, whole), whole)
|
||||
added = got["1단위"]["계"] - bare["1단위"]["계"]
|
||||
# ㎡ 몫 = 100㎡ 값 ÷100 · 비목 합 1 원 버림(751-3)이라 바탕 몫 ÷10 = 0.1 원 안
|
||||
assert abs(added - alone * qty / 10) <= Decimal("0.1")
|
||||
src = (ROOT / "M02_MasterTemplete/M02_MasterTemplete_Sangeun_Detail.ts").read_text(
|
||||
encoding="utf-8"
|
||||
)
|
||||
assert "addBase(" not in src # 840-1 [항목 추가] 걷음
|
||||
assert old["배"] == 100 and round(old["1단위"]["계"], 2) == Decimal("2551.86")
|
||||
assert "화면배" not in old and old["기준"]["계"] == Decimal("255186") # 화면 = 바탕 몫 그대로
|
||||
|
||||
|
||||
def test_돈_아닌_기초_고르기_창에서_뺌(whole):
|
||||
|
||||
@@ -20,7 +20,6 @@ from fastapi.testclient import TestClient
|
||||
|
||||
from common_util.common_util_auth import verify_session
|
||||
from M01_MasterData import M01_MasterData_Store as m01
|
||||
from M02_MasterTemplete import M02_Labor_Doc as labor
|
||||
from M02_MasterTemplete import M02_Labor_Ref as refs
|
||||
from M02_MasterTemplete import M02_Library_Flat as flat
|
||||
from M02_MasterTemplete import M02_Library_Same as same
|
||||
@@ -97,65 +96,6 @@ def _y(folder):
|
||||
)
|
||||
|
||||
|
||||
def test_SK_에_SK_몸_통째_금액_같음_원본_고쳐도_지워도_그대로(world):
|
||||
me = world["personal"]
|
||||
y = _y(me)
|
||||
legacy = {
|
||||
"이름": "밖",
|
||||
"단위": "㎥",
|
||||
"바탕": {"로직": GF},
|
||||
"더한줄": [{"참조": {**MINE, "키": y}, "수량": 2}],
|
||||
}
|
||||
before = _sk_total(me, {"키": "SK-000099", **legacy})
|
||||
x = _make(me, "sangeun", **legacy)
|
||||
doc = _read(me, "sangeun", x)
|
||||
entry = doc["더한줄"][0]
|
||||
assert not refs.refs_in(doc)
|
||||
assert entry["로직"] == PCT and entry["덮개"] and entry["더한줄"][0]["요소"] == "LB000002"
|
||||
assert entry["본뜬"]["키"] == y and entry["본뜬"]["이름"] == "원본" and entry["본뜬"]["때"]
|
||||
assert _sk_total(me, doc) == pytest.approx(before, rel=1e-9)
|
||||
with store.at(me): # 원본 고침 · 지움 → 넣은 쪽 그대로
|
||||
now = store.read("sangeun", y)
|
||||
store.write(
|
||||
"sangeun", y, now["판"], {**now["문서"], "덮개": {"labor:LB000002#0": {"qty": 2}}}
|
||||
)
|
||||
assert refs.users({**MINE, "키": y}) == []
|
||||
store.delete("sangeun", y)
|
||||
assert _sk_total(me, _read(me, "sangeun", x)) == pytest.approx(before, rel=1e-9)
|
||||
with store.at(me): # 화면 셈 길 = 넣은 줄 세부 펼침(안 더한줄 = add:#0/add:#0)
|
||||
got = calc.calc_doc(_read(me, "sangeun", x))
|
||||
sub = next(r for r in got["줄"] if r["cid"] == "add:#0")["펼침"]
|
||||
assert "add:#0/add:#0" in [r["cid"] for r in sub]
|
||||
|
||||
|
||||
def test_SC_에_SK_패치_겹침_E1_원본_고쳐도_그대로(world):
|
||||
"""분석 579-2 E1 — 밖 SC(SK 참조 + 줄 패치 · 안 SC) 의 원본 SK 다른 줄을 고쳐도 밖 금액
|
||||
그대로."""
|
||||
me = world["personal"]
|
||||
sk = _make(me, "sangeun", 이름="밑", 바탕={"로직": PCT}, 더한줄=[])
|
||||
inner = _make(me, "precombo", 이름="안", 담은로직=[{"로직": "GC001111"}])
|
||||
lines = [
|
||||
{"참조": {**MINE, "키": sk}, "패치": {"덮개": {"labor:LB000036#0": {"qty": 0.5}}}},
|
||||
{"참조": {**MINE, "키": inner}},
|
||||
]
|
||||
old = _raw(me, "precombo", 이름="옛 밖", 담은로직=lines)
|
||||
before = _sc_value(me, old)
|
||||
host = _make(me, "precombo", 이름="밖", 담은로직=lines)
|
||||
doc = _read(me, "precombo", host)
|
||||
assert doc["담은로직"][0]["참조"] == {**MINE, "키": sk} # 811-1 SK 줄 = 참조 한 행(안 펼침)
|
||||
assert doc["담은로직"][0]["패치"]["덮개"] == {"labor:LB000036#0": {"qty": 0.5}}
|
||||
assert doc["담은로직"][1]["참조"]["층"] == "사본" # 하위 호표(SC 안 SC) = 사본 블록
|
||||
assert doc["담은로직"][1]["본뜬"]["키"] == inner
|
||||
assert _sc_value(me, host) == pytest.approx(before, rel=1e-9)
|
||||
with store.at(me): # E1 — 원본 SK 의 덮지 않은 줄 품 2
|
||||
now = store.read("sangeun", sk)
|
||||
store.write(
|
||||
"sangeun", sk, now["판"], {**now["문서"], "덮개": {"labor:LB000002#0": {"qty": 2}}}
|
||||
)
|
||||
assert _sc_value(me, old) > before * 3 # 참조 = 따라감(129,073 → 481,406 꼴)
|
||||
assert _sc_value(me, host) == pytest.approx(_sc_value(me, old), rel=1e-9) # 811-1 = SK 따라감
|
||||
|
||||
|
||||
def test_SC_에_SC_사본_블록_실무수량_겹침_원본_지워도(world):
|
||||
"""하위 호표(SC 안 SC) = 사본 블록 — 원본 연결 없음 · 금액 같음 · 같은 기초 겹침도 블록 안."""
|
||||
me = world["personal"]
|
||||
@@ -180,108 +120,6 @@ def test_SC_에_SC_사본_블록_실무수량_겹침_원본_지워도(world):
|
||||
assert got["담은로직"][0]["참조"]["층"] == "사본" # 넣기 길도 블록(겹침 없음)
|
||||
|
||||
|
||||
def test_SK_에_SC_줄마다_더한줄(world):
|
||||
me = world["personal"]
|
||||
sc = _make(me, "precombo", 이름="조합", 담은로직=[{"로직": GF}])
|
||||
with store.at(me):
|
||||
got = flat.flat_lines("sangeun", {**MINE, "키": sc}, 2)["더한줄"]
|
||||
assert len(got) == 1 and got[0]["로직"] == GF and got[0]["수량"] == 2 # 실무수량 없음 = 1 × 2
|
||||
assert got[0]["본뜬"]["키"] == sc
|
||||
# 742-1 저장 수량(수량.손)이 있으면 그 수 · 안 SC 펴기 = 바깥 × 안
|
||||
from decimal import Decimal
|
||||
|
||||
hand = flat.sc_adds({"담은로직": [{"로직": GF, "수량": {"손": 3}}]}, Decimal(2), _whole(), {})
|
||||
assert hand[0]["수량"] == 6
|
||||
block = {"참조": refs.copy_ref({"담은로직": [{"로직": GF, "수량": {"손": 3}}]}, "SC-000001")}
|
||||
deep = flat.sc_adds({"담은로직": [{**block, "수량": {"손": 2}}]}, Decimal(1), _whole(), {})
|
||||
assert deep[0]["로직"] == GF and deep[0]["수량"] == 6 # 사본 블록 = 바깥 × 안
|
||||
doc = {"키": "SK-000099", "이름": "x", "단위": "㎥", "바탕": None, "더한줄": got}
|
||||
one = float(labor.run_line(_whole(), GF, {})["기준"]["계"])
|
||||
assert _sk_total(me, doc) == pytest.approx(2 * one, rel=1e-9)
|
||||
|
||||
|
||||
def test_바탕_SK_겹침_못_펼침_까닭(world):
|
||||
me = world["personal"]
|
||||
under = _make(
|
||||
me, "sangeun", 이름="밑", 바탕={"로직": PCT}, 덮개={"labor:LB000036#0": {"qty": 0.1}}
|
||||
)
|
||||
over = {"이름": "위", "단위": "㎡", "바탕": {"참조": {**MINE, "키": under}}, "더한줄": [ADD]}
|
||||
over |= {"덮개": {"labor:LB000036#0": {"배율": 2}}, "뺀줄": ["labor:LB000002#0"]}
|
||||
before = _sk_total(me, {"키": "SK-000099", **over})
|
||||
got = flat.flat_doc("sangeun", {"키": "SK-000099", **over})
|
||||
assert got["바탕"] == {"로직": PCT} and got["덮개"]["labor:LB000036#0"]["qty"] == 0.2
|
||||
assert got["뺀줄"] == ["labor:LB000002#0"]
|
||||
assert _sk_total(me, got) == pytest.approx(before, rel=1e-9)
|
||||
# SC 에 바탕 없는 SK · 단위 환산 SK = 못 넣음
|
||||
bare = _make(me, "sangeun", 이름="바탕 없음", 바탕=None, 더한줄=[ADD])
|
||||
with store.at(me):
|
||||
for key, why in ((bare, "바탕 기초 없는"),):
|
||||
with pytest.raises(store.StoreError) as e:
|
||||
flat.flat_lines("precombo", {**MINE, "키": key})
|
||||
assert e.value.status == 400 and why in str(e.value.detail)
|
||||
|
||||
|
||||
def test_초기화_SK_SC_M01_값_옵션_남음(world):
|
||||
me = world["personal"]
|
||||
rock = {"보정작업": "암석작업(연암・보통암・경암)"}
|
||||
entry = {
|
||||
"종류": "로직",
|
||||
"로직": PCT,
|
||||
"입력값": {},
|
||||
"수량": 1,
|
||||
"덮개": {"labor:LB000036#0": {"qty": 1}},
|
||||
}
|
||||
priced = {**ADD, "단가": 1}
|
||||
x = _make(
|
||||
me,
|
||||
"sangeun",
|
||||
이름="고친 것",
|
||||
단위="㎥",
|
||||
바탕={"로직": GF},
|
||||
입력값=rock,
|
||||
덮개={"labor:LB000002#0": {"qty": 1}},
|
||||
뺀줄=["logic:GC000267#0"],
|
||||
더한줄=[entry, priced],
|
||||
)
|
||||
with store.at(me):
|
||||
look = flat.reset_doc("sangeun", x, None, True, None)
|
||||
assert look["걷힘"] == 4 and _read(me, "sangeun", x)["덮개"] # 미리 보기 = 안 씀
|
||||
done = flat.reset_doc("sangeun", x, None, False, None)
|
||||
doc = _read(me, "sangeun", x)
|
||||
assert doc["덮개"] == {} and doc["뺀줄"] == [] and doc["입력값"] == rock
|
||||
assert [x.get("요소") or x.get("로직") for x in doc["더한줄"]] == [PCT, "LB000002"]
|
||||
assert "덮개" not in doc["더한줄"][0] and "단가" not in doc["더한줄"][1]
|
||||
assert done["걷힘"] == 4
|
||||
plain = {"키": "SK-000099", "이름": "x", "단위": "㎥", "바탕": {"로직": GF}, "입력값": rock}
|
||||
plain["더한줄"] = [{**entry, "덮개": {}}, ADD]
|
||||
assert _sk_total(me, doc) == pytest.approx(_sk_total(me, plain), rel=1e-9)
|
||||
sc = _make(
|
||||
me,
|
||||
"precombo",
|
||||
이름="줄 덮개",
|
||||
담은로직=[
|
||||
{"로직": PCT, "패치": {"덮개": {"labor:LB000036#0": {"qty": 1}}, "더한줄": [priced]}}
|
||||
],
|
||||
)
|
||||
with store.at(me):
|
||||
got = flat.reset_doc("precombo", sc, None, False, None)
|
||||
line = _read(me, "precombo", sc)["담은로직"][0]
|
||||
assert got["걷힘"] == 2 and line["패치"] == {"더한줄": [{**ADD, "수량": 0.5, "처음수량": 0.5}]}
|
||||
# 이음 기계 고정 줄(736-3) = M01 기계 한 시간 값 다시 받음
|
||||
from M02_MasterTemplete import M02_Machine_Hourly as machine
|
||||
|
||||
hour = machine.hourly("EQ000019")
|
||||
fx = {"이름": "굴착기", "단위": "시간", "단가": {"노무비": 1, "재료비": 1, "경비": 1}}
|
||||
fx["이음"] = {"기계": "EQ000019"}
|
||||
mc = _make(me, "precombo", 이름="기계", 담은로직=[{"고정": fx}])
|
||||
with store.at(me):
|
||||
assert flat.reset_doc("precombo", mc, None, False, None)["걷힘"] == 1
|
||||
price = _read(me, "precombo", mc)["담은로직"][0]["고정"]["단가"]
|
||||
assert price["노무비"] == pytest.approx(hour["노무비"]) and price["경비"] == pytest.approx(
|
||||
hour["경비"]
|
||||
)
|
||||
|
||||
|
||||
def test_길_넣기_초기화_권한(world):
|
||||
app = FastAPI()
|
||||
app.include_router(same_router.router)
|
||||
@@ -309,48 +147,3 @@ def test_733_지문_옛_참조_펼친_것_같음(world):
|
||||
assert refs.refs_in(_read(me, "precombo", new)) == [{**MINE, "키": y}] # 811-1 참조 한 행
|
||||
fingers = {k: same.finger("precombo", _read(me, "precombo", k)) for k in (old, new)}
|
||||
assert fingers[old] == fingers[new]
|
||||
|
||||
|
||||
def test_B09_SC_덮개_줄_대가_금액_M02_같음(world, tmp_path):
|
||||
"""SC 덮개 줄(SK 넣기 꼴) — 옛 B09 = 산근(덮개 안 읽음) · 이제 굳힌 줄 대가 = M02 값."""
|
||||
from B09_Estimation import B09_Estimation_Bill_Library as library
|
||||
from resources.tester.test_719_2_sk_project import _b09, _project
|
||||
|
||||
me = world["personal"]
|
||||
cover = {"labor:LB000036#0": {"qty": 0.5}}
|
||||
sc = _make(
|
||||
me,
|
||||
"precombo",
|
||||
이름="덮은 줄",
|
||||
담은로직=[{"로직": PCT, "패치": {"덮개": cover, "더한줄": [ADD]}}],
|
||||
)
|
||||
m02 = _sc_value(me, sc)
|
||||
bare = float(labor.run_line(_whole(), PCT, {})["기준"]["계"])
|
||||
assert m02 > bare * 2 # 덮개 · 더한줄이 값에 듦(옛 B09 산근 = bare)
|
||||
root = _project(tmp_path / "proj", [])
|
||||
made = library.import_copy(root, "precombo", "personal", "7/42", sc)
|
||||
daega, done, _ = _b09(root)
|
||||
block = done[daega["libs"][made["폴더"]]]
|
||||
line = block["lines"][0]
|
||||
assert line["kind"] == "daega" and block["blank"] == 1 # 안 줄 수량 = 이 공사에서 입력(723-4)
|
||||
cover_qty = {block["cover"]: {line["cid"]: {"qty": 1}}}
|
||||
block = _b09(root, cover_qty)[1][daega["libs"][made["폴더"]]]
|
||||
assert block["blank"] == 0
|
||||
assert block["sum"] == pytest.approx(m02, abs=5) # 끝수(내림)만 다름
|
||||
|
||||
|
||||
def test_747_SK_재료_직접계산_일위대가에_넣어도_같은_금액(world):
|
||||
"""747-1 SK 바탕 재료 = 직접계산 · 일위대가 줄 기본 = 별도계상 → 펼친 줄에 적어 둠."""
|
||||
me = world["personal"]
|
||||
form = "GC000211" # 합판거푸집 — 재료 줄 있음
|
||||
plain = _make(me, "sangeun", 이름="거푸집", 바탕={"로직": form})
|
||||
cover = {"material:합판(내수 12㎜)#0": {"qty": 2}}
|
||||
covered = _make(me, "sangeun", 이름="거푸집 고침", 바탕={"로직": form}, 덮개=cover)
|
||||
for sk in (plain, covered):
|
||||
lines = [{"참조": {**MINE, "키": sk}}]
|
||||
old = _raw(me, "precombo", 이름="옛", 담은로직=lines)
|
||||
before = _sc_value(me, old)
|
||||
host = _make(me, "precombo", 이름="새", 담은로직=lines)
|
||||
line = _read(me, "precombo", host)["담은로직"][0]
|
||||
assert line["참조"]["키"] == sk # 811-1 참조 한 행 = SK 재료 직접계산 그대로
|
||||
assert _sc_value(me, host) == pytest.approx(before, rel=1e-9)
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
"""
|
||||
|
||||
import os
|
||||
from decimal import Decimal
|
||||
|
||||
import pytest
|
||||
|
||||
@@ -109,22 +108,6 @@ def test_B09_옛_사본_null_은_그대로_빈_줄():
|
||||
assert compute_labor(daega, SHEETS)["daega_blocks"][0]["blank"] == 3
|
||||
|
||||
|
||||
def test_단가산출_안_일위대가_저장_수량_금액(world): # noqa: F811
|
||||
from M02_MasterTemplete import M02_Sangeun_Calc as calc
|
||||
|
||||
key = _sc(world, [{"로직": STONE, "수량": {"손": 2}}])
|
||||
sk = {
|
||||
"키": "SK-000001",
|
||||
"이름": "겹",
|
||||
"단위": "식",
|
||||
"더한줄": [{"참조": {**SYS, "키": key}, "수량": 3}],
|
||||
}
|
||||
with store.at(world["system"]):
|
||||
got = calc.calc_doc(calc.clean_doc(sk, refs.here()))
|
||||
assert not got["빠진줄"]
|
||||
assert got["1단위"]["계"] == pytest.approx(float(Decimal(str(_stone())) * 2 * 3), rel=1e-6)
|
||||
|
||||
|
||||
def _src(name: str) -> str:
|
||||
return open(os.path.join(SRC, name), encoding="utf-8").read()
|
||||
|
||||
@@ -133,7 +116,9 @@ def test_화면_수량_칸_저장_새_줄_1_두_칸():
|
||||
table = _src("M02_MasterTemplete_Labor_Table.ts")
|
||||
assert "const temp = new Map" not in table and "withTemp" not in table # 휘발 칸 걷음
|
||||
assert "row.수량 = raw ? { 손: v } : null;" in table and "changed(true);" in table
|
||||
assert table.count("수량: fresh()") == 4 # 기초 · 참조 · 고정 · 자재 새 줄 = 서고 1 · 조합 면적 따름(806-1)
|
||||
assert (
|
||||
table.count("수량: fresh()") == 4
|
||||
) # 기초 · 참조 · 고정 · 자재 새 줄 = 서고 1 · 조합 면적 따름(806-1)
|
||||
assert "const fresh = (): LaborRow" in table and "{ ...ONE }" in table
|
||||
assert 'BasePrice: ["기준단위 단가"' in table and 'QtyAmount: ["수량 반영 금액"' in table
|
||||
assert 'sum_price: t("BasePrice"), sum: t("QtyAmount")' in table
|
||||
|
||||
@@ -1,93 +0,0 @@
|
||||
# ruff: noqa: F811 — 임시 층 fixture(world)를 test_m02_labor_ref 에서 받아 씀
|
||||
"""744-1 서버 — 둘째 기초 세부 품 원문 · 되돌리기 기억(임시 storage · M01 읽기만).
|
||||
|
||||
- 둘째 기초 `펼침` 줄 `원문` = 그 기초 1 기준단위 몫(GF000316 품 그대로) · 줄 수량 · 금액 = 머리
|
||||
수량 곱한 몫(상자 합) 그대로 · 머리 수량 = 더한줄 수량
|
||||
- 더한줄 `처음수량` = 넣을 때 수량(없으면 저장 때 지금 수량) · 셈 · 지문 안 듦
|
||||
- `뺀더한줄 [{차례, 줄}]` = [기초 빼기] · 더한 항목 빼기 기억 · 셈 · 지문 안 듦 · 못 읽는 줄 버림 ·
|
||||
일위대가 줄 패치도 같음
|
||||
"""
|
||||
|
||||
import pytest
|
||||
|
||||
from M01_MasterData import M01_MasterData_Store as m01
|
||||
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
|
||||
from M02_MasterTemplete import M02_MasterTemplete_Store as store
|
||||
from M02_MasterTemplete import M02_Sangeun_Calc as calc
|
||||
from resources.tester.test_m02_labor_ref import world # noqa: F401
|
||||
|
||||
GF = "GF000099" # 원/㎥
|
||||
BIG = "GF000316" # 기준단위 100㎥ — ㎥ 바탕에서 처음 수량 0.01
|
||||
PCT = "GC001109"
|
||||
MAN = {"종류": "인력", "요소": "LB000002", "수량": 1}
|
||||
|
||||
|
||||
def _sk(folder, **doc):
|
||||
with store.at(folder):
|
||||
made = refs.create("sangeun", {"이름": "744", "단위": "㎥", "더한줄": [], **doc})
|
||||
return store.read("sangeun", made["이름"])["문서"]
|
||||
|
||||
|
||||
def _calc(folder, doc):
|
||||
with store.at(folder):
|
||||
return calc.calc_doc(doc)
|
||||
|
||||
|
||||
def test_둘째_기초_세부_원문_품_머리_수량(world):
|
||||
doc = _sk(
|
||||
world["personal"], 바탕={"로직": GF}, 더한줄=[{"종류": "로직", "로직": BIG, "수량": 0.01}]
|
||||
)
|
||||
got = _calc(world["personal"], doc)
|
||||
head = next(x for x in got["줄"] if x["cid"] == "add:#0")
|
||||
m01_lines = labor.run_line(m01.loaded()[1], BIG, {})["줄"]
|
||||
assert head["수량"] == pytest.approx(0.01)
|
||||
for row, line in zip(head["펼침"], m01_lines):
|
||||
assert row["원문"]["수량"] == pytest.approx(float(line["수량"]), rel=1e-9) # 원문 그대로
|
||||
assert row["수량"] == pytest.approx(float(line["수량"]) * 0.01, rel=1e-9) # 상자 몫
|
||||
# 머리 = 수량 × 기초 끝수 계(751-3 · 비목 1 원 · 줄 0.1 원 버림) — 펼침 합과 0.3 + 수량 × 3 원 안
|
||||
near = 0.3 + 3 * 0.01
|
||||
assert sum(x["금액"] for x in head["펼침"]) == pytest.approx(head["금액"], abs=near)
|
||||
assert sum(x["원문"]["금액"] for x in head["펼침"]) * 0.01 == pytest.approx(
|
||||
head["금액"], abs=near
|
||||
)
|
||||
|
||||
|
||||
def test_처음수량_넣을때_값_셈_지문_안_듦(world):
|
||||
me = world["personal"]
|
||||
plain = _sk(me, 바탕={"로직": PCT}, 단위="㎡", 더한줄=[{**MAN, "수량": 3}])
|
||||
assert plain["더한줄"][0]["처음수량"] == 3 # 없으면 저장 때 지금 수량
|
||||
kept = _sk(me, 바탕={"로직": PCT}, 단위="㎡", 더한줄=[{**MAN, "수량": 3, "처음수량": 1}])
|
||||
assert kept["더한줄"][0]["처음수량"] == 1
|
||||
assert _calc(me, kept)["기준"]["계"] == _calc(me, plain)["기준"]["계"]
|
||||
assert same.finger("sangeun", kept) == same.finger("sangeun", plain)
|
||||
|
||||
|
||||
def test_뺀더한줄_기억_셈_지문_안_듦_못읽는_줄_버림(world):
|
||||
me = world["personal"]
|
||||
gone = [
|
||||
{"차례": 0, "줄": {"종류": "로직", "로직": BIG, "수량": 0.01, "덮개": {}}},
|
||||
{"차례": 1, "줄": MAN},
|
||||
{"차례": -1, "줄": MAN}, # 차례 틀림
|
||||
{"차례": 2, "줄": {"종류": "로직", "로직": "GX999999", "수량": 1}}, # 없는 기초
|
||||
{"차례": 3}, # 줄 없음
|
||||
]
|
||||
doc = _sk(me, 바탕={"로직": GF}, 뺀더한줄=gone)
|
||||
assert [x["차례"] for x in doc["뺀더한줄"]] == [0, 1]
|
||||
assert doc["뺀더한줄"][1]["줄"]["요소"] == "LB000002"
|
||||
bare = _sk(me, 바탕={"로직": GF})
|
||||
assert _calc(me, doc)["기준"]["계"] == _calc(me, bare)["기준"]["계"]
|
||||
assert same.finger("sangeun", doc) == same.finger("sangeun", bare)
|
||||
|
||||
|
||||
def test_일위대가_줄_패치_기억_처음수량(world):
|
||||
me = world["personal"]
|
||||
patch = {"더한줄": [{**MAN, "수량": 2}], "뺀더한줄": [{"차례": 0, "줄": MAN}]}
|
||||
with store.at(me):
|
||||
sc = refs.create(
|
||||
"precombo", {"이름": "744", "단위": "㎡", "담은로직": [{"로직": PCT, "패치": patch}]}
|
||||
)
|
||||
line = store.read("precombo", sc["이름"])["문서"]["담은로직"][0]
|
||||
assert line["패치"]["더한줄"][0]["처음수량"] == 2
|
||||
assert line["패치"]["뺀더한줄"][0]["줄"]["요소"] == "LB000002"
|
||||
@@ -28,18 +28,17 @@ def test_base_materials_count_like_m01():
|
||||
got = _run(바탕={"로직": FORM})
|
||||
assert got["기준"]["재료비"] == pytest.approx(m01_["기준"]["재료비"])
|
||||
assert got["기준"]["계"] == pytest.approx(m01_["기준"]["계"])
|
||||
qty = {x["cid"]: x["수량"] for x in got["줄"]}
|
||||
assert qty[PLY] == pytest.approx(1.03)
|
||||
assert qty["material:폼타이 12.7㎜#0"] == 0 # M01 수량 0 = 0 그대로
|
||||
qty = {x["이름"]: x["수량"] for x in got["줄"]} # 줄 = 수식 문서 금액 줄(855 2-C1)
|
||||
assert qty["합판(내수 12㎜)"] == pytest.approx(1.03)
|
||||
assert qty["폼타이 12.7㎜"] == 0 # M01 수량 0 = 0 그대로
|
||||
|
||||
|
||||
def test_cover_and_explicit_apart():
|
||||
def test_explicit_apart():
|
||||
"""「별도계상」 고른 재료 줄만 계 밖(문서 금액 줄 `합밖`) — 옛 칸 덮개는 셈 은퇴(855 2-C1)."""
|
||||
base = _run(바탕={"로직": FORM})
|
||||
more = _run(바탕={"로직": FORM}, 덮개={PLY: {"qty": 2}})
|
||||
ply = next(x for x in base["줄"] if x["cid"] == PLY)
|
||||
assert more["기준"]["재료비"] > base["기준"]["재료비"] + ply["단가"] * 0.9
|
||||
ply = next(x for x in base["줄"] if x["이름"] == "합판(내수 12㎜)")
|
||||
out = _run(바탕={"로직": FORM}, 자재표시={PLY: {"별도계상": "별도계상"}})
|
||||
assert all(x["cid"] != PLY for x in out["줄"])
|
||||
assert next(x for x in out["줄"] if x["이름"] == "합판(내수 12㎜)")["합밖"] is True
|
||||
assert out["기준"]["재료비"] < base["기준"]["재료비"] - ply["금액"] + 1
|
||||
|
||||
|
||||
|
||||
@@ -1,96 +0,0 @@
|
||||
"""SK 보기 넷 = 셈 답 하나(PLAN 750-1 · 요구 588-1) — 화면 셈 답 `글`(텍스트 수식) ·
|
||||
시험 계산(`줄` · `기준` · `중간`) = SK 줄 · 계 · 변형 일곱(기본 · 줄 빼기 · 더하기 · 덧줄 ·
|
||||
별도계상 · 단위 환산 · 재료 고름) + 참조 바탕 · 일위대가 줄 모달(`줄모드`) = 일위대가 그 줄 셈 ·
|
||||
`보기` false = 덧칸 없음 · M01 엔진 · storage 안 씀."""
|
||||
|
||||
import pytest
|
||||
|
||||
from M01_MasterData import M01_MasterData_Store as m01
|
||||
from M02_MasterTemplete import M02_Labor_Doc as labor
|
||||
from M02_MasterTemplete import M02_Sangeun_Calc as calc
|
||||
from M02_MasterTemplete import M02_Sangeun_Doc as sd
|
||||
from M02_MasterTemplete import M02_Sangeun_Views as views
|
||||
|
||||
FORM = "GC000211" # 6-3-1 합판거푸집 — 재료 일곱 · 소모자재 = 재료비 % 덧줄
|
||||
PLY = "material:합판(내수 12㎜)#0"
|
||||
DOC = {"키": "SK-000002", "이름": "테스트1", "단위": "㎡", "바탕": {"로직": FORM}}
|
||||
ADD = {"종류": "인력", "요소": "LB000002", "이름": "보통인부(더함)", "단위": "인", "수량": 0.05}
|
||||
CASES = {
|
||||
"기본": {},
|
||||
"줄 빼기": {"뺀줄": ["material:각재#0"]},
|
||||
"더하기": {"더한줄": [ADD]},
|
||||
"덧줄": {"덮개": {"pct:소모자재#0": {"qty": 5}}},
|
||||
"별도계상": {"자재표시": {PLY: {"별도계상": "별도계상"}}},
|
||||
"단위 환산": {"단위": "10㎡"},
|
||||
"재료 고름": {"고름": {PLY: "MT000037"}}, # 830-2 — 지역 줄(부산) 통합 · 다른 품목 줄을 고름
|
||||
}
|
||||
|
||||
|
||||
def _whole():
|
||||
return m01.loaded()[1]
|
||||
|
||||
|
||||
def _answer(doc: dict, read=None, line: bool = False) -> dict:
|
||||
"""`calc_doc` 와 같은 길(층 검사만 뺌)."""
|
||||
whole = _whole()
|
||||
clean = sd.clean(doc, None, whole)
|
||||
got = calc.run(clean, whole, None, read or calc.refs.read_ref, detail=True, line=line)
|
||||
return labor._json(views.finish(calc.per_unit(got, clean)))
|
||||
|
||||
|
||||
def _same(a: dict) -> None:
|
||||
text, base = a["글"], a["기준"]
|
||||
assert text["ok"] is True
|
||||
money: dict[str, float] = {}
|
||||
for g in text["groups"]:
|
||||
assert g["소계"] == pytest.approx(base[g["비목"]])
|
||||
for one in g["줄"]:
|
||||
money[one["cid"]] = money.get(one["cid"], 0) + (one["금액"] or 0)
|
||||
assert set(money) == {x["cid"] for x in a["줄"]} # 글 줄 = SK 줄(cid)
|
||||
for x in a["줄"]:
|
||||
assert money[x["cid"]] == pytest.approx(x["금액"] or 0)
|
||||
assert text["계"] == pytest.approx(base["계"])
|
||||
# 시험 계산 표 합 — 줄 0.1 원 · 비목 합 1 원 버림(751-3) = 줄 합 아래 비목마다 1 원(× 화면 배) 안
|
||||
gap = sum(x["금액"] or 0 for x in a["줄"]) - base["계"]
|
||||
assert -1e-6 <= gap < 3 / (a.get("화면배") or 1)
|
||||
assert a["중간"] and all(not isinstance(v, (dict, list)) for v in a["중간"].values())
|
||||
|
||||
|
||||
@pytest.mark.parametrize("name", list(CASES))
|
||||
def test_four_views_one_answer(name):
|
||||
a = _answer({**DOC, **CASES[name]})
|
||||
_same(a)
|
||||
if name == "별도계상":
|
||||
assert all(one.get("cid") != PLY for g in a["글"]["groups"] for one in g["줄"])
|
||||
if name == "단위 환산":
|
||||
assert a["글"]["나눔"] == pytest.approx(0.1)
|
||||
plain = _answer(DOC)
|
||||
assert a["기준"]["계"] == pytest.approx(plain["기준"]["계"] * 10)
|
||||
if name == "재료 고름":
|
||||
assert a["기준"]["재료비"] != pytest.approx(_answer(DOC)["기준"]["재료비"])
|
||||
|
||||
|
||||
def test_ref_base_same():
|
||||
"""참조 바탕(SK 위 SK) — 글도 바탕 SK 고친 줄 위에서."""
|
||||
parent = {**DOC, **CASES["덧줄"], "뺀줄": ["material:각재#0"]}
|
||||
ref = {"층": "personal", "주인": None, "키": "SK-000002"}
|
||||
_same(_answer({**DOC, "키": "SK-000003", "바탕": {"참조": ref}}, read=lambda r: parent))
|
||||
|
||||
|
||||
def test_row_modal_is_hopyo_line():
|
||||
"""일위대가 줄 모달(`줄모드`) = 일위대가 그 줄 셈(별도계상 기본 · 747 한쪽 흠)."""
|
||||
whole = _whole()
|
||||
line = labor._json(labor.drop_apart(labor.run_line(whole, FORM, None), {}))
|
||||
got = _answer({**DOC, "단위": "식", "줄모드": True}, line=True)
|
||||
assert got["기준"]["계"] == pytest.approx(line["기준"]["계"])
|
||||
assert [x["이름"] for x in got["줄"]] == [x["이름"] for x in line["줄"]]
|
||||
_same(got)
|
||||
|
||||
|
||||
def test_no_views_flag():
|
||||
"""`보기` false(바탕 원값 셈) = 금액만 · 덧칸 없음 · 금액 같음."""
|
||||
whole = _whole()
|
||||
clean = sd.clean(DOC, None, whole)
|
||||
got = labor._json(calc.run(clean, whole, None, detail=True, seen=False))
|
||||
assert "글" not in got and "중간" not in got
|
||||
assert got["기준"]["계"] == pytest.approx(_answer(DOC)["기준"]["계"])
|
||||
@@ -16,10 +16,6 @@ import master_sheet_line as msl # noqa: E402
|
||||
import master_text as mtx # noqa: E402
|
||||
import pytest # noqa: E402
|
||||
|
||||
from M01_MasterData import M01_MasterData_Store as m01 # noqa: E402
|
||||
from M02_MasterTemplete import M02_Labor_Doc as labor # noqa: E402
|
||||
from M02_MasterTemplete import M02_Sangeun_Calc as calc # noqa: E402
|
||||
from M02_MasterTemplete import M02_Sangeun_Doc as sd # noqa: E402
|
||||
|
||||
FORM = "GC000211" # 6-3-1 합판거푸집 — 폼타이 12.7 · 9.5 · 7.9 규격마다 줄
|
||||
TIES = ("폼타이 12.7㎜", "폼타이 9.5㎜", "폼타이 7.9㎜")
|
||||
@@ -95,14 +91,3 @@ def test_sheet_text_carries_mark(master):
|
||||
assert lines["폼타이 9.5㎜"].get(mg.KEY) is None
|
||||
assert lines["폼타이 12.7㎜"][mg.KEY] is True and lines["폼타이 7.9㎜"][mg.KEY] is True
|
||||
assert mg.KEY in msl.KEYS # M02 `/logic-lib/sheet` 도 같은 칸
|
||||
|
||||
|
||||
def test_sk_calc_carries_mark():
|
||||
whole = m01.loaded()[1]
|
||||
doc = {"키": "SK-000001", "이름": "시험", "단위": "㎡", "바탕": {"로직": FORM}}
|
||||
clean = sd.clean(doc, None, whole)
|
||||
got = labor._json(calc.run(clean, whole, {"폼타이": "사용", "폼타이규격": "12.7㎜"}))
|
||||
marked = {x["cid"] for x in got["줄"] if x.get(mg.KEY)}
|
||||
assert marked == {"material:폼타이 9.5㎜#0", "material:폼타이 7.9㎜#0"}
|
||||
base = labor._json(calc.run(clean, whole))
|
||||
assert base["기준"]["계"] == pytest.approx(got["기준"]["계"])
|
||||
|
||||
@@ -15,10 +15,13 @@ from resources.tester.test_m02_hopyo_excel import client # noqa: F401
|
||||
def test_목록_밖_기계_서버_둘째_요청에도_셈(client): # noqa: F811
|
||||
m01.loaded() # 마스터 = 이 스레드에서 지음 · 요청 = 다른 스레드(문맥 안 따라감)
|
||||
client.app.include_router(sangeun_router.router)
|
||||
one = {"종류": "로직", "로직": "GC000268", "입력값": {units.MACH_IN: "0211-0060"},
|
||||
"이름": "굴착기(타이어) 0.6㎥", "단위": "시간", "수량": 1} # fmt: skip
|
||||
doc = {"키": "SK-000000", "이름": "t", "단위": "시간", "바탕": None, "입력값": {}, "덮개": {},
|
||||
"뺀줄": [], "자재표시": {}, "더한줄": [one]} # fmt: skip
|
||||
doc = {
|
||||
"키": "SK-000000",
|
||||
"이름": "t",
|
||||
"단위": "시간",
|
||||
"바탕": {"로직": "GC000268"},
|
||||
"입력값": {units.MACH_IN: "0211-0060"},
|
||||
} # fmt: skip — 855 2-C1 바탕 로직 + 입력값
|
||||
for _ in range(2):
|
||||
got = client.post("/api/m02/layers/personal/sangeun/calc", json={"문서": doc})
|
||||
assert got.status_code == 200, got.text
|
||||
|
||||
@@ -68,71 +68,6 @@ LABOR = [
|
||||
|
||||
|
||||
# ── 서버 셈 ──────────────────────────────────────────────────────────────────
|
||||
def test_묶음_인력은_인력_줄만_노무비와_다름():
|
||||
got = _run(_doc([*LABOR, _rate("인력"), _rate("노무비", 3, name="노무 율")]))
|
||||
by = {x["cid"]: x for x in got["줄"]}
|
||||
people = sum(Decimal(str(by[f"add:#{k}"]["금액"])) for k in (0, 1))
|
||||
mach = Decimal(str(by["add:#2"]["비목"]["노무비"]))
|
||||
assert mach > 0 # 기계 노무 섞인 블록
|
||||
tool, cost = by["add:#3"], by["add:#4"]
|
||||
assert tool["금액"] == pytest.approx(float(people * 2 / 100), abs=0.1)
|
||||
assert cost["금액"] == pytest.approx(float((people + mach) * 3 / 100), abs=0.1)
|
||||
assert tool["율"] == 2 and tool["규격"] == "인력의 %" and tool["묶음"] == "경비"
|
||||
assert tool["비목"]["경비"] == pytest.approx(tool["금액"])
|
||||
assert got["짝잃음"] == []
|
||||
|
||||
|
||||
def test_줄_목록_절_소계와_율_위_율():
|
||||
adds = [*LABOR, _rate("인력"), _rate(["add:#0", "add:#3"], 10, "재료비", "율 위 율")]
|
||||
adds.append(_rate(["add:#0", "add:#1"], 5, name="절 소계"))
|
||||
got = _run(_doc(adds))
|
||||
by = {x["cid"]: x for x in got["줄"]}
|
||||
first = Decimal(str(by["add:#0"]["금액"]))
|
||||
tool = (first + Decimal(str(by["add:#1"]["금액"]))) * 2 / 100
|
||||
assert by["add:#4"]["금액"] == pytest.approx(float((first + tool) * 10 / 100), abs=0.1)
|
||||
assert by["add:#4"]["비목"]["재료비"] == pytest.approx(by["add:#4"]["금액"])
|
||||
part = first + Decimal(str(by["add:#1"]["금액"]))
|
||||
assert by["add:#5"]["금액"] == pytest.approx(float(part * 5 / 100), abs=0.1)
|
||||
|
||||
|
||||
def test_줄_목록_비목_몫_절_노무비():
|
||||
adds = [*LABOR, _rate(["add:#0", "add:#2@노무비"], 6, name="제잡비")]
|
||||
by = {x["cid"]: x for x in _run(_doc(adds))["줄"]}
|
||||
want = Decimal(str(by["add:#0"]["금액"])) + Decimal(str(by["add:#2"]["비목"]["노무비"]))
|
||||
assert by["add:#3"]["금액"] == pytest.approx(float(want * 6 / 100), abs=0.1)
|
||||
with pytest.raises(sd.DocError, match="자기"):
|
||||
sd.clean(_doc([LABOR[0], _rate(["add:#1@노무비"])]), None, _whole())
|
||||
|
||||
|
||||
def test_바탕_SK_율_줄과_바탕_덧줄():
|
||||
whole = _whole()
|
||||
doc = {**_doc([_rate("인력", 2)]), "바탕": {"로직": SUB}, "단위": "주"}
|
||||
got = labor._json(calc.run(sd.clean(doc, None, whole), whole))
|
||||
bare = labor.run_line(whole, SUB, {})
|
||||
people = sum(Decimal(str(bare["줄"][k]["금액"])) for k in (0, 1))
|
||||
rate = next(x for x in got["줄"] if x["cid"] == "add:#0")
|
||||
assert rate["금액"] == pytest.approx(float(people * 2 / 100), abs=0.1)
|
||||
assert got["기준"]["경비"] == pytest.approx(
|
||||
float(Decimal(str(bare["기준"]["경비"])) + Decimal(str(rate["금액"]))), abs=1
|
||||
)
|
||||
|
||||
|
||||
def test_없는_기준_줄_짝잃음():
|
||||
got = _run(_doc([LABOR[0], _rate(["add:#0", "labor:LB000099#0"])]))
|
||||
assert got["짝잃음"] == [{"cid": "add:#1", "까닭": "율 기준 줄 없음 「labor:LB000099#0」"}]
|
||||
got = _run(_doc([LABOR[0], _rate([])])) # 기준 줄을 지운 뒤 = 밑 0 · 알림
|
||||
assert got["짝잃음"] == [{"cid": "add:#1", "까닭": "율 기준 줄 없음 「」"}]
|
||||
assert got["줄"][1]["금액"] == 0
|
||||
|
||||
|
||||
def test_율_줄_없으면_엔진_한_번(monkeypatch):
|
||||
calls = []
|
||||
real = labor.run_line
|
||||
monkeypatch.setattr(labor, "run_line", lambda *a, **k: calls.append(1) or real(*a, **k))
|
||||
_run(_doc(LABOR))
|
||||
assert len(calls) == 1
|
||||
_run(_doc([*LABOR, _rate("인력")]))
|
||||
assert len(calls) == 3
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
||||
@@ -18,7 +18,6 @@ import pytest
|
||||
|
||||
from M01_MasterData import M01_MasterData_Store as m01
|
||||
from M02_MasterTemplete import M02_Labor_Ref as refs
|
||||
from M02_MasterTemplete import M02_Library_Flat as flat
|
||||
from M02_MasterTemplete import M02_MasterTemplete_Store as store
|
||||
from M02_MasterTemplete import M02_Sangeun_Calc as calc
|
||||
from M02_MasterTemplete import M02_Sangeun_Const as const
|
||||
@@ -87,30 +86,6 @@ def test_scan_엔진_차례():
|
||||
|
||||
|
||||
# ── 금액 = 견본(서버 셈) ──────────────────────────────────────────────
|
||||
def test_상수_표값_덮개_견본_금액():
|
||||
roof = {**F211, "지붕슬래브": ROOF}
|
||||
assert _sum(_doc(FORM, F211)) == 51419
|
||||
assert _sum(_doc(FORM, roof)) == 59341
|
||||
assert _sum(_doc(FORM, roof, 상수덮개={"mid:시공량": {"2": 20}})) == 61088
|
||||
assert _sum(_doc(FORM, F211, 상수덮개={TOOL: {"0": 2}})) == 51802
|
||||
assert _sum(_doc(CARRY, _carry())) == 42917
|
||||
assert _sum(_doc(CARRY, _carry(), 상수덮개={"mid:일운반회수": {"1": 100}})) == 38696
|
||||
assert _sum(_doc(CARRY, _carry(), 표값덮개={"mid:운반량": {"0": 30}})) == 35764
|
||||
|
||||
|
||||
def test_옵션_바꿔도_상수_덮개_따라감():
|
||||
"""품 덮개(숫자로 굳힘)와 달리 식 구조 그대로 — 유형 복잡 = 손으로 식 고친 줄과 같은 값."""
|
||||
from M02_MasterTemplete import M02_Labor_Doc as labor
|
||||
|
||||
whole = _whole()
|
||||
given = {**F211, "지붕슬래브": ROOF, "유형": "복잡"}
|
||||
got = _sum(_doc(FORM, given, 상수덮개={"mid:시공량": {"2": 20}}))
|
||||
row = json.loads(json.dumps(whole.logic(FORM), ensure_ascii=False, default=str))
|
||||
for s in row["중간"]:
|
||||
if s["이름"] == "시공량":
|
||||
s["식"] = s["식"].replace(", 0, 17))", ", 0, 20))")
|
||||
hand = labor.run_line(calc._Over(whole, FORM, row), FORM, given)["기준"]["계"]
|
||||
assert got == float(hand) and got not in (61088, _sum(_doc(FORM, given)))
|
||||
|
||||
|
||||
# ── 문서 꼴 ──────────────────────────────────────────────────────────
|
||||
@@ -168,67 +143,7 @@ def _calc(folder, doc, given=None):
|
||||
return calc.calc_doc(doc, given)
|
||||
|
||||
|
||||
def test_저장_M01판_셈답_원래_시트(world):
|
||||
mine = world["personal"]
|
||||
key = _sk(
|
||||
mine,
|
||||
바탕={"로직": FORM},
|
||||
입력값={**F211, "지붕슬래브": ROOF},
|
||||
상수덮개={"mid:시공량": {"2": 20}},
|
||||
덮개={"labor:LB000002#0": {"qty": 0.05}},
|
||||
글줄=[{"자리": "", "글": "※ 지붕 경사 반영"}],
|
||||
까닭={"mid:시공량": "감률 20 % 적용"},
|
||||
)
|
||||
doc = _read(mine, key)
|
||||
assert doc["상수덮개"] == {"mid:시공량": {"2": 20}} and len(doc["바탕판"]) == 16
|
||||
assert set(doc["M01판"]) >= {"mid:시공량", TOOL, "labor:LB000007#0"}
|
||||
got = _calc(mine, doc)
|
||||
assert got["원래"]["계"] == 59341 # 같은 옵션 · 덮개 없음
|
||||
assert got["기준"]["계"] != 59341
|
||||
no_qty = _calc(mine, {**doc, "덮개": {}})
|
||||
assert no_qty["기준"]["계"] == 61088 and no_qty["원래"]["계"] == 59341
|
||||
spot = got["시트"]["자리"]["mid:시공량"]
|
||||
assert spot["갈래"] == "중간" and spot["덮개"] == ["상수"] and spot["까닭"] == "감률 20 % 적용"
|
||||
assert spot["상수"][2] == {"n": 2, "값": 20, "원값": 17}
|
||||
assert spot["표값"][0]["글"].startswith("찾기(QC000431") and spot["표값"][0]["값"] == 45
|
||||
assert spot["원래"] > spot["지금"] and spot["M01바뀜"] is False
|
||||
line = got["시트"]["자리"]["labor:LB000002#0"]
|
||||
assert line["덮개"] == ["품"] and line["원래"] != line["지금"]
|
||||
assert got["시트"]["글줄"] == [{"자리": "", "글": "※ 지붕 경사 반영"}]
|
||||
assert got["시트"]["짝잃음"] == []
|
||||
# M01 바뀜 — 저장 지문과 지금 바탕이 다른 자리만 · 사라진 자리 = 짝잃음
|
||||
stale = {**doc, "M01판": {**doc["M01판"], "mid:시공량": "000000000000", "mid:없는줄": "1"}}
|
||||
got = _calc(mine, stale)
|
||||
flags = {s for s, x in got["시트"]["자리"].items() if x.get("M01바뀜")}
|
||||
assert flags == {"mid:시공량"}
|
||||
assert {"cid": "mid:없는줄", "까닭": "M01 바뀜 — 바탕에 없는 줄"} in got["시트"]["짝잃음"]
|
||||
|
||||
|
||||
def test_짝잃은_새_덮개_알림(world):
|
||||
doc = _doc(FORM, F211, 상수덮개={"mid:없음": {"0": 1}, "mid:시공량": {"9": 1}})
|
||||
got = _calc(world["personal"], doc)
|
||||
assert got["기준"]["계"] == 51419
|
||||
why = {(x["cid"], x["까닭"]) for x in got["시트"]["짝잃음"]}
|
||||
assert why == {
|
||||
("mid:없음", "상수덮개 — 바탕에 없는 줄"),
|
||||
("mid:시공량", "상수덮개 — 10 번째 없음"),
|
||||
}
|
||||
|
||||
|
||||
def test_옛_저장본_셈답(world):
|
||||
"""새 칸 없는 옛 저장본(M01판 없음) = 금액 그대로 · M01바뀜 없음."""
|
||||
"""새 칸 없는 옛 저장본(M01판 없음) = 금액 그대로(옛 `원래` · `시트` 덧칸은 855 2-C1 에서 걷음)."""
|
||||
got = _calc(world["personal"], {**_doc(FORM, F211), "바탕판": "0" * 16})
|
||||
assert got["기준"]["계"] == 51419 == got["원래"]["계"]
|
||||
assert not any(x.get("M01바뀜") for x in got["시트"]["자리"].values())
|
||||
|
||||
|
||||
def test_펼침_막음_초기화_걷음(world):
|
||||
mine = world["personal"]
|
||||
a = _sk(mine, 바탕={"로직": CARRY}, 입력값=_carry(), 상수덮개={"mid:일운반회수": {"1": 100}})
|
||||
b = _sk(mine, 바탕=None, 더한줄=[{"참조": {**MINE, "키": a}, "수량": 1}])
|
||||
assert _read(mine, b)["더한줄"][0]["참조"]["키"] == a # 안 펼침 = 참조 그대로
|
||||
assert _calc(mine, _read(mine, b))["기준"]["계"] == 38696
|
||||
with store.at(mine), pytest.raises(store.StoreError):
|
||||
flat.flat_lines("sangeun", {**MINE, "키": a})
|
||||
doc, n = flat.reset("sangeun", {**_read(mine, a), "까닭": {"mid:일운반회수": "가정"}})
|
||||
assert n == 1 and not set(doc) & {"상수덮개", "까닭"}
|
||||
assert got["기준"]["계"] == 51419
|
||||
|
||||
@@ -18,7 +18,6 @@ from pathlib import Path
|
||||
import pytest
|
||||
|
||||
from M01_MasterData import M01_MasterData_Store as m01
|
||||
from M02_MasterTemplete import M02_Item_Sangeun as sk
|
||||
from M02_MasterTemplete import M02_Labor_Ref as refs
|
||||
from M02_MasterTemplete import M02_Library_Flat as flat
|
||||
from M02_MasterTemplete import M02_MasterTemplete_Store as store
|
||||
@@ -75,40 +74,6 @@ def _plus(**more):
|
||||
|
||||
|
||||
# ── 견본 금액 ─────────────────────────────────────────────────────────
|
||||
def test_변수_줄_할증율_견본():
|
||||
assert _sum(_doc(CARRY, _carry())) == 42917
|
||||
assert _sum(_plus()) == 51501 # _분석_650-H2 4 장
|
||||
var = [{"이름": "할증율", "식": "만약(운반거리 > 5, 20, 0)", "표시": 0, "자리": "mid:무게"}]
|
||||
assert _sum(_sk_doc(CARRY, _carry(), 변수줄=var, 식덮개={MAN: PLUS})) == 51501
|
||||
eng = PLUS.replace("×", "*")
|
||||
assert _sum(_sk_doc(CARRY, _carry(), 변수줄=var, 식덮개={MAN: eng})) == 51501 # 엔진 꼴도
|
||||
|
||||
|
||||
def test_합판거푸집_줄_식_고침():
|
||||
base = _sum(_doc(FORM, F211))
|
||||
assert base == 51419
|
||||
tool = "(형틀목공 × [노임 형틀목공] + 보통인부 × [노임 보통인부]) × 2 / 100"
|
||||
assert _sum(_sk_doc(FORM, F211, 식덮개={TOOL: tool})) == 51802 # = 790-2 공구손료 2 %
|
||||
more = "[합판거푸집설치및해체일당].형틀목공 × 1.1 / 시공량"
|
||||
got = _run(_sk_doc(FORM, F211, 식덮개={"mid:형틀목공": more}))
|
||||
line = next(x for x in got["줄"] if x["cid"] == "labor:LB000007#0")
|
||||
assert float(line["수량"]) == pytest.approx(5 * 1.1 / 45)
|
||||
assert got["기준"]["계"] > base
|
||||
|
||||
|
||||
def test_더한줄_수량식():
|
||||
add = {
|
||||
"종류": "인력",
|
||||
"요소": "LB000002",
|
||||
"수량": 1,
|
||||
"수량식": "무게 / 운반량 / 일운반회수 / 2",
|
||||
}
|
||||
got = _run(_sk_doc(CARRY, _carry(), 더한줄=[add]))
|
||||
one, mine = (next(x for x in got["줄"] if x["cid"] == c) for c in (MAN, "add:#0"))
|
||||
assert float(mine["수량"]) == pytest.approx(float(one["수량"]) / 2)
|
||||
for bad in ({"수량식": "1", "종류": "로직", "로직": FORM, "수량": 1},):
|
||||
with pytest.raises(sd.DocError, match="수만"):
|
||||
sd.clean(_sk_doc(FORM, F211, 더한줄=[bad]), None, _whole())
|
||||
|
||||
|
||||
# ── 이름 꼴 ↔ 엔진 식 ────────────────────────────────────────────────
|
||||
@@ -150,33 +115,7 @@ def test_꼴_상한_겹침():
|
||||
sd.clean(_sk_doc(FORM, F211, **bad), None, whole)
|
||||
|
||||
|
||||
def test_틀린_식은_그_자리만_M01_식():
|
||||
"""셈 길 = 틀린 자리만 M01 식 + 짝잃음 · 이름 겹친 변수 = 뺌."""
|
||||
doc = _sk_doc(
|
||||
CARRY,
|
||||
_carry(),
|
||||
변수줄=[{"이름": "무게", "식": "1", "자리": ""}],
|
||||
식덮개={MAN: "무게 / 없는것", "mid:없는줄": "1"},
|
||||
)
|
||||
got = _run(doc)
|
||||
assert got["기준"]["계"] == 42917
|
||||
why = {(x["cid"], x["까닭"]) for x in got["짝잃음"]}
|
||||
assert (MAN, "식 — 모르는 이름 「없는것」") in why
|
||||
assert ("mid:없는줄", "식 — 바탕에 없는 줄") in why
|
||||
assert any(c == "mid:무게" and "이미 있음" in w for c, w in why)
|
||||
|
||||
|
||||
# ── 옛 SK · 저장 · 셈 답 · 펼침 · 초기화 ─────────────────────────────────
|
||||
def test_옛_SK_그대로():
|
||||
whole = _whole()
|
||||
old = _sk_doc(
|
||||
FORM, F211, 덮개={"labor:LB000007#0": {"qty": 0.2}}, 상수덮개={"mid:시공량": {"2": 20}}
|
||||
)
|
||||
got = sd.clean(old, None, whole)
|
||||
assert not set(got) & set(fx.FIELDS) and not fx.has(got)
|
||||
row = whole.logic(FORM)
|
||||
assert fx.settle(row, got) == (row, [], got)
|
||||
assert _sum(_doc(FORM, F211)) == 51419 and _sum(old) == _sum({**old, "식덮개": {}})
|
||||
|
||||
|
||||
def _sk(folder, **doc):
|
||||
@@ -195,32 +134,6 @@ def _calc(folder, doc):
|
||||
return calc.calc_doc(doc)
|
||||
|
||||
|
||||
def test_저장_엔진_식_셈_답(world):
|
||||
mine = world["personal"]
|
||||
add = {"종류": "인력", "요소": "LB000002", "수량": 1, "수량식": "1 ÷ 일운반회수"}
|
||||
var = [{"이름": "할증율", "식": "20", "자리": ""}]
|
||||
key = _sk(mine, 바탕={"로직": CARRY}, 입력값=_carry(), 변수줄=var, 식덮개={MAN: PLUS})
|
||||
doc = _read(mine, key)
|
||||
assert doc["식덮개"] == {MAN: PLUS.replace("×", "*")} and doc["변수줄"] == var
|
||||
got = _calc(mine, doc)
|
||||
assert got["기준"]["계"] == 51501 and got["원래"]["계"] == 42917
|
||||
spot = got["시트"]["자리"][MAN]
|
||||
assert spot["식덮개"] is True and spot["덮개"] == ["식"] and spot["식글"] == PLUS
|
||||
assert spot["원식글"] == "무게 / 운반량 / 일운반회수" and spot["식"] == spot["원식글"]
|
||||
v = got["시트"]["자리"]["mid:할증율"]
|
||||
assert v["갈래"] == "변수" and v["식글"] == "20" and float(v["지금"]) == 20
|
||||
names = {(x["글"], x["갈래"]) for x in got["시트"]["이름표"]}
|
||||
assert {("할증율", "변수"), ("[인력운반기본공식]", "별칭"), ("노무비", "비목")} <= names
|
||||
assert ("[노임 보통인부]", "자원") in names # 호표 요소
|
||||
key2 = _sk(mine, 바탕={"로직": CARRY}, 입력값=_carry(), 더한줄=[add])
|
||||
doc2 = _read(mine, key2)
|
||||
assert doc2["더한줄"][0]["수량식"] == "1 / 일운반회수"
|
||||
assert _calc(mine, doc2)["시트"]["자리"]["add:#0"]["식글"] == "1 / 일운반회수"
|
||||
with store.at(mine), pytest.raises(store.StoreError) as e: # 틀린 식 저장 = 400
|
||||
refs.create("sangeun", {**_plus(식덮개={MAN: "무게 / 없는것"}), "더한줄": []})
|
||||
assert e.value.status == 400 and "모르는 이름" in str(e.value.detail)
|
||||
|
||||
|
||||
def test_펼침_막음_초기화_걷음(world):
|
||||
mine = world["personal"]
|
||||
a = _sk(mine, 바탕={"로직": CARRY}, 입력값=_carry(), 변수줄=[{"이름": "할증율", "식": "20"}])
|
||||
@@ -233,21 +146,6 @@ def test_펼침_막음_초기화_걷음(world):
|
||||
|
||||
|
||||
# ── B09 사본 굳힘 ─────────────────────────────────────────────────────
|
||||
def test_B09_굳힘_식_칸_그대로():
|
||||
whole = _whole()
|
||||
add = {"종류": "인력", "요소": "LB000002", "수량": 1, "수량식": "1 / 일운반회수"}
|
||||
doc = sd.clean({**_plus(), "더한줄": [add]}, None, whole)
|
||||
live = calc.run(doc, whole)["기준"]["계"]
|
||||
rid = "personal|7/42|SK-000001"
|
||||
frozen = sk.freeze({rid: doc})[rid]
|
||||
row, key = frozen[sk.ROW], frozen["바탕"]["로직"]
|
||||
assert key.startswith("GX9") and frozen["원본"]["식덮개"] == doc["식덮개"]
|
||||
assert [x["이름"] for x in row["중간"]][0] == "할증율"
|
||||
assert row["호표"][0]["수량"] == PLUS.replace("×", "*")
|
||||
assert row["호표"][1]["수량"] == "1 / 일운반회수"
|
||||
over = calc._Over(whole, key, json.loads(json.dumps(row)))
|
||||
again = calc.run(sd.clean(frozen, None, over), over)["기준"]["계"]
|
||||
assert again == live and float(live) > 51501
|
||||
|
||||
|
||||
def test_같은_내용_지문_식_칸_가림():
|
||||
|
||||
@@ -113,10 +113,3 @@ def test_층_섞임_없음_개인_자재는_그때_층에서만(world):
|
||||
assert Decimal(str(mine["기준단가"])) == 1234
|
||||
assert theirs["기준단가"] is None
|
||||
assert code not in whole.index.get(code[:2], {})
|
||||
|
||||
|
||||
def test_상수_덮개_셈_답_전후_같음():
|
||||
got = calc.calc_doc(_sk(상수덮개={"pct:공구손료 및 경장비#0": {"0": 2}}))
|
||||
assert got["기준"]["계"] == 51802
|
||||
assert got["원래"]["계"] == 51419
|
||||
assert got["시트"]["자리"]["pct:공구손료 및 경장비#0"]["덮개"] == ["상수"]
|
||||
|
||||
@@ -176,13 +176,10 @@ def test_셈_답_원래_엑셀_원본_글(world):
|
||||
got = calc.calc_doc(doc)
|
||||
assert got["원래"] == {"노무비": 34119, "재료비": 11192, "경비": 341, "계": 45652}
|
||||
assert got["기준"]["계"] > 45652
|
||||
spot = got["시트"]["자리"]["labor:형틀목공#0"]
|
||||
assert spot["덮개"] == ["품"] and spot["까닭"] == "현장 품"
|
||||
view = got[imp.KEY]
|
||||
assert view["단가기준"] == "엑셀" and view["파일"] == "봉화.xlsx" and view["행"] == [2909, 2943]
|
||||
lines = view["글줄"]
|
||||
assert lines[0] == {"행": 2909, "글": "합판거푸집 ㎡ 당", "자리": None}
|
||||
assert lines[1]["같음"] is True and lines[2]["같음"] is False # 덮은 줄 = 엑셀과 다름
|
||||
assert [x["이름"] for x in view["이음없음"]] == ["합판(내수)", "각재", "형틀목공"]
|
||||
|
||||
|
||||
@@ -382,8 +379,6 @@ def test_실무_블록_가져온_식(tag, code, world):
|
||||
assert check["같음"] is True and check["셈"] == excel and len(check["줄"]) >= 3
|
||||
assert all(":" in x["자리"] for x in check["줄"]) # 줄 이름 → cid · mid: · 단계:
|
||||
assert ans["원래"] == out["원본"]["엑셀금액"] and round(ans["기준"]["계"]) == excel["계"]
|
||||
shown = [x for x in ans[imp.KEY]["글줄"] if "같음" in x]
|
||||
assert shown and all(x["같음"] for x in shown)
|
||||
assert _frozen_total(doc, _whole()) == excel["계"]
|
||||
ours = imp.to_price(doc, "우리")
|
||||
assert {k: round(float(v)) for k, v in ours["전"].items()} == excel
|
||||
|
||||
@@ -138,20 +138,3 @@ def test_부품상자만_700줄_공용_안_고침():
|
||||
assert "#" not in "".join(re.findall(r"color:\s*[^;]+", text)), name
|
||||
for name in ("Labor_Rows", "Labor_SkEdit", "Sangeun_Detail", "Sangeun_Tabs"):
|
||||
assert "Hopyo_Imported" not in _src(name), name # 공용 쪽은 새 모달을 모름
|
||||
|
||||
|
||||
def test_가져온_식_시트_M01바뀜_없음(client):
|
||||
"""가져온 식 SK 는 M01 짝이 없음 — 저장 M01판이 있어도 시트 「M01 바뀜」 · 짝잃음 안 띄움."""
|
||||
from M02_MasterTemplete import M02_Sangeun_Calc as calc
|
||||
|
||||
client.app.include_router(sangeun_router.router)
|
||||
assert _post(client).status_code == 200
|
||||
name = _open(client).json()["이름"]
|
||||
folder = layers.personal_dir(7, 42)
|
||||
with store.at(folder):
|
||||
doc = store.read("sangeun", name)["문서"]
|
||||
spots = list(calc.calc_doc(doc)["시트"]["자리"])
|
||||
ans = calc.calc_doc({**doc, "M01판": {k: "다름" for k in [*spots, "x"]}})
|
||||
sheet = ans["시트"]
|
||||
assert sheet["자리"] and not any(x["M01바뀜"] for x in sheet["자리"].values())
|
||||
assert sheet["짝잃음"] == []
|
||||
|
||||
@@ -81,10 +81,6 @@ def _sum(folder, key):
|
||||
return _calc(folder, _doc(folder, key))["기준"]["계"]
|
||||
|
||||
|
||||
def _cids(folder, key):
|
||||
return [x["cid"] for x in _calc(folder, _doc(folder, key))["줄"]]
|
||||
|
||||
|
||||
def _changed(row, at=0):
|
||||
row = copy.deepcopy(row)
|
||||
row["호표"][at]["수량"] = f"({row['호표'][at]['수량']}) * 2"
|
||||
@@ -115,7 +111,7 @@ def test_price_refresh_only_on_press(world, monkeypatch):
|
||||
me = world["personal"]
|
||||
key = _sk(me, 바탕={"로직": PCT})
|
||||
was = _sum(me, key)
|
||||
lb = _cids(me, key)[0].split(":")[1].split("#")[0]
|
||||
lb = next(r["키"] for r in _doc(me, key)["사본"]["단가"] if r["키"].startswith("LB"))
|
||||
row = copy.deepcopy(_live().get(lb))
|
||||
row["값"] = row["값"] * 2
|
||||
_fake(monkeypatch, [row])
|
||||
@@ -133,35 +129,12 @@ def test_price_refresh_only_on_press(world, monkeypatch):
|
||||
assert saved["사본"]["단가시점"] >= saved["사본"]["시점"]
|
||||
|
||||
|
||||
def test_regen_reapplies_covers(world, monkeypatch):
|
||||
"""③ [재생성] — 덮개 · 까닭 새 사본에 다시 얹힘 · 없어진 줄 덮개 = 못얹은 · 배지 꺼짐."""
|
||||
me = world["personal"]
|
||||
probe = _sk(me, 바탕={"로직": PCT})
|
||||
one, two = _cids(me, probe)[:2]
|
||||
covers = {one: {"qty": 0.5}, two: {"qty": 0.7}}
|
||||
key = _sk(me, 바탕={"로직": PCT}, 덮개=covers, 까닭={one: "현장 실측"})
|
||||
row = copy.deepcopy(_live().logic(PCT))
|
||||
row["호표"] = [x for n, x in enumerate(row["호표"]) if n != 1] # 둘째 줄 없앤 새 판
|
||||
_fake(monkeypatch, [row])
|
||||
with store.at(me):
|
||||
got = skc.preview(_doc(me, key), skc.REGEN)
|
||||
assert [x["cid"] for x in got["못얹은"]] == [two]
|
||||
assert got["전"]["계"] != got["후"]["계"]
|
||||
_save(me, key, got["문서"])
|
||||
doc = _doc(me, key)
|
||||
assert doc["덮개"][one]["qty"] == 0.5 and doc["까닭"][one] == "현장 실측"
|
||||
now = _calc(me, doc)
|
||||
assert now["줄"][0]["덮개"] == ["qty"]
|
||||
assert now["사본"]["M01새판"] is False
|
||||
assert now["기준"]["계"] == got["후"]["계"]
|
||||
|
||||
|
||||
def test_deleted_keys_keep_last_value(world, monkeypatch):
|
||||
"""⑤ 사본이 부르는 M01 키(바탕 로직 · 노임)가 지워져도 마지막 값 · 지운키 표지."""
|
||||
me = world["personal"]
|
||||
key = _sk(me, 바탕={"로직": PCT})
|
||||
was = _sum(me, key)
|
||||
lb = _cids(me, key)[0].split(":")[1].split("#")[0]
|
||||
lb = next(r["키"] for r in _doc(me, key)["사본"]["단가"] if r["키"].startswith("LB"))
|
||||
_fake(monkeypatch, drop=[PCT, lb])
|
||||
with pytest.raises(Exception):
|
||||
m01.loaded()[1].logic(PCT)
|
||||
|
||||
@@ -109,23 +109,6 @@ def test_price_refresh_only_on_press(world, monkeypatch):
|
||||
assert _calc(me, sc)["사본"]["단가새값"] is False
|
||||
|
||||
|
||||
def test_regen_reapplies_line_cover(world, monkeypatch):
|
||||
"""③ [재생성] — 줄 덮개(cid) 새 사본에 다시 얹힘 · 배지 꺼짐."""
|
||||
me = world["personal"]
|
||||
two = {"덮개": {f"labor:{LB}#0": {"qty": 0.5}, "labor:LB000002#0": {"qty": 0.7}}}
|
||||
_labor(me, [{"로직": PCT, "수량": {"손": 1}, "패치": two}])
|
||||
row = copy.deepcopy(_live().logic(PCT))
|
||||
row["호표"] = [x for n, x in enumerate(row["호표"]) if n != 1] # 둘째 줄 없앤 새 판
|
||||
_fake(monkeypatch, [row])
|
||||
assert not _calc(me, COL)["줄"][0].get("짝잃음") # 사본 = 옛 판 그대로
|
||||
was = _calc(me, COL)["기준합"]["계"]
|
||||
_write(me, "labor", COL, {**_read(me, "labor", COL), lc.JOB: lc.REGEN})
|
||||
doc = _read(me, "labor", COL)
|
||||
assert doc["담은로직"][0]["패치"]["덮개"][f"labor:{LB}#0"] == {"qty": 0.5}
|
||||
now = _calc(me, COL)
|
||||
assert now["사본"]["M01새판"] is False and now["기준합"]["계"] != was
|
||||
|
||||
|
||||
def test_layer_and_column_copy_keep_copy(world, monkeypatch):
|
||||
"""④ 층 사이 복사(회사 → 개인) · 열 복사 = 원본 사본 그대로(지금 M01 로 다시 안 찍음)."""
|
||||
co, me = world["company"], world["personal"]
|
||||
|
||||
@@ -8,24 +8,17 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import copy
|
||||
|
||||
import pytest
|
||||
|
||||
from M01_MasterData import M01_MasterData_Store as m01
|
||||
from M02_MasterTemplete import M02_MasterTemplete_Store as store
|
||||
from M02_MasterTemplete import M02_Sangeun_Copy as skc
|
||||
from M02_MasterTemplete import M02_Sangeun_Equation as eqm
|
||||
from M02_MasterTemplete import M02_Sangeun_Imported as imp
|
||||
from resources.tester.test_795_1_sk_copy import (
|
||||
_calc,
|
||||
_doc,
|
||||
_fake,
|
||||
_imported_row,
|
||||
_live,
|
||||
_save,
|
||||
_sk,
|
||||
_sum,
|
||||
)
|
||||
from resources.tester.test_m02_labor_ref import world # noqa: F401 — 같은 임시 층
|
||||
|
||||
@@ -42,47 +35,6 @@ KEY = "GC000211" # 합판거푸집 — 중간 시공량 · 형틀목공 · 보
|
||||
DOUBLE = [{"할일": "식", "자리": "호표:0", "식": "형틀목공 × 2", "까닭": "sub2임시 시험"}]
|
||||
|
||||
|
||||
def test_edit_changes_amount_save_is_canonical(world):
|
||||
"""③ 고침 [저장] = 고침 목록 남음 · 서버 셈 = 금액 바뀜 · 원래 대비 · M01 그대로 · 틀린 고침 400."""
|
||||
me = world["personal"]
|
||||
key = _sk(me, 바탕={"로직": KEY})
|
||||
was = _sum(me, key)
|
||||
m01_row = copy.deepcopy(_live().logic(KEY))
|
||||
doc = {**_doc(me, key), eqm.KEY: DOUBLE}
|
||||
_save(me, key, doc)
|
||||
saved = _doc(me, key)
|
||||
assert saved[eqm.KEY][0]["까닭"] == "sub2임시 시험"
|
||||
assert saved["사본"]["로직"][0]["호표"][0]["수량"] == m01_row["호표"][0]["수량"] # 사본 = 원래
|
||||
now = _calc(me, saved)
|
||||
after = now["기준"]["계"]
|
||||
assert after > was
|
||||
assert now["원래"]["계"] == was # 원래 대비 = 고침 없는 사본
|
||||
assert _live().logic(KEY) == m01_row # M01 정본 안 바뀜
|
||||
bad = {**saved, eqm.KEY: [{"할일": "식", "자리": "호표:0", "식": "없는값 × 2"}]}
|
||||
with pytest.raises(store.StoreError):
|
||||
_save(me, key, bad)
|
||||
assert _sum(me, key) == after
|
||||
|
||||
|
||||
def test_variables_add_drop_rename(world):
|
||||
"""④ 변수 더함 → 식에서 부름(금액 바뀜) · 쓰는 변수 지움 = 저장 400 · 기호 = 금액 그대로."""
|
||||
me = world["personal"]
|
||||
key = _sk(me, 바탕={"로직": KEY})
|
||||
doc = _doc(me, key)
|
||||
was = _calc(me, doc)["기준"]
|
||||
add = [
|
||||
{"할일": "더함", "갈래": "중간", "열쇠": "할증", "식": "1.5", "뒤": "보통인부"},
|
||||
{"할일": "식", "자리": "호표:1", "식": "보통인부 × 할증"},
|
||||
]
|
||||
_save(me, key, {**doc, eqm.KEY: add})
|
||||
assert _calc(me, _doc(me, key))["기준"]["노무비"] > was["노무비"]
|
||||
with pytest.raises(store.StoreError):
|
||||
_save(me, key, {**_doc(me, key), eqm.KEY: [{"할일": "지움", "열쇠": "시공량"}]})
|
||||
sign = [{"할일": "변수", "열쇠": "시공량", "기호": "Q", "아래": "d", "이름": "하루 시공량"}]
|
||||
_save(me, key, {**_doc(me, key), eqm.KEY: sign})
|
||||
assert _calc(me, _doc(me, key))["기준"]["계"] == was["계"] # 이름만 — 금액 그대로
|
||||
|
||||
|
||||
def test_imported_same_path(world):
|
||||
"""⑥ 가져온 식 SK(바탕 null · 가져온.로직) — 같은 고침 · 저장."""
|
||||
me = world["personal"]
|
||||
@@ -97,28 +49,6 @@ def test_imported_same_path(world):
|
||||
assert _doc(me, key)["가져온"]["로직"]["호표"][0]["수량"] == "0.5" # 엑셀 줄 그대로
|
||||
|
||||
|
||||
def test_m01_change_kept_regen_reapplies(world, monkeypatch):
|
||||
"""⑦ M01 바뀌어도 고친 SK 그대로 · [재생성] = 새 사본에 고침 다시 · 자리 없으면 못얹은."""
|
||||
me = world["personal"]
|
||||
key = _sk(me, 바탕={"로직": KEY})
|
||||
_save(me, key, {**_doc(me, key), eqm.KEY: DOUBLE})
|
||||
was = _sum(me, key)
|
||||
row = copy.deepcopy(_live().logic(KEY))
|
||||
row["호표"][1]["수량"] = f"({row['호표'][1]['수량']}) * 3"
|
||||
_fake(monkeypatch, [row])
|
||||
assert _sum(me, key) == was
|
||||
with store.at(me):
|
||||
got = skc.preview(_doc(me, key), skc.REGEN)
|
||||
assert not got["못얹은"] and got["후"]["계"] > was # 새 판 + 같은 고침
|
||||
gone = copy.deepcopy(row)
|
||||
gone["호표"] = []
|
||||
_fake(monkeypatch, [gone])
|
||||
with store.at(me):
|
||||
got = skc.preview(_doc(me, key), skc.REGEN)
|
||||
assert eqm.LOST in [x["cid"] for x in got["못얹은"]] # 그 밖 = 없어진 줄 M01판(790-2)
|
||||
assert m01.loaded()[1].logic(KEY)["호표"] == []
|
||||
|
||||
|
||||
def test_screen_same_part_first_tab():
|
||||
"""화면 — M02 수식 = 공용 수식 문서 화면(802-4b-2 · 옛 수식 나무 화면 걷음) · 첫 탭 · 옛 탭 걷음(799-2)."""
|
||||
import re
|
||||
|
||||
@@ -38,8 +38,6 @@ def _manual(monkeypatch):
|
||||
|
||||
|
||||
FORM = "GC000211" # 합판거푸집(옵션 많음)
|
||||
BASIC = "GF000089" # 토사깍기(기계) — 굴착기 시간당 × 1 / 작업량(813-2 GC001148 지움 뒤)
|
||||
ADD = {"종류": "로직", "로직": BASIC, "수량": 2, "입력값": {}, "이름": "sub2임시 굴착기"}
|
||||
|
||||
|
||||
def _sum(folder, key):
|
||||
@@ -139,26 +137,33 @@ def test_regen_takes_m01_doc_drops_edits(world, monkeypatch):
|
||||
assert got["사본"]["M01새판"] is False and got["사본"]["문서새판"] == []
|
||||
|
||||
|
||||
CALLER, CALLED = "GC000006", "GC000267" # 가설울타리 강관 지주 → 굴착기(무한궤도) 시간당
|
||||
|
||||
|
||||
def test_link_follows_on_regen_unlink_freezes(world, monkeypatch):
|
||||
"""⑤ 단가산출 연결 = 부름 사본(M01 바뀌어도 그대로 · [재생성] 때 따라감) · 끊기 = 사본 안 고침."""
|
||||
me = world["personal"]
|
||||
key = _sk(me, 바탕={"로직": FORM}, 더한줄=[copy.deepcopy(ADD)])
|
||||
key = _sk(
|
||||
me, 바탕={"로직": CALLER}, 단위="m"
|
||||
) # 기초 문서가 부르는 단가산출(855 2-C1 — 옛 더한줄 대신)
|
||||
was = _sum(me, key)
|
||||
read = _at(me, path.read, key)
|
||||
assert BASIC in read["부름"]
|
||||
cut = {BASIC: _twice(read["부름"][BASIC])}
|
||||
assert CALLED in read["부름"]
|
||||
cut = {CALLED: _twice(read["부름"][CALLED])}
|
||||
pre = _at(me, path.preview, key, {"끊음": cut})
|
||||
assert pre["후"]["계"] > was
|
||||
saved = _at(me, path.save, key, {"끊음": cut, "판": read["판"]})
|
||||
assert saved["끊음"][BASIC] == {**cut[BASIC], "키": BASIC} and _sum(me, key) == pre["후"]["계"]
|
||||
_fake(monkeypatch, [_changed(_live().logic(BASIC))]) # 원본 바뀜
|
||||
assert (
|
||||
saved["끊음"][CALLED] == {**cut[CALLED], "키": CALLED} and _sum(me, key) == pre["후"]["계"]
|
||||
)
|
||||
_fake(monkeypatch, [_changed(_live().logic(CALLED))]) # 원본 바뀜
|
||||
assert _sum(me, key) == pre["후"]["계"] # 끊은 것 · 연결 모두 그대로(누르기 전)
|
||||
with pytest.raises(store.StoreError) as e: # 부르지 않는 키 끊기
|
||||
_at(me, path.preview, key, {"끊음": {"GC999999": read["부름"][BASIC]}})
|
||||
_at(me, path.preview, key, {"끊음": {"GC999999": read["부름"][CALLED]}})
|
||||
assert e.value.status == 400
|
||||
read = _at(me, path.read, key)
|
||||
pre = _at(me, path.preview, key, {"할일": "재생성"})
|
||||
assert pre["버림"]["끊음"] == [BASIC]
|
||||
assert pre["버림"]["끊음"] == [CALLED]
|
||||
got = _at(me, path.save, key, {"할일": "재생성", "판": read["판"]})
|
||||
assert got["끊음"] == {} and got["셈"]["계"] > was # 연결 = 새 원본 따라감
|
||||
|
||||
|
||||
@@ -31,8 +31,6 @@ from resources.tester.test_m02_structure import write_sample_table
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
HERE = os.path.dirname(os.path.abspath(__file__))
|
||||
FORM = "GC000211" # 합판거푸집 — 폼타이 · 측압 · 규격 옵션
|
||||
BASIC = "GF000089" # 토사깍기(기계) — 굴착기 시간당 × 1 / 작업량(813-2 GC001148 지움 뒤)
|
||||
ADD = {"종류": "로직", "로직": BASIC, "수량": 2, "입력값": {}, "이름": "sub3임시 굴착기"}
|
||||
|
||||
|
||||
def _at(folder, fn, *args):
|
||||
@@ -82,27 +80,27 @@ def _replay(read: dict) -> dict:
|
||||
return dc.mc.calc(doc, _Replay(read["연결"]))
|
||||
|
||||
|
||||
CALLER, CALLED = "GC000006", "GC000267" # 가설울타리 강관 지주 → 굴착기(무한궤도) 시간당
|
||||
|
||||
|
||||
def test_연결기록만으로_같은셈_끊음먼저(world):
|
||||
me = world["personal"]
|
||||
key = _sk(
|
||||
me,
|
||||
바탕={"로직": FORM},
|
||||
입력값={"폼타이": "사용", "측압": "4t/㎡"},
|
||||
더한줄=[copy.deepcopy(ADD)],
|
||||
)
|
||||
me, 바탕={"로직": CALLER}, 단위="m"
|
||||
) # 기초 문서가 부르는 단가산출(855 2-C1 — 옛 더한줄 대신)
|
||||
read = _at(me, path.read, key)
|
||||
rec = read["연결"]
|
||||
assert {"요소", "표", "문서", "이름"} <= set(rec) and BASIC in rec["문서"]
|
||||
assert {"요소", "표", "문서", "이름"} <= set(rec) and CALLED in rec["문서"]
|
||||
assert _replay(read)["계"] == read["셈"]["계"]
|
||||
cut = copy.deepcopy(read["부름"][BASIC])
|
||||
cut = copy.deepcopy(read["부름"][CALLED])
|
||||
line = cut["금액"][0]
|
||||
line["수량"] = f"({line.get('수량') or 1}) × 2" # 끊은 문서 안 줄 고침
|
||||
saved = _at(me, path.save, key, {"끊음": {BASIC: cut}, "판": read["판"]})
|
||||
assert saved["연결"]["문서"][BASIC]["금액"][0]["수량"] == line["수량"] # 끊음 먼저
|
||||
saved = _at(me, path.save, key, {"끊음": {CALLED: cut}, "판": read["판"]})
|
||||
assert saved["연결"]["문서"][CALLED]["금액"][0]["수량"] == line["수량"] # 끊음 먼저
|
||||
assert saved["셈"]["계"] > read["셈"]["계"]
|
||||
assert _replay(saved)["계"] == saved["셈"]["계"]
|
||||
again = _at(me, path.read, key)
|
||||
assert again["끊음"][BASIC]["금액"][0]["수량"] == line["수량"] and again["판"] == saved["판"]
|
||||
assert again["끊음"][CALLED]["금액"][0]["수량"] == line["수량"] and again["판"] == saved["판"]
|
||||
got = _at(me, path.save, key, {"끊음": {}, "판": again["판"]}) # 다시 잇기
|
||||
assert got["끊음"] == {} and got["셈"]["계"] == read["셈"]["계"]
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
- 옮긴 뒤 상태 = 마스터 층 로직 줄 0(한 번용 옮기기 도구는 894 에서 걷음)
|
||||
"""
|
||||
|
||||
import copy
|
||||
import json
|
||||
import re
|
||||
from pathlib import Path
|
||||
@@ -15,13 +16,12 @@ from fastapi import FastAPI
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from common_util.common_util_auth import verify_session
|
||||
from M02_MasterTemplete import M02_Doc_Sk_Path as sk_path
|
||||
from M02_MasterTemplete import M02_Labor_Doc as labor
|
||||
from M02_MasterTemplete import M02_Labor_Ref as refs
|
||||
from M02_MasterTemplete import M02_Labor_SkRow as skrow
|
||||
from M02_MasterTemplete import M02_Library_Flat as flat
|
||||
from M02_MasterTemplete import M02_MasterTemplete_Store as store
|
||||
from M02_MasterTemplete import M02_Sangeun_Calc as calc
|
||||
from M02_MasterTemplete import M02_Sangeun_Doc as sd
|
||||
from M02_MasterTemplete import M02_Sangeun_Router as sk_router
|
||||
from M02_MasterTemplete import M02_Template_Layers as layers
|
||||
from M02_MasterTemplete.M02_Labor_Expand import Expand
|
||||
@@ -60,11 +60,11 @@ def test_모달_저장_SK_문서_뒤_일위대가_따라감(world):
|
||||
sk = _make(me, "sangeun", 이름="sub1임시 SK", 바탕={"로직": TEN})
|
||||
sc = _make(me, "precombo", 이름="sub1임시 SC", 담은로직=[{"참조": {**MINE, "키": sk}, "수량": {"손": 1}}]) # fmt: skip
|
||||
before = _value(me, sc)["계"]
|
||||
with store.at(me): # 모달 [저장] = 그 SK 문서 쓰기(`saveTemplate` sangeun)
|
||||
now = store.read("sangeun", sk)
|
||||
cid = sd.line_ids(_whole().logic(TEN))[0]
|
||||
doc = {**now["문서"], "덮개": {cid: {"배율": 2}}}
|
||||
store.write("sangeun", sk, now["판"], calc.clean_doc(doc, refs.here()))
|
||||
with store.at(me): # 모달 [저장] = 그 SK 수식 문서 저장(`Labor_SkEdit` · 수식 길)
|
||||
read = sk_path.read(sk)
|
||||
twice = copy.deepcopy(read["문서"])
|
||||
twice["금액"][0]["수량"] = f"({twice['금액'][0].get('수량') or 1}) × 2"
|
||||
sk_path.save(sk, {"문서": twice, "판": read["판"]})
|
||||
assert _value(me, sc)["계"] != before # 일위대가 금액이 SK 를 따라감
|
||||
assert _read(me, "precombo", sc)["담은로직"][0]["참조"]["키"] == sk # 일위대가 문서는 그대로
|
||||
|
||||
|
||||
@@ -52,9 +52,17 @@ def _easy(**vals):
|
||||
|
||||
|
||||
def _sk(folder, machine_no):
|
||||
line = {"종류": "로직", "로직": "GC000268", "입력값": {"기계": machine_no, "지역": "전국평균"},
|
||||
"수량": "1"} # fmt: skip
|
||||
body = {"이름": "sub3임시 내기계", "단위": "시간", "더한줄": [line]}
|
||||
given = {
|
||||
"기계": machine_no,
|
||||
"지역": "전국평균",
|
||||
} # 바탕 로직 + 입력값(855 2-C1 — 옛 더한줄 대신)
|
||||
body = {
|
||||
"이름": "sub3임시 내기계",
|
||||
"단위": "시간",
|
||||
"바탕": {"로직": "GC000268"},
|
||||
"입력값": given,
|
||||
"더한줄": [],
|
||||
}
|
||||
return _at(folder, lambda: refs.create("sangeun", body)["이름"])
|
||||
|
||||
|
||||
|
||||
@@ -187,21 +187,6 @@ OLD_ADDS = {
|
||||
} # fmt: skip
|
||||
|
||||
|
||||
@pytest.mark.parametrize("name", list(OLD_ADDS))
|
||||
def test_old_added_lines(world, monkeypatch, name):
|
||||
"""옛 로직 길 더한줄(로직 기계 · 재료 요소 · 인력 요소) — 저장 뒤 그대로 · 갱신 뒤 반영."""
|
||||
me = world["personal"]
|
||||
adds, given, moved = OLD_ADDS[name]
|
||||
key = _sk(me, 더한줄=adds, 입력값=given)
|
||||
was = _sum(me, key)
|
||||
assert was > 0
|
||||
assert _at(me, path.read, key)["사본"]["사본없음"] == 0
|
||||
_move(monkeypatch, moved)
|
||||
assert _sum(me, key) == was
|
||||
got = _price(me, key)
|
||||
assert moved in got["바뀐"] and got["후"] > was
|
||||
|
||||
|
||||
# ── 가져온 식 · 층 복사 · 재생성 ──────────────────────────────────────
|
||||
def test_imported_ours(world, monkeypatch):
|
||||
"""가져온 식 단가기준 우리 — 이음 노임 바뀌어도 그대로 · 갱신 뒤 반영 · 엑셀 기준 = 엑셀 값."""
|
||||
|
||||
@@ -179,13 +179,17 @@ def test_direct_formula_my_machine(world):
|
||||
whole = _at(me, mym.whole)
|
||||
run = m01.cm.mf.run(whole, DIRECT, {"기계": no}) # 직접 값 식 — 내 기계 원문번호를 받음
|
||||
assert (run["노무비"], run["재료비"], run["경비"]) == (10, 20, 30)
|
||||
line = {"종류": "로직", "로직": DIRECT, "입력값": {"기계": no}, "수량": "2"}
|
||||
name = _at(
|
||||
me, lambda: refs.create("sangeun", {"이름": NAME, "단위": "시간", "더한줄": [line]})["이름"]
|
||||
)
|
||||
body = {
|
||||
"이름": NAME,
|
||||
"단위": "시간",
|
||||
"바탕": {"로직": DIRECT},
|
||||
"입력값": {"기계": no},
|
||||
"더한줄": [],
|
||||
}
|
||||
name = _at(me, lambda: refs.create("sangeun", body)["이름"]) # 855 2-C1 — 옛 더한줄 대신 바탕
|
||||
doc = _at(me, lambda: store.read("sangeun", name)["문서"])
|
||||
got = _at(me, calc.calc_doc, doc, None, False)["기준"]
|
||||
assert (got["노무비"], got["재료비"], got["경비"]) == (20, 40, 60)
|
||||
assert (got["노무비"], got["재료비"], got["경비"]) == (10, 20, 30)
|
||||
|
||||
|
||||
# ⑤ 전력 줄 ────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -211,7 +211,7 @@ def test_old_big_copy_reads_then_slims(world):
|
||||
|
||||
|
||||
def test_save_path_once(world, monkeypatch):
|
||||
"""SK 다시 저장 한 번 — M01 모으기 0 · SK 파일 읽기(셈 쪽) 한 번 · 옛 셈 한 번."""
|
||||
"""SK 다시 저장 한 번 — M01 모으기 0 · SK 파일 읽기(셈 쪽) 한 번 · 옛 셈 0(855 2-C1)."""
|
||||
me = world["personal"]
|
||||
key = _sk(me, 바탕={"로직": DIG_BASE}, 단위="㎥")
|
||||
count = {"모으기": 0, "읽기": 0, "셈": 0}
|
||||
@@ -236,7 +236,7 @@ def test_save_path_once(world, monkeypatch):
|
||||
monkeypatch.setattr(Path, "read_bytes", reading)
|
||||
store.write("sangeun", key, got["판"], got["문서"])
|
||||
# 읽기 = 사본 정함 한 번 + 판 맞춤(쓰기 전) + 새 판(쓰기 뒤)
|
||||
assert count == {"모으기": 0, "읽기": 3, "셈": 1}
|
||||
assert count == {"모으기": 0, "읽기": 3, "셈": 0} # 옛 SK 셈 길 안 돎(855 2-C1)
|
||||
|
||||
|
||||
def test_doc_path_save_keeps_both_slots(world):
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
# ruff: noqa: F811 — 임시 층 fixture(world)를 test_m02_labor_ref 에서 받아 씀
|
||||
"""855-A 지킴 ③ — 단가산출(SK) 셈 답 · 견본 꼴마다 옛 엔진 길(`M02_Doc_Sk.OLD`) 대 지금 길(수식 사본 →
|
||||
문서 계산기) · 지금 길 답의 줄 비목 합(원 버림) = 기준.
|
||||
"""855 지킴 ③ — 단가산출(SK) 셈 답 = 수식 사본 문서 셈 한 길(2-C1) · 견본 꼴마다.
|
||||
|
||||
견본(임시 storage · 개인 층 · M01 은 읽기만): 바탕 로직 · 옛 칸 값(더한줄 로직) · 율 더한줄 · 형제 SK(바탕 참조) ·
|
||||
「따로」(수식 사본을 고쳐 저장) · 가져온 식(엑셀 줄 · 저장 없음).
|
||||
걸음 2-C1(SK 셈 한 길)이 이 시험을 자로 씀 — 「따로」 단언은 지금 사실(줄 = 옛 · 기준 = 새)이고 2-C1 에서 뒤집음.
|
||||
견본(임시 storage · 개인 층 · M01 은 읽기만): 바탕 로직 · 율 바탕 · 형제 SK(바탕 참조로 만듦) ·
|
||||
「따로」(수식 사본을 고쳐 저장) · 가져온 식(엑셀 줄 · 저장 없음) · 옛 칸 고침(더한줄 로직 · 율 더한줄).
|
||||
판정 — 셈 답 기준 = 수식 길 셈(`M02_Doc_Sk_Path` · 화면 줄 쌓기와 같은 계산기) · 줄 비목 합(원 버림 ·
|
||||
합밖 줄 뺌) = 기준 · 줄 수 > 0 · 옛 칸 고침 SK = 못 셈 + 까닭 하나(옛 엔진 안 돎 · 올림 없음).
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -17,6 +17,7 @@ import pytest
|
||||
from M01_MasterData import M01_MasterData_Store as m01
|
||||
from M02_MasterTemplete import M02_Doc_Sk as dsk
|
||||
from M02_MasterTemplete import M02_Doc_Sk_Path as path
|
||||
from M02_MasterTemplete import M02_Labor_Doc as labor
|
||||
from M02_MasterTemplete import M02_MasterTemplete_Store as store
|
||||
from M02_MasterTemplete import M02_Sangeun_Calc as calc
|
||||
from M02_MasterTemplete import M02_Sangeun_Doc as sd
|
||||
@@ -38,18 +39,10 @@ def _manual(monkeypatch):
|
||||
monkeypatch.setattr(renew, "on", lambda: False)
|
||||
|
||||
|
||||
def _run(doc: dict, old: bool) -> dict:
|
||||
def _run(folder, doc: dict) -> dict:
|
||||
whole = m01.loaded()[1]
|
||||
token = dsk.OLD.set(old)
|
||||
try:
|
||||
return calc.run(sd.clean(doc, None, whole), whole)
|
||||
finally:
|
||||
dsk.OLD.reset(token)
|
||||
|
||||
|
||||
def _both(folder, doc) -> tuple[dict, dict]:
|
||||
with store.at(folder):
|
||||
return _run(doc, True), _run(doc, False)
|
||||
return calc.run(sd.clean(doc, None, whole), whole)
|
||||
|
||||
|
||||
def _lines_sum(got: dict) -> dict:
|
||||
@@ -57,7 +50,7 @@ def _lines_sum(got: dict) -> dict:
|
||||
for ln in got.get("줄") or []:
|
||||
for k in COSTS:
|
||||
v = (ln.get("비목") or {}).get(k)
|
||||
total[k] += Decimal(str(v)) if v is not None else 0
|
||||
total[k] += Decimal(str(v)) if v is not None and not ln.get("합밖") else 0
|
||||
return {k: v.quantize(Decimal(1), ROUND_DOWN) for k, v in total.items()}
|
||||
|
||||
|
||||
@@ -65,53 +58,80 @@ def _base(got: dict) -> dict:
|
||||
return {k: Decimal(str(got["기준"][k])).quantize(Decimal(1), ROUND_DOWN) for k in COSTS}
|
||||
|
||||
|
||||
def _same_paths(old: dict, new: dict) -> None:
|
||||
assert old["기준"] is not None and new["기준"] is not None
|
||||
assert {k: Decimal(str(old["기준"][k])) for k in COSTS} == {
|
||||
k: Decimal(str(new["기준"][k])) for k in COSTS
|
||||
}
|
||||
assert _lines_sum(new) == _base(new)
|
||||
def _one_path(got: dict, screen: dict | None = None) -> None:
|
||||
"""한 길 — 문서 셈 · 줄 있음 · 줄 합 = 기준 · (있으면) 수식 길 셈과 같음."""
|
||||
assert got["수식셈"]["셈됨"] is True and got["기준"] is not None
|
||||
assert len(got["줄"]) > 0
|
||||
assert _lines_sum(got) == _base(got)
|
||||
if screen is not None:
|
||||
assert {k: Decimal(str(got["기준"][k])) for k in COSTS} == {
|
||||
k: Decimal(str(screen[k])) for k in COSTS
|
||||
}
|
||||
|
||||
|
||||
def _screen(folder, key: str) -> dict:
|
||||
with store.at(folder):
|
||||
return path.read(key)["셈"]
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"body",
|
||||
[{"바탕": {"로직": FORM}}, {"바탕": {"로직": PCT}}],
|
||||
ids=["바탕", "율_바탕"],
|
||||
)
|
||||
def test_층_SK_한_길_줄_합_기준(world, body):
|
||||
me = world["personal"]
|
||||
key = _sk(me, **copy.deepcopy(body))
|
||||
_one_path(_run(me, _doc(me, key)), _screen(me, key))
|
||||
|
||||
|
||||
def test_옛_엔진_안_돎(world, monkeypatch):
|
||||
"""한 번 셈에 옛 엔진(`run_line`) 부름 0."""
|
||||
me = world["personal"]
|
||||
key = _sk(me, 바탕={"로직": FORM})
|
||||
hits = []
|
||||
real = labor.run_line
|
||||
monkeypatch.setattr(labor, "run_line", lambda *a, **k: hits.append(1) or real(*a, **k))
|
||||
_one_path(_run(me, _doc(me, key)))
|
||||
assert hits == []
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"body",
|
||||
[
|
||||
{"바탕": {"로직": FORM}},
|
||||
{"바탕": {"로직": PCT}},
|
||||
{"바탕": {"로직": FORM}, "더한줄": [ADD]}, # 옛 칸 값(더한줄 로직)
|
||||
{"바탕": {"로직": SUB}, "더한줄": [_rate("인력", 2)], "단위": "주"}, # 율 더한줄
|
||||
],
|
||||
ids=["바탕", "율_바탕", "옛칸_더한줄", "율_더한줄"],
|
||||
ids=["옛칸_더한줄", "율_더한줄"],
|
||||
)
|
||||
def test_층_SK_옛_대_새_같고_줄_합_기준(world, body):
|
||||
def test_옛_칸_고침_SK_못_셈_까닭(world, body):
|
||||
me = world["personal"]
|
||||
key = _sk(me, **copy.deepcopy(body))
|
||||
doc = _doc(me, key)
|
||||
old, new = _both(me, doc)
|
||||
assert "수식셈" in new # 지금 길 = 수식 사본 문서 셈
|
||||
_same_paths(old, new)
|
||||
got = _run(me, _doc(me, key))
|
||||
assert got["기준"] is None and got["줄"] == []
|
||||
assert got["까닭"] == dsk.OLD_WHY
|
||||
assert calc.unit(_doc(me, key), m01.loaded()[1], None, ())["까닭"] == dsk.OLD_WHY
|
||||
|
||||
|
||||
def test_형제_SK_바탕_참조(world):
|
||||
me = world["personal"]
|
||||
first = _sk(me, 바탕={"로직": FORM})
|
||||
second = _sk(me, 바탕={"참조": {"층": "personal", "주인": "7/42", "키": first}})
|
||||
old, new = _both(me, _doc(me, second))
|
||||
_same_paths(old, new)
|
||||
assert new["기준"] == _both(me, _doc(me, first))[1]["기준"]
|
||||
new = _run(me, _doc(me, second))
|
||||
_one_path(new)
|
||||
assert new["기준"] == _run(me, _doc(me, first))["기준"]
|
||||
|
||||
|
||||
def test_가져온_식_옛_대_새(world):
|
||||
old, new = _both(world["personal"], imported._doc())
|
||||
assert "수식셈" in new
|
||||
_same_paths(old, new)
|
||||
def test_가져온_식(world):
|
||||
new = _run(world["personal"], imported._doc())
|
||||
_one_path(new)
|
||||
|
||||
|
||||
def test_따로_SK_지금은_줄_옛_기준_새(world):
|
||||
"""「따로」 = 고친 수식 사본이 정본 — 지금 셈 답은 줄 = 옛 엔진(옛 칸) · 기준 = 문서 계산기라 갈림.
|
||||
2-C1 에서 뒤집을 단언 — 그 뒤엔 `_same_paths` 꼴(줄 합 = 기준)로 바꿈."""
|
||||
def test_따로_SK_줄도_문서_답(world):
|
||||
"""「따로」 = 고친 수식 사본이 정본 — 줄 · 기준 모두 그 문서 셈(2-C1 전에는 줄 = 옛 엔진으로 갈렸음)."""
|
||||
me = world["personal"]
|
||||
key = _sk(me, 바탕={"로직": PCT})
|
||||
plain = _run(me, _doc(me, key))
|
||||
with store.at(me):
|
||||
read = path.read(key)
|
||||
twice = copy.deepcopy(read["문서"])
|
||||
@@ -119,7 +139,7 @@ def test_따로_SK_지금은_줄_옛_기준_새(world):
|
||||
line["수량"] = f"({line.get('수량') or 1}) × 2"
|
||||
saved = path.save(key, {"문서": twice, "판": read["판"]})
|
||||
assert saved["사본"]["따로"] is True
|
||||
old, new = _both(me, _doc(me, key))
|
||||
new = _run(me, _doc(me, key))
|
||||
assert new["수식셈"]["따로"] is True
|
||||
assert _base(new) != _base(old) # 2-C1 에서 뒤집을 단언 — 기준이 옛 길과 다름
|
||||
assert _lines_sum(new) == _base(old) != _base(new) # 2-C1 에서 뒤집을 단언 — 줄 = 옛 길
|
||||
_one_path(new, saved["셈"])
|
||||
assert _base(new) != _base(plain) # 고친 문서 = 새 금액
|
||||
|
||||
@@ -87,21 +87,6 @@ def test_고름_정리_틀리면_400():
|
||||
assert e.value.status == 400
|
||||
|
||||
|
||||
def test_사용자_자재가_로직_자재와_같으면_저장_400():
|
||||
with pytest.raises(store.StoreError) as e:
|
||||
labor.server(_doc(담은로직=[{"로직": NET}], 자재=[{"코드": WIRE}]))
|
||||
assert e.value.status == 400 and WIRE in str(e.value.detail)
|
||||
# 고른 품목도 같음 — 결속선 줄을 다른 품목으로 바꾸면 사용자 자재로 담을 수 있음
|
||||
with pytest.raises(store.StoreError):
|
||||
labor.server(
|
||||
_doc(담은로직=[{"로직": NET, "고름": {"3": "MT000008"}}], 자재=[{"코드": "MT000008"}])
|
||||
)
|
||||
ok = labor.server(
|
||||
_doc(담은로직=[{"로직": NET, "고름": {"4": NET_ITEM}}], 자재=[{"코드": WIRE}])
|
||||
)
|
||||
assert ok["자재"][0]["코드"] == WIRE
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def system(tmp_path, monkeypatch):
|
||||
write_sample_table(tmp_path)
|
||||
@@ -110,15 +95,6 @@ def system(tmp_path, monkeypatch):
|
||||
return tmp_path
|
||||
|
||||
|
||||
def test_저장_뒤_고름_남고_계산값에_반영(system):
|
||||
have = store.read("labor", "rv")
|
||||
sent = {**have["문서"], "담은로직": [{"로직": NET, "고름": {"3": WIRE}, "수량": None}]}
|
||||
store.write("labor", "rv", have["판"], sent)
|
||||
doc = store.read("labor", "rv")["문서"]
|
||||
assert doc["담은로직"][0]["고름"] == {"3": WIRE}
|
||||
assert doc["계산값"]["줄"][0]["재료"][0]["품목"]["키"] == WIRE
|
||||
|
||||
|
||||
def test_단가승격도_고름을_따름_없으면_지금_값():
|
||||
expand = refs.Expand(_whole())
|
||||
plain = expand._promote({"담은로직": [{"로직": NET}], "배": 1})
|
||||
|
||||
Reference in New Issue
Block a user