Files
Aislo/resources/tester/test_155_b09_tabs.py
T
eomsangdonandClaude Opus 5.5 5dd72cfa38 feat(b09): 산근 텍스트 수식 칸 · 일위대가화 글 · % 덧줄 표기(155-5)
- 산근 블록마다 서버가 글 지음(sub4 render_sangeun_text · B09 굳힌 단가) — head · 줄마다 text · foot(계)
- 단가산출근거 탭 = 엑셀 꼴(공종 · 산출내역 · 합계 · 노무비 · 재료비 · 경비 · 비고) · 제목 · 총계 굵게
- 중기 = 노 · 재 · 경 세 줄(서버 글 줄 수와 같게)
- % 덧줄 = 규격 「노무비의 %」 · 수량 = 율 · 단위 %(sub3 pct_extras)
- 산근목록 안내 글 = 단가산출 줄 · 사전조합 안 줄 · 일위대가화 줄의 하위 로직(「단가승격」 글 지움)
- 시험: 145-1 화면 글 대조 새 갈래 · test_155_b09_sources · test_155_b09_tabs 덧붙임

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015KYZ2HWWdUwZWYnn3tQz7X
2026-10-09 19:26:40 +09:00

105 lines
4.4 KiB
Python

"""155 B09 탭 화면 꼴 — 일위대가표 줄 꼴(155-2) · 단가산출근거 텍스트 수식 칸(155-5).
`B09_Estimation_UI_Tabs.ts` + `B09_Estimation_UI_Tabs_Labor.ts` 를 Node(타입 지움)로 돌려
견본 블록 하나(머리 · 품셈 인용 · 줄 둘 · 합계)의 표 줄 글 · 줄 꼴을 판정.
"""
import json
import re
import subprocess
from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
IMPORTS = re.compile(r"^import[^;]*;\n", re.MULTILINE)
BLOCK = {
"id": "DG1",
"no": 1,
"name": "찰쌓기",
"spec": "",
"unit": "m2",
"kind": "품셈",
"cite": "건설표준품셈 7-1-2",
"lines": [
{"kind": "labor", "key": "L00005", "name": "석공", "qty": 0.072, "unit": "인",
"price": 258935, "amount": 18643.3, "ref_no": "노무3",
"prices": {"labor": 258935, "material": None, "expense": None},
"amounts": {"labor": 18643.3, "material": None, "expense": None}},
{"kind": "sangeun", "key": "SG1", "name": "뒷채움", "qty": 0.5, "unit": "m3",
"price": 8328, "amount": 4164, "ref_no": "산근 1호표",
"prices": {"labor": 6878, "material": 538, "expense": 912},
"amounts": {"labor": 3439, "material": 269, "expense": 456}},
],
"sum": 22807, "labor": 22082, "material": 269, "expense": 456,
} # fmt: skip
def _node(js_body, tab="UI_Tabs_Labor"):
src = "".join(
IMPORTS.sub("", (ROOT / "B09_Estimation" / f"B09_Estimation_{n}.ts").read_text("utf-8"))
for n in ("UI_Tabs", tab)
)
result = subprocess.run(
["node", "--experimental-strip-types", "--no-warnings",
"--input-type=module-typescript", "-e", src + js_body],
capture_output=True, text=True, encoding="utf-8", timeout=60,
) # fmt: skip
assert result.returncode == 0, result.stderr
return json.loads(result.stdout)
def test_155_2_일위대가표_제목_굵게_하위_ㄴ():
out = _node(
f"\nconst t = buildDaegaBlocks({{ sheets: {{ daega_blocks: [{json.dumps(BLOCK)}] }} }});"
"\nconsole.log(JSON.stringify({ names: t.rows.map((r) => r.name),"
" cls: t.rows.map((_, i) => t.rowClass(i) ?? null) }));"
)
assert out["names"] == [
"제 1 호표 찰쌓기",
" ㄴ 건설표준품셈 7-1-2",
" ㄴ 석공",
" ㄴ 뒷채움",
" 합 계",
]
assert out["cls"] == ["is-title", None, None, None, "is-title"]
SG = {
"key": "SG:A", "no": 1, "name": "뒷채움", "unit": "m3", "spec": "규격=150",
"head": ["뒷채움 / m3", "산림품셈 13-3-2 적용", "규격 : 150 mm"],
"lines": [
{"kind": "labor", "name": "보통인부", "ref": {"tab": "labor", "key": "LB2"}, "why": None,
"labor": 2979.8, "material": 0.0, "expense": 0.0,
"text": ["보통인부 : 165,545 * 0.018 = 2,979.8"]},
{"kind": "machine", "name": "굴착기", "ref": {"tab": "machine", "key": "EQ1"}, "why": None,
"labor": 3899.0, "material": 538.6, "expense": 912.8,
"text": ["굴착기 노무비 : 55,700 * 0.07 = 3,899.0", "굴착기 재료비 : 7,695 * 0.07 = 538.6",
"굴착기 경비 : 13,041 * 0.07 = 912.8"]},
],
"labor": 6878, "material": 538, "expense": 912, "sum": 8328, "why": None,
"foot": "계 : 노무비 6,878 + 재료비 538 + 경비 912 = 8,328",
} # fmt: skip
def test_155_5_단가산출근거_엑셀_꼴_칸():
out = _node(
f"\nconst t = buildSg({{ sheets: {{ sg: [{json.dumps(SG, ensure_ascii=False)}] }} }});"
"\nconsole.log(JSON.stringify({ rows: t.rows, cols: t.columns.map((c) => c.key),"
" cls: t.rows.map((_, i) => t.rowClass(i) ?? null) }));",
"UI_Tabs_Sangeun",
)
assert out["cols"] == ["kind", "text", "sum", "labor", "material", "expense", "note"]
rows = out["rows"]
assert [(r.get("kind"), r["text"]) for r in rows] == [
("제 1 호표", "뒷채움 / m3"),
(None, " 산림품셈 13-3-2 적용"),
(None, " 규격 : 150 mm"),
("노무", " 보통인부 : 165,545 * 0.018 = 2,979.8"),
("중기", " 굴착기 노무비 : 55,700 * 0.07 = 3,899.0"),
("", " 굴착기 재료비 : 7,695 * 0.07 = 538.6"),
("", " 굴착기 경비 : 13,041 * 0.07 = 912.8"),
("총 계", "계 : 노무비 6,878 + 재료비 538 + 경비 912 = 8,328"),
]
assert [r.get("sum") for r in rows[3:7]] == [2979.8, 3899.0, 538.6, 912.8]
assert out["cls"] == ["is-title"] + [None] * 6 + ["is-title"]