Files
Aislo/resources/tester/test_155_5_sangeun_text.py
T
eomsangdonandClaude Opus 5.5 cd7878e8b6 test(855-E L3 미리): 산근 산출근거 글 엑셀 견본을 수식 문서로
L3 둘째 박자(sub7 9847aa3d6)가 「M01 문서 없는 키 = 로직 줄 변환」 받이를 걷어 깨질 견본(브레인 넘김 여덟 가운데 넷).
- test_155_5 엑셀 견본 = GF000218 수식 문서를 고쳐 색인이 실어 옴(금액 줄 둘 수량 · 작업량 Q 변수 + 식 줄 「21.594」 · 공구손료 % 줄 「노무비 × 3%」 · 견본 두 줄이 쓰는 변수만) — 옛 = 로직 줄 호표 · 중간 · 덧줄 고친 값 사본
- 뜻 그대로: 머리 · 중기 세 줄 · Q 공식 줄 ROUND 2 「21.594 = 21.59」 · 값 넣은 수량식 「(1 ÷ 21.59 × 2)」 · % 덧줄 밑수 · 켜쌓기율 꼬리
지금 판 · 없는 판 둘 다 6 통과

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 13:18:30 +09:00

146 lines
6.4 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""155-5 · 855-F B9-4 산근 산출근거 글(`B09_Estimation_Sangeun_Text.render`) — 풀이 블록 + 문서 셈 답.
- 머리 = 「이름 / 단위」 · 「출처 적용」 · 입력 「이름 : 값 단위」(801-5 단위)
- 줄 = 「이름 : 단가 원/단위 × 수량 단위 = 금액 원」(화면 줄 쌓기 산출근거 꼴 · `master_doc_text`) ·
중기 노 · 재 · 경 세 줄 · 결과단위 배 「÷ 배」 · 켜쌓기율 「× 율 %」 · 글 속 금액 = 풀이 블록 줄 값
- 작업량 Q = ROUND 2 공식 줄 「Q = 21.594 = 21.59」 · 수량 식 = 값 넣은 식 「(1 ÷ 21.59 × 2)」
- % 덧줄 = 「공구손료 (노무비의 %) : 밑수 × 3 % = 금액 원」 · 계 = 블록 합
"""
import copy
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
if str(ROOT) not in sys.path:
sys.path.insert(0, str(ROOT))
from B09_Estimation import B09_Estimation_Sangeun as sg # noqa: E402
from M02_MasterTemplete import M02_Item_Prices as item_prices # noqa: E402
BASE = "GF000218" # 기초다짐 및 뒷채움(기계) — 보통인부 + 굴착기 0.2㎥ 문서 금액 줄
GIVEN = {"규격": 150, "지역": "전국평균", "보정작업": "해당 없음"}
KEEP = ("규격", "지역", "보정작업", "w_보통인부", "P_굴착기무한궤") # 엑셀 견본 두 줄이 쓰는 변수
TOOL = {"이름": "공구손료", "단위": "식", "비목": "경비", "단가": "노무비 × 3%", "묶음": "공구손료"}
def _copy(codes, edit=None):
"""사본 셈 색인(855-E 2-E4) = 수식 문서 묶음 + 그 문서가 잇는 자원 · 표 줄(`Item_Bundle.load`) ·
`edit(문서)` = 견본 — 고친 문서를 색인이 실어 옴(855 L3 · 로직 줄 · 변환기 안 읽음)."""
from M02_MasterTemplete import M02_Doc_Copy as dc
from M02_MasterTemplete import M02_Item_Bundle as item_bundle
docs = dc.closure(item_prices.master()[1], codes)
if edit:
docs[codes[0]] = copy.deepcopy(docs[codes[0]])
edit(docs[codes[0]])
return item_bundle.load(item_prices.to_json(item_bundle.collect(docs)), docs)
def _whole(edit=None):
"""사본 셈 색인 — `edit(문서)` 로 GF000218 을 엑셀 견본 꼴로 바꿈(금액 줄 수량 · 식 · % 줄)."""
return _copy([BASE], edit)
def _excel(qty_labor: str, qty_eq: str, mids=(), extras=()):
"""엑셀 견본 = 보통인부 · 굴착기 두 줄(수량 고침) + 작업량 식(변수 · 식 줄) + % 줄."""
def edit(doc):
labor, eq = doc["금액"][0], doc["금액"][1]
doc["금액"] = [{**labor, "수량": qty_labor}, {**eq, "수량": qty_eq}, *extras]
doc["식"] = [{"기호": n, "식": f} for n, f in mids]
doc["변수"] = [v for v in doc["변수"] if v["열쇠"] in KEEP] + [
{
"열쇠": n,
"기호": n,
"아래": "",
"위": "",
"이름": n,
"단위": "㎥/hr",
"연결": {"갈래": "식"},
}
for n, _ in mids
]
return edit
def _block(edit, code=BASE, given=GIVEN, **src):
return sg.Solver().add(
_whole(edit) if edit else _whole(), {"code": code, "given": given, **src}, "s1"
)
def _texts(block) -> list[str]:
return [t for ln in block["lines"] for t in ln.get("text") or []]
def _foot(block) -> str:
parts = " + ".join(
f"{n} {block[p]:,.0f}" for p, n in zip(sg.PARTS, ("노무비", "재료비", "경비"))
)
return f"계 : {parts} = {block['sum']:,.0f}"
def test_머리_줄_중기_세_줄_계():
block = _block(_excel("0.018", "0.07"))
assert block["head"][:3] == [
"기초다짐 및 뒷채움(기계) / ㎥",
"산림품셈 13-3-2 적용",
"규격 : 150 ㎜",
]
labor, eq = block["lines"]
assert labor["text"] == [
f"보통인부 : {labor['price']['labor']:,.0f} 원/인 × 0.018 인 = {labor['labor']:,.1f} 원"
]
assert [t.split(" : ")[0] for t in eq["text"]] == [
f"굴착기(무한궤도) 0.2㎥ {n}" for n in ("노무비", "재료비", "경비")
]
assert [t.endswith(f"= {eq[p]:,.1f} 원") for t, p in zip(eq["text"], sg.PARTS)] == [True] * 3
assert block["foot"] == _foot(block)
def test_작업량_Q_공식_줄_값_넣은_수량식():
block = _block(_excel("0", "1 ÷ Q × 2", mids=[("Q", "21.594")]))
assert "Q = 21.594 = 21.59 ㎥/hr" in block["head"] # ROUND(식, 2) 뒤 쓰임
assert all("× (1 ÷ 21.59 × 2) 시간 = " in t for t in block["lines"][1]["text"])
def test_퍼센트_덧줄_노무비의_퍼센트():
block = _block(_excel("0.018", "0.07", extras=[TOOL]))
pct = block["lines"][-1]
base = sum(ln["labor"] for ln in block["lines"][:-1]) # 밑수 = 인력 + 중기 노무비
assert pct["text"] == [f"공구손료 (노무비의 %) : {base:,.1f} × 3 % = {pct['expense']:,.1f} 원"]
assert block["foot"] == _foot(block)
def test_켜쌓기율_꼬리():
block = _block(_excel("0.018", "0.07"), rate=90)
assert block["lines"][0]["text"][0].startswith("보통인부 : ")
assert "× 0.018 인 × 90 % = " in block["lines"][0]["text"][0]
assert block["foot"] == _foot(block)
def test_글_속_금액은_산근_풀이_값과_같음():
for code, given in ((BASE, GIVEN), ("GF000288", {})): # 중기 · 노무 · % 덧줄 · 배 1,000
whole = _copy([code])
block = sg.Solver().add(whole, {"code": code, "given": given}, "s1")
assert block["foot"] == _foot(block), code
for ln in block["lines"]:
if ln["kind"] in ("labor", "material"):
part = next(iter(ln["price"]))
assert ln["text"][0].endswith(f"= {ln[part]:,.1f} 원"), (code, ln["text"])
if sg._unit(whole.logic(code))[1] != 1:
assert all(" ÷ 1,000" in t for t in _texts(block)[:2]), code
def test_자재_자리표시_키는_실제_키로():
"""「MO:휘발유:{지역}」 자리표시 = 대비표 키(MO…) · 수집량 공식 줄 · 「× (6.5 × 0.125)」 · % 덧줄."""
whole = _copy(["GF000062"])
block = sg.Solver().add(whole, {"code": "GF000062", "given": {}}, "s1")
fuel = next(ln for ln in block["lines"] if ln["name"].startswith("휘발유"))
assert fuel["ref"]["key"].startswith("MO") and ":" not in fuel["ref"]["key"]
assert "일수 = 1 ÷ 수집량 = 1 ÷ 8 = 0.125 일/㎥" in block["head"]
assert "× (6.5 × 0.125) ℓ = " in fuel["text"][0]
assert block["lines"][3]["text"][0].startswith("잡품 (재료비의 %) : ")