Files
Aislo/resources/tester/test_145_1_b09_sangeun.py
T
eomsangdonandClaude Opus 5.5 5d8d9a4fd3 test(841-1): B09 = M02 값 — 산근 · 대가 · 고정 줄 셈 다듬기 · 낡은 시험 정리 — C 걸음
코드
- 고정 줄 단가 = M02_Labor_Fixed.line(사본 묶음 · 이은 노임 · 자재 = 묶음 값) — B09 단가 책으로 다시 안 덮음
- 대가 · 산근 고친 칸 = 품만 실제로(단가 칸 덮기 줄 남던 흠 · 품 고친 뒤 줄 금액 다시 셈 흠 py · ts 짝)
- 산근 글 = 엔진 단가 셈 그대로 · 별도계상 재료 줄 끝 「· 별도계상 = 0.0」 · 계 줄 = 블록 합
- 노무비 · 중기목록 이름에서 규격 겹침 뗌 · TS 바탕 셈 이름 PARTS → MACHINE_PARTS(짝 시험이 TS 를 이어 붙일 때 겹침)

시험(고친 까닭 = 단가 원천이 B09 책 → M02 엔진 · 노임 · 기계 덮개 · 단가 고친 칸 · 중기사용료 걷음)
- 144 바탕 · 뼈대: 운전사 · 중기사용료 · 경비 · 덮개 시험 걷음 → 노무 · 중기 나열 · 사급 표시 · 자재만 책
- 145-1 · 145-2 · 155 · 157-1 · 166-2 · 166-6 · 719-3 · 719-4 · 723-4 · 778-4 · 792-3: 줄 단가 = own(엔진) · 산근 = Solver() · collect 새 부름 꼴
- 702 · 705-1 · 719-2: 단가 칸 덮개 = 안 읽음 · 고정 줄 = M02 셈(노임 새 판 따라가기 시험 걷음)
- 203-1 · 296 · 703-3 · 795-4: 단가 책 = 자재 줄로
- 707 · 707-6 · 707-7: 단가표 불러오기 = 자재만 · 거창 이은 안내판 줄 = M02 사본 셈(엑셀 −50,000)
- 201-1: 환율 · 중기사용료 표 걷음 · b09 저장 속도: 산근 앞 풀이 그대로(단가 표 같음 견줌 걷음)
- 대상 113 파일 764 통과 · 25 실패 = 원래 실패(formatMoney · formatPrice 없음 · 단위 글 ㎜ · sec · 719-1 · 796-2e · 717-4 · 721 · 311 · 243 · 246)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 16:57:01 +09:00

145 lines
7.5 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.
"""145-1 B09 단가산출근거 · 목록표 — 단가산출 줄 → 산근 블록 · 엑셀 검산 · 같은 산근 하나 · 빈 표.
- 산근 = 155-4 갈래(사용자 뜻 · 145 정함 뒤집음) — 일위대가 로직 줄 중 단가산출 줄(승격 아님) +
사전조합 안 단가산출 줄 · 일위대가화(승격 · 옛 SP) 줄 자체는 산근 아님(대가 블록)
- 줄 단가 = M02 엔진 줄 금액 ÷ 수량(841-1 · 사본 단가 묶음 · B09 단가 책 안 읽음) · 줄 금액 =
ROUNDDOWN(단가 × 1 단위 수량, 1) · 총계 = 비목마다 ROUNDDOWN 0 — 엑셀 단가산출근거 제 6호표(뒷채움)
줄 값 · 총계 8,328(6,878 · 538 · 912)과 같음 · 산근 합 = M02 엔진 기준
- 관급 · 별도계상 재료(supply) = 산근 안 0원 · `aside` 에 금액(841-1)
- 같은 로직 + 같은 입력값 = 산근 하나(쓰는 구조물이 늘어남) · 입력이 다르면 둘 · 번호 = 첫 등장
- 사본 없으면 빈 표 + 「연결 없음」 · 조합 밖 토공 · 운반 산근 안내 한 줄 · 작업량 Q = ROUND 2
"""
import asyncio
import json
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_Router as router_mod # noqa: E402
from B09_Estimation import B09_Estimation_Sangeun as sg # noqa: E402
from M02_MasterTemplete import M02_Item_Prices as item_prices # noqa: E402
from M02_MasterTemplete import M02_Labor_Doc as labor_doc # noqa: E402
STONE = "GF000219" # 돌쌓기 메쌓기(인력) — 석공 0.195 · 보통인부 0.156 / ㎡
NET = "GC000337" # 낙석방지망 — 노무 · 크레인(중기) · 자재 셋
NET_IN = {"구분": "기계식", "방지망": "포켓식", "지역": "전국평균", "크레인": "2104-0010"}
SP_REF = {"층": "system", "주인": None, "키": "SP-000001"}
SC_REF = {"층": "system", "주인": None, "키": "SC-000001"}
def _snapshot(folder: Path, rows, values=None, copies=None) -> Path:
folder.mkdir(parents=True, exist_ok=True)
labor = {
"줄": {"종류": "일위대가", "담은로직": rows},
**({"참조사본": copies} if copies else {}),
}
files = {
"단가.json": item_prices.to_json(item_prices.collect([STONE, NET])),
"일위대가.json": labor,
"입력값.json": {k: {n: {"값": v} for n, v in d.items()} for k, d in (values or {}).items()},
}
for name, data in files.items():
(folder / name).write_text(json.dumps(data, ensure_ascii=False), encoding="utf-8")
return folder
def _engine(folder: Path, code: str, given=None) -> dict:
"""M02 엔진 기준(사본 단가 묶음 · 날 값 줄 · 끝수 뒤 기준)."""
whole = item_prices.load_prices(json.loads((folder / "단가.json").read_text(encoding="utf-8")))
return labor_doc.run_line(whole, code, given or {})
def test_단가산출_줄만_산근_블록_단가는_M02_엔진(tmp_path):
a = _snapshot(tmp_path / "a", [{"로직": STONE}, {"로직": NET, "승격": True}], {NET: NET_IN})
got = sg.collect([("s1", a)])
(block,) = got["sg"]
assert (block["no"], block["logic"], block["unit"]) == (1, STONE, "㎡")
lines = block["lines"]
assert [(ln["kind"], ln["ref"]["key"], ln["qty"]) for ln in lines] == [
("labor", "LB000033", 0.195),
("labor", "LB000002", 0.156),
]
want = _engine(a, STONE)["기준"]
assert block["labor"] == float(want["노무비"]) and block["sum"] == float(want["계"])
assert block["material"] == 0 and block["expense"] == 0 and block["why"] is None
assert got["sg_list"][0]["key"] == block["key"] and got["sg_gaps"] == []
assert sg.price_of(got, block["key"]) == {
"no": 1, "labor": block["labor"], "material": 0.0, "expense": 0.0, "sum": block["sum"],
} # fmt: skip
def test_중기_자재_단가_M02_엔진_별도계상은_0원(tmp_path):
a = _snapshot(tmp_path / "a", [{"로직": NET}], {NET: NET_IN})
(block,) = sg.collect([("s1", a)])["sg"]
kinds = [ln["kind"] for ln in block["lines"]]
assert kinds == ["labor", "labor", "machine", "material", "material", "material"]
want = _engine(a, NET, NET_IN)["기준"]
assert [block[p] for p in (*sg.PARTS, "sum")] == [
float(want[k]) for k in ("노무비", "재료비", "경비", "계")
]
(apart,) = sg.collect([("s1", a)], supply=lambda key: "별도")["sg"]
mats = [ln for ln in apart["lines"] if ln["kind"] == "material"]
assert all(ln["material"] == 0 and ln["aside"] for ln in mats if ln["qty"])
assert apart["material"] < block["material"] and apart["labor"] == block["labor"]
def test_엑셀_6호표_뒷채움_검산():
"""단가산출근거 C285 = 8,328(6,878 · 538 · 912) — 보통인부 0.018 × 165,545 · 굴삭기(0.2m3) 0.07 ×
중기목록표 55,700 · 7,695 · 13,041(줄 2,979.8 · 3,899.0 · 538.6 · 912.8 · 계 8,330.2 → 비목마다 버림)."""
zero = dict.fromkeys(sg.PARTS, 0.0)
labor = {**zero, "labor": sg._money(165545, 0.018)}
machine = {p: sg._money(v, 0.07) for p, v in zip(sg.PARTS, (55700, 7695, 13041))}
assert labor["labor"] == 2979.8
assert (machine["labor"], machine["material"], machine["expense"]) == (3899.0, 538.6, 912.8)
assert sg.block_totals([labor, machine]) == {
"labor": 6878, "material": 538, "expense": 912, "sum": 8328,
} # fmt: skip
assert sg.block_totals([labor, {**machine, "material": None}])["sum"] is None # 빈칸 = 빈칸
def test_같은_로직_같은_입력은_하나_다르면_둘_사전조합_안_줄도_같은_산근(tmp_path):
a = _snapshot(tmp_path / "a", [{"로직": NET}], {NET: NET_IN})
b = _snapshot(tmp_path / "b", [{"로직": NET}], {NET: {**NET_IN, "": ""}})
other = {**NET_IN, "방지망": "비포켓식"}
c = _snapshot(tmp_path / "c", [{"로직": NET}], {NET: other})
sc = {"이름": "사전조합", "담은로직": [{"로직": NET, "입력값": NET_IN}]}
sp = {"담은로직": [{"로직": NET, "입력값": other}], "배": 1} # 옛 SP = 일위대가화 = 산근 아님
d = _snapshot(
tmp_path / "d",
[{"로직": "", "참조": SC_REF}, {"로직": "", "참조": SP_REF}, {"로직": STONE}],
copies={"참조|system||SC-000001": sc, "참조|system||SP-000001": sp},
)
got = sg.collect([("s1", a), ("s2", b), ("s3", c), ("s4", d)])
blocks = got["sg"]
assert [(x["no"], x["logic"], x["uses"]) for x in blocks] == [
(
1,
NET,
["s1", "s2", "s4"],
), # 빈 입력 칸은 무시 · 사전조합 안 줄(같은 로직 · 입력) = 같은 산근
(2, NET, ["s3"]),
(3, STONE, ["s4"]),
]
assert blocks[0]["key"] == sg.sangeun_key(NET, {**NET_IN, "x": None}, 100, {})
assert blocks[0]["key"] != sg.sangeun_key(NET, NET_IN, 90) # 켜쌓기율이 다르면 다른 산근
def test_사본_없으면_빈_표_연결_없음(tmp_path, monkeypatch):
got = sg.collect([("s1", tmp_path / "없음")])
assert got["sg"] == [] and got["sg_list"] == [] and got["sg_gaps"] == []
assert got["sg_notes"] == [sg.NO_SOURCE, sg.EMPTY]
plain = _snapshot(tmp_path / "p", [{"로직": STONE, "승격": True}]) # 일위대가화만 = 빈 표
assert sg.collect([("s1", plain)])["sg"] == []
async def fake_materials(_project_id):
return {}
monkeypatch.setattr(router_mod, "material_sheets", fake_materials)
sheets = asyncio.run(router_mod.payload("p", tmp_path))["sheets"]
assert sheets["sg"] == [] and sheets["sg_list"] == []
assert sg.EMPTY in sheets["sg_notes"] and sg.NO_SOURCE in sheets["sg_notes"]