feat(M02): 일위대가 자재 줄 2행 · 가격 다섯(43-3) — M01 값 열 다섯(물가자료 · 유통물가 · 물가정보 · 거래가격 · 관급) · 기준단가 칸 강조

- 서버 calc 답 자재 줄에 가격 · 기준칸(마스터 · 회사 · 개인 층 calc · 프로젝트 복사본 calc 같은 함수 material_price) · 원본 자료는 읽기만
- 자재목록 표 = 코드 · 이름 · 규격 · 수량산출(위 1 단위 / 아래 지금 수량) · 단위 · 가격 다섯(빈 것 「—」) · 기준단가 / 반영 금액
- 화면 판정 시나리오 resources/tester/ui_checks/43-3_자재가격.js

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NPJGtfXo6GMbcpiboQC4uK
This commit is contained in:
2026-10-05 00:33:28 +09:00
co-authored by Claude Opus 5.5
parent 31a753b7fd
commit bc1314e94c
8 changed files with 145 additions and 41 deletions
+28 -12
View File
@@ -5,7 +5,8 @@
수량 = `null`(면적산출 알약 칸 값 · 로직 알약 「이름|단위」 · 자재 알약 「자재|MT키」) | `{손: 수}`
(손이 칸보다 앞섬) · 같은 로직 두 번 금지 · 입력값 = 그 로직 입력 이름만(빈 값 = 자동값).
금액: 기준 = 결과단위 그대로(서버 단독 · M01 엔진) · 반영 = 기준 × 수량 ÷ 배 · 돈 아닌 로직은
반영 없음 · 자재 기준 단가 = `master_material.element` 기본값.
반영 없음 · 자재 기준 단가 = `master_material.element` 기본값 · 자재 줄에 값 열 다섯(`가격`) ·
기준단가가 된 칸 이름(`기준칸`)도 실음(43-3).
짝(CLAUDE.md 5장 ①): 수량 · 반영 · 합 `settle` ↔ `M02_MasterTemplete_Labor_Calc.ts` —
거울 시험 `resources/tester/test_m02_labor_calc_mirror.py`.
"""
@@ -247,6 +248,24 @@ def settle(result: dict, doc: dict, given: dict[str, Any]) -> dict[str, Any]:
return _json({"줄": lines, "자재": mats, "기준합": _sum(bases), "반영합": _sum(reflects)})
def material_price(master: Any, code: str, unit: str | None) -> dict[str, Any]:
"""자재 한 줄 기준 — `{기준단가, 가격: {값 열 다섯}, 기준칸, 까닭}` · 기준단가 = `mm.element`
(값 열 가운데 낮은 값) · 기준칸 = 그 값이 나온 열 이름(출처 `키.열`) · 원본 자료는 읽기만."""
row = master.get(code) or {}
prices = {slot: row.get(slot) for slot in mm.SLOTS}
try:
price, source = mm.element(master, code, {}, unit or None)
except mf.FormulaError as e:
return {"기준단가": None, "가격": prices, "기준칸": None, "까닭": str(e)}
slot = str(source).split(".")[-1] if source else None
return {
"기준단가": price,
"가격": prices,
"기준칸": slot if slot in mm.SLOTS else None,
"까닭": None if price is not None else "단가 없음",
}
def calc(doc: dict, given: dict[str, Any] | None = None) -> dict[str, Any]:
"""`doc` = 정리한 문서 · `given` = {알약 키: 값}(없으면 지금 층 면적산출 파일에서) —
줄마다 기준(서버 단독 · M01 엔진) → `settle`. 못 도는 줄은 까닭만(통째로 멈추지 않음)."""
@@ -277,17 +296,14 @@ def calc(doc: dict, given: dict[str, Any] | None = None) -> dict[str, Any]:
lines.append({**line, "결과": got["결과"], "기준": None, "까닭": None})
continue
lines.append({**line, "기준": {k: got[k] for k in (*COSTS, "계")}, "까닭": None})
mats = []
for one in doc.get("자재") or []:
try:
price, _ = mm.element(whole, one["코드"], {}, one.get("단위") or None)
except mf.FormulaError as e:
price, why = None, str(e)
else:
why = None if price is not None else "단가 없음"
mats.append(
{"코드": one["코드"], "알약": material_key(one["코드"]), "기준단가": price, "까닭": why}
)
mats = [
{
"코드": one["코드"],
"알약": material_key(one["코드"]),
**material_price(whole, one["코드"], one.get("단위")),
}
for one in doc.get("자재") or []
]
have = _area_of(doc.get("열")) if given is None else given
return settle(_json({"줄": lines, "자재": mats}), doc, have)