Files
Aislo/resources/master_data/scripts/master_cut.py
T
eomsangdonandClaude Opus 5.5 dd8759edc5 refactor(855-E 2-E4 ㉯-4 ⑥): 옛 계산 엔진 몸 지움 — master_formula 무리 아홉 · 계산기 하나
- git rm(부르는 곳 0 다시 셈 — import · import_module 글 · getattr 별칭 cm.mf · store.mau · mtx 포함): master_formula · master_formula_check · master_formula_sum · master_text · master_text_item · master_sheet_line · master_gate · master_auto · master_copy(−2,625 줄)
- master_cut = down · row · sums 만(일위대가 반영 끝수 · TS 짝) — engine · settle · plain · _line · _sub · kept(손님 0) 지움 · 바탕 = master_base
- master_bundle = BUNDLES · BY_ITEM · BY_KIND · is_machine(M01 목록 묶음) — called · bundle · tag 지움 · master_combo = 조합 칸만(run 지움)
- check_master · check_master_body · compare_estx: import master_formula → master_base(바탕 이름만) · compare_estx 기계 · 일위대가 대조 = 수식 문서 셈(옛 mf.run · 로직 줄 고르기 덧붙임 걷음 · 일위대가 28 · 기계 207 건 그대로 나옴)
- M01 Store: 다시 내보냄 mau · mtx 지움(부르는 곳 0) · cm.mf = master_base
- 죽은 주석: master_material · master_pick · master_base · Item_Prices · San_Emit · check_master
- test_855_sk_layers: 옛 엔진 안 돎 = 엔진 모듈 없음 확인
- 검증: 관련 146 파일 1,135 통과 · test_855_golden 전수 지문 같음 · 모든 제품 · scripts 모듈 읽기 깨짐 0 · typecheck 0 · 8008 health 200 · 로그 오류 0 · 서버 길 469 → 469

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 16:02:20 +09:00

48 lines
1.9 KiB
Python

# -*- coding: utf-8 -*-
"""M01 · M02 셈 끝수(PLAN 751-3) — 품셈 1-2-2 금액의 단위표준
(일위대가 금액란 0.1 원 · 계금 1 원 · 미만버림).
규칙 = B09 일위대가 · 산근과 같은 함수 `rounddown`(`B09_Estimation_Calc_Base` · 엑셀 ROUNDDOWN):
반영 한 줄 = 비목마다 ROUNDDOWN(·, 1) · 계 = 셋 합 · 비목 합 = ROUNDDOWN(Σ 줄, 0) · 계 = 셋 합.
쓰는 곳 = 일위대가 반영(`M02_Labor_Doc` · `M02_Labor_Fixed` · `M02_Labor_Expand` · TS 짝
`M02_MasterTemplete_Labor_Calc.ts` · 거울 시험 `test_m02_labor_calc_mirror.py`).
옛 엔진 답 끝수(`engine` · `settle` · `plain` · 줄 `자리`)는 855-E 2-E4 에서 걷음 — 단가산출 끝수 = 수식 문서
계산기(`master_doc_calc`).
"""
from __future__ import annotations
import sys
from decimal import Decimal
from pathlib import Path
import master_base as mb
_ROOT = str(Path(__file__).resolve().parents[3])
if _ROOT not in sys.path: # 스크립트 · 시험 길 — 서버는 이미 뿌리에서 돎
sys.path.insert(0, _ROOT)
from B09_Estimation.B09_Estimation_Calc_Base import rounddown # noqa: E402
COSTS = mb.COST_ITEMS
def down(value, places: int):
"""ROUNDDOWN(value, places) — Decimal 로 · 빈 값 = None."""
if value is None:
return None
return Decimal(str(rounddown(float(value), places)))
def row(money: dict | None) -> dict | None:
"""반영 한 줄 `{노무비, 재료비, 경비, 계}` — 비목마다 0.1 원 버림 · 계 = 셋 합."""
if money is None:
return None
cut = {k: down(money.get(k) or 0, 1) for k in COSTS}
return {**cut, "계": sum(cut.values(), Decimal(0))}
def sums(rows: list) -> dict:
"""비목 합 — 비목마다 ROUNDDOWN(Σ 줄, 0) · 계 = 셋 합(빈 줄 = 뺌)."""
cut = {k: down(sum((Decimal(str(r[k])) for r in rows if r), Decimal(0)), 0) for k in COSTS}
return {**cut, "계": sum(cut.values(), Decimal(0))}