refactor(855-E 2-E4): M02 로직 줄 옛 엔진 셈 걷음 — Labor_Doc.run_line · pct_extras · logic_mats · layered · drop_apart
- M02_Labor_Copy.line: 프로젝트 층 · `dsk.OLD` 옛 엔진 갈래 걷음(층 셈과 같은 문서 셈) · 재료 줄 `걸림`(재료 조건 · 요소 키 틀 구멍의 입력 이름 = 문서 몫 · 화면 `releaseTied` 가 읽음 — 옛 logic_mats 와 같은 뜻) - M02_Labor_Doc: `run_line` · `pct_extras` · `_pct_base` · `logic_mats` · `layered` · `drop_apart` · `_specs`(mf.inputs_of) 지움 (제품 부르는 곳 0) · 담기 검사 = 새 `_head`(문서 입력 이름 · 재료 금액 줄 차례 — M01 로직 줄 안 읽음) - M02_Doc_Sk: 아무도 안 켜는 `OLD` ContextVar 지움 - 시험: 옛 날 답 자리 = 새 `helper_855_line.run_line`(층 문서 셈 · 재료 직접계산) — 175 · 222_1 · 715_3 · 715_sangeun_store · 727 · 742_1 · 747_1 · 795_1 · 795_2 · m02_labor_layer · m02_labor_logic_mats · m02_labor_ref · 옛 엔진만 붙든 것 걷음: test_149_4 통째(옛 % 덧줄 표기) · 751_3 다섯(run_line 끝수) · 792_3 다시 버림 · 802_4a 옛 길 대조(OLD · run_line) · 855_sk_layers 옛 엔진 안 돎 = master_formula.run 부름 0 으로 · helper_855_old_engine_routes 의 % 덧줄 표기 = 그 도우미 안으로(옛 길 도우미 · 엔진 몸과 같이 지움) - 222_1 시멘트 단위 글 kg → ㎏(문서 단위) - 검증: 관련 82 파일 + 지킴 + 관문 776 통과 · 빌더 --check 같음 · typecheck 0 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -47,7 +47,6 @@ OLD_FIELDS = (
|
||||
"수식고침", "고름", "자재표시", "켜쌓기율",
|
||||
) # fmt: skip
|
||||
_STAMPED = ("원값", "바탕판", "처음수량", "M01판", "끊음") # 서버가 적는 칸 — 옛 칸 대조에서 뺌
|
||||
OLD: ContextVar[bool] = ContextVar("옛길", default=False) # 옛 셈 길(옮기기 전 금액 대조)
|
||||
SAVING: ContextVar[dict | None] = ContextVar("수식길저장", default=None) # {키, 사본} — 수식 길만
|
||||
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ import master_doc_trace as mt # noqa: E402 — scripts 길 = dc(855-F 셈 기
|
||||
|
||||
KEY, JOB, PRICE, REGEN = skc.KEY, skc.JOB, skc.PRICE, skc.REGEN
|
||||
_SC = re.compile(r"^SC-\d{6}$")
|
||||
_HOLE = re.compile(r"\{([^{}]+)\}") # 틀 구멍 `{S_규격}`
|
||||
|
||||
|
||||
def _project() -> bool:
|
||||
@@ -136,14 +137,9 @@ def _formula_of(doc: dict) -> dict | None:
|
||||
|
||||
def line(whole: Any, doc: dict, one: dict) -> dict[str, Any]:
|
||||
"""로직 줄 기준 — 층 셈 = 수식 문서 셈 한 길(줄 옵션 = 문서 규칙 · `dc.line_doc` · 줄 = 문서 답 줄 ·
|
||||
재료 = 셈 기록이 읽은 품목 · 옛 엔진 안 돎 · 855 2-C1 · 2-C5) · 수식 사본 있음 = 사본 · 없음(저장 전 새 문서) =
|
||||
지금 M01 문서(저장 때 사본 찍음) · 프로젝트 층 · B09(단가 책) · `OLD` 시험 = 옛 길(B9 걸음 몫)."""
|
||||
from M02_MasterTemplete import M02_Labor_Doc as labor
|
||||
|
||||
재료 = 셈 기록이 읽은 품목 · 옛 엔진 안 돎 · 855 2-C1 · 2-C5) · 수식 사본 있음 = 사본 · 없음(저장 전 새 문서 ·
|
||||
프로젝트 층) = 지금 M01 문서(저장 때 사본 찍음 · 프로젝트 층 옛 엔진 갈래 걷음 · 855-E 2-E4)."""
|
||||
code, rate, picks = one["로직"], one.get("켜쌓기율"), one.get("고름")
|
||||
if _project() or dsk.OLD.get():
|
||||
got = labor.run_line(whole, code, one.get("입력값"), rate, picks)
|
||||
return labor.drop_apart(got, one.get("자재표시"))
|
||||
copy = _formula_of(doc)
|
||||
if copy and getattr(whole, "_tag", None) == (copy.get("판"), copy.get("단가판")):
|
||||
base, docs = copy["부름"].get(code), dc.docs_of(copy)
|
||||
@@ -167,7 +163,7 @@ def line(whole: Any, doc: dict, one: dict) -> dict[str, Any]:
|
||||
for n, x in enumerate(ans.get("줄") or [])
|
||||
if n not in apart
|
||||
]
|
||||
found = _mats(mats, ans, picks)
|
||||
found = _mats(mats, ans, picks, base)
|
||||
return {"기준": got, "줄": lines, "재료": found, "까닭": None if got else dc.why(ans)}
|
||||
|
||||
|
||||
@@ -183,9 +179,24 @@ def _traced(doc: dict, whole: Any, docs: dict, given: dict, copy: dict) -> dict:
|
||||
}
|
||||
|
||||
|
||||
def _mats(mats: list, ans: dict, picks: Any) -> list[dict[str, Any]]:
|
||||
def _tied(link: dict, doc: dict) -> list[str]:
|
||||
"""재료 조건 · 요소 키 틀 구멍에 든 입력 이름(화면 `releaseTied` 가 그 입력이 바뀌면 고름을 풂 · 문서 몫 ·
|
||||
855-E 2-E4 — 옛 `logic_mats` 의 `걸림`)."""
|
||||
texts = [v for v in (link.get("재료") or {}).values() if isinstance(v, str)]
|
||||
texts += [str(link.get("키") or "")]
|
||||
holes = {h for t in texts for h in _HOLE.findall(t)}
|
||||
ids = {dc.md.var_id(v): v for v in doc.get("변수") or []}
|
||||
names = {
|
||||
str(ids[h].get("열쇠"))
|
||||
for h in holes
|
||||
if h in ids and (ids[h].get("연결") or {}).get("갈래") in ("입력", "선택")
|
||||
}
|
||||
return sorted(names)
|
||||
|
||||
|
||||
def _mats(mats: list, ans: dict, picks: Any, doc: dict) -> list[dict[str, Any]]:
|
||||
"""로직 자재(103-1) — 재료 금액 줄(`_mat_lines` · 단위 = 연결 단위 = 로직 원문 표기)마다
|
||||
셈 기록이 읽은 품목 키 · 수량 · 단가 · 금액(별도계상 · 같은 품목 400 · `_inside` 가 읽음)."""
|
||||
셈 기록이 읽은 품목 키 · 수량 · 단가 · 금액 · 걸린 입력(별도계상 · 같은 품목 400 · `_inside` 가 읽음)."""
|
||||
calls, lines, out = ans.get("부름") or [], ans.get("줄") or [], []
|
||||
for n, line, link in mats:
|
||||
if n >= len(lines):
|
||||
@@ -204,6 +215,7 @@ def _mats(mats: list, ans: dict, picks: Any) -> list[dict[str, Any]]:
|
||||
}
|
||||
| head
|
||||
| {"품목": {"키": key} if key else None, "고름": str(n) in (picks or {})}
|
||||
| {"걸림": _tied(link, doc)}
|
||||
)
|
||||
return out
|
||||
|
||||
|
||||
@@ -7,34 +7,32 @@
|
||||
이름은 구조물 열 이름(따로 안 둠).
|
||||
수량 = `null`(면적산출 알약 칸 값 · 로직 알약 「이름|단위」 · 자재 알약 「자재|MT키」) | `{손: 수}`
|
||||
(손이 칸보다 앞섬) · 같은 로직 두 번 금지 · 입력값 = 그 로직 입력 이름만(빈 값 = 자동값).
|
||||
금액: 기준 = 결과단위 그대로(서버 단독 · M01 엔진) · 반영 = 기준 × 수량 ÷ 배 · 돈 아닌 로직은
|
||||
금액: 기준 = 결과단위 그대로(서버 단독 · 로직 줄 = 수식 문서 셈 `Labor_Copy.line`) · 반영 = 기준 × 수량 ÷ 배 · 돈 아닌 로직은
|
||||
반영 없음 · 자재 기준 단가 = `master_material.element` 기본값 · 자재 줄에 값 열 다섯(`가격`) ·
|
||||
기준단가가 된 칸 이름(`기준칸`)도 실음(43-3).
|
||||
켜쌓기율(85-2) = 표 주문 「골쌓기 기준」 로직만 · % · 없음 = 100 · 그 로직 세부항목 줄 전부 수량 × 율
|
||||
(`layered` · `run_line` 한 곳 → 문서 · 프로젝트 사본 · 서고 같은 함수).
|
||||
(문서 규칙 `M02_Doc_Copy.line_doc` · 문서 · 프로젝트 사본 · 서고 같은 함수).
|
||||
참조 줄(단가승격 · 사전조합 · 50-3) = 기준이 가리킨 문서 1 단위 값(펼침 `M02_Labor_Ref.Expand` · 안 줄
|
||||
수량 = 같은 given 의 안 줄 알약 · 723-1) · 분모 = 그 문서 단위 · 배 1 · 알약 키 = `ref_id` · 같은 참조 두 번 금지.
|
||||
짝(CLAUDE.md 5장 ①): 수량 · 반영 · 합 `settle` ↔ `M02_MasterTemplete_Labor_Calc.ts` —
|
||||
거울 시험 `resources/tester/test_m02_labor_calc_mirror.py`.
|
||||
규격 열(704-4) = 문서 `규격?` 칸 · 열마다 줄 수량(`M02_Labor_Spec` · settle `col`) · 계산값 `규격합`.
|
||||
로직 자재(103-1) = 담은 로직 맨 위 층 호표 재료 줄(`logic_mats` · 줄마다 `재료`) ·
|
||||
로직 자재(103-1) = 담은 로직 문서 재료 금액 줄(`Labor_Copy.line` · 줄마다 `재료`) ·
|
||||
고름 = `{호표 차례: MT키}`(엔진 `choosing` 그대로) · 금액은 로직 재료비 안이라 합 · 알약에 안 더함(보기만) · 사용자 자재와
|
||||
같은 품목 두 번은 [저장] 때 400.
|
||||
승격(134-1) = 로직 줄 「단가승격」 표시(`true` 만 · 없음 = 단가산출) · 금액 무관 · B09 호표 몫.
|
||||
자재 세 칸(148-4) = `MARKS` 허용 값만(그 밖 · 빈 것 버림 · 별도계상만 금액에 닿음) — 사용자 자재 = 줄 덧칸 ·
|
||||
로직 자재 = 로직 줄 `자재표시 {호표 차례: {세 칸}}`(차례가 재료 줄인 것만 · 틀리면 버림) ·
|
||||
빈 칸 = 읽을 때 `MARK_DEFAULT`(`mark_of` · 저장은 비움 · 옛 「일반」 = 버림 → 사급 · 162-1).
|
||||
별도계상(222-1) = 그 자재 금액은 기준 · 합에서 빠지고 로직 `줄` 에서 지움(`drop_apart` · `settle` ·
|
||||
별도계상(222-1) = 그 자재 금액은 기준 · 합에서 빠지고 로직 `줄` 에서 지움(문서 `합밖` · `settle` ·
|
||||
짝 `Labor_Calc.ts`) · `재료` · `자재`(자재목록 · B08 수량)엔 남음.
|
||||
고정 줄(705-1) = `{고정: {이름 · 규격 · 단위 · 단가 · 이음 · 출처}}` — 숫자 그대로 · 셈 `M02_Labor_Fixed`.
|
||||
% 덧줄(149-4) = 식 「X * Y / 100」 덧줄에 덧칸 `율`(Y) · `규격`(「노무비의 %」 등 · `pct_extras`) — 표기만 ·
|
||||
단위 · 수량 · 금액 그대로(「식 · 1」) · 화면이 율 · % 로 그림 · M01 시험계산 표도 이 함수.
|
||||
옛 엔진 줄 셈(`run_line` · `pct_extras` · `logic_mats` · `layered` · `drop_apart`) = 855-E 2-E4 에서 걷음.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import re
|
||||
from decimal import Decimal, InvalidOperation
|
||||
from typing import Any
|
||||
|
||||
@@ -62,7 +60,6 @@ MARKS = {
|
||||
}
|
||||
MARK_DEFAULT = {"자재구분": "사급", "별도계상": "별도계상", "운반비": "포함"} # 읽을 때 기본(162-1)
|
||||
ALIAS_MAX = 40 # 별칭(44-6) 글자 수 상한 — 화면 칸과 같음
|
||||
_BRACE = re.compile(r"\{([^{}]+)\}") # 품목 조건의 {입력}
|
||||
|
||||
|
||||
def _bad(text: str) -> store.StoreError:
|
||||
@@ -80,11 +77,26 @@ def _number(raw: Any) -> Decimal | None:
|
||||
return got if got.is_finite() else None
|
||||
|
||||
|
||||
def _specs(logic: dict) -> list[dict]:
|
||||
"""로직 입력 꼴 — 흐름 로직은 「설계 때 정할 것」."""
|
||||
if isinstance(logic.get("흐름"), dict):
|
||||
return mf.inputs_of(logic)
|
||||
return list(logic.get("입력") or [])
|
||||
def _head(whole: Any, code: str) -> dict:
|
||||
"""담을 로직 머리(855-E 2-E4 · M01 로직 줄 안 읽음) — 입력 이름 = 문서 입력 · 선택 열쇠 · 호표 = 문서
|
||||
금액 줄(재료 줄 표지 · 차례 = 호표 차례) · 문서 없음 = FormulaError."""
|
||||
from M02_MasterTemplete import M02_Doc_Copy as dc
|
||||
from M02_MasterTemplete import M02_Item_Prices as prices
|
||||
|
||||
doc = dc.doc_of(whole, code)
|
||||
if doc is None:
|
||||
raise mf.FormulaError(f"없는 로직 「{code}」")
|
||||
mats = {n for n, _, _ in prices._mat_lines(doc)}
|
||||
return {
|
||||
"키": code,
|
||||
"이름": doc.get("이름"),
|
||||
"결과단위": doc.get("결과단위"),
|
||||
"입력": [{"이름": n} for n in prices.doc_inputs(doc)],
|
||||
"호표": [
|
||||
{"이름": x.get("이름"), "종류": "재료" if n in mats else ""}
|
||||
for n, x in enumerate(doc.get("금액") or [])
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
def _qty(value: Any, where: str) -> dict | None:
|
||||
@@ -136,13 +148,13 @@ def clean(doc: Any) -> dict[str, Any]:
|
||||
continue
|
||||
code = str(one.get("로직") or "")
|
||||
try:
|
||||
logic = whole.logic(code)
|
||||
logic = _head(whole, code)
|
||||
except mf.FormulaError as e:
|
||||
raise _bad(f"{where} · {e}") from e
|
||||
if code in seen:
|
||||
raise _bad(f"{where} · 같은 로직을 두 번 담음 「{code}」")
|
||||
seen.add(code)
|
||||
names = {str(spec.get("이름")) for spec in _specs(logic)}
|
||||
names = {str(x["이름"]) for x in logic["입력"]}
|
||||
given = one.get("입력값") or {}
|
||||
if not isinstance(given, dict):
|
||||
raise _bad(f"{where} · 입력값이 묶음 아님")
|
||||
@@ -254,23 +266,6 @@ def apart(one: Any) -> bool:
|
||||
return mark_of(one, "별도계상") == "별도계상"
|
||||
|
||||
|
||||
def drop_apart(got: dict[str, Any], shown: Any) -> dict[str, Any]:
|
||||
"""로직 줄 답(`run_line`)에서 별도계상 로직 자재 빼기(222-1) — 그 재료 줄 금액을 기준에서 빼고
|
||||
`줄`(일위대가 상세)에서 지움 · `재료`(자재목록 · 세 칸 고침)는 그대로.
|
||||
ponytail: 「재료비의 %」 덧줄은 엔진 값 그대로(뺀 재료 몫 안 고침) — 그런 로직이 별도계상을 쓰면 엔진에 넘김."""
|
||||
shown = shown if isinstance(shown, dict) else {}
|
||||
lines = got.get("줄") or []
|
||||
out = {
|
||||
n
|
||||
for m in got.get("재료") or []
|
||||
if (n := m["차례"]) < len(lines) and apart(shown.get(str(n)))
|
||||
}
|
||||
if not out or not got.get("기준"):
|
||||
return got
|
||||
got = mcut.plain(got, out) # 기준 = 남은 줄 합(751-3 끝수 · 791-1 셈법)
|
||||
return {**got, "기준": _json(got["기준"])}
|
||||
|
||||
|
||||
def _mat_marks(value: Any, logic: dict) -> dict[str, dict[str, str]] | None:
|
||||
"""로직 자재 세 칸(148-4) `{호표 차례: {세 칸}}` — 맨 위 층 재료 줄 차례 · 허용 값만 ·
|
||||
빈 것 = None."""
|
||||
@@ -297,28 +292,6 @@ def _rate(value: Any, code: str, where: str) -> int | float | None:
|
||||
return int(rate) if rate == rate.to_integral_value() else float(rate)
|
||||
|
||||
|
||||
def layered(got: dict[str, Any], rate: Any) -> dict[str, Any]:
|
||||
"""엔진 답 × 켜쌓기율(85-2) — 세부항목 줄 전부 수량 · 금액 · 비목 · 비목 합 · 계 · 단가는 그대로."""
|
||||
if rate in (None, 100) or "결과" in got:
|
||||
return got
|
||||
times = Decimal(str(rate)) / 100
|
||||
|
||||
def mul(value: Any) -> Any:
|
||||
return value * times if isinstance(value, Decimal) else value
|
||||
|
||||
lines = [
|
||||
{
|
||||
**x,
|
||||
"수량": mul(x.get("수량")),
|
||||
"금액": mul(x.get("금액")),
|
||||
"비목": {k: mul(v) for k, v in (x.get("비목") or {}).items()},
|
||||
}
|
||||
for x in got.get("줄") or []
|
||||
]
|
||||
sums = {k: mul(got[k]) for k in COSTS}
|
||||
return {**got, "줄": lines, **sums, "계": sum(sums.values())}
|
||||
|
||||
|
||||
def from_combo(key: str) -> dict[str, Any]:
|
||||
"""옛 일위대가 조합(마스터 UA · 회사 UC · 개인 UP) → 일위대가 문서 몸 —
|
||||
담은로직 · 단위 복사 · 입력값 {} · 수량 null · 자재 [] · `본뜬` = 그 조합(층 · 주인 · 키).
|
||||
@@ -542,110 +515,6 @@ def calc(
|
||||
return settle(_json({"줄": lines, "자재": mats}), doc, have)
|
||||
|
||||
|
||||
def run_line(
|
||||
whole: Any, code: str, given: Any, rate: Any = None, picks: Any = None, raw: bool = False
|
||||
) -> dict[str, Any]:
|
||||
"""로직 한 줄 기준(서버 단독 · M01 엔진 · 빈 입력 = 자동값 · × 켜쌓기율 · 고른 재료 = 엔진
|
||||
`choosing`) — `{기준, 줄, 재료, 까닭}` · 돈 아닌 로직은 `{결과, 기준: None}`(반영 없음) ·
|
||||
끝수 = 품셈 1-2-2(`master_cut` · 751-3) · `raw` = 엔진 날 값(B09 = 제 단가로 버림)."""
|
||||
try:
|
||||
logic = whole.logic(code)
|
||||
auto = {k: v for k, v in m01.mau.values(whole, logic).items() if v is not None}
|
||||
with mf.mp.choosing(picks):
|
||||
got = layered(mf.run(whole, code, {**auto, **m01._dec(given or {})}), rate)
|
||||
got = got if raw else mcut.engine(whole, code, got) # 율 곱 → 끝수(문서 셈 · 844-1)
|
||||
except (mf.FormulaError, ArithmeticError, KeyError, TypeError, ValueError) as e:
|
||||
return {"기준": None, "까닭": str(e) or type(e).__name__}
|
||||
if "결과" in got:
|
||||
return {"결과": got["결과"], "기준": None, "까닭": None}
|
||||
# 「줄」 = 그 로직 재료 · 노무 · 경비 줄(줄 누름 상세 · 50-4)
|
||||
money = {k: got[k] for k in (*COSTS, "계")}
|
||||
mats = logic_mats(whole, logic, got["줄"], picks)
|
||||
lines = pct_extras(whole, logic, got["줄"], got.get("중간") or {})
|
||||
out = {"기준": money, "줄": lines, "재료": mats, "까닭": None, **mcut.kept(got)}
|
||||
return out
|
||||
|
||||
|
||||
def pct_extras(whole: Any, logic: dict, lines: list[dict], env: dict) -> list[dict]:
|
||||
"""% 덧줄(149-4) — 덧줄 식이 「X * Y / 100」 이면 그 엔진 줄(호표 수 뒤 같은 차례)에 덧칸
|
||||
`율` = Y(엔진 마지막 env 로 셈) · `규격` = X 이름(「노무비의 %」 · 인력 줄 합 「인건비의 %」 ·
|
||||
`줄.'이름'` · 중간값 「이름의 %」 · 그 밖 복합 = 빈 글). 다른 덧줄 · 흐름 로직 · 못 셈 = 그대로."""
|
||||
if isinstance(logic.get("흐름"), dict):
|
||||
return lines
|
||||
out, head = list(lines), len(logic.get("호표") or [])
|
||||
for n, add in enumerate(logic.get("덧줄") or []):
|
||||
if head + n >= len(out):
|
||||
break
|
||||
try:
|
||||
node = mf.parse(add.get("식") or "")
|
||||
except mf.FormulaError:
|
||||
continue
|
||||
if not (
|
||||
node[0] == "bin"
|
||||
and node[1] == "/"
|
||||
and node[3] == ("num", Decimal(100))
|
||||
and node[2][0] == "bin"
|
||||
and node[2][1] == "*"
|
||||
):
|
||||
continue # 금액 식(기계손료 등) · 조건부 % = 「식」 그대로
|
||||
base, part = node[2][2], node[2][3]
|
||||
try:
|
||||
rate = mf.evaluate(part, dict(env), whole)
|
||||
except (mf.FormulaError, ArithmeticError, KeyError, TypeError, ValueError):
|
||||
continue
|
||||
if isinstance(rate, Decimal):
|
||||
out[head + n] = {**out[head + n], "율": rate, "규격": _pct_base(base)}
|
||||
return out
|
||||
|
||||
|
||||
def _pct_base(node: tuple) -> str:
|
||||
"""% 덧줄 밑수 이름 — B09 대가(`B09_Estimation_Labor_Source._base_of`)와 같은 말."""
|
||||
if node[0] == "name":
|
||||
return f"{node[1]}의 %" # 노무비 · 재료비 · 경비 · 중간값 이름
|
||||
if node[0] == "field" and node[1] == ("name", "줄"):
|
||||
return f"{node[2]}의 %"
|
||||
parts = list(mf.walk(node))
|
||||
if any(x[0] == "ref" and str(x[1]).startswith("LB") for x in parts) and not any(
|
||||
x[0] == "name" and x[1] in COSTS for x in parts
|
||||
):
|
||||
return "인건비의 %"
|
||||
return ""
|
||||
|
||||
|
||||
def logic_mats(whole: Any, logic: dict, lines: list[dict], picks: Any) -> list[dict[str, Any]]:
|
||||
"""로직 자재(103-1) — 맨 위 층 호표 재료 줄마다 엔진 답 줄(같은 차례) 그대로 · 금액은 로직
|
||||
재료비 안(합에 안 더함) · `걸림` = 품목 조건에 든 입력 이름(중간값이면 입력 전부 — 그 입력이
|
||||
바뀌면 화면이 고름을 풂 · 짝 `M02_Labor_LogicMats_Model.ts` `releaseTied`)."""
|
||||
if isinstance(logic.get("흐름"), dict):
|
||||
return [] # 흐름 로직 재료 자리는 입력 이름 — 이번엔 안 보임
|
||||
names = {str(spec.get("이름")) for spec in _specs(logic)}
|
||||
out = []
|
||||
for n, item in enumerate(logic.get("호표") or []):
|
||||
if item.get("종류") != "재료" or n >= len(lines):
|
||||
continue
|
||||
line, goods = lines[n], lines[n].get("품목")
|
||||
try:
|
||||
row = (whole.get(goods["키"]) if goods else None) or {}
|
||||
except mf.FormulaError:
|
||||
row = {}
|
||||
cond = item.get("요소")
|
||||
texts = cond.values() if isinstance(cond, dict) else [cond]
|
||||
tied = {w for t in texts if isinstance(t, str) for w in _BRACE.findall(t)}
|
||||
out.append(
|
||||
{
|
||||
"차례": n,
|
||||
"이름": item.get("이름") or "",
|
||||
"단위": item.get("단위") or "",
|
||||
**{k: line.get(k) for k in ("수량", "단가", "금액", "까닭")},
|
||||
"품목": goods,
|
||||
"가격": {slot: row.get(slot) for slot in mm.SLOTS},
|
||||
"고름": str(n) in (picks or {}),
|
||||
"걸림": sorted(tied if tied <= names else names) if tied else [],
|
||||
}
|
||||
)
|
||||
return out
|
||||
|
||||
|
||||
def ref_line(ref: dict, got: dict[str, Any]) -> dict[str, Any]:
|
||||
"""참조 줄 계산 답 — 분모 = 가리킨 문서 단위 · 배 1 · `안` = 사전조합 안 줄(한 층)."""
|
||||
line = {"참조": ref, "이름": got.get("이름"), "알약": refs.ref_id(ref), "분모": got.get("단위")}
|
||||
|
||||
Reference in New Issue
Block a user