refactor(855-E 2-E4): B09 블록 줄 꼴 읽기를 master_formula_sum 대신 B09 안에
- B09_Estimation_Labor_Rule: `ms`(items · uses · _cover · skipped · ADDR · STEP — 줄 꼴만 읽는 작은 함수 · 셈 몸 없음)를 이 파일로 옮김 · master_formula_sum import 0 · B09_Estimation_Sangeun_Sum 도 이것을 씀 - 검증: 묶음 ① 커밋 글과 같음(B09 골든 · 792_3 · 실제 B09 해시 같음) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -22,13 +22,62 @@ from typing import Any
|
||||
from M01_MasterData import M01_MasterData_Store as _m01 # noqa: F401 — scripts 길을 둠
|
||||
|
||||
md = importlib.import_module("master_doc") # 식 꼴 읽기 = 새 계산기 파서(855-F B9-3)
|
||||
ms = importlib.import_module("master_formula_sum")
|
||||
|
||||
PART = {"노무비": "labor", "재료비": "material", "경비": "expense"}
|
||||
FLAGS = ("place", "out") # 블록 줄 덧칸 — 단가산출 블록이 줄을 바꿔도 이어 받음
|
||||
Refs = list[tuple[int, str | None]] # (줄 차례, 비목 | None = 줄 전체)
|
||||
|
||||
|
||||
# ── 블록 줄 꼴 읽기(옛 `master_formula_sum` 의 줄 꼴 함수 · 셈 아님 · 855-E 2-E4 에서 옮김) ──────────
|
||||
class ms: # noqa: N801 — 부르는 쪽 이름(`ms.items` …) 그대로
|
||||
"""줄 꼴(`Doc_Run.row` — 호표 · 덧줄 · 단계)만 읽는 작은 함수 — 엔진 셈 몸 없음."""
|
||||
|
||||
ROW_KEYS = ("단계", "끝전", "조정") # 블록 칸
|
||||
LINE_KEYS = ("번지", "합밖", "자리") # 호표 · 덧줄 칸
|
||||
ADDR, STEP = "번지", "단계" # 덧줄 식 이름 — `번지.A01.재료비` · `단계.'소계'.계`
|
||||
|
||||
@staticmethod
|
||||
def items(row: dict) -> list[dict]:
|
||||
"""줄 차례 = 호표 하나씩 뒤 덧줄 하나씩."""
|
||||
return [*row.get("호표", []), *row.get("덧줄", [])]
|
||||
|
||||
@staticmethod
|
||||
def uses(row: dict) -> bool:
|
||||
"""새 의미(번지 · 단계 · 끝전 · 조정 · 합밖 · 줄 자리)를 쓰는 블록."""
|
||||
lines = ms.items(row)
|
||||
return any(k in row for k in ms.ROW_KEYS) or any(
|
||||
k in x for x in lines for k in ms.LINE_KEYS
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def _cover(row: dict) -> list[tuple[dict, set]]:
|
||||
"""단계마다 (단계, 담은 줄 차례) — 단 1 = 제 `줄` · 단 k = 제 `줄` + 아직 안 담긴 아래 단 단계 ·
|
||||
제외 단계는 위로 안 올라감."""
|
||||
where = {x.get("이름"): i for i, x in enumerate(ms.items(row)) if x.get("이름")}
|
||||
out, open_ = [], []
|
||||
for st in row.get(ms.STEP) or []:
|
||||
level = int(st.get("단") or 1)
|
||||
mine = {where[n] for n in st.get("줄") or [] if n in where}
|
||||
keep = []
|
||||
for low, got in open_:
|
||||
if low < level:
|
||||
mine |= got
|
||||
else:
|
||||
keep.append((low, got))
|
||||
open_ = keep if st.get("제외") else [*keep, (level, mine)]
|
||||
out.append((st, mine))
|
||||
return out
|
||||
|
||||
@staticmethod
|
||||
def skipped(row: dict) -> set:
|
||||
"""비목 합에서 빼는 줄 차례 — `합밖` 줄(번지엔 쌓음) · 제외 단계가 담은 줄."""
|
||||
out = {i for i, x in enumerate(ms.items(row)) if x.get("합밖")}
|
||||
for st, mine in ms._cover(row):
|
||||
if st.get("제외"):
|
||||
out |= mine
|
||||
return out
|
||||
|
||||
|
||||
def _f(value: Any) -> float | None:
|
||||
try:
|
||||
return None if value is None else float(value)
|
||||
|
||||
@@ -16,7 +16,6 @@ from B09_Estimation.B09_Estimation_Calc_Base import rounddown, total
|
||||
from M01_MasterData import M01_MasterData_Store as _m01 # noqa: F401 — scripts 길을 둠
|
||||
|
||||
mc = importlib.import_module("master_doc_calc")
|
||||
ms = importlib.import_module("master_formula_sum")
|
||||
|
||||
PARTS = ("labor", "material", "expense")
|
||||
COST_PART = {"노무비": "labor", "재료비": "material", "경비": "expense"}
|
||||
@@ -61,6 +60,8 @@ def doc_totals(answer: Any, lines: list[dict]) -> dict[str, float | None]:
|
||||
def doc_shown(row: dict) -> dict[str, int]:
|
||||
"""중간값 표시 자리 {이름: 자리} — `shown` 과 같은 뜻(`표시` · 옛 로직 작업량 Q = ROUND 2 · 엑셀 자리) ·
|
||||
문서 셈에 그 식 줄을 반올림으로 씌워 셈(`Doc_Run.solve` `shown`)."""
|
||||
from B09_Estimation.B09_Estimation_Labor_Rule import ms # 줄 꼴 읽기(855-E 2-E4)
|
||||
|
||||
new = ms.uses(row)
|
||||
out: dict[str, int] = {}
|
||||
for step in row.get("중간", []):
|
||||
|
||||
Reference in New Issue
Block a user