Files
Aislo/B09_Estimation/B09_Estimation_Supply.py
T
eomsangdonandClaude Opus 5.5 11d348492e refactor(855-F B9-5): 사본 단가산출 굳힘 걷음 — 굳힌 로직 줄(GX9) 대신 M02 문서 + 수식 따로 사본 · B09 대가가 문서 셈
- M02_Item_Sangeun: freeze = SK 마다 지금 M02 셈 사본(Doc_Sk.copy_of · 덮음 반영)을 수식에 따로 · 굳힘 표지로 굳힘 ·
  원본 · 처음 · 덮음바탕(M01 따라옴 기록) 뺌 · 옛 GX9 키 · 굳힌줄 · 정체 · 원본 · SC 굳힌 덮개 줄 지움
  · bundle_keys = SK 셈이 읽는 바탕 로직 · 부름 문서 키 · 값 사본 자원 키 · 가져온 식 줄
- M02_Item_Source: 단가.json 에 로직_단가산출.json(GX9) 없음 · SK 줄은 bundle_keys 로 모음
- B09 Labor_Source.sangeun: SK 대가 블록 = 수식 사본 문서 답(줄 이름 · 단위 · 종류 · 자원 키 · 하위 부름) ·
  셈법(792-4)은 줄이 기초 줄과 맞을 때만 · cid 열쇠 = SK 이름표 · 줄 덮개(패치) = M02 처럼 못 셈
- B09 Linked: sk_answer(사본 SK 문서 셈 · 가져온 식 = 단가기준) · 수요 키 = 셈 기록
- B09 Refresh: 바뀐 SK = SK 문서 · 수식 사본 대조 · Supply.sk_money: 배 = 바탕 줄(바탕 없음 = 1)
- 골든 test_855_b09_golden 다시 뜸 — daega_inputs · 수요 두 갈래만(calc_user · 산근 · 미리보기 · B08 같음):
  SK 블록 origin · cid 열쇠(GX9 → SK 이름표) · 재료 단위 = 문서 표기(kg → ㎏) ·
  따로 고친 SK 줄 수량 = M02 문서(0.018 → 0.036 · 옛 굳힘은 고친 문서를 못 봄) ·
  옛 칸(율 더한줄) SK = M02 처럼 못 셈 → 그 SK 자원 키 둘(LB000038 · EQ000153) 빠짐
- 시험: test_719_1 · 719_2 견본을 수식 사본 있는 SK(M02 에서 고친 문서)로 · 단언을 새 사본 꼴로 ·
  719_2 옛 칸 견본 셋 지움(단가 덮개 · SC 더한줄 펼침 · 내 자료집 둘 — 옛 칸 SK 만들기 = 2-C1 셈 은퇴) ·
  test_778_4 옛 칸 율 더한줄 SK 블록 하나 지움 · test_792_3 ⑤ · test_793_2 = 새 사본 꼴(793_2 우리 단가 = 사본 굳힘)
- 검증: 관련 + 핵심 672 — 통과 671 · test_848_1 ㉦ 하나 = sub4 2-D 굳힘 표지 읽기 두 줄 뒤 통과(브레인 정함) ·
  사본 칸(골든 견본) SK 굳힌줄 · GX9 10 → 0 · 수식 따로 2 → 9 · typecheck 0 · 빌더 --check 같음 · 서버 뜸 로그 오류 0

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

94 lines
5.0 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.
"""B09 자재 관급 · 별도 표시 · 사본 단가 목록(PLAN 841-1) — 서버 단독 · 순수 함수.
자재 표시 = M02 자재표시를 대비표 기본 표시로 · 노무비 · 중기목록 = 엔진 단가 나열(`price_lists`).
M02 일위대가 · 단가산출 셈은 재료 줄을 자재표시(자재구분 관급 · 별도계상 — 빈 칸 = 별도계상)로
합에서 뺌(`M02_Labor_Doc.apart`) → B09 도 같은 표시로 대가 · 산근 안 0 원 · 4 자재대 · 관급자재대로
(`B09_Estimation_Calc_Labor._apart` · `Sangeun.Solver._aside` · `Calc_Bill` 자재대 수량 = `aside_qty`).
대비표 표시 = 사용자 › 이 기본 · 사용자 「사급」 = 기본을 끔.
"""
from __future__ import annotations
from typing import Any
from M02_MasterTemplete import M02_Labor_Doc as labor_doc
PARTS = ("labor", "material", "expense")
def supply_mark(one: Any) -> str | None:
"""M02 자재표시(841-1) → 대비표 기본 표시 — 관급 · 별도(별도계상 · M02 기본) · None(직접계산)."""
if labor_doc.mark_of(one, "자재구분") == "관급":
return "관급"
return "별도" if labor_doc.apart(one) else None
def material_marks(blocks: list[dict[str, Any]]) -> dict[str, str | None]:
"""대가 블록 재료 줄 M02 표시를 자재 키마다 하나로(841-1) — 관급 하나라도 = 관급 · 별도 하나라도 =
별도 · 모두 직접계산 = None. ponytail: 키 하나 = 표시 하나(줄마다 다르면 별도 쪽 · 자재대에 한 번)."""
out: dict[str, str | None] = {}
for block in blocks:
for line in block.get("lines") or []:
if line.get("kind") != "material" or not line.get("key") or "mark" not in line:
continue
key, was = str(line["key"]), out.get(str(line["key"]))
out[key] = "관급" if "관급" in (was, line["mark"]) else was or line["mark"]
return out
def supply_defaults(inputs: dict[str, Any], user: dict[str, Any]) -> Any:
"""841-1 대비표 기본 표시 = M02 자재표시(대가 재료 줄 · 없으면 M02 기본 별도계상) — 로직 자재
(B08 줄 밖 · 유가 밖) 입력 줄에 `supply` 를 얹음 → 자재 키 → 관급 · 별도(사용자 표시 › 기본)."""
marks = material_marks((inputs.get("daega") or {}).get("blocks") or [])
for row in inputs.get("materials") or []:
if row.get("origin") == "M01" and "supply" not in row and marks.get(row["key"], "별도"):
row["supply"] = marks.get(row["key"], "별도")
mine = user.get("materials") or {}
default = {row["key"]: row.get("supply") for row in inputs.get("materials") or []}
def supply(key: Any) -> str | None:
got = (mine.get(key) or {}).get("supply")
return None if got == "사급" else got or default.get(key, marks.get(key, "별도"))
return supply
def price_lists(blocks: list[dict[str, Any]], sg_blocks: list[dict[str, Any]]) -> tuple[list, list]:
"""노무비목록표 · 중기목록표 입력(841-1) — 대가 입력 줄 `own` · 산근 줄 `price` = M02 엔진 단가
(사본 값) 나열 · 다시 안 셈 · 수량 있는 줄만. ponytail: 키 하나 = 처음 본 단가(사본마다 시점이 달라도)."""
labor: dict[str, dict] = {}
machine: dict[str, dict] = {}
for block in [*blocks, *sg_blocks]:
for ln in block.get("lines") or []:
kind = ln.get("kind")
key = ln.get("key") or (ln.get("ref") or {}).get("key")
if kind not in ("labor", "machine") or not key or not ln.get("qty"):
continue
price = ln.get("own") or ln.get("price") or {}
name, spec = str(ln.get("name") or ""), str(ln.get("spec") or "")
name = name.removesuffix(spec).strip() if spec else name # 「굴착기 0.7㎥」 + 규격 겹침
head = {"key": key, "name": name, "spec": spec}
if kind == "labor" and price.get("labor") is not None:
labor.setdefault(key, {**head, "unit": "인", "price": price["labor"]})
elif kind == "machine" and None not in [price.get(p) for p in PARTS]:
machine.setdefault(key, {**head, **{p: price[p] for p in PARTS}})
return list(labor.values()), list(machine.values())
def sk_money(doc: dict, whole: Any, expand: Any, rid: str) -> dict[str, float] | None:
"""단가산출 블록 합(841-1) = M02 가 일위대가 안 SK 를 셀 때 쓰는 1 단위 셈(`M02_Sangeun_Calc.unit` ·
수식 문서 · 기계 덮음 · 별도계상까지) × 배(블록 = 바탕 기준단위) — 못 셈 = None(줄 합 그대로)."""
from M02_MasterTemplete import M02_Sangeun_Calc as calc
try:
got = calc.unit(doc, whole, expand, (rid,)).get("기준")
per = float(calc.ratio_of(doc, calc._row_of(doc, whole), whole)) # 바탕 없음 = 1
except Exception: # noqa: BLE001 — M02 셈이 못 돌면 줄 합(옛 길) 그대로
return None
if not got:
return None
return {
p: float(got[k]) * per for p, k in zip(PARTS, ("노무비", "재료비", "경비"), strict=True)
}