Merge remote-tracking branches 'origin/main_laptop_1' and 'origin/sub_laptop_1' into sub_laptop_5
This commit is contained in:
@@ -22,6 +22,7 @@ import { showToast } from "@ui/ui_template_elements";
|
||||
import { PART_OF, projectItems, withCopyValues } from "@ui/ui_template_item_picker_project";
|
||||
import type { EditView } from "@ui/ui_template_item_picker_edit";
|
||||
import type { LaborDoc } from "../M02_MasterTemplete/M02_MasterTemplete_Labor_Api";
|
||||
import { lineId } from "../M02_MasterTemplete/M02_MasterTemplete_Labor_Calc";
|
||||
import type { ValueDoc } from "../M02_MasterTemplete/M02_Labor_Values_Model";
|
||||
import type { EditKind, ItemCardsHandle } from "../M02_MasterTemplete/M02_MasterTemplete_ItemCards";
|
||||
import type { ItemSource } from "../M02_MasterTemplete/M02_MasterTemplete_ItemSource";
|
||||
@@ -79,6 +80,9 @@ function sourceOf(projectId: string, folder: string): ItemSource {
|
||||
return { 문서: withCopyValues(labor.줄, values, picks) };
|
||||
},
|
||||
calc: () => items.calcLabor(folder),
|
||||
// 856-3 단가산출 줄 = 사본의 굳힌 SK 문서(`참조사본`) — 줄 쌓기 보기만
|
||||
sk: async (ref) =>
|
||||
((await items.read(folder, "일위대가")) as { 참조사본?: Record<string, Record<string, unknown>> } | null)?.참조사본?.[lineId({ 참조: ref }) ?? ""] ?? null, // prettier-ignore
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -40,7 +40,6 @@ from B08_Quantity.B08_Quantity_Haul_Cycle import FILL, cycle_inputs, cycle_time
|
||||
from B09_Estimation.B09_Estimation_Store import folder as store_folder
|
||||
from B09_Estimation.B09_Estimation_Store import ref_rows
|
||||
from common_util.common_util_json import atomic_write_json
|
||||
from M01_MasterData import M01_MasterData_Store as m01
|
||||
from M02_MasterTemplete import M02_Doc_B09 as doc_b09
|
||||
from M02_MasterTemplete import M02_Labor_Ref as refs
|
||||
from M02_MasterTemplete.M02_Item_Snapshot import (
|
||||
@@ -159,10 +158,12 @@ def refresh_copy(project_root: str | Path, one: tuple) -> None:
|
||||
|
||||
# ── 운반 값 사본(263-2) ────────────────────────────────────────────────
|
||||
def _logic(code: str) -> dict[str, Any]:
|
||||
try:
|
||||
return dict(m01.loaded()[1].logic(code) or {})
|
||||
except Exception: # noqa: BLE001 — 없는 로직 = 입력 없음
|
||||
return {}
|
||||
"""M01 기초 이름 · 입력 꼴 — 지금 수식 문서(855-F B9-6) · 없는 기초 = 입력 없음."""
|
||||
from M02_MasterTemplete import M02_Doc_Copy as dc
|
||||
from M02_MasterTemplete import M02_Item_Prices as item_prices
|
||||
|
||||
doc = dc.folder().get(str(code))
|
||||
return {"이름": doc.get("이름"), "입력": item_prices.doc_specs(doc)} if doc else {}
|
||||
|
||||
|
||||
def _line_at(labor: Any, lid: str) -> dict[str, Any] | None:
|
||||
|
||||
@@ -144,7 +144,7 @@ class Answer:
|
||||
out.append({**x, "단위": items[n].get("단위") or x["단위"]})
|
||||
else:
|
||||
pct = self.pct(n)
|
||||
out.append({**x, "율": pct[0]} if pct else x)
|
||||
out.append({**x, "율": pct[0], "밑": pct[1]} if pct else x)
|
||||
return out
|
||||
|
||||
def pct(self, n: int) -> tuple[Decimal, str] | None:
|
||||
@@ -209,6 +209,69 @@ class Answer:
|
||||
return mc._settle(self.doc, self.rules, sums)
|
||||
|
||||
|
||||
def doc(whole: Any, docs: dict[str, dict], code: str) -> dict | None:
|
||||
"""키 하나의 수식 문서 — `docs`(사본 수식 문서) › 그 자리 닫힌 묶음(받은 묶음에 더함) ·
|
||||
없음 = None."""
|
||||
code = str(code)
|
||||
if code not in docs:
|
||||
docs.update(dc.closure(whole, [code], docs))
|
||||
return docs.get(code)
|
||||
|
||||
|
||||
def row_of(doc: dict) -> dict[str, Any]:
|
||||
"""수식 문서 → B09 풀이가 읽는 줄 꼴(855-F B9-6 · 옛 로직 줄 대신 문서에서) — 이름 ·
|
||||
결과단위 · 출처 · 입력(변수 열쇠) · 중간(식 변수 열쇠) · 호표 = 수량 있는 금액 줄(종류 = 단가
|
||||
연결: 단가산출 → 로직 「로직(키)」 · 노임 요소 → 인력 · 그 밖 → 재료) · 덧줄 = 수량 없는 금액 줄
|
||||
(식 = 단가 글 · 늘 끝) · 단계."""
|
||||
ids = {md.var_id(v): v for v in doc.get("변수") or []}
|
||||
heads: list[dict] = []
|
||||
extras: list[dict] = []
|
||||
for line in doc.get("금액") or []:
|
||||
keep = {k: line[k] for k in ("이름", "단위", "비목", "자리", "번지", "합밖") if k in line}
|
||||
if "수량" not in line:
|
||||
extras.append({**keep, "식": str(line.get("단가") or "")})
|
||||
continue
|
||||
link = (ids.get(str(line.get("단가"))) or {}).get("연결") or {}
|
||||
key = str(link.get("키") or "")
|
||||
frozen = link.get("갈래") == "숫자" and isinstance(
|
||||
link.get("값"), dict
|
||||
) # 굳은 기계 묶음(847-1)
|
||||
kind = (
|
||||
"로직"
|
||||
if link.get("갈래") == "단가산출" or frozen
|
||||
else "인력"
|
||||
if key[:2] == "LB"
|
||||
else "재료"
|
||||
)
|
||||
elem = (
|
||||
f"로직({key})" if kind == "로직" and key else key
|
||||
) # 노임 · 요소 키(줄 정체 · 덮개 cid)
|
||||
heads.append({**keep, "종류": kind, **({"요소": elem} if elem else {})})
|
||||
out = {
|
||||
**{k: doc.get(k) for k in ("키", "이름", "결과단위", "출처")},
|
||||
"입력": [
|
||||
{"이름": str(v["열쇠"])} for v in ids.values() if _kind(v) in INPUTS and v.get("열쇠")
|
||||
],
|
||||
"중간": [
|
||||
{"이름": str(v["열쇠"])} for v in ids.values() if _kind(v) == "식" and v.get("열쇠")
|
||||
],
|
||||
"호표": heads,
|
||||
"덧줄": extras,
|
||||
**({"단계": doc["단계"]} if doc.get("단계") else {}),
|
||||
}
|
||||
return {**out, "결과": doc["결과"]} if "결과" in doc else out
|
||||
|
||||
|
||||
def _kind(var: dict) -> str:
|
||||
return str((var.get("연결") or {}).get("갈래") or "")
|
||||
|
||||
|
||||
def row(whole: Any, docs: dict[str, dict], code: str) -> dict[str, Any] | None:
|
||||
"""키 하나의 B09 풀이 줄 꼴(`row_of`) — 문서 없음 = None."""
|
||||
got = doc(whole, docs, code)
|
||||
return None if got is None else row_of(got)
|
||||
|
||||
|
||||
def solve(
|
||||
whole: Any,
|
||||
docs: dict[str, dict],
|
||||
@@ -228,7 +291,7 @@ def solve(
|
||||
if base is None:
|
||||
return None
|
||||
doc = _shown(dc.line_doc(base, rate, picks or None), shown or {})
|
||||
copy, given = {"부름": docs}, dc.given_of(whole, code, given)
|
||||
copy, given = {"부름": docs}, dc.given_of(whole, code, given, docs)
|
||||
try:
|
||||
ans = mt.calc(doc, mt.Trace(whole, docs), given, dc.cover_of(copy, doc))
|
||||
except Exception: # noqa: BLE001 — 계산기는 예외 없음이 원칙 · 남은 틈 = 못 셈
|
||||
|
||||
@@ -28,7 +28,6 @@ from __future__ import annotations
|
||||
|
||||
import hashlib
|
||||
import json
|
||||
import re
|
||||
from decimal import Decimal
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
@@ -61,10 +60,6 @@ mf = item_prices.mf
|
||||
#: 엔진 비목 → 블록 비목
|
||||
PART = {"노무비": "labor", "재료비": "material", "경비": "expense"}
|
||||
GROUP = {"인력": "labor", "재료": "material", "장비": "machine"} # 율 기준 묶음(778-4)
|
||||
#: % 덧줄 밑수 — `노무비 * …` · `줄.'이름' * …` · `(석공 * LB… + …) * …`(인력 줄)
|
||||
BASE_PART = re.compile(r"^\s*(노무비|재료비|경비)\s*\*")
|
||||
BASE_LINE = re.compile(r"^\s*줄\.'([^']+)'\s*\*")
|
||||
BASE_LABOR = re.compile(r"^\s*\(.*\*\s*LB\d+")
|
||||
AREA_FILE = "면적.json"
|
||||
ASK = "수량 없음 — 이 공사에서 입력" # 723-4 SC 안 줄 수량 빈칸(펼침 품 · 수량 칸)
|
||||
|
||||
@@ -140,9 +135,8 @@ class Builder:
|
||||
(금액 줄 차례 · 단가산출 블록이 씀)."""
|
||||
code = str(one.get("로직") or "")
|
||||
given, rate, picks = one.get("입력값") or {}, one.get("켜쌓기율"), one.get("고름")
|
||||
try:
|
||||
logic = whole.logic(code)
|
||||
except mf.FormulaError:
|
||||
logic = dr.row(whole, self.shelf.of(whole), code) # 수식 문서 줄 꼴(855-F B9-6)
|
||||
if logic is None:
|
||||
return None
|
||||
got = dr.solve(
|
||||
whole, self.shelf.of(whole), code, given, picks, rate
|
||||
@@ -228,9 +222,9 @@ class Builder:
|
||||
out["place"] = dict(place) # 줄 자리(792-4) = 문서 금액 줄 칸
|
||||
if pct := got.pct(n):
|
||||
word = pct[1].removesuffix("의 %")
|
||||
base = {"노무비": "part:labor", "재료비": "part:material", "경비": "part:expense",
|
||||
"인건비": "lines:labor"}.get(word, f"line:{word}") # fmt: skip
|
||||
base = base if word else _doc_base(got.doc, n) # 번지 · 단계 밑(792-4)
|
||||
base = (
|
||||
_BASE.get(word, f"line:{word}") if word else _doc_base(got.doc, n)
|
||||
) # 번지 · 단계 밑(792-4)
|
||||
if base is None: # 밑을 모르는 덧줄 — 옛 길과 같게 빈 줄
|
||||
why = "덧줄 — 대가 단가로 못 셈"
|
||||
return {**head, **out, "kind": "blank", "qty": qty, "why": why}
|
||||
@@ -265,7 +259,8 @@ class Builder:
|
||||
goods = x.get("품목") or {}
|
||||
if item is None: # 덧줄 — 밑수 × % / 100(% = 엔진 값 ÷ 엔진 밑수)
|
||||
add = (logic.get("덧줄") or [])[extra]
|
||||
base, label = _base_of(str(add.get("식") or ""))
|
||||
label = str(x.get("밑") or "").removesuffix("의 %") # 문서 셈 % 밑 이름(855-F B9-6)
|
||||
base = _BASE.get(label, f"line:{label}") if label else None
|
||||
value, under = _f(x.get("금액")), bases.get(base) if base else None
|
||||
if value is None or not under:
|
||||
# ponytail: 밑수 없는 덧줄(손료 식 등)은 B09 단가로 못 셈 — 줄만 두고 빈칸
|
||||
@@ -288,6 +283,10 @@ class Builder:
|
||||
if call and call.get("code"):
|
||||
key = sg.sangeun_key(call["code"], call["given"])
|
||||
return {**head, "kind": "sangeun", "key": key, "qty": qty}
|
||||
if (
|
||||
call is not None and "machine" in call and own is not None
|
||||
): # 키 모르는 굳은 기계 = M02 값
|
||||
return {**head, "kind": "fixed", "qty": qty, "own": own, "link": {}}
|
||||
return {**head, "kind": "blank", "qty": qty, "why": "하위 로직 줄 — 못 펼침"}
|
||||
|
||||
# ── 조합 · 사전조합 줄 ──────────────────────────────────────────────
|
||||
@@ -347,11 +346,11 @@ class Builder:
|
||||
"unit": doc.get("단위") or "", "qty": each} # fmt: skip
|
||||
code = str(one.get("로직") or "")
|
||||
if one.get("승격") is not True: # 단가산출 줄 = 산근
|
||||
if not sg.is_money(whole, code):
|
||||
if not sg.is_money(whole, code, self.shelf.of(whole)):
|
||||
return {"kind": "blank", "name": name or code, "qty": q, "why": "돈 아닌 로직"}
|
||||
key = sangeun_ref(code, one.get("입력값"), one.get("켜쌓기율"), one.get("고름"))
|
||||
return {"kind": "sangeun", "key": key, "name": name or code,
|
||||
"unit": sg.unit_of(whole, code), "qty": q} # fmt: skip
|
||||
"unit": sg.unit_of(whole, code, self.shelf.of(whole)), "qty": q} # fmt: skip
|
||||
bid = self.poomsem(whole, one, str(one.get("별칭") or "") or name)
|
||||
if bid is None:
|
||||
return {
|
||||
@@ -624,15 +623,9 @@ def _engine_bases(engine: list[dict], items: list[dict]) -> dict[str, float]:
|
||||
return out
|
||||
|
||||
|
||||
def _base_of(formula: str) -> tuple[str | None, str]:
|
||||
"""덧줄 식 → (밑수 갈래, 이름) — 모르는 꼴이면 (None, "")."""
|
||||
if hit := BASE_PART.match(formula):
|
||||
return f"part:{PART[hit.group(1)]}", hit.group(1)
|
||||
if hit := BASE_LINE.match(formula):
|
||||
return f"line:{hit.group(1)}", hit.group(1)
|
||||
if BASE_LABOR.match(formula):
|
||||
return "lines:labor", "인건비"
|
||||
return None, ""
|
||||
#: % 밑 이름(`Doc_Run.Answer.pct`) → 밑수 갈래(옛 덧줄 식 글 풀이 대신 · 855-F B9-6)
|
||||
_BASE = {"노무비": "part:labor", "재료비": "part:material", "경비": "part:expense",
|
||||
"인건비": "lines:labor"} # fmt: skip
|
||||
|
||||
|
||||
def _plain(value: Any) -> Any:
|
||||
|
||||
@@ -10,7 +10,8 @@
|
||||
로직 줄이 부르는 다른 돈 로직(기계경비 밖) = 하위 산근(그 산근도 목록에 · 산근 → 산근).
|
||||
풀이 = 사본 수식 문서(`수식.json`)를 M02 와 같은 계산기로 셈한 답 + 셈 기록(`B09_Estimation_Doc_Run` ·
|
||||
855-F B9-3)에서 줄마다 수량 · 단가 · 자원 키 · 하위 산근 · % 줄 율 · 끝수를 읽음(옛 엔진 안 부름) ·
|
||||
줄 이름 · 단위 · 종류 = 사본 로직 줄 글(B9-5 에서 문서로) · 산출근거 글 = 풀이 블록 + 문서 셈 답(B9-4) ·
|
||||
줄 이름 · 단위 · 종류 = 수식 문서(`Doc_Run.row_of` · B9-6) · 산출근거 글 = 풀이 블록 + 문서
|
||||
셈 답(B9-4) ·
|
||||
단가 = B09 프로젝트 한 벌 굳힌 단가(144 · `compute_base` 표) — 노무 = 노무비목록표 ·
|
||||
중기 = 중기목록표 노 · 재 · 경 · 재료 = 자재단가대비표 적용 단가 ·
|
||||
% 줄(덧줄) = 엔진 식에 B09 비목 합.
|
||||
@@ -46,10 +47,10 @@ from B08_Quantity.B08_Quantity_Haul_Cycle import fill_given
|
||||
from B09_Estimation import B09_Estimation_Doc_Run as dr
|
||||
from B09_Estimation import B09_Estimation_Sangeun_Sum as ss
|
||||
from B09_Estimation import B09_Estimation_Sangeun_Text as st
|
||||
from B09_Estimation import B09_Estimation_Sheet as sheet
|
||||
from B09_Estimation.B09_Estimation_Calc_Base import SUPPLY, gap, num, rounddown, total
|
||||
from B09_Estimation.B09_Estimation_Copy_Prices import bundle
|
||||
from B09_Estimation.B09_Estimation_Store import ref_rows
|
||||
from M01_MasterData import M01_MasterData_Store as m01
|
||||
from M01_MasterData import M01_MasterData_Store_Combo as combo_store
|
||||
from M02_MasterTemplete import M02_Item_Prices as item_prices
|
||||
from M02_MasterTemplete import M02_Labor_Inputs as labor_inputs
|
||||
@@ -62,7 +63,6 @@ from M02_MasterTemplete.M02_Item_Snapshot import (
|
||||
from M02_MasterTemplete.M02_Item_Source import LABOR_FILE, read_json
|
||||
|
||||
mf = item_prices.mf
|
||||
import master_sheet_line as msl # noqa: E402 — 계산서 줄 덧칸(714-1) · scripts 길은 `m01` 이 둠
|
||||
|
||||
PARTS = ("labor", "material", "expense")
|
||||
COST_PART = {"노무비": "labor", "재료비": "material", "경비": "expense"}
|
||||
@@ -122,7 +122,7 @@ def rows_of(folder: Path, whole: Any = None, docs: dict | None = None) -> list[d
|
||||
out: list[dict[str, Any]] = []
|
||||
|
||||
def logic_line(code: str, given: Any, rate: Any, chosen: Any, promoted: bool) -> None:
|
||||
if not is_money(whole, code):
|
||||
if not is_money(whole, code, docs):
|
||||
return
|
||||
if not promoted:
|
||||
out.append({"code": code, "given": _clean_given(given), "rate": rate, "picks": chosen})
|
||||
@@ -181,21 +181,16 @@ def _unit(row: dict) -> tuple[str, Decimal]:
|
||||
return unit, Decimal(per[0][0]) if len(per) == 1 else Decimal(1)
|
||||
|
||||
|
||||
def unit_of(whole: Any, code: str) -> str:
|
||||
"""산근 1 단위 이름(「원/10㎡」 = ㎡) — `whole` = 사본 단가 묶음."""
|
||||
try:
|
||||
return _unit(whole.logic(code))[0]
|
||||
except mf.FormulaError:
|
||||
return ""
|
||||
def unit_of(whole: Any, code: str, docs: dict | None = None) -> str:
|
||||
"""산근 1 단위 이름(「원/10㎡」 = ㎡) — 수식 문서 결과단위(`docs` = 사본 수식 문서)."""
|
||||
row = dr.row(whole, {} if docs is None else docs, code)
|
||||
return _unit(row)[0] if row else ""
|
||||
|
||||
|
||||
def is_money(whole: Any, code: str) -> bool:
|
||||
"""돈 로직(호표 줄 꼴)인지 — 없는 로직 · 흐름 · 결과 로직 = 아님."""
|
||||
try:
|
||||
row = whole.logic(code)
|
||||
except mf.FormulaError:
|
||||
return False
|
||||
return not (isinstance(row.get("흐름"), dict) or "결과" in row)
|
||||
def is_money(whole: Any, code: str, docs: dict | None = None) -> bool:
|
||||
"""돈 문서(금액 줄 꼴)인지 — 없는 문서 · 결과 문서 = 아님(수식 문서 · 855-F B9-6)."""
|
||||
row = dr.row(whole, {} if docs is None else docs, code)
|
||||
return row is not None and "결과" not in row
|
||||
|
||||
|
||||
def call_of(line: dict) -> dict[str, Any] | None:
|
||||
@@ -236,11 +231,10 @@ def line_calls(
|
||||
) -> dict[int, dict | None]:
|
||||
"""로직 하나의 로직 호표 줄마다 `call_of`(호표 차례 n → 부른 것) — 못 셈 줄 = None ·
|
||||
셈 = 문서 셈 답(`Doc_Run` · `docs` = 사본 수식 문서 · 없으면 그 자리 닫힌 묶음)."""
|
||||
try:
|
||||
row = whole.logic(code)
|
||||
except mf.FormulaError:
|
||||
return {}
|
||||
docs = {} if docs is None else docs
|
||||
row = dr.row(whole, docs, code)
|
||||
if row is None:
|
||||
return {}
|
||||
got = dr.solve(
|
||||
whole,
|
||||
docs,
|
||||
@@ -311,18 +305,18 @@ class Solver:
|
||||
|
||||
def _solve(self, whole: Any, src: dict[str, Any], depth: int) -> dict[str, Any]:
|
||||
code = src["code"]
|
||||
try:
|
||||
row = whole.logic(code)
|
||||
except mf.FormulaError as e:
|
||||
return self._stop(code, code, f"로직 없음 — {e}")
|
||||
docs = self.shelf.of(whole)
|
||||
doc = dr.doc(whole, docs, code) # 수식 문서(855-F B9-6 · 옛 로직 줄 안 읽음)
|
||||
if doc is None:
|
||||
return self._stop(code, code, f"수식 문서 없음 「{code}」")
|
||||
row = dr.row_of(doc)
|
||||
name = str(row.get("이름") or code)
|
||||
if isinstance(row.get("흐름"), dict) or "결과" in row:
|
||||
if "결과" in row:
|
||||
return self._stop(code, name, "돈 로직 아님(흐름 · 결과 로직) — 산근 풀이 꼴 없음")
|
||||
unit, times = _unit(row)
|
||||
rate = Decimal(str(src["rate"])) / 100 if src.get("rate") not in (None, 100) else None
|
||||
lines: list[dict[str, Any]] = []
|
||||
# 841-1 단가 = M02 셈(문서 셈) 줄 금액 ÷ 수량(켜쌓기율 없이 · 날 값 · B09 단가 책 안 읽음)
|
||||
docs = self.shelf.of(whole)
|
||||
shown = ss.doc_shown(row) # 작업량 Q = ROUND 2(엑셀 자리)
|
||||
eng = dr.solve(whole, docs, code, src["given"], src.get("picks"), None, shown)
|
||||
if eng is None:
|
||||
@@ -340,7 +334,7 @@ class Solver:
|
||||
self._extras(row, per or eng, lines)
|
||||
head = self._text(whole, eng, lines, times, src.get("rate"))
|
||||
self._aside(lines)
|
||||
_annotate(whole, row, eng.env, lines)
|
||||
sheet.annotate(whole, doc, lines) # 계산서 줄 덧칸(719-4) = 문서
|
||||
except (ArithmeticError, KeyError, TypeError, ValueError) as e:
|
||||
return self._stop(code, name, str(e) or type(e).__name__)
|
||||
sums = ss.doc_totals(eng, lines) # 끝수 · 끝전 · 조정 = 문서 답 끝수(792-3)
|
||||
@@ -362,7 +356,7 @@ class Solver:
|
||||
"why": why,
|
||||
"head": head,
|
||||
"foot": foot,
|
||||
"기준단위": msl._per_text(msl.mbs.result_per(row.get("결과단위"))) or None,
|
||||
"기준단위": sheet.base_unit(doc),
|
||||
}
|
||||
|
||||
@staticmethod
|
||||
@@ -488,31 +482,15 @@ class Solver:
|
||||
lines.append({**line, "price": {part: value}, part: money, "why": None})
|
||||
|
||||
|
||||
def _annotate(whole: Any, row: dict, env: dict, lines: list[dict[str, Any]]) -> None:
|
||||
"""719-4 계산서 줄 덧칸 `sheet`{쓰는입력 · 기준단위 · 환산근거} — `master_sheet_line` 한 벌
|
||||
(M01 `/text` · M02 `/logic-lib/sheet` 와 같은 뜻) · 묶음 · 장비 = 줄 `kind` 로 화면이 가름."""
|
||||
per = msl.mbs.result_per(row.get("결과단위"))
|
||||
items = [*row.get("호표", []), *row.get("덧줄", [])]
|
||||
for item, ln in zip(items, lines):
|
||||
goods = ln.pop("_goods", None) or {}
|
||||
exprs = [item["식"]] if "식" in item else [item.get("수량"), item.get("요소")]
|
||||
seen = {"품목": goods, "단위": item.get("단위")}
|
||||
try:
|
||||
got = msl._fields(whole, row, exprs, dict(env), per, seen, None)
|
||||
except (mf.FormulaError, ArithmeticError, KeyError, TypeError, ValueError):
|
||||
got = {}
|
||||
ln["sheet"] = got
|
||||
|
||||
|
||||
# ── 모음 ──────────────────────────────────────────────────────────────
|
||||
LISTED = ("no", "key", "logic", "name", "spec", "spec_raw", "unit", "sum", *PARTS, "uses")
|
||||
|
||||
|
||||
def _input_names(code: str) -> list[str]:
|
||||
try:
|
||||
return [str(i.get("이름")) for i in m01.loaded()[1].logic(code).get("입력") or []]
|
||||
except mf.FormulaError:
|
||||
return []
|
||||
"""M01 기초 입력 이름 — 지금 수식 문서(855-F B9-6)."""
|
||||
from M02_MasterTemplete import M02_Doc_Copy as dc
|
||||
|
||||
return item_prices.doc_inputs(dc.folder().get(str(code)))
|
||||
|
||||
|
||||
def hand_sources(user: dict[str, Any] | None) -> list[tuple[str, str, dict[str, Any]]]:
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
"""B09 산근 계산서 줄 덧칸 `sheet`{쓰는입력 · 기준단위 · 환산근거}(719-4) — 수식 문서에서
|
||||
(855-F B9-6) · 서버 단독(짝 없음).
|
||||
|
||||
옛 `master_sheet_line._fields`(옛 로직 줄 식 풀이)와 같은 뜻:
|
||||
- `쓰는입력` = 그 줄 값(수량 · 단가 식)이 쓰는 문서 입력 변수 열쇠 — 식 변수 · 표 조건 ·
|
||||
단가산출 넘긴 입력 · 요소 키 틀 · 재료 조건 글 구멍을 거슬러 감 · 문서 변수 차례.
|
||||
- `기준단위` = 그 줄이 찾는 표의 기준(「10㎡」 · `master_basis.basis`) · 없으면 None.
|
||||
- `환산근거` = 표 기준배 ↔ 결과단위 배 · 재료 품목 단위 ↔ 줄 단위(`master_unit.note`) · 없으면 「」.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
from decimal import Decimal
|
||||
from typing import Any
|
||||
|
||||
import master_basis as mbs # noqa: E402
|
||||
import master_doc as md # noqa: E402
|
||||
import master_unit as mu # noqa: E402
|
||||
|
||||
from B09_Estimation import B09_Estimation_Doc_Run as dr
|
||||
from M01_MasterData import M01_MasterData_Store as _m01 # noqa: F401 — scripts 길을 둠
|
||||
|
||||
_HOLE = re.compile(r"\{([^{}]+)\}")
|
||||
|
||||
|
||||
def _times(x: Decimal) -> str:
|
||||
return format(x.normalize(), "f")
|
||||
|
||||
|
||||
def per_text(per: list[tuple[Decimal, str]]) -> str:
|
||||
"""결과단위 분모 글(「10㎡」 · 여럿 = 「㎡ · ㎥」)."""
|
||||
return " · ".join(dict.fromkeys(f"{_times(n) if n != 1 else ''}{u}" for n, u in per))
|
||||
|
||||
|
||||
def base_unit(doc: dict) -> str | None:
|
||||
"""답 머리 `기준단위` = 결과단위 분모."""
|
||||
return per_text(mbs.result_per(doc.get("결과단위"))) or None
|
||||
|
||||
|
||||
def _reach(doc: dict, texts: list) -> tuple[list[str], list[str]]:
|
||||
"""식들이 쓰는 (입력 열쇠 · 표 키) — 식 변수 · 표 조건 · 단가산출 넘긴 입력을 거슬러 감."""
|
||||
ids = {md.var_id(v): v for v in doc.get("변수") or []}
|
||||
steps = {md.var_id(x): x.get("식") for x in doc.get("식") or []}
|
||||
seen: set[str] = set()
|
||||
tables: list[str] = []
|
||||
todo = [t for t in texts if t not in (None, "")]
|
||||
while todo:
|
||||
try:
|
||||
names = set(md.names(md.parse(todo.pop())))
|
||||
except md.DocError:
|
||||
continue
|
||||
for name in names - seen:
|
||||
seen.add(name)
|
||||
link = (ids.get(name) or {}).get("연결") or {}
|
||||
if name in steps:
|
||||
todo.append(steps[name])
|
||||
if link.get("갈래") == "표":
|
||||
tables += [str(link["표"])] if link.get("표") and link["표"] not in tables else []
|
||||
todo += [str(x) for x in (link.get("조건") or {}).values()]
|
||||
elif link.get("갈래") == "단가산출":
|
||||
todo += [str(x) for x in (link.get("입력") or {}).values()]
|
||||
elif (
|
||||
link.get("갈래") == "요소"
|
||||
): # 키 틀 · 재료 조건 글 구멍(「LB:{S_직종}」 · 「{D_관}」)
|
||||
cond = link.get("재료") if isinstance(link.get("재료"), dict) else {}
|
||||
for text in [str(link.get("키") or ""), *(str(x) for x in cond.values())]:
|
||||
todo += _HOLE.findall(text)
|
||||
inputs = [
|
||||
str(v["열쇠"])
|
||||
for vid, v in ids.items()
|
||||
if vid in seen and dr._kind(v) in dr.INPUTS and v.get("열쇠")
|
||||
]
|
||||
return inputs, tables
|
||||
|
||||
|
||||
def _basis(whole: Any, tables: list[str]) -> dict | None:
|
||||
for ref in tables:
|
||||
try:
|
||||
got = mbs.basis(whole.get(ref))
|
||||
except Exception: # noqa: BLE001 — 없는 표 · 기준 없음 = 다음
|
||||
continue
|
||||
if got["갈래"] == "단위":
|
||||
return got
|
||||
return None
|
||||
|
||||
|
||||
def _note(basis: dict | None, per: list, line: dict) -> str:
|
||||
notes = []
|
||||
if basis and len(per) == 1:
|
||||
times, one = per[0]
|
||||
if mu.plain(basis["기준단위"]) == mu.plain(mbs.unit(one)) and basis["기준배"] != times:
|
||||
ratio = basis["기준배"] / times
|
||||
how = f"÷{_times(ratio)}" if ratio > 1 else f"×{_times(1 / ratio)}"
|
||||
notes.append(
|
||||
f"{_times(basis['기준배'])}{basis['기준단위']}당 → {_times(times)}{one}당 {how}"
|
||||
)
|
||||
goods = line.get("품목") or {}
|
||||
if goods.get("단위") and line.get("단위"):
|
||||
notes.append(mu.note(goods["단위"], line["단위"]))
|
||||
return " · ".join(n for n in notes if n)
|
||||
|
||||
|
||||
def annotate(whole: Any, doc: dict, lines: list[dict[str, Any]]) -> None:
|
||||
"""블록 줄마다 `sheet` — 줄 차례 = 문서 금액 줄 차례(호표 · 뒤 덧줄) · 제자리."""
|
||||
per = mbs.result_per(doc.get("결과단위"))
|
||||
for dl, ln in zip(doc.get("금액") or [], lines):
|
||||
goods = ln.pop("_goods", None) or {}
|
||||
inputs, tables = _reach(doc, [dl.get("수량"), dl.get("단가")])
|
||||
basis = _basis(whole, tables)
|
||||
unit = None
|
||||
if basis:
|
||||
unit = f"{_times(basis['기준배']) if basis['기준배'] != 1 else ''}{basis['기준단위']}"
|
||||
seen = {"품목": goods, "단위": dl.get("단위")}
|
||||
ln["sheet"] = {"쓰는입력": inputs, "기준단위": unit, "환산근거": _note(basis, per, seen)}
|
||||
@@ -22,7 +22,9 @@ from __future__ import annotations
|
||||
import copy as cp
|
||||
import hashlib
|
||||
import json
|
||||
import re
|
||||
import sys
|
||||
from decimal import Decimal
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
@@ -33,7 +35,6 @@ _SCRIPTS = str(Path(__file__).resolve().parents[1] / "resources/master_data/scri
|
||||
if _SCRIPTS not in sys.path:
|
||||
sys.path.insert(0, _SCRIPTS)
|
||||
|
||||
import master_auto as mau # noqa: E402
|
||||
import master_doc as md # noqa: E402
|
||||
import master_doc_calc as mc # noqa: E402
|
||||
import master_doc_convert as cv # noqa: E402
|
||||
@@ -262,17 +263,121 @@ def _apart(doc: dict, lines: list[dict], n: int) -> None:
|
||||
later[slot] = md.text_of(_plus(node, cost, sym))
|
||||
|
||||
|
||||
def given_of(whole: Any, code: str, given: Any) -> dict:
|
||||
"""옛 `run_line` 과 같은 입력 — 빈 입력 = 자동값(M01 줄) › 받은 값."""
|
||||
def given_of(whole: Any, code: str, given: Any, docs: dict | None = None) -> dict:
|
||||
"""옛 `run_line` 과 같은 입력 — 빈 입력 = 자동값(`auto_of` · 문서 = `docs` › 값 사본 줄 문서) ›
|
||||
받은 값."""
|
||||
from M01_MasterData import M01_MasterData_Store as m01
|
||||
|
||||
try:
|
||||
auto = {k: v for k, v in mau.values(whole, whole.logic(code)).items() if v is not None}
|
||||
doc = (docs or {}).get(code) or doc_of(whole, code)
|
||||
auto = {k: v for k, v in auto_of(doc, whole).items() if v is not None} if doc else {}
|
||||
except _ERR:
|
||||
auto = {}
|
||||
return {**auto, **m01._dec(given or {})}
|
||||
|
||||
|
||||
# ── 자동값(옛 `master_auto.values` 같은 규칙 · 문서에서 · 855-F B9-6) ──────────
|
||||
_GUARD = re.compile(r"만약\(\s*(\w+)\s*>\s*0\s*,\s*\1\s*,")
|
||||
_INPUTS = ("입력", "선택")
|
||||
|
||||
|
||||
def _num(v: Any) -> Any:
|
||||
try:
|
||||
return Decimal(str(v)) if not isinstance(v, Decimal) else v
|
||||
except ArithmeticError:
|
||||
return v
|
||||
|
||||
|
||||
def _fits(whole: Any, ref: str, cond: str) -> list:
|
||||
"""표 `ref` 조건 칸 `cond` 에 드는 수 — 낮은 차례 · 범위 칸 = 줄마다 그 줄에 드는 끝."""
|
||||
try:
|
||||
table = whole.get(ref)
|
||||
except _ERR:
|
||||
return []
|
||||
ranged = (table.get("조건") or {}).get(cond) == "범위"
|
||||
out = set()
|
||||
for r in table.get("줄") or []:
|
||||
if r.get(cond) is None:
|
||||
continue
|
||||
low, high = r[cond] if ranged else (r[cond], None)
|
||||
ends = [Decimal(0) if low is None else low, high]
|
||||
out |= {v for v in ends if isinstance(v, Decimal) and ml._match(table, r, cond, v)}
|
||||
return sorted(out)
|
||||
|
||||
|
||||
def _lowest(whole: Any, uses: list) -> Any:
|
||||
"""같은 입력을 여러 표가 쓰면 모두에 드는 가장 낮은 수 · 없으면 첫 표의 가장 낮은 수."""
|
||||
sets = [_fits(whole, ref, cond) for ref, cond in uses]
|
||||
both = sorted(set.intersection(*map(set, sets))) if sets else []
|
||||
return (both or next((s for s in sets if s), [None]))[0]
|
||||
|
||||
|
||||
def _divisors(doc: dict, ids: dict) -> set[str]:
|
||||
"""나누는 자리에 든 이름 — 그 이름이 쓰는 이름(식 · 표 조건 · 단가산출 넘긴 입력)까지 ·
|
||||
「만약(X > 0, X, 기본)」 의 X 는 안 퍼뜨림."""
|
||||
texts = [x.get("식") for x in doc.get("식") or []]
|
||||
texts += [(doc.get("결과") or {}).get("식") if isinstance(doc.get("결과"), dict) else None]
|
||||
texts += [x.get(k) for x in doc.get("금액") or [] for k in ("수량", "단가")]
|
||||
divs, guard = set(), set()
|
||||
for text in (x for x in texts if x not in (None, "")):
|
||||
guard |= set(_GUARD.findall(str(text)))
|
||||
try:
|
||||
divs |= {
|
||||
n for p in md.walk(md.parse(text)) if p[:2] == ("bin", "/") for n in md.names(p[3])
|
||||
}
|
||||
except md.DocError:
|
||||
continue
|
||||
feeds: dict[str, list] = {}
|
||||
for x in doc.get("식") or []:
|
||||
feeds.setdefault(md.var_id(x), []).append(x.get("식"))
|
||||
for vid, v in ids.items():
|
||||
link = v.get("연결") or {}
|
||||
part = {"표": "조건", "단가산출": "입력"}.get(str(link.get("갈래")))
|
||||
if part:
|
||||
feeds.setdefault(vid, []).extend((link.get(part) or {}).values())
|
||||
todo = list(divs)
|
||||
while todo:
|
||||
for text in feeds.get(todo.pop(), []):
|
||||
try:
|
||||
more = set(md.names(md.parse(text))) - guard - divs
|
||||
except md.DocError:
|
||||
continue
|
||||
divs |= more
|
||||
todo += list(more)
|
||||
return divs
|
||||
|
||||
|
||||
def auto_of(doc: dict, whole: Any) -> dict:
|
||||
"""문서 입력마다 자동값 — 고르기 = 목록 첫째 · 범위 = 아래 끝 · 표 조건 값 = 그 표 가장 낮은
|
||||
수 · 나누는 자리 = 1 · 그 밖 0 · 가격(원) 입력 = None(1,521 문서 옛 `master_auto` 와 같음)."""
|
||||
ids = {md.var_id(v): v for v in doc.get("변수") or []}
|
||||
finds: dict[str, list] = {}
|
||||
for v in ids.values():
|
||||
link = v.get("연결") or {}
|
||||
if link.get("갈래") == "표":
|
||||
for col, arg in (link.get("조건") or {}).items():
|
||||
if isinstance(arg, str) and arg in ids:
|
||||
finds.setdefault(arg, []).append((link.get("표"), col))
|
||||
divs = _divisors(doc, ids)
|
||||
out: dict[str, Any] = {}
|
||||
for vid, v in ids.items():
|
||||
link = v.get("연결") or {}
|
||||
if link.get("갈래") not in _INPUTS or not v.get("열쇠"):
|
||||
continue
|
||||
name = str(v["열쇠"])
|
||||
if link.get("목록"):
|
||||
out[name] = link["목록"][0]
|
||||
elif link.get("범위"):
|
||||
out[name] = _num(link["범위"][0])
|
||||
else:
|
||||
got = _lowest(whole, finds.get(vid, []))
|
||||
if got is None and "원" in str(v.get("단위") or ""):
|
||||
out[name] = None
|
||||
else:
|
||||
out[name] = got if got is not None else Decimal(1 if vid in divs else 0)
|
||||
return out
|
||||
|
||||
|
||||
def apart_of(marks: Any, mats: Any) -> list[int]:
|
||||
"""별도계상 금액 줄 차례 — 옛 `drop_apart` 와 같은 판정(엔진 답 `재료` 의 차례 · 자재표시)."""
|
||||
from M02_MasterTemplete import M02_Labor_Doc as labor
|
||||
|
||||
@@ -17,7 +17,7 @@ STmate 꼴(「일위대가표」 · 「단가산출근거」 시트) = `M02_Hopy
|
||||
% 줄 = floor(바탕 × 율 / 100 × 10) / 10 · 호표 비목 = floor(줄 금액 합) · 총괄표 합계 —
|
||||
어긋남은 글 목록(막지 않음).
|
||||
행(329-1) = 호표 [제N호표 줄, 마지막 구성 줄] · 구성 줄 한 줄(엑셀 1부터) ·
|
||||
근거(330-1) = 단산N참조 줄에 「단가산출」 블록 `{출처, 직종, 행}`(`M02_Hopyo_ReadEst.read`) ·
|
||||
근거(330-1) = 단산N참조 줄에 「단가산출」 블록 `{출처, 직종, 행}`(`M02_Hopyo_ReadEst.from_two`) ·
|
||||
`단산` = 블록마다 `{번, 이름, 단위, 행, 출처, 직종, 글, 금액, 항목}`(338 · 글 = 머리 뺀 몸 줄) ·
|
||||
`꼴` = 「엑셀꼴」 · 두 형식 끝에 `UnitLine.settle`(단위 줄 하위 · 재현 · 덮음 · 일위대가 줄
|
||||
투영 · 778-3).
|
||||
@@ -40,7 +40,6 @@ SHEET = "일위대가"
|
||||
SUMMARY = "일위대가총괄표"
|
||||
LISTS = ("단가산출총괄표", "일위대가목록표") # 엑셀 보기 목록 시트(779-1 격자) — 같이 읽음
|
||||
COSTS = ("노무비", "재료비", "경비")
|
||||
HEADS = ("호표", "품명", "규격", "수량", "단위", "비고")
|
||||
NO_SHEET = "일위대가 시트 없음"
|
||||
_HOPYO = re.compile(r"제\s*(\d+)\s*호표")
|
||||
_REF = re.compile(r"^(?:(단산|산근|단가산출)|(일위대가|일위|대가))(\d+)(?:참조|호표)?$")
|
||||
@@ -88,19 +87,6 @@ def _out(value: Decimal | None) -> int | float | None:
|
||||
return int(value) if value == value.to_integral_value() else float(value)
|
||||
|
||||
|
||||
def _columns(rows: list[list[Any]], money: tuple[str, ...]) -> tuple[int, dict[str, int]]:
|
||||
"""(자료 첫 줄, {머리: 열}) — 머리 글은 앞 10 줄 안 「호표」 · 「품명」 이 든 줄."""
|
||||
for at, row in enumerate(rows[:10]):
|
||||
flat = [_flat(v) for v in row]
|
||||
if "호표" not in flat or "품명" not in flat:
|
||||
continue
|
||||
cols = {head: flat.index(head) for head in (*HEADS, *money) if head in flat}
|
||||
below = [_flat(v) for v in rows[at + 1]] if at + 1 < len(rows) else []
|
||||
start = at + 2 if "단가" in below or "금액" in below else at + 1
|
||||
return start, cols
|
||||
raise ExcelError(f"{SHEET} 시트 머리 글(호표 · 품명)을 못 찾음")
|
||||
|
||||
|
||||
def _cell(row: list[Any], col: int | None) -> Any:
|
||||
return row[col] if col is not None and col < len(row) else None
|
||||
|
||||
@@ -200,23 +186,6 @@ def _check_hopyo(hopyo: dict[str, Any], lines: list[dict[str, Any]]) -> list[str
|
||||
return bad
|
||||
|
||||
|
||||
def _summary(rows: list[list[Any]] | None) -> dict[int, Decimal]:
|
||||
"""총괄표 {호표 번: 합계} — 머리 글이 없으면 빈 것."""
|
||||
if not rows:
|
||||
return {}
|
||||
try:
|
||||
start, cols = _columns(rows, ("합계",))
|
||||
except ExcelError:
|
||||
return {}
|
||||
out = {}
|
||||
for row in rows[start:]:
|
||||
hit = _HOPYO.fullmatch(_flat(_cell(row, cols.get("호표"))))
|
||||
total = _num(_cell(row, cols.get("합계")))
|
||||
if hit and total is not None:
|
||||
out[int(hit.group(1))] = total
|
||||
return out
|
||||
|
||||
|
||||
def _by_name(raw: list[list[dict[str, Any]]], blocks: dict[int, dict[str, Any]]) -> None:
|
||||
"""비고 빈 줄(노무비 · 경비 단가 있음) → 품명 + 단위가 같은 블록이 하나뿐이면 단산 이음."""
|
||||
index: dict[tuple[str, str], list[int]] = {}
|
||||
|
||||
@@ -8,16 +8,12 @@
|
||||
걷음(742-1 · 다르면 남김 = 금액 그대로)) · SK · SC `본뜬.또` = 그 HP 몫만 뺌 ·
|
||||
문서 몸(줄 · 덮개 · 더한줄 · 별칭 · 구분)과 별칭 장부는 그대로 ·
|
||||
끝낸 기록 없음(같은 엑셀 다시 올림 됨 · 키 번은 `불러옴.json` 번으로 다시 안 씀).
|
||||
옛 파일 정리 `tidy`(한 번 · 층 폴더마다 · 미리 보기 = 표만) — 옛 HP(지문 없음) · 하루 지난 HP 끝냄 ·
|
||||
끝낸 기록 지문 비움 · HP 가 없는 SC · SK 엑셀 사본 걷음.
|
||||
`python -m M02_MasterTemplete.M02_Hopyo_Forget <층 폴더>… [--apply]`(없으면 미리 보기).
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import re
|
||||
import sys
|
||||
from collections.abc import Callable
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
@@ -30,7 +26,6 @@ from M02_MasterTemplete import M02_Labor_Ref as refs
|
||||
ORIGIN = "실무자료"
|
||||
KEEP = ("층", "파일", "전국자재", "복사원본")
|
||||
_MEMO = re.compile(r"^실무 ")
|
||||
_HP = re.compile(r"^(HP-\d{6}) ")
|
||||
|
||||
|
||||
# ── 사본 걷음(순수) ───────────────────────────────────────────────────
|
||||
@@ -99,8 +94,8 @@ def _here(got: dict[str, Any], here: refs.Here) -> bool:
|
||||
return not got.get("원본") or tuple(got["원본"]) == tuple(here)
|
||||
|
||||
|
||||
def forget(folder: str | Path, gone: Callable[[str], bool], apply: bool = True) -> list[str]:
|
||||
"""`gone(본뜬 키)` 인 이 층 SC · SK 엑셀 사본 걷음 → 걷은 문서 키(`apply` 거짓 = 셈만)."""
|
||||
def forget(folder: str | Path, gone: Callable[[str], bool]) -> list[str]:
|
||||
"""`gone(본뜬 키)` 인 이 층 SC · SK 엑셀 사본 걷음 → 걷은 문서 키."""
|
||||
folder, out = Path(folder), []
|
||||
here = refs.where(folder)
|
||||
|
||||
@@ -120,8 +115,7 @@ def forget(folder: str | Path, gone: Callable[[str], bool], apply: bool = True)
|
||||
new["본뜬"]["또"] = also # 777-1 같은 내용 SC 를 나눠 쓴 다른 불러오기 몫은 그대로
|
||||
if new != doc:
|
||||
out.append(path.stem)
|
||||
if apply:
|
||||
atomic_write_json(path, new)
|
||||
atomic_write_json(path, new)
|
||||
return out
|
||||
|
||||
|
||||
@@ -150,46 +144,3 @@ def sweep(folder: str | Path, now: datetime | None = None) -> list[str]:
|
||||
for key in (got := expired(folder, now)):
|
||||
finish(folder, key)
|
||||
return got
|
||||
|
||||
|
||||
# ── 옛 파일 정리(한 번) ───────────────────────────────────────────────
|
||||
def tidy(folder: str | Path, apply: bool = False) -> list[dict[str, str]]:
|
||||
"""옛 실무자료 정리 표 `[{할일, 대상}]` — `apply` 거짓 = 미리 보기(쓰기 없음)."""
|
||||
folder = Path(folder)
|
||||
home = folder / hopyo_store.DIRNAME
|
||||
rows: list[dict[str, str]] = []
|
||||
every = sorted(p.stem for p in home.glob("HP-*.json"))
|
||||
old = [k for k in every if not (hopyo_store._load(home / f"{k}.json") or {}).get("지문")]
|
||||
ended = [*old, *expired(folder)]
|
||||
live = set(every) - set(ended)
|
||||
for key in ended:
|
||||
rows.append({"할일": "HP 끝냄(옛 · 하루 지남)", "대상": f"{hopyo_store.DIRNAME}/{key}"})
|
||||
if apply:
|
||||
finish(folder, key)
|
||||
log = hopyo_store.done(folder)
|
||||
if log["지문"]:
|
||||
rows.append({"할일": f"끝낸 기록 지문 {len(log['지문'])} 비움", "대상": "불러옴.json"})
|
||||
if apply:
|
||||
hopyo_store._put_done(folder, {"번": log["번"]})
|
||||
|
||||
def gone(mark: str) -> bool:
|
||||
m = _HP.match(mark)
|
||||
return bool(m) and m.group(1) not in live
|
||||
|
||||
for key in forget(folder, gone, apply):
|
||||
rows.append({"할일": "엑셀 사본 걷음(출처만)", "대상": key})
|
||||
return rows
|
||||
|
||||
|
||||
def main(argv: list[str]) -> int:
|
||||
apply = "--apply" in argv
|
||||
for one in [a for a in argv if a != "--apply"]:
|
||||
rows = tidy(one, apply)
|
||||
print(f"# {one} — {'고침' if apply else '미리 보기'} {len(rows)}")
|
||||
for row in rows:
|
||||
print(f"{row['할일']}\t{row['대상']}")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main(sys.argv[1:]))
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
"""M02 일위대가 실무자료 EST(엑셀꼴) 단가산출 어댑터(PLAN 776-2 · 요구 621-1 ② 정규화) —
|
||||
엑셀 「단가산출」 시트 → 블록 `{번, 이름, 단위, 행, 출처, 직종, 글, 금액, 항목}`.
|
||||
둘 꼴 EST 산근 블록(`from_two` · 857-2) → 블록 `{번, 이름, 단위, 행, 출처, 직종, 글, 금액, 항목}`.
|
||||
형식(EST 글)을 아는 곳은 여기까지.
|
||||
|
||||
블록 = B열(머리 「산출근거」) 머리 줄 「N.이름[단위]」(앞 빈칸 없음)부터 다음 머리 앞까지 ·
|
||||
블록 = 머리 「N.이름[단위]」부터 다음 머리 앞까지 ·
|
||||
출처 = 「…품셈」(오타 「품줌」) 뒤 20 글자 안 절 번호 — 책 = 앞 낱말(`book_of` · 781-1: 산림 ·
|
||||
임도(옛) · 사방(옛) · 건설 부문 · 그 밖 건설품셈(부문 모름)) ·
|
||||
부문 풀이 · 옛 번호 대응 = `M02_Hopyo_Clause.settle` ·
|
||||
직종 = 「이름 : 수」 줄의 빈칸 뺀 이름이 우리 인력(LB) 이름 · 옛이름일 때만(지금 이름으로) ·
|
||||
글 = 머리 뺀 몸 줄 `GLINES` 줄 · 줄마다 `GCHARS` 자 안 · 산출근거 열이 빈 줄은 그 오른쪽 ~ 돈 머리
|
||||
(맨 오른쪽 묶음) 앞 칸을 빈칸으로 이어 붙임(거창 꼴 · 돈 머리 없으면 `WIDE` 열) ·
|
||||
글 = 머리 뺀 몸 줄 `GLINES` 줄 · 줄마다 `GCHARS` 자 안 ·
|
||||
금액 = 머리 줄 돈 칸(1 단위).
|
||||
항목(Book 블록 항목 · 778-3) = 글 줄 → 단위 줄(꼴 = `M02_Hopyo_UnitLine`) · 줄 금액 = 「= 금액」 ·
|
||||
끝 점(「28,500. ×」) 뗌 · 율(호표 줄 이름 · 규격)에 기대지 않는 것만(섞음 율은 지문 몫):
|
||||
@@ -34,7 +33,7 @@ from M02_MasterTemplete import M02_Labor_Inputs as labor_inputs
|
||||
from M02_MasterTemplete.M02_Hopyo_Words import mtypes, parse_rhs
|
||||
|
||||
SHEET = "단가산출"
|
||||
GLINES, GCHARS, WIDE = 200, 300, 140
|
||||
GLINES, GCHARS = 200, 300
|
||||
_HEAD = re.compile(r"^(\d+)\.\s*(.*?)\s*\[([^\[\]]*)\]\s*$")
|
||||
_BOOK = re.compile(r"품[셈줌]")
|
||||
_TRADE = re.compile(r"^[\s*·\-]*([가-힣][가-힣\s]*?)\s*:\s*[\d,]")
|
||||
@@ -46,7 +45,6 @@ _BOOK_WORDS = { # 책 낱말(781-1) — 옛 책 = 「(옛)」 · 건설 부문
|
||||
}
|
||||
_BOOK_WORD = re.compile(r"(" + "|".join(_BOOK_WORDS) + r")\s*(?:부문|사업|공사)?\s*(?:표준)?\s*$")
|
||||
_TYPO_CLAUSE = re.compile(r"^(\d+)-(\d)(\d)(\d)$") # 「13-114」 = 13-11-4
|
||||
_MONEY = {"합계": "계", "노무비": "노무비", "재료비": "재료비", "경비": "경비"}
|
||||
# 항목 풀이 — 지문(`Finger`)과 같은 규칙
|
||||
COST = ("노무비", "재료비", "경비")
|
||||
SKIPW = frozenset(
|
||||
@@ -88,12 +86,6 @@ def _flat(value: Any) -> str:
|
||||
return re.sub(r"\s+", "", str(value or ""))
|
||||
|
||||
|
||||
def _cell_text(value: Any) -> str:
|
||||
if isinstance(value, float) and value == int(value):
|
||||
value = int(value)
|
||||
return str(value).strip() if value is not None else ""
|
||||
|
||||
|
||||
# ── 이름 · 출처(두 어댑터 · 뒤 단계 공용) ────────────────────────────────
|
||||
@lru_cache(maxsize=2)
|
||||
def _trade_names(whole_id: int) -> dict[str, str]:
|
||||
@@ -156,66 +148,6 @@ def rates_in(text: Any) -> set[float]:
|
||||
return out
|
||||
|
||||
|
||||
# ── 블록 읽기 ─────────────────────────────────────────────────────────
|
||||
def _columns(rows: list[list[Any]]) -> tuple[int, int, dict[str, int]]:
|
||||
"""(자료 첫 줄, 산출근거 열, {계 · 노무비 · 재료비 · 경비: 열}) — 머리 없으면 (0, 1, {}) ·
|
||||
돈 머리가 둘 묶음이면 맨 오른쪽(거창 꼴 · 값이 든 쪽)."""
|
||||
for at, row in enumerate(rows[:10]):
|
||||
flat = [_flat(v) for v in row]
|
||||
if "산출근거" in flat:
|
||||
last = len(flat) - 1
|
||||
money = {
|
||||
key: last - flat[::-1].index(head) for head, key in _MONEY.items() if head in flat
|
||||
}
|
||||
return at + 1, flat.index("산출근거"), money
|
||||
return 0, 1, {}
|
||||
|
||||
|
||||
def read(rows: list[list[Any]] | None) -> dict[int, dict[str, Any]]:
|
||||
"""단가산출 시트 줄 → `{N: {번, 이름, 단위, 행: [시작, 끝], 출처, 직종, 글, 글행, 금액, 항목,
|
||||
절}}`(행 = 엑셀 1부터 · 글행 = 글 줄마다 행 · 절 = `M02_Hopyo_Formula.tree`)."""
|
||||
if not rows:
|
||||
return {}
|
||||
start, col, money = _columns(rows)
|
||||
end = min(money.values()) if money and min(money.values()) > col + 1 else WIDE
|
||||
names = trade_names()
|
||||
blocks: dict[int, dict[str, Any]] = {}
|
||||
block: dict[str, Any] | None = None
|
||||
for at, row in enumerate(rows[start:], start + 1):
|
||||
text = row[col] if col < len(row) else None
|
||||
head = None
|
||||
if isinstance(text, str) and text.strip():
|
||||
head = None if text[:1].isspace() else _HEAD.match(text)
|
||||
else:
|
||||
text = " ".join(_cell_text(v) for v in row[col + 1 : end] if _cell_text(v))
|
||||
if not text:
|
||||
continue
|
||||
if head:
|
||||
block = blocks.setdefault(
|
||||
int(head.group(1)),
|
||||
{
|
||||
"번": int(head.group(1)),
|
||||
"이름": head.group(2),
|
||||
"단위": head.group(3).strip(),
|
||||
"행": [at, at],
|
||||
"출처": [],
|
||||
"직종": [],
|
||||
"글": [],
|
||||
"금액": {
|
||||
key: v
|
||||
for key, c in money.items()
|
||||
for v in [row[c] if c < len(row) else None]
|
||||
if isinstance(v, (int, float)) and not isinstance(v, bool)
|
||||
},
|
||||
"_글행": [],
|
||||
},
|
||||
)
|
||||
continue
|
||||
if block is not None:
|
||||
_take(block, at, text, names)
|
||||
return _finish(blocks)
|
||||
|
||||
|
||||
def _take(block: dict[str, Any], at: int, text: str, names: dict[str, str]) -> None:
|
||||
"""몸 줄 하나 → 블록 끝 행 · 글(`GLINES` 줄 · 줄마다 `GCHARS` 자) · 출처 · 직종."""
|
||||
block["행"][1] = at
|
||||
|
||||
@@ -40,13 +40,10 @@ LISTS = ("단가산출근거목록표", "노무비목록표", "중기목록표",
|
||||
SHEETS = (SHEET, CALC, *LISTS)
|
||||
_CODE = ilwi.CODE
|
||||
_META = re.compile(r"(?<![A-Z])COD\|([A-Z]{1,2}\d{5})") # 숨은 칸 「`COD|L00001」
|
||||
_HEAD_B = re.compile(r"BDCOD\|(B\d{5})")
|
||||
_HEAD_D = re.compile(r"BDCOD\|(D\d{5})")
|
||||
_RES = re.compile(r"^([LMXS])(\d{5})_\d+$")
|
||||
_RES_A = re.compile(r"^([LMXS]\d{5})[LMS]$") # A 열 「L00002L」
|
||||
_RES_G = re.compile(r"&([LMXS]\d{5})[LMS]&") # G 열 식 「&L00002L&」
|
||||
_SECTION = re.compile(r"^\s*(?:\d+\s*[.)]|[①-⑩])\s*(.*\S)")
|
||||
_COLS = {"합계": 4, "노무비": 6, "재료비": 8, "경비": 10}
|
||||
_CALC_AMOUNT = {"합계": 2, "노무비": 3, "재료비": 4, "경비": 5} # 단가산출근거 C~F 금액
|
||||
_CALC_PRICE = {"합계": 8, "노무비": 9, "재료비": 10, "경비": 11} # I~L 단가(T · L · M · S)
|
||||
NOTE, CODE_COLS, RES_COL, QTY_COL, NAME_COL = 12, range(12, 26), 12, 7, 23
|
||||
@@ -293,27 +290,9 @@ def _finish(out: dict[str, dict[str, Any]]) -> dict[str, dict[str, Any]]:
|
||||
return out
|
||||
|
||||
|
||||
def _blocks(rows: list[list[Any]], table: dict[str, dict[str, str]]) -> dict[str, dict[str, Any]]:
|
||||
"""{D 코드: {번, 코드, 이름, 규격, 단위, 행, 출처, 직종, 글, 자원, 금액, 항목}}."""
|
||||
out: dict[str, dict[str, Any]] = {}
|
||||
block: dict[str, Any] | None = None
|
||||
state = {"절": "", "라벨": ""} # 절 제목 · 율 행 위 라벨 줄(코드 · 금액 없는 글)
|
||||
for at, row in enumerate(rows, 1):
|
||||
head = next(
|
||||
(hit for v in row[:8] if (hit := _HEAD_D.search(_s(v)))), None
|
||||
) # 머리 = G 열(판마다 B 열 글이 다름)
|
||||
if head:
|
||||
block = out.setdefault(head.group(1), _new(head.group(1), at, row, table))
|
||||
state = {"절": "", "라벨": ""}
|
||||
continue
|
||||
if block is not None and not _take(block, at, row, table, state):
|
||||
block = None
|
||||
return _finish(out)
|
||||
|
||||
|
||||
def from_two(blocks: list[dict[str, Any]], table: dict[str, dict[str, str]]) -> dict[str, Any]:
|
||||
"""둘 꼴 STmate 산근 블록 `칸줄`(머리 ~ 다음 머리 앞 칸 · `M02_San_Xlsx_Stmate.cells` · 857-2) →
|
||||
`_blocks` 와 같은 블록 — 시트를 다시 가르지 않음 · D 코드 블록만."""
|
||||
블록 — 시트를 다시 가르지 않음 · D 코드 블록만."""
|
||||
out: dict[str, dict[str, Any]] = {}
|
||||
for b in blocks:
|
||||
code = str(b.get("코드") or "")
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
층 종류(`layers.KINDS`) 밖 폴더 — 양식 목록 · 복사 · 프로젝트 씨앗에 안 섞임 · 권한은 길 몫.
|
||||
한시 불러오기(718-1 · 743-1) — 파일에 `지문`(올린 엑셀 sha256) · 목록 = 지문 있고 하루 안 지난 것
|
||||
(작업 중)만 · 옛 HP · 하루 지난 HP 는 목록에서 숨김(지움 = `M02_Hopyo_Forget`) ·
|
||||
`실무자료/불러옴.json` `{번}` = 낸 키 가장 큰 번(지운 뒤에도 키를 다시 안 씀 · 옛 `지문` 안 읽음).
|
||||
`실무자료/불러옴.json` `{번}` = 낸 키 가장 큰 번(지운 뒤에도 키를 다시 안 씀).
|
||||
판(776-2) = 읽기 꼴(Book) 판 `BOOK` 을 HP 에 찍음 · 다른 판 = 지난 것(목록에서 숨김 ·
|
||||
다음 올림 때 끝냄 · 작업 중 열기 = 409 「다시 올림」 · 옛 꼴 읽기 갈래 없음).
|
||||
"""
|
||||
@@ -95,11 +95,9 @@ def rows(folder: str | Path) -> list[dict[str, Any]]:
|
||||
|
||||
|
||||
def done(folder: str | Path) -> dict[str, Any]:
|
||||
"""키 번 기록 `{번, 지문}`(지문 = 743 전 끝낸 기록 · 안 읽음 · 정리 `Forget.tidy`)."""
|
||||
"""키 번 기록 `{번}`."""
|
||||
doc = _load(_dir(folder) / f"{DONE}.json")
|
||||
doc = doc if isinstance(doc, dict) else {}
|
||||
marks = doc.get("지문")
|
||||
return {"번": int(doc.get("번") or 0), "지문": marks if isinstance(marks, dict) else {}}
|
||||
return {"번": int((doc if isinstance(doc, dict) else {}).get("번") or 0)}
|
||||
|
||||
|
||||
def _put_done(folder: str | Path, got: dict[str, Any]) -> None:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"""M02 일위대가 실무자료 단위 줄(PLAN 778-3 · D-1 · 요구 622) — 단가산출 블록 · 일위대가 줄을 같은
|
||||
「세부항목 계산 단위」 꼴로 · 자체 검산. 형식(EST · STmate)을 모름 — 읽기 어댑터
|
||||
(`M02_Hopyo_ReadEst.items` · `M02_Hopyo_Stmate._blocks`)가 블록 `항목` 을 단위 줄로 냄.
|
||||
(`M02_Hopyo_ReadEst.items` · `M02_Hopyo_Stmate.from_two`)가 블록 `항목` 을 단위 줄로 냄.
|
||||
|
||||
단위 줄 = `{묶음, 이름, 규격, 단위, 품, 밑품, 율, 인자, 계수, 단가, 금액, 밖, 기준, 기준값,
|
||||
하위, 할증, 재현, 직종, 절, 절율, 코드, 어떻게, 행}`:
|
||||
|
||||
@@ -22,6 +22,7 @@ from common_util.common_util_summary_item import GROUP_JOIN
|
||||
from M02_MasterTemplete import M02_Item_Personal as personal
|
||||
from M02_MasterTemplete import M02_Item_Prices as prices
|
||||
from M02_MasterTemplete import M02_Template_Layers as layers
|
||||
from M02_MasterTemplete.M02_Doc_B09 import FILE as FORMULA_FILE
|
||||
from M02_MasterTemplete.M02_Item_Snapshot import (
|
||||
FOLDER_PATTERN,
|
||||
LOCAL_FILES,
|
||||
@@ -191,12 +192,9 @@ def write_file(
|
||||
# ── 새로 가져오기 · 미리 가져오기 ─────────────────────────────────────
|
||||
|
||||
|
||||
def _kept_values(values: Any, labor: dict[str, Any]) -> dict[str, Any]:
|
||||
"""같은 로직 · 같은 입력 이름만 살림."""
|
||||
names = {
|
||||
str(row.get("키")): {spec["이름"] for spec in row.get("입력", [])}
|
||||
for row in labor.get("로직", [])
|
||||
}
|
||||
def _kept_values(values: Any, docs: dict[str, dict]) -> dict[str, Any]:
|
||||
"""같은 로직 · 같은 입력 이름만 살림(입력 = 새 사본 수식 문서 · 855-F B9-6)."""
|
||||
names = {key: set(prices.doc_inputs(doc)) for key, doc in docs.items()}
|
||||
out: dict[str, Any] = {}
|
||||
for logic, inputs in (values or {}).items():
|
||||
kept = {k: v for k, v in (inputs or {}).items() if k in names.get(logic, set())}
|
||||
@@ -205,14 +203,10 @@ def _kept_values(values: Any, labor: dict[str, Any]) -> dict[str, Any]:
|
||||
return out
|
||||
|
||||
|
||||
def _kept_picks(picks: Any, labor: dict[str, Any]) -> dict[str, Any]:
|
||||
"""같은 로직 · 있는 호표 차례만 살림."""
|
||||
lines = {str(row.get("키")): len(row.get("호표", [])) for row in labor.get("로직", [])}
|
||||
slots = { # 흐름 로직 — 고른 자재는 재료 자리 이름(= 입력 이름)
|
||||
str(row.get("키")): {s["이름"] for s in row.get("입력", [])}
|
||||
for row in labor.get("로직", [])
|
||||
if isinstance(row.get("흐름"), dict)
|
||||
}
|
||||
def _kept_picks(picks: Any, docs: dict[str, dict]) -> dict[str, Any]:
|
||||
"""같은 로직 · 있는 줄 차례(문서 금액 줄) · 흐름 로직 재료 자리 이름(= 입력 이름)만 살림."""
|
||||
lines = {key: len(doc.get("금액") or []) for key, doc in docs.items()}
|
||||
slots = {key: set(prices.doc_inputs(doc)) for key, doc in docs.items()}
|
||||
out: dict[str, Any] = {}
|
||||
for logic, chosen in (picks or {}).items():
|
||||
kept = {
|
||||
@@ -238,12 +232,12 @@ def reapply(
|
||||
picks = read_json(target / PICKS_FILE)
|
||||
before = {name: read_json(target / file) for name, file in KINDS.items()}
|
||||
files = build_snapshot(manifest["원본"])
|
||||
labor = files.get(LABOR_FILE) or {}
|
||||
docs = (files.get(FORMULA_FILE) or {}).get("문서") or {} # 새 사본 수식 문서
|
||||
seeded = files[VALUES_FILE] # 새 원본의 첫 값 — 프로젝트에서 넣은 값이 같은 키면 이김
|
||||
kept_values = _kept_values(values, labor)
|
||||
kept_values = _kept_values(values, docs)
|
||||
for logic, inputs in kept_values.items():
|
||||
seeded[logic] = {**seeded.get(logic, {}), **inputs}
|
||||
files[PICKS_FILE] = _kept_picks(picks, labor)
|
||||
files[PICKS_FILE] = _kept_picks(picks, docs)
|
||||
for old in target.glob("*.json"): # 원본에서 빠진 파일(도면 없앰 등)은 지움
|
||||
if old.name != MANIFEST_NAME and old.name not in files:
|
||||
old.unlink()
|
||||
|
||||
@@ -303,22 +303,43 @@ def load_prices(prices: dict[str, Any]) -> Any:
|
||||
|
||||
def _logic_keys(labor: dict[str, Any]) -> list[str]:
|
||||
"""담은 로직 키 — 참조 줄(로직 없음 · 50-3)은 뺌."""
|
||||
return [key for key in mcb.logic_keys(labor.get("줄") or {}) if key]
|
||||
lines = (labor.get("줄") or {}).get("담은로직") or []
|
||||
return [str(one["로직"]) for one in lines if isinstance(one, dict) and one.get("로직")]
|
||||
|
||||
|
||||
def missing_inputs(snapshot: Any, labor: dict[str, Any], values: dict[str, Any]) -> list[dict]:
|
||||
"""담은 로직마다 값이 없는(null · 안 적음) 입력 — `{로직, 입력}`."""
|
||||
def doc_inputs(doc: Any) -> list[str]:
|
||||
"""수식 문서 입력 이름(입력 · 선택 변수 열쇠 · 옛 로직 줄 `입력` 이름 · 차례와 같음)."""
|
||||
return [
|
||||
str(v["열쇠"])
|
||||
for v in (doc or {}).get("변수") or []
|
||||
if (v.get("연결") or {}).get("갈래") in ("입력", "선택") and v.get("열쇠")
|
||||
]
|
||||
|
||||
|
||||
def doc_specs(doc: Any) -> list[dict[str, Any]]:
|
||||
"""수식 문서 입력 꼴(옛 로직 줄 `입력` 자리) — {이름(열쇠), 단위, 설명, 출처, 고르기, 범위}."""
|
||||
out = []
|
||||
for v in (doc or {}).get("변수") or []:
|
||||
link = v.get("연결") or {}
|
||||
if link.get("갈래") not in ("입력", "선택") or not v.get("열쇠"):
|
||||
continue
|
||||
spec = {"이름": str(v["열쇠"]), **{k: v[k] for k in ("단위", "설명", "출처") if v.get(k)}}
|
||||
spec |= {"고르기": list(link["목록"])} if link.get("목록") else {}
|
||||
out.append(spec | ({"범위": list(link["범위"])} if link.get("범위") else {}))
|
||||
return out
|
||||
|
||||
|
||||
def missing_inputs(
|
||||
docs: dict[str, dict], labor: dict[str, Any], values: dict[str, Any]
|
||||
) -> list[dict]:
|
||||
"""담은 로직마다 값이 없는(null · 안 적음) 입력 — `{로직, 입력}` · 입력 = 사본 수식 문서."""
|
||||
out = []
|
||||
for key in _logic_keys(labor):
|
||||
try:
|
||||
row = snapshot.logic(key)
|
||||
except mf.FormulaError:
|
||||
continue
|
||||
mine = values.get(key) or {}
|
||||
for spec in row.get("입력", []):
|
||||
got = mine.get(spec["이름"])
|
||||
for name in doc_inputs(docs.get(key)):
|
||||
got = mine.get(name)
|
||||
if not isinstance(got, dict) or got.get("값") in (None, ""):
|
||||
out.append({"로직": key, "입력": spec["이름"]})
|
||||
out.append({"로직": key, "입력": name})
|
||||
return out
|
||||
|
||||
|
||||
@@ -401,7 +422,7 @@ def line(whole: Any, docs: dict[str, dict] | None, one: dict[str, Any]) -> dict[
|
||||
return {"기준": None, "줄": [], "재료": [], "까닭": f"수식 문서 없음 「{code}」"}
|
||||
apart = dc.apart_of(one.get("자재표시"), [{"차례": n} for n, _, _ in _mat_lines(base)])
|
||||
doc = dc.line_doc(base, one.get("켜쌓기율"), one.get("고름"), apart)
|
||||
given = dc.given_of(whole, code, one.get("입력값"))
|
||||
given = dc.given_of(whole, code, one.get("입력값"), docs)
|
||||
copy = {"부름": docs}
|
||||
try:
|
||||
ans = mt.calc(doc, mt.Trace(whole, docs), given, dc.cover_of(copy, doc))
|
||||
@@ -450,5 +471,5 @@ def calc(
|
||||
return {
|
||||
**got,
|
||||
"알약": saved if isinstance(saved, list) else labor_doc.pills(doc),
|
||||
"빠진입력": missing_inputs(snapshot, labor, values or {}),
|
||||
"빠진입력": missing_inputs(docs, labor, values or {}),
|
||||
}
|
||||
|
||||
@@ -333,6 +333,7 @@ export function createItemCards(opts: ItemCardsOptions): ItemCardsHandle {
|
||||
? {
|
||||
calc: (doc, 수량) => via.calc(at, doc, 수량),
|
||||
readArea: () => src.read("area", at),
|
||||
...(via.sk ? { skCopy: via.sk } : {}), // 856-3 사본 단가산출 줄 = 보기만
|
||||
}
|
||||
: {}),
|
||||
onChanged: (dirty) => laborCard.saver.mark(dirty && laborWritable()),
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
type Layer,
|
||||
} from "./M02_MasterTemplete_Api_Fetch";
|
||||
import type { LaborDoc } from "./M02_MasterTemplete_Labor_Api";
|
||||
import type { LaborCalc } from "./M02_MasterTemplete_Labor_Calc";
|
||||
import type { LaborCalc, LaborRef } from "./M02_MasterTemplete_Labor_Calc";
|
||||
|
||||
/** 집계표 열 하나에 딸린 문서 — 구조물 도면 · 면적산출 */
|
||||
export type ItemPart = "structure" | "area";
|
||||
@@ -34,6 +34,8 @@ export interface ItemSource {
|
||||
doc: LaborDoc,
|
||||
수량?: Record<string, number>,
|
||||
) => Promise<LaborCalc & { 알약: unknown[] }>;
|
||||
/** 프로젝트 사본(856-3) — 단가산출 줄의 굳힌 SK 문서(`참조사본`) · 줄 누름 = 줄 쌓기 보기만 */
|
||||
sk?: (ref: LaborRef) => Promise<Record<string, unknown> | null>;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
import type { DataColumn } from "@ui/ui_template_data_table";
|
||||
import type { Layer } from "./M02_MasterTemplete_Api_Fetch";
|
||||
import type { LaborCalc, LaborDoc } from "./M02_MasterTemplete_Labor_Api";
|
||||
import type { LaborRef } from "./M02_MasterTemplete_Labor_Calc";
|
||||
import { mountLaborTable } from "./M02_MasterTemplete_Labor_Table";
|
||||
|
||||
export interface LaborDetailOptions {
|
||||
@@ -32,6 +33,8 @@ export interface LaborDetailOptions {
|
||||
/** 셈 · 면적 자리 주입(142-1 · 고르기 모달 = 프로젝트 복사본) — 없으면 층 길 */
|
||||
calc?: (doc: LaborDoc, 수량?: Record<string, number>) => Promise<LaborCalc & { 알약: unknown[] }>;
|
||||
readArea?: () => Promise<{ 문서: unknown; 판?: string | null }>;
|
||||
/** 프로젝트 사본(856-3) — 단가산출 줄의 굳힌 SK 문서 · 있으면 그 줄 누름 = 줄 쌓기 보기만 */
|
||||
skCopy?: (ref: LaborRef) => Promise<Record<string, unknown> | null>;
|
||||
}
|
||||
|
||||
/** 덧칸 — `cell(n, 열)` = 문서 줄 n 의 값 · `onRow(n)` 참 = 기본 줄 모달 안 엶 */
|
||||
|
||||
@@ -2,34 +2,19 @@
|
||||
* M02_MasterTemplete_Labor_LogicMats.ts
|
||||
* 자재목록 표의 로직 자재 줄(103-1) — 담은 로직 맨 위 층 재료 줄(서버 calc `줄[].재료`) · 사용자 자재 줄과 같은 칸
|
||||
* (코드 · 이름 · 규격 · 수량 · 단위 · 가격 다섯 · 단가 / 금액) · 사용자 자재 앞.
|
||||
* · 삭제 없음 · [바꾸기] = M01 자재품목 표에서 고름(문서 `담은로직[].고름` · 엔진 `choosing`) · 바꾼 줄만 [기본](고름 풂)
|
||||
* · 금액은 로직 단가 안이라 합에 다시 안 더함(보기만) · 수량은 로직 것(누름 · 알약 없음)
|
||||
* · 하위 로직 안 재료는 안 보임(엔진이 맨 위 층만 고름)
|
||||
* · 줄 누름(148-1) = 그 로직 줄 [옵션] 모달(읽기만이면 보기) · [바꾸기] · [기본]은 고칠 때만
|
||||
* · 보기만(856-3 — 로직 줄 창 · [바꾸기] · [기본] · 세 칸 고침 걷음 · 일위대가 면적 보기 `Labor_View` 가 씀)
|
||||
* · 금액은 로직 단가 안이라 합에 다시 안 더함 · 수량은 로직 것 · 하위 로직 안 재료는 안 보임(엔진이 맨 위 층만 고름)
|
||||
* ========================================================================== */
|
||||
|
||||
import { createButton, el } from "@ui/ui_template_elements";
|
||||
import { el } from "@ui/ui_template_elements";
|
||||
import { formatMoney } from "../common_util/common_util_money";
|
||||
import { openPickTable } from "../M01_MasterData/M01_MasterData_UI_Logic_PickTable";
|
||||
import { headWord } from "../M01_MasterData/M01_MasterData_UI_LogicLab_Modal";
|
||||
import type { LaborCalc, LaborRow, MatMarkKey } from "./M02_MasterTemplete_Labor_Api";
|
||||
import type { LaborCalc, LaborRow } from "./M02_MasterTemplete_Labor_Api";
|
||||
import { lineId } from "./M02_MasterTemplete_Labor_Calc";
|
||||
import { markCells } from "./M02_MasterTemplete_Labor_MatMarks";
|
||||
import { moneyCell, PRICE_SLOTS } from "./M02_MasterTemplete_Labor_Rows";
|
||||
import { tc } from "./M02_MasterTemplete_Labor_Text";
|
||||
import type { LogicMat } from "./M02_Labor_LogicMats_Model";
|
||||
|
||||
export interface LogicMatHandlers {
|
||||
/** 줄 누름(148-1) = 그 자재를 낸 로직 줄 [옵션] 모달 — `row` = 담은 로직 차례 */
|
||||
open: (row: number) => void;
|
||||
/** [바꾸기]로 고른 품목 키 — `row` = 담은 로직 차례 · `at` = 호표 차례 · 없으면(읽기만) 단추 칸 없음 */
|
||||
swap?: (row: number, at: number, key: string) => void;
|
||||
/** [기본] — 그 줄 고름 풂 */
|
||||
reset?: (row: number, at: number) => void;
|
||||
/** 세 칸(148-4) — 로직 줄 `자재표시` · 없으면 글만 */
|
||||
mark?: (row: number, at: number, key: MatMarkKey, v: string) => void;
|
||||
}
|
||||
|
||||
const num = (v: number | null): string =>
|
||||
v === null
|
||||
? "—"
|
||||
@@ -40,21 +25,14 @@ export function logicMatRows(
|
||||
rows: LaborRow[],
|
||||
calc: LaborCalc | null,
|
||||
wait: boolean,
|
||||
on?: LogicMatHandlers,
|
||||
): HTMLElement[] {
|
||||
return rows.flatMap((row, r) => {
|
||||
return rows.flatMap((row) => {
|
||||
const line = row.참조 ? undefined : calc?.줄.find((l) => lineId(l) === lineId(row));
|
||||
return (line?.재료 ?? []).map((mat) => matRow(row, r, mat, wait, on));
|
||||
return (line?.재료 ?? []).map((mat) => matRow(row, mat, wait));
|
||||
});
|
||||
}
|
||||
|
||||
function matRow(
|
||||
row: LaborRow,
|
||||
r: number,
|
||||
mat: LogicMat,
|
||||
wait: boolean,
|
||||
on?: LogicMatHandlers,
|
||||
): HTMLElement {
|
||||
function matRow(row: LaborRow, mat: LogicMat, wait: boolean): HTMLElement {
|
||||
const item = mat.품목;
|
||||
const name = item?.이름 ?? mat.이름;
|
||||
const owner = `${row.별칭 ?? row.로직} · ${mat.이름}`;
|
||||
@@ -69,51 +47,8 @@ function matRow(
|
||||
};
|
||||
const money = moneyCell(mat.단가, mat.금액, wait, tc("Labor_AppliedSum"));
|
||||
money.title = tc("LogicMat_Inside");
|
||||
const swap = on?.swap;
|
||||
const reset = on?.reset;
|
||||
const tools = swap
|
||||
? [
|
||||
el("td", {
|
||||
className: "m02-labrow__move",
|
||||
children: [
|
||||
el("div", {
|
||||
className: "ui-btn-group",
|
||||
children: [
|
||||
createButton({
|
||||
label: tc("LogicMat_Swap"),
|
||||
variant: "ghost",
|
||||
onClick: (e) => {
|
||||
e.stopPropagation();
|
||||
openPickTable({
|
||||
kind: "재료",
|
||||
title: `${tc("LogicMat_PickTitle")} · ${mat.이름}`,
|
||||
seed: headWord(name),
|
||||
alt: [headWord(mat.이름)],
|
||||
isCurrent: (x) => String(x["키"]) === item?.키,
|
||||
onPick: (x) => swap(r, mat.차례, String(x["키"])),
|
||||
});
|
||||
},
|
||||
}),
|
||||
...(mat.고름 && reset
|
||||
? [
|
||||
createButton({
|
||||
label: tc("LogicMat_Reset"),
|
||||
variant: "ghost",
|
||||
onClick: (e) => {
|
||||
e.stopPropagation();
|
||||
reset(r, mat.차례);
|
||||
},
|
||||
}),
|
||||
]
|
||||
: []),
|
||||
],
|
||||
}),
|
||||
],
|
||||
}),
|
||||
]
|
||||
: [];
|
||||
const tr = el("tr", {
|
||||
className: `m02-labrow__row m02-labrow__logic-mat${mat.고름 ? " is-picked-mat" : ""}${on ? " is-open" : ""}`,
|
||||
return el("tr", {
|
||||
className: `m02-labrow__row m02-labrow__logic-mat${mat.고름 ? " is-picked-mat" : ""}`,
|
||||
attrs: { "data-labor-logic-mat": `${row.로직}|${mat.차례}` },
|
||||
children: [
|
||||
el("td", { className: "m02-labrow__code", text: item?.키 ?? "—" }),
|
||||
@@ -146,15 +81,9 @@ function matRow(
|
||||
text: mat.단위,
|
||||
attrs: { "data-label": tc("Labor_Unit") },
|
||||
}),
|
||||
...markCells(
|
||||
row.자재표시?.[String(mat.차례)] ?? {},
|
||||
on?.mark ? (k, v) => on.mark?.(r, mat.차례, k, v) : undefined,
|
||||
),
|
||||
...markCells(row.자재표시?.[String(mat.차례)] ?? {}),
|
||||
...PRICE_SLOTS.map(priceCell),
|
||||
money,
|
||||
...tools,
|
||||
],
|
||||
});
|
||||
if (on) tr.addEventListener("click", () => on.open(r));
|
||||
return tr;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ import { createSelectField, el } from "@ui/ui_template_elements";
|
||||
import {
|
||||
MAT_MARK_DEFAULT,
|
||||
MAT_MARKS,
|
||||
type LaborRow,
|
||||
type MatMarkKey,
|
||||
type MatMarks,
|
||||
} from "./M02_MasterTemplete_Labor_Api";
|
||||
@@ -60,12 +59,3 @@ export function setMark(target: MatMarks, key: MatMarkKey, v: string): void {
|
||||
if (v) (target as Record<string, string>)[key] = v;
|
||||
else delete target[key];
|
||||
}
|
||||
|
||||
/** 로직 줄 `자재표시` 한 차례 한 칸 — 빈 차례 · 빈 묶음은 뺌 */
|
||||
export function setLogicMark(row: LaborRow, at: number, key: MatMarkKey, v: string): void {
|
||||
const all = (row.자재표시 ??= {});
|
||||
const one = (all[String(at)] ??= {});
|
||||
setMark(one, key, v);
|
||||
if (!Object.keys(one).length) delete all[String(at)];
|
||||
if (!Object.keys(all).length) delete row.자재표시;
|
||||
}
|
||||
|
||||
@@ -1,134 +1,20 @@
|
||||
/* =============================================================================
|
||||
* M02_MasterTemplete_Labor_RowModal.ts
|
||||
* 일위대가표 줄 누름 모달(PLAN 723-2 · 요구서_내역16 2장 4 · 5 · 856-1) — 일위대가표에서 빠진 줄 동작을 모달 안으로.
|
||||
* · 로직 줄(단가산출 문서 없음) · 셈 주입 줄(프로젝트 사본) = 머리(이름 · 「1 ㎡ 당」 · 옵션 값 · 메모) + 안내 한 줄
|
||||
* (856-1 — 옛 단가산출 상세 몸 · [적용] 걷음 · 고침 = 단가산출 줄 쌓기 · 856-3 에서 줄 쌓기 보기로) ·
|
||||
* 로직 자재(바꾸기 · 기본 · 세 칸 · `Labor_LogicMats`)
|
||||
* · 사용자 자재 줄 = 자재 모달(세 칸 · `Labor_MatTable` 한 줄)
|
||||
* 일위대가표 사용자 자재 줄 누름 모달(PLAN 723-2 · 요구서_내역16 2장 4 · 5) — 세 칸(`Labor_MatTable` 한 줄) · 가격 다섯 보기.
|
||||
* · 고침 = 그 줄 화면 캐시(저장은 [저장]) · 금액은 표가 다시 셈 → `watch` 로 받아 다시 그림
|
||||
* · 단가산출(SK) 줄 = `Labor_SkEdit`(프로젝트 사본 = 보기만) · M01 로직 줄 창은 걷음(856-3)
|
||||
* ========================================================================== */
|
||||
|
||||
import { createBanner } from "@ui/ui_template_banner";
|
||||
import { el, showToast } from "@ui/ui_template_elements";
|
||||
import { el } from "@ui/ui_template_elements";
|
||||
import { openModal } from "@ui/ui_template_modal";
|
||||
import { createText } from "@ui/ui_template_text";
|
||||
import type { ItemLogic } from "./M02_MasterTemplete_Api_Fetch";
|
||||
import type { LaborCalc, LaborMat, LaborRow, MatMarkKey } from "./M02_MasterTemplete_Labor_Api";
|
||||
import { logicMatRows } from "./M02_MasterTemplete_Labor_LogicMats";
|
||||
import { setLogicMark, setMark } from "./M02_MasterTemplete_Labor_MatMarks";
|
||||
import type { LaborCalc, LaborMat } from "./M02_MasterTemplete_Labor_Api";
|
||||
import { setMark } from "./M02_MasterTemplete_Labor_MatMarks";
|
||||
import { matTable } from "./M02_MasterTemplete_Labor_MatTable";
|
||||
import { tc } from "./M02_MasterTemplete_Labor_Text";
|
||||
import { valueLine } from "./M02_Labor_Values_Model";
|
||||
|
||||
/** 표가 다시 센 답을 받음 — 돌려준 함수 = 그만 받음 */
|
||||
export type CalcWatch = (fn: (calc: LaborCalc | null) => void) => () => void;
|
||||
|
||||
export interface RowModalOptions {
|
||||
row: LaborRow;
|
||||
logic: ItemLogic | null;
|
||||
title: string;
|
||||
/** 일위대가 머리(이름 · 「1 ㎡ 당」) */
|
||||
head: string;
|
||||
readOnly: boolean;
|
||||
/** 셈 주입(프로젝트 복사본) — 안내 글이 다름 */
|
||||
inject: boolean;
|
||||
/** 사용자 자재 코드 — 로직 자재 [바꾸기]로 같은 품목 막음 */
|
||||
userMats: string[];
|
||||
watch: CalcWatch;
|
||||
/** 고침 뒤 — `again` = 서버 다시 셈(입력 · 고름 · 별도계상) · 아니면 화면만 */
|
||||
done: (again: boolean) => void;
|
||||
}
|
||||
|
||||
const TEXT = {
|
||||
NoDoc: [
|
||||
"M01 로직을 바로 담은 줄 — 단가산출 화면 없음 · 고침은 단가산출로 담아(일위대가 [로직 추가]) 그 줄에서",
|
||||
"Uses the M01 logic directly — add it as a build-up to edit",
|
||||
],
|
||||
FromSk: [
|
||||
"단가산출 「{k}」 에서 담아 온 줄 — 고침은 그 단가산출에서 고쳐 다시 담음",
|
||||
"Copied from build-up 「{k}」 — edit it there and re-add",
|
||||
],
|
||||
Inject: [
|
||||
"프로젝트 사본 줄 — 단가산출 화면 없음 · 수식 고침은 M02 단가산출에서 고쳐 [재생성]",
|
||||
"Project copy line — edit the build-up in M02 and regenerate",
|
||||
],
|
||||
} as const;
|
||||
const t = (k: keyof typeof TEXT): string => TEXT[k][0];
|
||||
|
||||
export function openRowModal(o: RowModalOptions): void {
|
||||
const row = o.row;
|
||||
const edit = !o.readOnly;
|
||||
const info = el("div", { attrs: { "data-row-head": "" } });
|
||||
const mats = el("div", { attrs: { "data-row-mats": "" } });
|
||||
let calc: LaborCalc | null = null;
|
||||
|
||||
const draw = (): void => {
|
||||
const values = valueLine(o.logic?.입력 ?? [], row.입력값);
|
||||
info.replaceChildren(
|
||||
createText(o.head, "muted", 14),
|
||||
...(values.text ? [createText(values.text)] : []),
|
||||
...(values.empty
|
||||
? [createText(tc("Labor_Empty").replace("{n}", String(values.empty)), "error")]
|
||||
: []),
|
||||
...(row.켜쌓기율 != null
|
||||
? [createText(tc("Labor_Layer").replace("{n}", String(row.켜쌓기율)), "muted")]
|
||||
: []),
|
||||
...(row.메모 ? [createText(row.메모, "muted")] : []),
|
||||
);
|
||||
const lead = row.참조
|
||||
? []
|
||||
: logicMatRows([row], calc, !calc, {
|
||||
open: () => undefined,
|
||||
...(edit
|
||||
? {
|
||||
swap: (_r: number, at: number, key: string) => {
|
||||
if (o.userMats.includes(key))
|
||||
return showToast(tc("Labor_AlreadyMat").replace("{value}", key), "error");
|
||||
row.고름 = { ...row.고름, [String(at)]: key };
|
||||
o.done(true);
|
||||
},
|
||||
reset: (_r: number, at: number) => {
|
||||
if (!row.고름) return;
|
||||
delete row.고름[String(at)];
|
||||
if (!Object.keys(row.고름).length) delete row.고름;
|
||||
o.done(true);
|
||||
},
|
||||
mark: (_r: number, at: number, key: MatMarkKey, v: string) => {
|
||||
setLogicMark(row, at, key, v);
|
||||
o.done(key === "별도계상");
|
||||
draw();
|
||||
},
|
||||
}
|
||||
: {}),
|
||||
});
|
||||
mats.replaceChildren(
|
||||
...(lead.length
|
||||
? [el("h4", { text: tc("Labor_Mats") }), matTable({ mats: [], calc, lead })]
|
||||
: []),
|
||||
);
|
||||
};
|
||||
|
||||
// 안내 한 줄(856-1) — 로직 줄 = 온 단가산출(`본뜬`) · 셈 주입 = 프로젝트 사본
|
||||
const from = row.본뜬 && typeof row.본뜬.이름 === "string" ? row.본뜬.이름 : "";
|
||||
const note = createBanner({
|
||||
tone: "info",
|
||||
text: o.inject ? t("Inject") : from ? t("FromSk").replace("{k}", from) : t("NoDoc"),
|
||||
});
|
||||
const stop = o.watch((c) => {
|
||||
calc = c;
|
||||
draw();
|
||||
});
|
||||
openModal({
|
||||
title: o.title,
|
||||
closeLabel: tc("In_Close"),
|
||||
width: "1100px",
|
||||
wide: true,
|
||||
beforeClose: () => (stop(), true),
|
||||
mount: (body) => body.append(info, note, mats),
|
||||
});
|
||||
draw();
|
||||
}
|
||||
|
||||
export interface MatModalOptions {
|
||||
mat: LaborMat;
|
||||
watch: CalcWatch;
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
* · [저장] = 수식 저장(`flush`) → 그 SK 문서 저장(`saveTemplate` · 그 층 · 그 주인) → 닫음 → 부르는 쪽이 일위대가 금액을 다시 셈
|
||||
* · 그 층을 못 고치면(위 층 · 남의 주인) 읽기만 · [저장] 없음 · 고친 것 있이 닫으면 물음(버리면 수식 캐시도 비움)
|
||||
* · 머리(808-1 · 요구 701-4 · 5) = 단가산출 페이지 머리와 같음 — 보기 고르기 · [단가 갱신] · [재생성] · [저장] · [닫기]
|
||||
* · 프로젝트 사본(856-3 · `copy`) = 사본의 굳힌 SK 문서째 줄 쌓기 보기만(`memory` · 파일 안 읽음 · 저장 없음) ·
|
||||
* 고침은 M02 단가산출에서 고쳐 [재생성](요구 898 ①)
|
||||
* 짝 모달 = `Labor_RefEdit`(일위조합 SC 줄).
|
||||
* ========================================================================== */
|
||||
|
||||
@@ -23,6 +25,8 @@ export interface SkEditOptions {
|
||||
/** 일위대가 머리(이름 · 「1 ㎡ 당」) */
|
||||
head: string;
|
||||
readOnly: boolean;
|
||||
/** 프로젝트 사본(856-3) — 그 사본의 굳힌 SK 문서(있으면 보기만 · 파일 안 읽음) */
|
||||
copy?: Record<string, unknown>;
|
||||
/** 닫힘 — `saved` = 그 SK 문서를 저장함(부르는 쪽이 금액을 다시 셈) */
|
||||
closed: (saved: boolean) => void;
|
||||
}
|
||||
@@ -39,12 +43,16 @@ export async function openSkEdit(opt: SkEditOptions): Promise<void> {
|
||||
const at = `${layer}/${opt.ref.주인 ?? ""}/${opt.ref.키}`;
|
||||
if (opened.has(at)) return;
|
||||
opened.add(at);
|
||||
let doc: unknown;
|
||||
let version: string;
|
||||
const copy = !!opt.copy;
|
||||
const readOnly = copy || opt.readOnly;
|
||||
let doc: unknown = opt.copy;
|
||||
let version = "";
|
||||
try {
|
||||
const got = await readTemplate(layer, "sangeun", opt.ref.키, null, opt.ref.주인);
|
||||
doc = got.문서;
|
||||
version = got.판 ?? "";
|
||||
if (!copy) {
|
||||
const got = await readTemplate(layer, "sangeun", opt.ref.키, null, opt.ref.주인);
|
||||
doc = got.문서;
|
||||
version = got.판 ?? "";
|
||||
}
|
||||
} catch (error) {
|
||||
opened.delete(at);
|
||||
return void showToast(error instanceof Error ? error.message : tc("Load_Failed"), "error");
|
||||
@@ -72,12 +80,13 @@ export async function openSkEdit(opt: SkEditOptions): Promise<void> {
|
||||
const host = el("div", { attrs: { "data-labor-sk": opt.ref.키 } });
|
||||
const slot = el("span", { className: "m02-main__tools" }); // 보기 고르기 · [단가 갱신] · [재생성](808-1 · 페이지 머리와 같음)
|
||||
handle = mountSangeunDetail(host, doc, {
|
||||
layer,
|
||||
owner: opt.ref.주인,
|
||||
readOnly: opt.readOnly,
|
||||
onChanged: (d) => (dirty = d && !opt.readOnly),
|
||||
// 사본 = 층 읽기 길(굳힌 문서째 셈 · 주인 층 권한 없이)
|
||||
layer: copy ? "system" : layer,
|
||||
owner: copy ? null : opt.ref.주인,
|
||||
readOnly,
|
||||
onChanged: (d) => (dirty = d && !readOnly),
|
||||
onVersion: (v) => (version = v), // 수식 저장이 파일 판을 바꿈 — 문서 저장이 이어 받음
|
||||
mode: "page", // 페이지와 같은 길 — 수식 저장 단추는 이 [저장] 한 번에 모임
|
||||
mode: copy ? "memory" : "page", // 페이지와 같은 길 — 수식 저장 단추는 이 [저장] 한 번에 모임
|
||||
slot,
|
||||
});
|
||||
const ok = createButton({
|
||||
@@ -110,13 +119,17 @@ export async function openSkEdit(opt: SkEditOptions): Promise<void> {
|
||||
body.append(
|
||||
createText(opt.head, "muted", 14),
|
||||
createText(
|
||||
opt.readOnly ? `${tc("Ref_Shared")} · ${tc("Ref_ReadOnly")}` : tc("Ref_Shared"),
|
||||
copy
|
||||
? tc("Ref_Copy")
|
||||
: opt.readOnly
|
||||
? `${tc("Ref_Shared")} · ${tc("Ref_ReadOnly")}`
|
||||
: tc("Ref_Shared"),
|
||||
"hint",
|
||||
),
|
||||
host,
|
||||
);
|
||||
head.append(slot);
|
||||
if (!opt.readOnly) head.append(ok); // [저장] = 머리 [닫기] 왼쪽
|
||||
if (!readOnly) head.append(ok); // [저장] = 머리 [닫기] 왼쪽
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -7,15 +7,16 @@
|
||||
* 금액 빠짐) → 그 줄 금액 · 합계 바로(짝 셈 `Labor_Calc.settle`) · 구조물 조합 · 공사 알약이 이어지면 그 값이 앞섬
|
||||
* · 합계 열 = 「기준단위 단가」(줄 1 단위) · 「수량 반영 금액」(× 수량)
|
||||
* · 머리 단추 = [항목 추가](736-1 · 자재는 찾기 창에서 고름 → 자재 목록) · 줄 우클릭 · 줄 끝 ⋯ = 위로 · 아래로 · 별칭 · 삭제
|
||||
* · 줄 누름 = 줄 모달(`Labor_RowModal` — 옵션 · 메모 · 켜쌓기율 · 로직 자재 바꾸기 · 세 칸 · 안내 한 줄 · 856-1) ·
|
||||
* 사전조합 참조 줄 = 서고 원본 모달(`Labor_RefEdit`) · 사용자 자재 줄 = 자재 모달(세 칸)
|
||||
* · 줄 누름 = 단가산출 줄 = 줄 쌓기(`Labor_SkEdit` · 프로젝트 사본 = 굳힌 문서 보기만 · 856-3) ·
|
||||
* 사전조합 참조 줄 = 서고 원본 모달(`Labor_RefEdit`) · 사용자 자재 줄 = 자재 모달(세 칸) ·
|
||||
* M01 로직을 바로 담은 줄 = 안내 한 줄(창 없음 · 새로 안 생김)
|
||||
* · 금액 = 서버 calc(최신 응답만 · 저장 안 함) · [저장]은 UI_Main(서버가 다시 셈)
|
||||
* · 안 이은 고정 줄(729-3) = 격자 위 띠 · [연결](`Labor_Unlinked` — 이음만 · 저장은 [저장])
|
||||
* 구조물 조합 일위대가(카드 · 열 상세 · PLAN 806-1)도 이 한 부품 — `mode` 없음 = 조합 갈래: 정보 칸(이름 · 구분)
|
||||
* 없음 · 수량 칸 = 수량산출 모달(`Labor_Combo` — 면적산출 잇기) · 규격 열 줄(`Labor_Spec`) · 다이어그램(열 상세) ·
|
||||
* 새 줄 수량 = 면적을 따름(빈 값). 단가산출(SK) 참조 줄 누름 = 그 단가산출 문서 모달(`Labor_SkEdit` — 수식 탭 · 저장 = 그 SK).
|
||||
* 811-1(요구 707-1) — 단가산출 줄 = SK 참조 한 행(저장 때 안 펼침) · [로직 추가] M01 기초 = 이 층 SK 사본 · 다른 층 SK =
|
||||
* 이 층 사본 뒤 참조(`Labor_SkPick`) · 프로젝트 · 셈 주입 = 옛 로직 줄.
|
||||
* 이 층 사본 뒤 참조(`Labor_SkPick`) · 프로젝트 · 셈 주입 표 = 늘 보기만이라 [로직 추가] 없음(856-3).
|
||||
* ========================================================================== */
|
||||
|
||||
import { createButton, createInputField, el, showToast } from "@ui/ui_template_elements";
|
||||
@@ -49,7 +50,7 @@ import { unlinkedBar } from "./M02_MasterTemplete_Labor_Unlinked";
|
||||
import { pasteInto } from "./M02_MasterTemplete_Labor_Paste";
|
||||
import { openLogicPicker, withSangeun } from "./M02_MasterTemplete_Labor_Pick";
|
||||
import { openRefEdit } from "./M02_MasterTemplete_Labor_RefEdit";
|
||||
import { openMatModal, openRowModal } from "./M02_MasterTemplete_Labor_RowModal";
|
||||
import { openMatModal } from "./M02_MasterTemplete_Labor_RowModal";
|
||||
import { tc } from "./M02_MasterTemplete_Labor_Text";
|
||||
import { insideKeys } from "./M02_Labor_LogicMats_Model";
|
||||
import { valueLine } from "./M02_Labor_Values_Model";
|
||||
@@ -333,26 +334,23 @@ export function mountLaborTable(
|
||||
closed: () => alive && recalc(),
|
||||
});
|
||||
if (row.고정) return; // 고정 줄 = 숫자 그대로(이름 · 별칭은 우클릭)
|
||||
// 단가산출(SK) 줄 = 그 단가산출 문서 모달(수식 탭 · 806-1) — 셈 주입(프로젝트 복사본)엔 줄 모달(안내 · 856-3 까지)
|
||||
if (isSkRef(row.참조) && !opt.calc)
|
||||
return void openSkEdit({
|
||||
ref: row.참조,
|
||||
title: nameOf(row),
|
||||
head: head(),
|
||||
readOnly: !edit || row.참조.층 !== opt.layer,
|
||||
closed: (done) => alive && done && recalc(), // 저장했으면 금액을 다시 셈
|
||||
});
|
||||
openRowModal({
|
||||
row,
|
||||
logic: logics.get(row.로직) ?? null,
|
||||
if (!isSkRef(row.참조)) return showToast(tc("Logic_Direct"), "info"); // M01 로직 줄 — 창 없음(856-3)
|
||||
const ref = row.참조;
|
||||
const sk = {
|
||||
ref,
|
||||
title: nameOf(row),
|
||||
head: head(),
|
||||
watch,
|
||||
readOnly: !edit,
|
||||
inject: !!opt.calc,
|
||||
userMats: cur.자재.map((m) => m.코드),
|
||||
done: (again) => changed(!again),
|
||||
});
|
||||
readOnly: !edit || ref.층 !== opt.layer,
|
||||
closed: (done: boolean) => alive && done && recalc(), // 저장했으면 금액을 다시 셈
|
||||
};
|
||||
// 단가산출(SK) 줄 = 그 단가산출 문서 줄 쌓기(806-1) · 프로젝트 사본 = 굳힌 문서 보기만(856-3)
|
||||
if (!opt.skCopy) return void openSkEdit(sk);
|
||||
void opt
|
||||
.skCopy(ref)
|
||||
.then(
|
||||
(copy) => (copy ? void openSkEdit({ ...sk, copy }) : showToast(tc("Sk_NoCopy"), "error")),
|
||||
failed,
|
||||
);
|
||||
}
|
||||
function openMat(i: number): void {
|
||||
const mat = cur.자재[i];
|
||||
@@ -456,7 +454,7 @@ export function mountLaborTable(
|
||||
changed();
|
||||
},
|
||||
};
|
||||
/** SK 사본 길(811-1) — M02 층 일위대가 · 조합만(프로젝트 · 셈 주입 = 옛 로직 줄) */
|
||||
/** SK 사본 길(811-1) — M02 층 일위대가 · 조합만(프로젝트 · 셈 주입 = 늘 보기만 · [로직 추가] 없음 · 856-3) */
|
||||
const own: SkPickScope | null =
|
||||
opt.layer !== "project" && !opt.calc ? { layer: opt.layer, owner: library.owner } : null;
|
||||
const addLogic = createButton({
|
||||
@@ -464,16 +462,12 @@ export function mountLaborTable(
|
||||
variant: "filled",
|
||||
onClick: () =>
|
||||
openLogicPicker((x) => {
|
||||
// 811-1 — M01 기초 = 이 층 SK 사본 참조 한 행(펼치지 않음)
|
||||
if (own)
|
||||
// 811-1 — M01 기초 = 이 층 SK 사본 참조 한 행(펼치지 않음)
|
||||
return void skFromLogic(own, x.키).then(
|
||||
void skFromLogic(own, x.키).then(
|
||||
(r) => r && alive && addRef(r, x.이름 || x.키, null),
|
||||
failed,
|
||||
);
|
||||
if (cur.담은로직.some((r) => r.로직 === x.키))
|
||||
return showToast(tc("Labor_Already").replace("{value}", `${x.키} ${x.이름}`), "error");
|
||||
cur.담은로직.push({ 로직: x.키, 별칭: null, 메모: null, 입력값: {}, 수량: fresh() });
|
||||
void loadLogics().then(() => changed());
|
||||
}, withSangeun(library)),
|
||||
});
|
||||
|
||||
@@ -538,7 +532,7 @@ export function mountLaborTable(
|
||||
className: "m01-logic__section-head",
|
||||
children: [
|
||||
el("h3", { text: tc("Grid_Title") }),
|
||||
...(edit && !(combo && opt.card)
|
||||
...(edit && own && !(combo && opt.card)
|
||||
? [el("div", { className: "ui-btn-group", children: [addLogic] })]
|
||||
: []),
|
||||
],
|
||||
|
||||
@@ -42,6 +42,15 @@ const TEXT = {
|
||||
"Edits the library original — every structure using it follows",
|
||||
],
|
||||
Ref_ReadOnly: ["이 층은 고칠 수 없음 — 읽기만", "Read-only layer"],
|
||||
Ref_Copy: [
|
||||
"프로젝트 사본 — 보기만 · 고침은 M02 단가산출에서 고쳐 [재생성]",
|
||||
"Project copy — view only · edit the build-up in M02 and regenerate",
|
||||
],
|
||||
Sk_NoCopy: ["사본에 이 단가산출 문서가 없음", "This copy has no build-up document"],
|
||||
Logic_Direct: [
|
||||
"M01 로직을 바로 담은 줄 — 단가산출 화면 없음 · 단가산출로 담아 쓰세요(일위대가 [로직 추가])",
|
||||
"Uses the M01 logic directly — add it as a build-up to view or edit",
|
||||
],
|
||||
Lib_SaveFailed: ["저장 못 함", "Save failed"],
|
||||
Ref_Discard: ["저장 안 한 고침을 버리고 닫음?", "Discard unsaved edits?"],
|
||||
Labor_Source: ["원문", "Source"],
|
||||
@@ -109,13 +118,9 @@ const TEXT = {
|
||||
],
|
||||
Labor_Code: ["코드", "Code"],
|
||||
Labor_Spec: ["규격", "Spec"],
|
||||
Labor_Already: ["이미 담은 단가산출 기초 — {value}", "Already added — {value}"],
|
||||
Labor_AlreadyMat: ["이미 담은 자재 — {value}", "Already added — {value}"],
|
||||
// 로직 자재(103-1)
|
||||
Labor_InLogicMat: ["로직 자재에 있는 품목 — {value}", "Already a logic material — {value}"],
|
||||
LogicMat_Swap: ["바꾸기", "Change"],
|
||||
LogicMat_Reset: ["기본", "Default"],
|
||||
LogicMat_PickTitle: ["로직 자재 바꾸기", "Change logic material"],
|
||||
LogicMat_Inside: [
|
||||
"로직 단가 안 금액 — 합계에 다시 안 더함",
|
||||
"Inside the logic price — not added again",
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
STmate(.xlsx) = 단가산출근거 시트 G 열 「BDCOD|D…」 머리 · POSS~POSE 몸(숨은 G 열 원문) ·
|
||||
꼬리(계 · 계약단가 · 총계) + 목록표 단가(노무비 · 재료비 · 경비 = E 열 · 숨은 G 열 `COD` ·
|
||||
중기 · 단가산출근거 = E~H 열 계 · 노 · 재 · 경 · 숨은 J 열 메타).
|
||||
EST(.xls · .xlsx) = 단가산출 시트 블록 글(`M02_Hopyo_ReadEst.read`) + 노임단가 ·
|
||||
EST(.xls · .xlsx) = 단가산출 시트 블록 글 + 노임단가 ·
|
||||
자재단가(적용단가) · 기계경비총괄표 · 견적단가 · 단가산출총괄표(적용 칸 · 합이 안 맞으면 당초 칸).
|
||||
"""
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
구성 없음 → 직접(그 파일 시간당 노 · 재 · 경).
|
||||
잇기(`attach` · 층 저장 길 `M02_Sangeun_FromHopyo.make` 만) = 그 층 내 기계 같은 이름 · 규격이면 그 줄 · 없으면
|
||||
새로(`M02_MyMachine.create`) · 바로 = 기계 줄 이음 키 · 로직 줄 = 시간당 부름 글 / 직접 = 이음 없이 자원
|
||||
`내기계` 키(셈 = 그 파일 값 · [우리 단가로] = 내 기계 시간당 · `M02_Sangeun_Imported.row_of`) ·
|
||||
`내기계` 키(셈 = 그 파일 값 · [우리 단가로] = 내 기계 시간당) ·
|
||||
원본 `내기계` [{키, 이름, 규격, 새로}] · 개인 층 아님 = 안 만듦(원본 `내기계예정` [{이름, 규격}] 만).
|
||||
금액(엑셀 단가 그대로)은 줄 값을 안 건드려 그대로.
|
||||
기계 한 대 안 여러 줄(842-4) = 구성에 `인력줄` [[직종 글, 인]] · `연료줄` [[종류, ℓ]] · `잡품줄` [율 %] · `재료줄` [[이름, 수량, 단위]]
|
||||
|
||||
@@ -92,11 +92,6 @@ def hourly_of(key: str) -> dict:
|
||||
return _HOURLY["rows"][key]
|
||||
|
||||
|
||||
def row_of(doc: Any) -> None:
|
||||
"""옛 가져온 줄(엔진 로직 줄) — 857-3b 부터 저장 안 함 · 읽지 않음(늘 None · 2-D 가 부름 걷음)."""
|
||||
return None
|
||||
|
||||
|
||||
def base_row(doc: dict) -> dict[str, Any]:
|
||||
"""바탕 없는 SK 바탕 줄(`sd.empty_row`) — 입력 · 줄 없음 · 가져온 식 결과단위 = 문서 결과단위(1 단위 배)."""
|
||||
first = (doc.get(KEY) or {}).get(FIRST) if isinstance(doc.get(KEY), dict) else None
|
||||
|
||||
@@ -5,15 +5,15 @@
|
||||
"calc_user": "6d74551273d6735f",
|
||||
"daega_inputs": "8b605fa95c5b9db4",
|
||||
"수요": "23b0132a8a7f46f7",
|
||||
"산근 값": "38455c2edce885ff",
|
||||
"산근 값": "6072e1180a1b81e7",
|
||||
"산근 글": "f5b884a2c49c91c6",
|
||||
"산근 관급 값": "d154925ee64c985c",
|
||||
"산근 관급 값": "6568e5cf9322b81c",
|
||||
"산근 관급 글": "9397c1d1a5fe0dcd",
|
||||
"미리보기 hand:rate 값": "091690571b7dc54b",
|
||||
"미리보기 hand:rate 글": "d17615784f25e4f5",
|
||||
"미리보기 hand:pick 값": "6c7f426d37e31998",
|
||||
"미리보기 hand:pick 글": "7836022de46b3072",
|
||||
"미리보기 hand:net 값": "b1c2c650567a14ae",
|
||||
"미리보기 hand:net 값": "e2809bd3259438b0",
|
||||
"미리보기 hand:net 글": "0254ea22d7a23e43",
|
||||
"B08 단위수량": "896710398b04b4fd"
|
||||
}
|
||||
|
||||
@@ -98,12 +98,13 @@ const input = (o = {}) => {
|
||||
return { root, input: i, setError() {} };
|
||||
};
|
||||
const modals = []; // 열린 모달 — 제목 · 몸
|
||||
const toasts = []; // 알림 글(856-3 M01 로직 줄 안내)
|
||||
const ui = {
|
||||
ui_template_elements: {
|
||||
el,
|
||||
createButton: button,
|
||||
createInputField: input,
|
||||
showToast() {},
|
||||
showToast: (text, kind) => toasts.push([kind, text]),
|
||||
showConfirmDialog: async () => true,
|
||||
},
|
||||
ui_template_button: { createButton: button },
|
||||
@@ -120,7 +121,7 @@ const ui = {
|
||||
const head = box("div");
|
||||
const close = () => {};
|
||||
o.mount?.(body, close, head);
|
||||
modals.push({ title: o.title, body, head, actions: o.actions ?? [] });
|
||||
modals.push({ title: o.title, body, head, actions: o.actions ?? [], shut: o.beforeClose });
|
||||
return { close };
|
||||
},
|
||||
askConfirm: async () => true,
|
||||
@@ -166,6 +167,7 @@ const screen = {
|
||||
|
||||
// 서버 부름 — 길 · 몸을 적고 견본 답
|
||||
const calls = [];
|
||||
const files = { reads: 0, saves: 0 }; // 층 파일 읽기 · 저장 수
|
||||
const api = {
|
||||
call: async (p, init) => {
|
||||
calls.push({ path: p, body: init?.body ? JSON.parse(init.body) : null });
|
||||
@@ -174,8 +176,11 @@ const api = {
|
||||
return { items: [{ ref: "X1", 이름: "견본", 단위: "EA", 값: 1 }] }; // 찾아 넣기(⑤)
|
||||
return {};
|
||||
},
|
||||
readTemplate: async (_l, _k, key) => ({ 문서: { 키: key, 이름: "견본", 단위: "㎡" }, 판: "1" }),
|
||||
saveTemplate: async () => ({}),
|
||||
readTemplate: async (_l, _k, key) => (
|
||||
files.reads++,
|
||||
{ 문서: { 키: key, 이름: "견본", 단위: "㎡" }, 판: "1" }
|
||||
),
|
||||
saveTemplate: async () => (files.saves++, {}),
|
||||
getActiveLayer: () => "system",
|
||||
getActiveOwner: () => null,
|
||||
};
|
||||
@@ -378,7 +383,7 @@ async function openSk(doc, opt = {}) {
|
||||
);
|
||||
out.bands_fail = await bandCase({ doc: null, answer: null, fail: "서버 못 닿음" }, "SK-000004");
|
||||
|
||||
// ② 일위대가 표 줄 누름 — SK 참조 줄 · M01 로직 줄 · 셈 주입(프로젝트 사본) SK 줄
|
||||
// ② 일위대가 표 줄 누름 — SK 참조 줄 · M01 로직 줄 · 셈 주입(원본 층 카드) · 프로젝트 사본(856-3 굳힌 SK 문서)
|
||||
const { mountLaborTable } = M("M02_MasterTemplete/M02_MasterTemplete_Labor_Table.ts");
|
||||
const rows = [
|
||||
{
|
||||
@@ -389,7 +394,9 @@ async function openSk(doc, opt = {}) {
|
||||
},
|
||||
{ 로직: "GC001109", 별칭: null, 메모: null, 입력값: {}, 수량: { 손: 1 } },
|
||||
];
|
||||
const click = async (calc) => {
|
||||
const copyDoc = { 키: "SK-000010", 이름: "사본", 단위: "㎡", 수식: { 따로: true, 굳힘: true } };
|
||||
const asked = [];
|
||||
const click = async (calc, copy) => {
|
||||
const res = [];
|
||||
for (let i = 0; i < rows.length; i++) {
|
||||
const t = mountLaborTable(
|
||||
@@ -399,16 +406,21 @@ async function openSk(doc, opt = {}) {
|
||||
mode: "precombo",
|
||||
layer: "system",
|
||||
column: "공통",
|
||||
readOnly: false,
|
||||
readOnly: !!calc && !copy, // 셈 주입 카드 = 보기만 · 사본은 표가 열려 있어도 줄 쌓기는 보기만인지 봄
|
||||
owner: null,
|
||||
onChanged() {},
|
||||
...(calc ? { calc: async () => ({ 줄: [], 자재: [] }) } : {}),
|
||||
...(copy
|
||||
? { skCopy: async (ref) => (asked.push(ref.키), ref.키 === copy.키 ? copy : null) }
|
||||
: {}),
|
||||
},
|
||||
);
|
||||
await settle();
|
||||
modals.length = 0;
|
||||
stacks.length = 0;
|
||||
calls.length = 0;
|
||||
toasts.length = 0;
|
||||
files.reads = files.saves = 0;
|
||||
grid.onRowClick(i);
|
||||
await settle();
|
||||
const m = modals[0];
|
||||
@@ -417,16 +429,25 @@ async function openSk(doc, opt = {}) {
|
||||
modal: m ? m.title : null,
|
||||
skModal: m ? all(m.body, (n) => "laborSk" in n.dataset).length : 0, // 그 SK 문서 모달(806-1)
|
||||
stack: s ? { shown: shown(s.root), draws: s.draws.map((d) => d.key) } : null,
|
||||
memory: s ? s.draws.map((d) => d.memory) : [],
|
||||
admin: s ? s.opt.admin : null, // 고침 칸(편집) 열림
|
||||
save: m ? all(m.head, (n) => n.dataset.button === "Save").length : 0, // [저장] 단추
|
||||
files: { ...files },
|
||||
toasts: toasts.map((x) => x[0]),
|
||||
body: m ? all(m.body, (n) => "skCover" in n.dataset && shown(n)).length : 0,
|
||||
banners: m ? all(m.body, (n) => "banner" in n.dataset).map((n) => n.dataset.banner) : [],
|
||||
calc: skCalls().length,
|
||||
});
|
||||
for (const one of modals) await one.shut?.(); // 닫기(같은 SK 다시 열 수 있게)
|
||||
t.destroy?.();
|
||||
}
|
||||
return res;
|
||||
};
|
||||
out.labor = await click(false);
|
||||
out.labor_inject = await click(true);
|
||||
out.labor_copy = await click(true, copyDoc);
|
||||
out.labor_copy_asked = asked.slice();
|
||||
out.labor_copy_none = await click(true, { ...copyDoc, 키: "SK-999999" });
|
||||
|
||||
// ④ M01 로직 상세 그릇 — 기본정보 접힘 + 줄 쌓기
|
||||
const { buildLabDetail } = M("M01_MasterData/M01_MasterData_UI_LogicLab_Detail.ts");
|
||||
|
||||
@@ -34,20 +34,6 @@ def _save(folder, doc):
|
||||
return key, json.loads((folder / "precombo" / f"{key}.json").read_bytes())
|
||||
|
||||
|
||||
def test_화면_서고_모드도_자재목록_세_칸_자재_저장(world): # noqa: F811
|
||||
"""723-2 — 서고 = 일위대가표만(`Labor_Table`) · [항목 추가] 머리(736-1 · 자재 추가 단추 걷음) · 세 칸 = 줄 모달(`Labor_RowModal`)."""
|
||||
read = lambda name: open(os.path.join(SRC, name), encoding="utf-8").read() # noqa: E731
|
||||
detail, lib = (
|
||||
read("M02_MasterTemplete_Labor_Detail.ts"),
|
||||
read("M02_MasterTemplete_Labor_Table.ts"),
|
||||
)
|
||||
modal = read("M02_MasterTemplete_Labor_RowModal.ts")
|
||||
assert "return mountLaborTable(host, doc, opt);" in detail # 806-1 — 조합도 같은 부품
|
||||
assert 'className: "ui-btn-group", children: [addLogic]' in lib and "addMat" not in lib
|
||||
assert "setLogicMark(row, at, key, v);" in modal and "setMark(o.mat, key, v);" in modal
|
||||
assert "delete out.자재" not in lib and "delete out.열" in lib
|
||||
|
||||
|
||||
def test_저장_왕복_고름_자재표시_자재_남음(world): # noqa: F811
|
||||
line = {"로직": NET, "고름": {"4": NET_ITEM}, "자재표시": {"3": {"자재구분": "관급"}}}
|
||||
mats = [
|
||||
|
||||
@@ -130,13 +130,6 @@ def test_사전조합_안_줄도_별도계상_뺌():
|
||||
assert got["기준"]["계"] == _kept(raw)["계"]
|
||||
|
||||
|
||||
def test_화면_별도계상_바꾸면_다시_셈():
|
||||
# 806-1 — 조합 · 서고 모두 일위대가표 부품 · 세 칸은 줄 모달(`Labor_RowModal`)
|
||||
modal = open(os.path.join(SRC, "M02_MasterTemplete_Labor_RowModal.ts"), encoding="utf-8").read()
|
||||
assert 'o.done(key === "별도계상");' in modal # 사용자 자재 · 로직 자재 모두 별도계상만 다시 셈
|
||||
assert modal.count('o.done(key === "별도계상");') == 2
|
||||
|
||||
|
||||
# ── ③ 원문 여럿 ──────────────────────────────────────────────────────
|
||||
def test_원문_출처는_같은_책_절_모두():
|
||||
src = inputs.sources(_whole().logic(MIX))
|
||||
|
||||
@@ -3,18 +3,14 @@
|
||||
서버 없이 잡음: 탭(역할) 따라 판 바꿈(일위대가표 = 호표 목록 · 단가산출 탭 = 단가산출 목록 · 칸은 처음 한 번만 지음) ·
|
||||
시트 행 → 목록 강조 · 목록 줄 → 지금 탭의 블록 자리 + 개인 층 가져온 식 모달(835-1 · [내 단가산출로] 단추 걷음) ·
|
||||
줄 끝 [가져온 식으로 열기](809-1 · 판정 블록 판 걷음) ·
|
||||
[끝내기] = 막지 않고 물음창 글만 ·
|
||||
화면 = 부품 상자만 · 700 줄.
|
||||
[끝내기] = 막지 않고 물음창 글만.
|
||||
"""
|
||||
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
HERE = os.path.dirname(__file__)
|
||||
M02 = Path(__file__).resolve().parents[2] / "M02_MasterTemplete"
|
||||
|
||||
|
||||
def _node(payload: dict) -> dict:
|
||||
@@ -59,7 +55,9 @@ def test_판_바꿈_목록_지음_강조_뛰기():
|
||||
assert got["opened"] == [{"no": 8, "canWrite": True, "to": "personal"}] * 6
|
||||
rows = {r["label"]: r for r in got["rows"]}
|
||||
assert rows["단산8 거푸집"]["sub"] == "㎡ · M02_JudgeCalls 1"
|
||||
assert rows["단산8 거푸집"]["tail"] == [] # 만들 층 = 개인 → [가져온 식으로 열기] 숨김 · 저장 단추 없음
|
||||
assert (
|
||||
rows["단산8 거푸집"]["tail"] == []
|
||||
) # 만들 층 = 개인 → [가져온 식으로 열기] 숨김 · 저장 단추 없음
|
||||
assert rows["단산9 잡석"]["sub"] == "㎥ · M02_JudgeOutside"
|
||||
assert rows["단산10 운반"]["tail"] == ["success:M02_JudgeMade SK-000001"]
|
||||
assert got["count"] == {"블록": 2, "밖": 1, "줄": 0} # 만든 SK 뺌
|
||||
@@ -71,37 +69,3 @@ def test_권한_그대로_넘김():
|
||||
{"no": 8, "canWrite": True, "to": "personal"},
|
||||
{"no": 8, "canWrite": False, "to": "company"},
|
||||
]
|
||||
|
||||
|
||||
def _src(name: str) -> str:
|
||||
return (M02 / f"M02_MasterTemplete_Hopyo_{name}.ts").read_text(encoding="utf-8")
|
||||
|
||||
|
||||
def test_캐시_공유_알림_칠_다시():
|
||||
sheet = _src("Sheet")
|
||||
assert "createSheetSk(" in sheet and "sk?.at(s);" in sheet
|
||||
side = _src("SheetSk")
|
||||
assert "readHopyoMarks(opt.scope, opt.key, opt.target)" in side # 809-1 블록 칠 재료 목록
|
||||
assert (
|
||||
"createJudgeBlock" not in side and "createJudgeMove" not in side
|
||||
) # 판정 블록 판 · 옮기기 걷음
|
||||
nav = _src("SheetNav")
|
||||
assert "blockAt(sheet: string, row: number)" in nav and "spotOf(no: number, role: Role)" in nav
|
||||
wizard = _src("Import")
|
||||
assert (
|
||||
'L("M02_SkUnmoved")' in wizard and "leftCount" not in wizard
|
||||
) # 밖 = 안 막음 · 옛 남은 줄 막음 걷음
|
||||
tone = (M02 / "logic" / "M02_MasterTemplete_Hopyo_SheetMap.ts").read_text(encoding="utf-8")
|
||||
assert '글: "일위대가 밖"' in tone
|
||||
|
||||
|
||||
def test_부품_상자만_700줄():
|
||||
for name in ("SheetSk", "Sheet", "SheetNav", "Import", "Side"):
|
||||
src = _src(name)
|
||||
assert len(src.splitlines()) <= 700, name
|
||||
assert not re.search(r"#[0-9a-fA-F]{3,6}\b|rgb\(", src), name
|
||||
for name in ("SheetSk", "Import"):
|
||||
assert not re.search(r'el\("(button|input|select)"|<button|<input', _src(name)), name
|
||||
css = (M02 / "M02_MasterTemplete_Hopyo.css").read_text(encoding="utf-8")
|
||||
block = css.split(".m02-hopyo-sheet.is-sk", 1)[1].split("/*", 1)[0]
|
||||
assert not re.search(r"#[0-9a-fA-F]{3,6}\b|rgb\(", block)
|
||||
|
||||
@@ -103,15 +103,18 @@ def test_구조물_사본_SK_줄_재생성_덮개_입력값_고른자재_그대
|
||||
}
|
||||
)
|
||||
|
||||
def build(_item_): # 원본 층 → 사본 파일(구조물 원본 대신 이 일위대가 문서)
|
||||
def build(
|
||||
_item_,
|
||||
): # 원본 층 → 사본 파일(구조물 원본 대신 이 일위대가 문서 · 수식.json 도 실제 길처럼)
|
||||
from M02_MasterTemplete import M02_Doc_B09 as doc_b09
|
||||
|
||||
rows = source.labor_doc_rows(doc)
|
||||
return _json(
|
||||
{
|
||||
source.LABOR_FILE: rows,
|
||||
source.PRICE_FILE: source.price_bundle(rows, world["personal"]),
|
||||
snapshots.VALUES_FILE: {},
|
||||
}
|
||||
)
|
||||
files = {
|
||||
source.LABOR_FILE: rows,
|
||||
source.PRICE_FILE: source.price_bundle(rows, world["personal"]),
|
||||
snapshots.VALUES_FILE: {},
|
||||
}
|
||||
return _json(doc_b09.attach(files))
|
||||
|
||||
monkeypatch.setattr(item_copy, "build_snapshot", build)
|
||||
root = _project(tmp_path / "proj", [(100, "SS000901")])
|
||||
|
||||
@@ -110,17 +110,3 @@ def test_B09_옛_사본_null_은_그대로_빈_줄():
|
||||
|
||||
def _src(name: str) -> str:
|
||||
return open(os.path.join(SRC, name), encoding="utf-8").read()
|
||||
|
||||
|
||||
def test_화면_수량_칸_저장_새_줄_1_두_칸():
|
||||
table = _src("M02_MasterTemplete_Labor_Table.ts")
|
||||
assert "const temp = new Map" not in table and "withTemp" not in table # 휘발 칸 걷음
|
||||
assert "row.수량 = raw ? { 손: v } : null;" in table and "changed(true);" in table
|
||||
assert (
|
||||
table.count("수량: fresh()") == 4
|
||||
) # 기초 · 참조 · 고정 · 자재 새 줄 = 서고 1 · 조합 면적 따름(806-1)
|
||||
assert "const fresh = (): LaborRow" in table and "{ ...ONE }" in table
|
||||
assert 'BasePrice: ["기준단위 단가"' in table and 'QtyAmount: ["수량 반영 금액"' in table
|
||||
assert 'sum_price: t("BasePrice"), sum: t("QtyAmount")' in table
|
||||
assert 'NeedQty: ["수량 입력"' in table
|
||||
assert 'if (!edit || key !== "qty" || n === null) return false;' in table # 읽기 층 못 고침
|
||||
|
||||
@@ -103,7 +103,7 @@ def test_끝내기_남는_파일_0_금액_그대로_출처만_다시_올림(clie
|
||||
assert not {"키", "원본", "확인", "품셈", "갈래", "엑셀품", "못옮김", "또"} & set(got)
|
||||
lines = doc.get("담은로직") or []
|
||||
assert not any(str(x.get("메모", "")).startswith("실무 ") for x in lines)
|
||||
assert hs.done(folder)["지문"] == {} # 끝낸 기록 없음
|
||||
assert hs.done(folder) == {"번": 1} # 끝낸 기록 없음 · 번만
|
||||
again = _post(client) # 같은 엑셀 다시 올림 = 새 키(409 없음)
|
||||
assert again.status_code == 200 and again.json()["키"] == "HP-000002"
|
||||
|
||||
@@ -121,31 +121,3 @@ def test_하루_지난_HP_목록_숨김_올림_때_지움(client):
|
||||
got = _post(client).json() # 같은 엑셀이어도 지난 것 = 지우고 새로(이어서 아님)
|
||||
assert got["키"] == "HP-000002" and not got.get("이어서")
|
||||
assert _files(folder) == ["HP-000002.json"] * 3 # 이번 것 + 격자 + 산근 시트(793-3b)
|
||||
|
||||
|
||||
def test_옛_파일_정리_미리_보기_쓰기_0_고침(client):
|
||||
folder = layers.personal_dir(7, 42)
|
||||
assert _post(client).json()["키"] == "HP-000001" # 작업 중 — 그대로
|
||||
home = folder / hs.DIRNAME
|
||||
(home / "HP-000007.json").write_text(json.dumps({"키": "HP-000007", "호표": []}), "utf-8")
|
||||
hs._put_done(folder, {"번": 7, "지문": {"ab": {"파일": "옛.xls", "만든": ["SC-000001"]}}})
|
||||
(folder / "precombo").mkdir(exist_ok=True)
|
||||
gone = {"이름": "옛", "단위": "개", "담은로직": [{"로직": "L", "메모": "실무 1개 × 1"}],
|
||||
"본뜬": {**HEAD, "키": "HP-000005 제1호표", "확인": SURE}} # fmt: skip
|
||||
live = {**gone, "본뜬": {**HEAD, "키": "HP-000001 제1호표", "확인": SURE}}
|
||||
for key, doc in (("SC-000001", gone), ("SC-000002", live)):
|
||||
text = json.dumps(doc, ensure_ascii=False)
|
||||
(folder / "precombo" / f"{key}.json").write_text(text, "utf-8")
|
||||
snap = {p: p.read_bytes() for p in folder.rglob("*.json")}
|
||||
|
||||
rows = forget.tidy(folder)
|
||||
assert [r["대상"] for r in rows] == ["실무자료/HP-000007", "불러옴.json", "SC-000001"]
|
||||
assert {p: p.read_bytes() for p in folder.rglob("*.json")} == snap # 미리 보기 = 쓰기 0
|
||||
|
||||
assert forget.tidy(folder, apply=True) == rows
|
||||
assert _files(folder) == ["HP-000001.json"] * 3
|
||||
assert hs.done(folder) == {"번": 7, "지문": {}}
|
||||
docs = _docs(folder, "precombo")
|
||||
assert "키" not in docs["SC-000001"]["본뜬"] and "메모" not in docs["SC-000001"]["담은로직"][0]
|
||||
assert docs["SC-000002"] == live # 작업 중 HP 것 그대로
|
||||
assert forget.tidy(folder) == [] # 두 번째 = 할 일 없음
|
||||
|
||||
@@ -118,7 +118,8 @@ def test_STmate_같은_코드_두_묶음_따로_계수_율_밖():
|
||||
), # fmt: skip
|
||||
_row(c0="총계"),
|
||||
]
|
||||
blocks = st._blocks(rows, {})
|
||||
lines = [{"행": at, **{chr(65 + c): v for c, v in enumerate(r) if v is not None}} for at, r in enumerate(rows, 1)] # fmt: skip
|
||||
blocks = st.from_two([{"코드": "D00001", "칸줄": lines}], {})
|
||||
units = blocks["D00001"]["항목"]
|
||||
xs = [u for u in units if u["묶음"] == "X"]
|
||||
assert [x["품"] for x in xs] == [0.1, 0.2] # 두 묶음 따로(단가 두 배 아님)
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
"""785-4 불러오기 화면 껍데기 — 가운데 상세 페이지(마법사) 없음 · 왼쪽 [불러오기] → 바로 본 칸 엑셀 + 오른쪽 목록 ·
|
||||
머리 막대 [끝내기] · 좁은 판 줄 판 자리 · 부품 상자만 · 700 줄(785-7 — 안 이은 줄 띠 · 마법사 단가산출 걸음 · 옛 캐시 걷음 반영).
|
||||
소스 글만 읽음(서버 · 화면 없이 돎)."""
|
||||
|
||||
import re
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
M02 = ROOT / "M02_MasterTemplete"
|
||||
|
||||
|
||||
def _src(name: str) -> str:
|
||||
return (M02 / f"M02_MasterTemplete_Hopyo_{name}.ts").read_text(encoding="utf-8")
|
||||
|
||||
|
||||
def test_가운데_상세_페이지_없음():
|
||||
assert not (M02 / "M02_MasterTemplete_Hopyo_Wizard.ts").exists()
|
||||
every = "\n".join(p.read_text(encoding="utf-8") for p in M02.glob("*.ts"))
|
||||
for gone in ("buildHopyoWizard", "HopyoWizard", "wantSangeun", "M02_WizSkCheck", "STEPS"):
|
||||
assert gone not in every, gone
|
||||
for key in ("M02_WizSkHead", "M02_WizIlwiHead", "M02_SkHint"):
|
||||
assert key not in (ROOT / "ui_template" / "ui_template_locale_m2.ts").read_text("utf-8")
|
||||
|
||||
|
||||
def test_누름_하나_바로_엑셀():
|
||||
side = _src("Side")
|
||||
choose = side.split("async function choose()")[1].split("input.addEventListener")[0]
|
||||
assert "input.click();" in choose # [불러오기] = 바로 파일 고르기 창
|
||||
change = side.split('input.addEventListener("change"')[1].split("async function leaveOk")[0]
|
||||
assert "uploadHopyo(MINE, file)" in change and "return show(got, true);" in change
|
||||
show = side.split("async function show(")[1].split("async function showLedger")[0]
|
||||
assert "buildHopyoImport({" in show and "opt.show(" in show # 올림 뒤 본 칸 바로
|
||||
imp = _src("Import")
|
||||
assert "m.buildHopyoSheet({" in imp and "headExtra: [finish]" in imp
|
||||
|
||||
|
||||
def test_층_가르기_없음_늘_개인(): # 837-1 · 요구 855 — 예전 「결과 층 고름」 걷음
|
||||
side, imp = _src("Side"), _src("Import")
|
||||
for gone in ("createSegment", "writableLayers", "LAYERS", "layerText", "seg.hidden", "pick"):
|
||||
assert gone not in side, gone
|
||||
for gone in ("LAYERS", "layerText", "writableLayers", "layerNote", "createBadge"):
|
||||
assert gone not in imp, gone
|
||||
assert 'export const MINE: HopyoScope = { layer: "personal", owner: null };' in imp
|
||||
|
||||
|
||||
def test_끝내기_머리_막대_끝냄_뒤_빈_본_칸():
|
||||
imp = _src("Import")
|
||||
end = imp.split("async function end()")[1]
|
||||
assert (
|
||||
"skCount()" in end.split("showConfirmDialog(")[0]
|
||||
) # 안 만든 단가산출 = 물음 글만(막지 않음)
|
||||
assert "deleteHopyo(scope, file.키)" in end and "a.onEnded();" in end
|
||||
side = _src("Side")
|
||||
assert "onEnded: () => {" in side and "void refresh();" in side
|
||||
sheet = _src("Sheet")
|
||||
assert "dropButton" not in sheet and "onDeleted" not in sheet # [삭제] 걷음
|
||||
|
||||
|
||||
def test_부품_상자만_700줄_늘리지_않음():
|
||||
for name in ("Import", "Side", "Sheet", "SheetSk"):
|
||||
src = _src(name)
|
||||
assert len(src.splitlines()) <= 700, name
|
||||
assert not re.search(r"#[0-9a-fA-F]{3,6}\b|rgb\(", src), name # 색 = 공통 값
|
||||
for name in ("Import", "SheetSk"):
|
||||
assert not re.search(r'el\("(button|input|select)"|<button|<input', _src(name)), name
|
||||
assert len(_src("Api").splitlines()) <= 632
|
||||
css = (M02 / "M02_MasterTemplete_Hopyo.css").read_text(encoding="utf-8")
|
||||
assert not re.search(r"#[0-9a-fA-F]{3,6}\b|rgb\(", css) and ".m02-hopyo-import" in css
|
||||
|
||||
|
||||
def test_해시_캐시_열쇠_없음():
|
||||
# 809-1 — 판정 고름 캐시(`Hopyo_Picks`) 걷음 · 옮기기 = [내 일위대가로]
|
||||
assert not (M02 / "logic" / "M02_MasterTemplete_Hopyo_Picks.ts").exists()
|
||||
assert "draftKey" not in _src("Import") and "dirty: () => body?.matDirty()" in _src("Import")
|
||||
assert "location.hash" not in _src("Import") + _src("Side") # 새 해시 열쇠 없음
|
||||
@@ -5,16 +5,10 @@
|
||||
블록 → 793-2a 내보내기 → 793-2 가져온 식 SK(만들 층 · 엑셀 단가 그대로 · 검산 = 엑셀) ·
|
||||
같은 내용 = 그 SK 다시 씀 · 산근 없는 옛 HP = 409 · HP 지우면 산근도 지움 ·
|
||||
STmate 블록 끝전 = 엑셀 계와 맞는 쪽
|
||||
- 화면 소스 — 단가산출 탭 목록 [가져온 식으로 열기](`Hopyo_SheetSk`) · 시트 모달
|
||||
(`Sangeun_Detail`) · 머리 판(검산 · [우리 단가로] / [엑셀 단가로] · [원본 글 보기] ·
|
||||
[이음 고르기] · 소요량 이음) · 부품 상자만 · 700 줄
|
||||
- 809-1 걷음(요구 703) — [우리 기초로 바꾸기] · 근거 세 단 · 입력 필요 · [이 줄에 잇기] · 옮기기 판정 길 없음
|
||||
임시 storage(`client` 마당) · M01 원본 그대로.
|
||||
"""
|
||||
|
||||
import re
|
||||
from pathlib import Path
|
||||
|
||||
import helper_m02_hopyo_golden as golden
|
||||
import pytest
|
||||
|
||||
@@ -26,15 +20,8 @@ from M02_MasterTemplete import M02_Template_Layers as layers
|
||||
# ruff: noqa: F811
|
||||
from resources.tester.test_m02_hopyo_excel import _post, client, master_hash # noqa: F401
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
M02 = ROOT / "M02_MasterTemplete"
|
||||
API = "/api/m02/layers/personal"
|
||||
KEY = "HP-000001"
|
||||
MINE = ("Hopyo_Imported", "Hopyo_ImportedPanel", "Hopyo_SheetSk", "Hopyo_View")
|
||||
|
||||
|
||||
def _src(name: str) -> str:
|
||||
return (M02 / f"M02_MasterTemplete_{name}.ts").read_text(encoding="utf-8")
|
||||
|
||||
|
||||
def _skcount() -> int:
|
||||
@@ -97,44 +84,3 @@ def test_STmate_끝전_엑셀_계와_맞는_쪽(tag, code, rule):
|
||||
got = sx.read(path.name, path.read_bytes())
|
||||
assert got["옵션"]["SAN_TYP"] == xs.RULE[rule]
|
||||
assert any(b["코드"] == code for b in got["산근"])
|
||||
|
||||
|
||||
# ── 화면 소스 ─────────────────────────────────────────────────────────
|
||||
def test_단산_줄_길_잇기():
|
||||
sk, view = _src("Hopyo_SheetSk"), _src("Hopyo_View")
|
||||
assert "openImported({" in sk and "dataset.skOpen" in sk # 단가산출 탭 목록 = 가져온 식 모달
|
||||
assert (
|
||||
'"/sangeun/from-hopyo"' not in view and "openImported({" in view
|
||||
) # [수정] 단산 줄 = 가져온 식 모달(미리 보기 · 835-1)
|
||||
imp = _src("Hopyo_Imported")
|
||||
assert '"/sangeun/from-hopyo/preview"' in imp and '"/sangeun/from-hopyo"' in imp
|
||||
assert "/sangeun/imported/${how}" in imp
|
||||
assert "mountSangeunDetail(" in imp and "saveTemplate(" in imp and "openModal({" in imp
|
||||
for how in ('run("price"', 'run("link"'):
|
||||
assert how in imp, how
|
||||
for gone in ("to-base", "toBase", "onLink", "skPick", "checkJudge", "readJudgeBlock"):
|
||||
assert gone not in imp, gone # 809-1 · 요구 703
|
||||
# 옛 M02 수식 나무 화면(「엑셀 원래」 위 줄) 걷음 — 수식 탭 = 공용 수식 문서 화면(802-4b-2)
|
||||
assert not (M02 / "M02_MasterTemplete_Sangeun_Equation.ts").exists()
|
||||
|
||||
|
||||
def test_머리_판_기초_없음():
|
||||
panel = _src("Hopyo_ImportedPanel")
|
||||
for word in ("ToOurs", "ToExcel", "Source", "Link", "Same", "Diff"):
|
||||
assert f'tx("{word}")' in panel, word
|
||||
for gone in ("ToBase", "PickBase", "data-basis-tiers", "우리 기초로 바꾸기", "근거 제안"):
|
||||
assert gone not in panel, gone
|
||||
model = (M02 / "logic/M02_Hopyo_Imported_Model.ts").read_text(encoding="utf-8")
|
||||
assert "BasisCand" not in model and "skPick" not in model and "근거후보" not in model
|
||||
assert not re.search(r"from \"@ui|document\.|fetch\(|sessionStorage\.", model) # 순수
|
||||
|
||||
|
||||
def test_부품상자만_700줄_공용_안_고침():
|
||||
for name in MINE:
|
||||
text = _src(name)
|
||||
assert len(text.splitlines()) <= 700, name
|
||||
assert not re.search(r"""\bel\(\s*["'](button|input|select)["']""", text), name
|
||||
assert not re.search(r"""createElement\(\s*["'](button|input|select)["']""", text), name
|
||||
assert "#" not in "".join(re.findall(r"color:\s*[^;]+", text)), name
|
||||
for name in ("Labor_Rows", "Labor_SkEdit", "Sangeun_Detail", "Sangeun_Tabs"):
|
||||
assert "Hopyo_Imported" not in _src(name), name # 공용 쪽은 새 모달을 모름
|
||||
|
||||
@@ -45,25 +45,6 @@ def test_조합_상세_카드_서고_한_부품():
|
||||
assert "openQtyModal({" in combo and "linkAreaCell(" in combo and "saveTemplate(" in combo
|
||||
|
||||
|
||||
def test_단가산출_줄은_SK_문서_모달_저장은_그_SK():
|
||||
table = _src("M02_MasterTemplete_Labor_Table.ts")
|
||||
modal = _src("M02_MasterTemplete_Labor_SkEdit.ts")
|
||||
assert 'ref.키.startsWith("SK-")' in modal # SK 참조 줄만
|
||||
assert "if (isSkRef(row.참조) && !opt.calc)" in table # 셈 주입(프로젝트 복사본)엔 옛 줄 모달
|
||||
assert "readOnly: !edit || row.참조.층 !== opt.layer," in table # 위 층 SK = 읽기만
|
||||
assert re.search(r'readTemplate\(layer, "sangeun", opt\.ref\.키, null, opt\.ref\.주인\)', modal)
|
||||
assert re.search(
|
||||
r'saveTemplate\(\s*layer,\s*"sangeun",\s*opt\.ref\.키', modal
|
||||
) # 저장 = 그 SK 문서
|
||||
assert (
|
||||
"mountSangeunDetail(host, doc," in modal and 'mode: "page"' in modal
|
||||
) # 수식 탭 부품 그대로
|
||||
assert "await handle.flush();" in modal # 수식 저장 먼저 → 문서 저장
|
||||
assert "if (!opt.readOnly) head.append(ok);" in modal # 읽기만 = [저장] 없음
|
||||
assert "if (opened.has(at)) return;" in modal # 빨리 두 번 눌러도 하나
|
||||
assert "closed: (done) => alive && done && recalc()," in table # 저장했으면 금액 다시 셈
|
||||
|
||||
|
||||
def test_부품상자만_700줄_명사형():
|
||||
for name in (
|
||||
"M02_MasterTemplete_Labor_Table.ts",
|
||||
@@ -119,18 +100,3 @@ def test_옛_판_저장_409(world):
|
||||
with pytest.raises(store.StoreError) as why:
|
||||
store.write("sangeun", key, got["판"], got["문서"])
|
||||
assert why.value.status == 409
|
||||
|
||||
|
||||
def test_808_1_모달_머리_일원화():
|
||||
"""808-1(요구 701-4 · 5) — 단가산출 줄 모달 머리 = 페이지 머리(보기 고르기 · [단가 갱신] · [재생성]) ·
|
||||
로직 줄 모달(저장된 일위대가 줄 = 펼친 로직 줄 · 740-1) = 옛 [옵션] · [단가산출로도 저장] · [항목 추가] · [율 줄 추가] 없음 ·
|
||||
보기 고르기 없이 상세만 + 안내(온 단가산출) · 줄 문서 키 SK-000000 = 수식 문서 안 읽음(404 없음)."""
|
||||
sk = _src("M02_MasterTemplete_Labor_SkEdit.ts")
|
||||
assert "slot,\n" in sk and "head.append(slot);" in sk
|
||||
row = _src("M02_MasterTemplete_Labor_RowModal.ts")
|
||||
for gone in ("AlsoSk", "createCheckbox", "openLaborInput", "saveAsSk", "Labor_Option"):
|
||||
assert gone not in row, gone
|
||||
assert 't("FromSk")' in row
|
||||
detail = _src("M02_MasterTemplete_Sangeun_Detail.ts")
|
||||
assert "...(opt.slot ? [] : [" in detail # 머리 칸 있으면 머리 줄 없음
|
||||
assert "children: [tabs.tools]" in detail and "tabs.picker" not in detail
|
||||
|
||||
@@ -145,16 +145,3 @@ def test_origin_card_and_clauses(world) -> None:
|
||||
("임도품셈", "5-1-2", 4),
|
||||
]
|
||||
assert plain is None # 우리 SK = 카드 없음(원문 먼저)
|
||||
|
||||
|
||||
def test_source_find_on_m01_and_m02_panels() -> None:
|
||||
m02 = (ROOT / "M02_MasterTemplete/M02_MasterTemplete_Sangeun_Side.ts").read_text("utf-8")
|
||||
m01 = (ROOT / "M01_MasterData/M01_MasterData_UI_LogicLab_Side.ts").read_text("utf-8")
|
||||
assert "createSourceFind" in m02 and "createSourceFind" in m01
|
||||
assert "originOf" in m02
|
||||
sheet = (ROOT / "M02_MasterTemplete/M02_MasterTemplete_Hopyo_Mine.ts").read_text("utf-8")
|
||||
block = (ROOT / "M02_MasterTemplete/M02_MasterTemplete_Hopyo_SheetSk.ts").read_text("utf-8")
|
||||
assert "/hopyo-build-all" in sheet and "번: h.번" in sheet
|
||||
assert '{ layer: "personal", owner: null }' in block and "openImported" in block
|
||||
detail = (ROOT / "M02_MasterTemplete/M02_MasterTemplete_Sangeun_Detail.ts").read_text("utf-8")
|
||||
assert "], doc);" in detail # 원문 패널에 SK 문서(가져온 머리 · 810-4 가져온보관)를 넘김
|
||||
|
||||
@@ -122,16 +122,6 @@ def test_마스터_층_단가산출_로직_줄_0():
|
||||
def test_화면_줄_넣기_SK_사본_참조_부품():
|
||||
table = _src("M02_MasterTemplete_Labor_Table.ts")
|
||||
pick = _src("M02_MasterTemplete_Labor_SkPick.ts")
|
||||
assert 'opt.layer !== "project" && !opt.calc ? { layer: opt.layer' in table # 프로젝트 = 옛 길
|
||||
assert "return void skFromLogic(own, x.키).then(" in table # M01 기초 = SK 사본
|
||||
assert "own && isSkRef(ref)" in table and "void ownSk(own, ref)" in table # 다른 층 = 사본
|
||||
assert "if (isSkRef(row.참조) && !opt.calc)" in table # 줄 누름 = SK 수식 모달
|
||||
assert "/sangeun/from-logic" in pick and "{ 본뜬 }" in pick and "withSameAsk(" in pick
|
||||
assert (
|
||||
"fetchSessionUser()" in pick
|
||||
) # 주인 null = 자기 층 → 서버 참조 꼴(같은 층 SK 를 사본으로 안 만듦)
|
||||
combo = _src("M02_MasterTemplete_Labor_Combo.ts")
|
||||
assert "...refCards(doc, calc)" in combo and "key: r.참조.키," in combo # 다이어그램 참조 카드
|
||||
for text in (table, pick):
|
||||
assert len(text.splitlines()) <= 700
|
||||
assert not re.search(r"""\bel\(\s*["'](button|input|select)["']""", text)
|
||||
|
||||
@@ -21,26 +21,3 @@ def test_불러오기_길_층_고정(monkeypatch):
|
||||
hopyo._root({}, layer, owner, write=True)
|
||||
hopyo._root({}, layer, owner)
|
||||
assert seen == [("personal", None, True), ("personal", None, False)] * 3
|
||||
|
||||
|
||||
def test_라우터_루트_모두_고정_함수():
|
||||
src = (ROOT / "M02_MasterTemplete" / "M02_Hopyo_Router.py").read_text(encoding="utf-8")
|
||||
assert "import _root as _layer_root" in src
|
||||
assert "_layer_root(" in src.split("def _root(")[1].split("\n\n")[0]
|
||||
assert src.count("_layer_root(") == 1 # 층 고르는 길은 이 한 곳뿐
|
||||
|
||||
|
||||
def test_단산_블록_만들기_개인_층만():
|
||||
src = (ROOT / "M02_MasterTemplete" / "M02_Sangeun_Router.py").read_text(encoding="utf-8")
|
||||
for fn in ("def sangeun_from_hopyo(", "def sangeun_from_hopyo_preview("):
|
||||
body = src.split(fn)[1].split("\n@router")[0]
|
||||
assert "body.층" not in body and "_root(session, layer" not in body, fn
|
||||
assert '_root(session, "personal", None' in body, fn
|
||||
|
||||
|
||||
def test_화면_층_고름_없음():
|
||||
m02 = ROOT / "M02_MasterTemplete"
|
||||
side = (m02 / "M02_MasterTemplete_Hopyo_Side.ts").read_text(encoding="utf-8")
|
||||
imp = (m02 / "M02_MasterTemplete_Hopyo_Import.ts").read_text(encoding="utf-8")
|
||||
assert "createSegment" not in side and "writableLayers" not in side + imp
|
||||
assert '"회사"' not in side + imp and '"마스터"' not in side + imp
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"""PLAN 856-0 — 단가산출 화면 지킴(가짜 DOM · 진짜 코드 · `helper_856_0_sk_screen.cjs`).
|
||||
|
||||
① 단가산출 화면을 열 때 서버 `/sangeun/calc` 부름 0(856-2) · 숨은 상세 몸 DOM · 줄 쌓기 그림
|
||||
② 일위대가 표 줄 누름 — 단가산출(SK) 참조 줄 = 그 SK 줄 쌓기 · M01 로직 줄 · 셈 주입(프로젝트 사본) 줄
|
||||
② 일위대가 표 줄 누름 — 단가산출(SK) 참조 줄 = 그 SK 줄 쌓기 · M01 로직 줄 = 안내 · 프로젝트 사본 = 보기만(856-3)
|
||||
③ 머리 띠(까닭 · M01 개정 · 빠진 줄)가 뜨는 경우 — 줄 쌓기 셈 답 · 사본 표지 견본(856-2 · 짝 잃음 = 덮개 없음)
|
||||
④ M01 로직 상세 그릇 = 기본정보 접힘 + 줄 쌓기
|
||||
⑤ 줄 쌓기 [+ 줄] 찾아 넣기 — 빈 낱말로 열어도 종류마다 서버 찾기 · 목록이 그려짐(856-F)
|
||||
@@ -45,20 +45,37 @@ def test_sk_page_open_calls_and_hidden_body() -> None:
|
||||
|
||||
def test_labor_row_click() -> None:
|
||||
sk, logic = _run()["labor"]
|
||||
# 단가산출 참조 줄 = 그 SK 문서 모달 · 줄 쌓기가 그 키로 보임
|
||||
# 단가산출 참조 줄 = 그 SK 문서 모달 · 줄 쌓기가 그 키로 보임 · 고칠 수 있음([저장] 있음)
|
||||
assert sk["skModal"] == 1 and sk["stack"]["shown"] is True
|
||||
assert sk["stack"]["draws"] == ["SK-000010"] and sk["calc"] == 0
|
||||
# M01 로직 줄 = 줄 모달(안내 한 줄) · 상세 몸 · 줄 쌓기 · 셈 없음(856-1)
|
||||
assert logic["skModal"] == 0 and logic["stack"] is None
|
||||
assert logic["body"] == 0 and logic["banners"] == ["info"] and logic["calc"] == 0
|
||||
assert sk["admin"] is True and sk["save"] == 1 and sk["files"] == {"reads": 1, "saves": 0}
|
||||
# M01 로직 줄 = 창 없음 · 안내 알림 한 줄(856-3) · 셈 없음
|
||||
assert logic["modal"] is None and logic["stack"] is None
|
||||
assert logic["toasts"] == ["info"] and logic["calc"] == 0
|
||||
|
||||
|
||||
def test_labor_row_click_inject() -> None:
|
||||
sk, logic = _run()["labor_inject"]
|
||||
# 셈 주입(프로젝트 사본) = 줄 모달 · 안내 한 줄(856-3 까지) · 셈 없음
|
||||
for row in (sk, logic):
|
||||
assert row["modal"] and row["stack"] is None
|
||||
assert row["body"] == 0 and row["banners"] == ["info"] and row["calc"] == 0
|
||||
# 셈 주입 원본 층 카드(보기만 표) = 그 층 SK 줄 쌓기 읽기만 · [저장] 없음
|
||||
assert sk["skModal"] == 1 and sk["stack"]["draws"] == ["SK-000010"]
|
||||
assert sk["admin"] is False and sk["save"] == 0 and sk["files"]["saves"] == 0
|
||||
assert logic["modal"] is None and logic["toasts"] == ["info"]
|
||||
|
||||
|
||||
def test_labor_row_click_project_copy() -> None:
|
||||
got = _run()
|
||||
sk, logic = got["labor_copy"]
|
||||
# 856-3 프로젝트 사본 = 그 사본의 굳힌 SK 문서째 줄 쌓기 보기만 — 빈 키 + 문서째(memory) ·
|
||||
# 고침 칸 잠김 · [저장] 없음 · 층 파일 읽기 · 저장 0 · 서버 셈 길 0
|
||||
assert sk["skModal"] == 1 and sk["stack"]["shown"] is True
|
||||
assert sk["stack"]["draws"] == [""] and sk["memory"] == [True]
|
||||
assert sk["admin"] is False and sk["save"] == 0
|
||||
assert sk["files"] == {"reads": 0, "saves": 0} and sk["calc"] == 0
|
||||
assert got["labor_copy_asked"] == ["SK-000010"]
|
||||
assert logic["modal"] is None and logic["toasts"] == ["info"]
|
||||
# 사본에 그 문서가 없음 = 창 없음 · 알림(error)
|
||||
none = got["labor_copy_none"][0]
|
||||
assert none["modal"] is None and none["toasts"] == ["error"]
|
||||
|
||||
|
||||
def test_head_bands() -> None:
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
"""일위대가 실무자료 화면(PLAN 324-4 · 718-1 · 785-4) — 좌측 판 자리 · 권한 · 불러오기 본 칸 · [끝내기] · 떠남.
|
||||
|
||||
옛 확인 창 · 고르기 창 · [로직 추가] 「실무 호표」 · 엑셀 보기 모달 시험은 785-7 에서 지움(판정 화면 = `test_642_6_screen`).
|
||||
"""
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
HERE = os.path.dirname(os.path.abspath(__file__))
|
||||
M02 = Path(HERE).parents[1] / "M02_MasterTemplete"
|
||||
|
||||
|
||||
def _text(name: str) -> str:
|
||||
return (M02 / name).read_text(encoding="utf-8")
|
||||
|
||||
|
||||
def test_좌측_판_자리와_권한():
|
||||
side = _text("M02_MasterTemplete_UI_Side.ts")
|
||||
assert 'import { buildHopyoSection } from "./M02_MasterTemplete_Hopyo_Side";' in side
|
||||
host = side.split('className: "m02-side__lists ui-sidebar-panel"')[1]
|
||||
# 716-3 차례 — 일위대가 › 구조물 조합 › 구분선 › 일위대가 불러오기 › 도면 양식
|
||||
order = ("precomboSec,", "summary,", "createDivider(),", "section(hopyo.title, hopyo.body),")
|
||||
assert [host.index(k) for k in order] == sorted(host.index(k) for k in order)
|
||||
assert host.index("section(hopyo.title, hopyo.body),") < host.index("drawing,")
|
||||
assert "canWrite: opt.canWrite," not in side # 옛 [별칭 장부] 걷음(815-2)
|
||||
assert "hopyo.paint();" in side.split("function paint(): void {")[1]
|
||||
hopyo_side = _text("M02_MasterTemplete_Hopyo_Side.ts")
|
||||
# 718-1 · 785-4 — 제목 = 화면 글 키 · [불러오기] = 구조물 조합 층 단추 꼴 → 바로 파일 고르기 → 본 칸 불러오기 보기
|
||||
assert 'L("M02_HopyoImport")' in hopyo_side and "일위대가 실무자료" not in hopyo_side
|
||||
start = hopyo_side.split("const start = createButton({")[1].split("start.title")[0]
|
||||
assert 'label: "불러오기"' in start and 'start.classList.add("m02-layers__btn");' in start
|
||||
assert "buildHopyoImport({" in hopyo_side and "Hopyo_Wizard" not in hopyo_side
|
||||
assert not (M02 / "M02_MasterTemplete_Hopyo_Wizard.ts").exists() # 가운데 상세 페이지 없음
|
||||
assert "uploadHopyo(" in hopyo_side and "openHopyoSheet" not in hopyo_side
|
||||
assert "buildHopyoLedger" not in hopyo_side and "data-hopyo-ledger" not in hopyo_side
|
||||
assert not (M02 / "M02_MasterTemplete_Hopyo_Ledger.ts").exists() # 옛 [별칭 장부] 걷음(815-2)
|
||||
imp = _text("M02_MasterTemplete_Hopyo_Import.ts")
|
||||
assert 'accept: ".xls,.xlsx,.estx,.stc"' in hopyo_side # 810-3 · 814-1 원파일도
|
||||
assert "input.hidden = true;" in hopyo_side
|
||||
choose = hopyo_side.split("async function choose()")[1].split("input.addEventListener")[0]
|
||||
assert "input.click();" in choose # 누름 하나 — 바로 파일 고르기 창
|
||||
assert "writableLayers" not in imp + hopyo_side # 837-1 층 고름 걷음 — 늘 개인 층
|
||||
assert "uploadHopyo(MINE, file)" in hopyo_side
|
||||
for gone in ("wantSangeun", "STEPS", "second(", "steps.set", "data-hopyo-sangeun"):
|
||||
assert gone not in imp + hopyo_side, gone # 중간 걸음 · 단가산출 체크 없음
|
||||
|
||||
|
||||
def test_372_2_저장은_개인_층에_삭제는_화면_층_권한():
|
||||
"""718-1 — 만들 층 = 올린 층 · [끝내기] 로 올린 파일 지움 → 빈 본 칸(785-4: 엑셀 보기 [삭제] 걷음) ·
|
||||
743-1 — 떠남(화면 바뀜 · 페이지 닫음) = 쥔 파일 지움."""
|
||||
imp = _text("M02_MasterTemplete_Hopyo_Import.ts")
|
||||
open_ = imp.split("m.buildHopyoSheet({")[1].split("});")[0]
|
||||
assert "target: scope," in open_ and "canWrite: true," in open_
|
||||
assert "onDeleted" not in imp and "dropButton" not in _text("M02_MasterTemplete_Hopyo_Sheet.ts")
|
||||
assert "a.onEnded();" in imp and "held = false;" in imp
|
||||
assert 'addEventListener("pagehide", leave)' in imp and " leave,\n" in imp
|
||||
panel = _text("M02_MasterTemplete_Hopyo_Side.ts")
|
||||
assert panel.count("open?.imp?.leave()") == 1 and panel.count("open.imp?.leave()") == 1
|
||||
@@ -142,16 +142,3 @@ def test_입력이_바뀌면_걸린_고름만_풂_화면_짝():
|
||||
def _src(name):
|
||||
with open(os.path.join(HERE, "..", "..", "M02_MasterTemplete", name), encoding="utf-8") as f:
|
||||
return f.read()
|
||||
|
||||
|
||||
def test_로직_자재_줄_누름은_그_로직_옵션_모달_사용자_줄은_그대로():
|
||||
"""148-1 — 고칠 때 · 읽기만 둘 다 `open: openRow` · 바꾸기 단추 칸은 swap 있을 때만 · 사용자 줄 = openMat."""
|
||||
# 806-1 — 조합 · 서고 모두 일위대가표 부품 — 로직 자재 바꾸기 · 세 칸은 줄 모달(`Labor_RowModal`) 안
|
||||
modal = _src("M02_MasterTemplete_Labor_RowModal.ts")
|
||||
assert (
|
||||
"open: () => undefined," in modal and "swap: (_r: number, at: number, key: string)" in modal
|
||||
)
|
||||
mats = _src("M02_MasterTemplete_Labor_LogicMats.ts")
|
||||
assert "const tools = swap" in mats
|
||||
assert 'tr.addEventListener("click", () => on.open(r))' in mats
|
||||
assert '${on ? " is-open" : ""}' in mats
|
||||
|
||||
@@ -118,15 +118,6 @@ def _src(name):
|
||||
|
||||
|
||||
def test_화면_칸_부품_사용자_줄_로직_줄_같은_칸():
|
||||
marks = _src("M02_MasterTemplete_Labor_MatMarks.ts")
|
||||
assert '"—"' not in marks # 「—」 항목 없음(162-1)
|
||||
assert "e.stopPropagation()" in marks # 줄 누름과 따로
|
||||
rows = _src("M02_MasterTemplete_Labor_MatTable.ts") # 717-3 자재목록 표 나눔
|
||||
assert "...markCells(mat, on?.mark" in rows and "...markHeads()," in rows
|
||||
assert "...markCells(" in _src("M02_MasterTemplete_Labor_LogicMats.ts")
|
||||
modal = _src("M02_MasterTemplete_Labor_RowModal.ts") # 806-1 — 조합 · 서고 모두 줄 모달 안
|
||||
assert "mark: (_r: number, at: number, key: MatMarkKey, v: string)" in modal
|
||||
assert "mark: (_i, key, v) =>" in modal
|
||||
# 서버 허용 값 = 화면 허용 값
|
||||
api = _src("M02_MasterTemplete_Labor_Api.ts")
|
||||
for key, allowed in labor.MARKS.items():
|
||||
|
||||
@@ -18,6 +18,7 @@ import { readTemplate } from "../M02_MasterTemplete/M02_MasterTemplete_Api_Fetch
|
||||
import { formatMoney } from "../common_util/common_util_money";
|
||||
import { dateText } from "../common_util/common_util_time";
|
||||
import { calcLabor, type LaborDoc } from "../M02_MasterTemplete/M02_MasterTemplete_Labor_Api";
|
||||
import { lineId } from "../M02_MasterTemplete/M02_MasterTemplete_Labor_Calc";
|
||||
import type { EditKind, ItemCardsHandle } from "../M02_MasterTemplete/M02_MasterTemplete_ItemCards";
|
||||
import type { ItemSource } from "../M02_MasterTemplete/M02_MasterTemplete_ItemSource";
|
||||
import type { ValueDoc } from "../M02_MasterTemplete/M02_Labor_Values_Model";
|
||||
@@ -193,6 +194,13 @@ export function createItemDetail(opts: ItemDetailOptions): ItemDetail {
|
||||
return { 문서: labor?.줄 ? withCopyValues(labor.줄, values, picks) : {} };
|
||||
},
|
||||
calc: () => calcCopy(at),
|
||||
// 856-3 단가산출 줄 = 사본의 굳힌 SK 문서(`참조사본`) — 줄 쌓기 보기만
|
||||
sk: async (ref) => {
|
||||
const labor = (await readCopy(at, "일위대가")) as {
|
||||
참조사본?: Record<string, Record<string, unknown>>;
|
||||
} | null;
|
||||
return labor?.참조사본?.[lineId({ 참조: ref }) ?? ""] ?? null;
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user