Merge remote-tracking branch 'origin/sub_laptop_6' into sub_laptop_5

This commit is contained in:
2026-10-31 14:18:05 +09:00
13 changed files with 553 additions and 16 deletions
@@ -11,6 +11,8 @@
대가 줄 = 부른 블록 합계(노무 · 재료 · 경비) · 산근 줄 = 145-1 산근 단가(`sangeun` {키: 값})
비고 = 대가 줄 「대가n」 · 산근 줄 「산근 n호표」(산근 목록 번호)
% 줄 = 밑수(그 블록 노무 줄 금액 합) × % / 100
고정 줄(705-1) = 줄 단가(`own`) · 이음(`link`) 있으면 그 비목만 단가 책 값(노임 = 노무 · 자재 =
재료(관급 · 별도 0원) · 기계 = 중기 세 비목) · 책에 없으면 줄 단가 그대로 · 빈칸 안 됨
끝수 = 엑셀 자리 그대로 — 줄 금액 = ROUNDDOWN(단가 × 수량, 1) ·
% 줄 = ROUNDDOWN(밑수 × % / 100, 1) · 관급 · 별도계상 자재 = 대가 안 0원 ·
블록 비목 합 = ROUNDDOWN(Σ, 0) · 합계 = 세 비목 합.
@@ -58,11 +60,31 @@ def _prices(line: dict[str, Any], books: dict[str, Any], sums: dict) -> dict[str
) or {}
for part in PARTS:
out[part] = None if row.get("blank") else num(row.get(part)) # 빈 줄 대가 = 빈칸
elif kind == "fixed":
out = _fixed(line, books)
else: # blank — 못 펼친 줄
out = dict.fromkeys(PARTS, None)
return out
def _fixed(line: dict[str, Any], books: dict[str, Any]) -> dict[str, float | None]:
"""고정 줄 단가(705-1) — 줄 단가 위에 이은 비목만 단가 책 값."""
own, link = line.get("own") or {}, line.get("link") or {}
out = {part: num(own.get(part)) or 0.0 for part in PARTS}
labor = books["labor"].get(link.get("labor")) if link.get("labor") else None
if labor and num(labor.get("price")) is not None:
out["labor"] = num(labor["price"])
row = books["material"].get(link.get("material")) if link.get("material") else None
if row and (row.get("supply") in SUPPLY or num(row.get("price")) is not None):
out["material"] = 0.0 if row.get("supply") in SUPPLY else num(row["price"])
machine = books["machine"].get(link.get("machine")) if link.get("machine") else None
if machine and not machine.get("blank"):
for part in PARTS:
if num(machine.get(part)) is not None:
out[part] = num(machine[part])
return out
def _base(spec: str, lines: list[dict[str, Any]]) -> float | None:
"""% 줄 밑수 — `part:비목` 그 비목 줄 금액 합 · `lines:labor` 노무 줄 금액 합 ·
`line:이름` 그 줄."""
+21 -1
View File
@@ -8,6 +8,8 @@
*
* 노무 줄 = 노무비목록표 · 재료 줄 = 재료비목록표 · 중기 줄 = 중기목록표 · 대가 줄 = 부른 블록 합계 ·
* 산근 줄 = 145-1 산근 단가 · % 줄 = 밑수(노무 줄 금액 합) × % / 100
* 고정 줄(705-1) = 줄 단가(own) · 이음(link) 있으면 그 비목만 단가 책 값(노임 = 노무 · 자재 = 재료
* (관급 · 별도 0원) · 기계 = 중기 세 비목) · 책에 없으면 줄 단가 그대로 · 빈칸 안 됨
* 비고 = 대가 줄 「대가n」 · 산근 줄 「산근 n호표」(산근 목록 번호)
* 줄 금액 ROUNDDOWN(단가 × 수량, 1) · 블록 비목 합 ROUNDDOWN(Σ, 0) · 합계 = 세 비목 합
* 관급 · 별도계상 자재 = 대가 안 0원(자재대 · 관급 단락에서 셈)
@@ -59,7 +61,25 @@ function linePrices(line: Row, books: Row, sums: Record<string, Row>): Parts {
const src: Row = ({ machine: books.machine, daega: sums, sangeun: books.sangeun } as Row)[kind];
const row: Row = src[key] || {};
for (const part of PARTS) out[part] = row.blank ? null : num(row[part]); // 빈 줄 대가 = 빈칸
} else return blanks(); // blank — 못 펼친 줄
} else if (kind === "fixed") return fixedPrices(line, books);
else return blanks(); // blank — 못 펼친 줄
return out;
}
/** 고정 줄 단가(705-1) — 줄 단가 위에 이은 비목만 단가 책 값(짝 `_fixed`) */
function fixedPrices(line: Row, books: Row): Parts {
const own: Row = line.own || {};
const link: Row = line.link || {};
const out = zeros();
for (const part of PARTS) out[part] = num(own[part]) ?? 0;
const labor: Row | undefined = link.labor ? books.labor[link.labor] : undefined;
if (labor && num(labor.price) !== null) out.labor = num(labor.price);
const row: Row | undefined = link.material ? books.material[link.material] : undefined;
const supplied = !!row && (SUPPLY as readonly string[]).includes(row.supply);
if (row && (supplied || num(row.price) !== null)) out.material = supplied ? 0 : num(row.price);
const machine: Row | undefined = link.machine ? books.machine[link.machine] : undefined;
if (machine && !machine.blank)
for (const part of PARTS) if (num(machine[part]) !== null) out[part] = num(machine[part]);
return out;
}
@@ -10,6 +10,7 @@
— 조합이 수량만큼 부름 · 기계 = 기계경비 로직 줄 · 다른 돈 로직 줄 = 하위 산근
산근 단가산출 줄(일위대가화 아닌 로직 줄) = 산근 호표 참조(키 = 145-1 `sangeun_key`)
(155-3 · 사용자 뜻 = 일위대가화 줄 = 대가 · 단가산출 줄 = 산근 · 145 정함 뒤집음)
고정 고정 줄(705-1) = `fixed` 줄 하나 · `own` = 줄 단가 · `link` = 이음 키(셈 짝이 단가 책 값)
같은 블록 = 같은 꼴 → 한 호표(id = 내용 해시 · 같은 원본 + 같은 셈 단가 = 하나) ·
덮개 열쇠(702-2 · 내용 해시 밖 · 수량 · 단가가 바뀌어도 그대로) = 블록 `cover` + 줄 `cid` —
@@ -34,6 +35,7 @@ from B09_Estimation import B09_Estimation_Sangeun as sg
from B09_Estimation import B09_Estimation_Sangeun_Text as st
from M02_MasterTemplete import M02_Item_Prices as item_prices
from M02_MasterTemplete import M02_Labor_Doc as labor_doc
from M02_MasterTemplete import M02_Labor_Fixed as fixed
from M02_MasterTemplete import M02_Labor_Ref as refs
from M02_MasterTemplete.M02_Item_Snapshot import (
MANIFEST_NAME,
@@ -194,6 +196,8 @@ class Builder:
q = _f(qty)
t = _f(times) or 1.0
each = None if q is None else q / t
if fixed.is_fixed(one):
return fixed_line(one[fixed.FIXED], q)
ref = one.get("참조")
if isinstance(ref, dict):
doc = copies.get(refs.ref_id(ref))
@@ -324,6 +328,22 @@ class Builder:
return self.precombo(whole, ref, doc, copies, 1)
def fixed_line(fx: dict, qty: Any) -> dict[str, Any]:
"""고정 줄(705-1) → 블록 줄 `fixed` — 수량 그대로(배 1) · 이음 없는 비목 = 줄 단가."""
link = fx.get("이음") or {}
return {
"kind": "fixed",
**{k: fx.get(v) or "" for k, v in (("name", "이름"), ("spec", "규격"), ("unit", "단위"))},
"qty": _f(qty),
"own": {PART[k]: _f(v) for k, v in (fx.get("단가") or {}).items() if k in PART},
"link": {
"labor": link.get("노임"),
"material": link.get("자재"),
"machine": link.get("기계"),
},
}
def _material(whole: Any, mat: dict, qty: Any) -> dict[str, Any]:
"""자재 줄 — 조합 사용자 자재 · 사전조합 자재(175-2) 한 꼴 · 이름 · 규격 · 단위 = 사본 단가."""
row = (whole.get(mat.get("코드")) if mat.get("코드") else None) or {}
+6 -3
View File
@@ -4,7 +4,7 @@
사본마다 `일위대가.json` 담은 로직을 그 사본 단가 묶음(`단가.json`) · 입력값 · 고른자재로 돌리며
실제로 부른 자원 줄(인력 LB · 기계 EQ · 자재 MT · 유가 MO)만 모음 — 단가 묶음 통째
(고르기 후보 전부)는 안 씀 · 값은 쓰지 않음(단가는 원가 한 벌 `price_book.json` 이 맡음) ·
사본 일위대가 자재 · 굳힌 사전조합 자재 코드도(183-1 · 로직을 안 돌아 `get` 에 안 걸림).
사본 일위대가 자재 · 굳힌 사전조합 자재 코드 · 고정 줄 이음 키도(183-1 · 705-1 · 로직을 안 돌아 `get` 에 안 걸림).
고르기가 훑은 후보 줄도 걸림 → 원가 길이 두 번 셈해 쓰는 줄만 남김(`Summary.used_materials`).
구조물 조합 사본 없으면 그 구조물은 없음 · 일위대가 없는 사본은 자원 없음.
"""
@@ -16,6 +16,7 @@ from typing import Any
from M02_MasterTemplete import M02_Item_Prices as item_prices
from M02_MasterTemplete import M02_Labor_Doc as labor_doc
from M02_MasterTemplete import M02_Labor_Fixed as fixed
from M02_MasterTemplete.M02_Item_Snapshot import (
PICKS_FILE,
VALUES_FILE,
@@ -59,8 +60,10 @@ def used_keys(folder: Path) -> list[str]:
labor_doc.run_line(
snapshot, one["로직"], one.get("입력값"), one.get("켜쌓기율"), one.get("고름")
)
for mat in [*(doc.get("자재") or []), *(m for d in inner for m in d.get("자재") or [])]:
code = str(mat.get("코드") or "") if isinstance(mat, dict) else ""
mats = [*(doc.get("자재") or []), *(m for d in inner for m in d.get("자재") or [])]
codes = [str(mat.get("코드") or "") if isinstance(mat, dict) else "" for mat in mats]
codes += [k for d in [doc, *inner] for k in fixed.link_keys(d)] # 705-1 고정 줄 이음
for code in codes:
if code[:2] in RESOURCE_TABLES and code not in seen:
seen.append(code)
return seen
+23 -1
View File
@@ -9,6 +9,8 @@
4 자재대 · 관급자재대 자재 줄 = 그 자재 그대로(호표 없음)
연결 없는 항목(수량 · 호표 없음 · 호표 구성 없음 — 조합 밖 토공 · 운반 산근 등) = 전개 안 함 ·
「연결 없음 n」(`unlinked`)
고정 줄(705-1) = 이은 노임 · 자재 · 기계 키 자원으로 셈 · 이음 없는 줄 = 집계에서 빠짐 ·
「고정 줄 n」(`fixed` · 빠진 줄 수)
끝수 = 엑셀 자리 그대로 — 총수량 ROUND 2 · 금액 = ROUND(수량 × 단가, 0)(여기만 반올림) ·
중기 = 노무 · 재료 · 경비 각 ROUND(시간 × 시간당, 0) · 합계 = 셋 합.
단가 = 목록표(노무비 · 재료비 · 경비 · 중기목록표) — 없으면 금액 빈칸(수량은 둠).
@@ -39,7 +41,7 @@ def expand(
kind = line.get("kind")
if kind == "hopyo":
expand(lines_of, str(line.get("key")), qty * q, out, depth + 1)
elif kind in KINDS:
elif kind in (*KINDS, "fixed"):
bucket = out.setdefault(kind, {})
bucket[str(line.get("key"))] = bucket.get(str(line.get("key")), 0.0) + qty * q
@@ -123,6 +125,7 @@ def compute_summary(sheets: dict[str, Any], lines_of: dict[str, Any]) -> dict[st
used, unlinked = totals(sheets, lines_of)
return {
"unlinked": unlinked,
"fixed": len(used.get("fixed", {})),
"sum_material": _resource_sheet(used.get("material", {}), _list(sheets["material"]), ""),
"sum_labor": _resource_sheet(used.get("labor", {}), _list(sheets["labor"]), "인"),
"sum_expense": _resource_sheet(used.get("expense", {}), _list(sheets["expense"]), ""),
@@ -147,6 +150,9 @@ def block_lines(blocks: list[dict[str, Any]] | None) -> dict[str, Any]:
for block in blocks or []:
lines = []
for line in block.get("lines") or []:
if line.get("kind") == "fixed" and num(line.get("qty")) is not None:
lines += _fixed_lines(block, line)
continue
kind = LINE_KIND.get(line.get("kind"))
key = (line.get("ref") or {}).get("key")
if kind and key and num(line.get("qty")) is not None:
@@ -155,6 +161,16 @@ def block_lines(blocks: list[dict[str, Any]] | None) -> dict[str, Any]:
return out
def _fixed_lines(block: dict[str, Any], line: dict[str, Any]) -> list[dict[str, Any]]:
"""고정 줄(705-1) → 이은 자원 줄(기계 = 중기 하나) · 이음 없음 = `fixed` 줄(빠짐 셈)."""
link = line.get("link") or {}
pairs = [("machine", link.get("machine"))] if link.get("machine") else []
pairs = pairs or [(k, link.get(k)) for k in ("labor", "material") if link.get(k)]
if not pairs:
pairs = [("fixed", f"{block['key']}|{line.get('cid') or line.get('name')}")]
return [{"kind": k, "key": str(v), "qty": line["qty"]} for k, v in pairs]
def used_materials(sheets: dict[str, Any], inputs: dict[str, Any], user: dict[str, Any]) -> set:
"""재료비목록표에 남길 자재 키(183-1) — 대가 · 산근 · 중기 블록 재료 줄(수량 빈칸 · 0 도 =
집계표 역전개와 같은 줄) · B08 총괄 줄(수량 있는 입력) · 관급 · 별도 표시 줄.
@@ -167,6 +183,12 @@ def used_materials(sheets: dict[str, Any], inputs: dict[str, Any], user: dict[st
for line in block.get("lines") or []
if line.get("kind") == "material" and (line.get("ref") or {}).get("key")
}
keep |= { # 705-1 고정 줄이 이은 자재
str(line["link"]["material"])
for block in blocks
for line in block.get("lines") or []
if line.get("kind") == "fixed" and (line.get("link") or {}).get("material")
}
marks = user.get("materials") or {}
for m in inputs.get("materials") or []:
if "qty" in m or m.get("supply") or (marks.get(m["key"]) or {}).get("supply"):
@@ -100,7 +100,7 @@ export const buildDaegaBlocks: TabBuild = ({ sheets }): TabTable | string => {
prices: { sum: ln.price, ...ln.prices },
amounts: { sum: ln.amount, ...ln.amounts },
note: ln.ref_no || ln.why || "",
tag: HOPYO_TAG.pum,
tag: ln.kind === "fixed" ? HOPYO_TAG.fix : HOPYO_TAG.pum, // 705-1 고정 줄
})),
})),
);
@@ -4,6 +4,7 @@
*
* 값 = 서버 단독 역전개(`B09_Estimation_Summary` · GET 응답 `summary`) — 조작 중엔 안 바뀜 · [저장] 뒤 정본
* 끝수 = 총수량 ROUND 2 · 금액 ROUND(수량 × 단가, 0) · 줄 누름 = 단가를 낸 목록표 줄
* 고정 줄(705-1) 이음 없는 줄 = 집계에서 빠짐 — 안내 「고정 줄 n」(서버 `summary.fixed`)
* 경비 집계표 빈 까닭(166-5) = 산근 · 대가 어느 길도 경비 자원 줄을 안 냄(기계 → 중기 · 구역화물 → 자재)
* ========================================================================== */
@@ -22,9 +23,14 @@ import {
const HINT = "줄을 누르면 목록표로 이동";
/** 안내 + 「빈 줄 n」(설계내역서와 같은 수 · 701-2 — 금액 모르는 줄은 집계에서 빠짐) */
const hint = (sheets: Row, extra = ""): string => {
const hint = (sheets: Row, payload: Row): string => {
const n = blankRows(sheets).length;
return `${HINT}${extra}${n ? ` · 빈 줄 ${n} — 집계에서 빠짐(좌측 데이터 점검)` : ""}`;
const fixed = Number((payload.summary || {}).fixed) || 0;
return [
HINT,
...(n ? [`빈 줄 ${n} — 집계에서 빠짐(좌측 데이터 점검)`] : []),
...(fixed ? [`고정 줄 ${fixed} — 이은 단가 없어 집계에서 빠짐`] : []),
].join(" · ");
};
/** 줄이 없을 때 표 위 맨 앞 안내 */
@@ -48,7 +54,7 @@ function resourceTab(id: string, list: TabId, unitPrice: string, none = ""): Tab
rows,
total: rows.length ? { name: "계", amount: sum } : null,
frozen: 2,
hint: !rows.length && none ? `${none} · ${hint(sheets)}` : hint(sheets),
hint: !rows.length && none ? `${none} · ${hint(sheets, payload)}` : hint(sheets, payload),
link: (i) => (rows[i] ? { tab: list, key: String(rows[i].key) } : null),
};
};
@@ -86,7 +92,7 @@ export const buildSumMachine: TabBuild = ({ payload, sheets }): TabTable => {
}
: null,
frozen: 2,
hint: hint(sheets),
hint: hint(sheets, payload),
link: (i) => (rows[i] ? { tab: "machine", key: String(rows[i].key) } : null),
};
};