feat(860-3): 호표 목록에 엑셀 금액 · 우리 금액 — 우리 = [수정] 창 「우리 단가」 판 셈 그대로

- 서버 hopyo-sums/{키} = 호표마다 {번, 엑셀, 우리} · 우리 = Hopyo_View.of 문서 판 「우리」 → Labor_Router._calc 줄 반영 합(창과 같은 길 · 새 셈 없음) · 못 셈 = 빈 값
- 목록 먼저 그리고 금액은 뒤에서 채움(북부청 68 호표 = 목록 뒤 약 17 초) · 읽는 중 「…」
- 줄 = 「엑셀 · 우리」 수만(꼬리표는 목록 머리 「금액 = 엑셀 · 우리」 · 풍선말) · 두 값 다르면 경고 색 · 좁은 폭(1277)에서 이름이 먼저 「…」 · n/m 안 잘림
- 시험: test_860_3_made_sk 목록 엑셀 = 엑셀 호표 금액 · 우리 = 창 길(hopyo-view → labor calc) 같음(우리 금액을 고정 수로 안 묶음)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-19 13:45:29 +09:00
co-authored by Claude Opus 5.5
parent 25974a7c68
commit 4ccf3527c8
6 changed files with 105 additions and 2 deletions
+12
View File
@@ -61,6 +61,18 @@ def hopyo_view(
return _call(folder, hopyo_view_.view, folder, key, no)
@router.get("/layers/{layer}/hopyo-sums/{key}")
def hopyo_sums(
layer: Layer,
key: str,
owner: str | None = None,
session: Session = Depends(verify_session),
) -> dict:
"""호표 목록 두 금액(860-3) — `{호표 [{번, 엑셀, 우리}]}` · 우리 = [수정] 창 우리 판 셈 · 읽기만."""
folder = _root(session, layer, owner)
return {"호표": _call(folder, hopyo_view_.sums, folder, key)}
# ── 그대로 쓰는 길 ─────────────────────────────────────────────────────
HOPYO_MAX_BYTES = 20 * 1024 * 1024
+20
View File
@@ -67,6 +67,26 @@ def view(source: str | Path, key: str, no: int) -> dict[str, Any]:
return of(hopyo_store.read(Path(source), key), no, linker)
def sums(source: str | Path, key: str) -> list[dict[str, Any]]:
"""호표 목록 두 금액(860-3) `[{번, 엑셀, 우리}]` — 엑셀 = 엑셀 호표 금액 · 우리 = [수정] 창 「우리 단가」 판과
같은 서버 셈(`of` 문서 · `본뜬.단가기준` 우리 → `M02_Labor_Router._calc` 의 줄 반영 합 · 못 셈 = None)."""
from M02_MasterTemplete import M02_Labor_Router as labor_router
book = hopyo_store.read(Path(source), key)
linker, out = hfix.Linker(True, hfix.clues(source, key)), []
for h in book.get("호표") or []:
no = int(h["번"])
doc = of(book, no, linker)["문서"]
doc["본뜬"] = {**doc["본뜬"], fixed.BASIS: fixed.OURS}
try:
got = labor_router._calc(f"제{no}호표", labor_router.CalcBody(doc=doc))
ours = (got.get("반영합") or {}).get("계")
except Exception: # noqa: BLE001 — 한 호표 못 셈 = 그 칸 빈 값(목록은 그림)
ours = None
out.append({"번": no, "엑셀": (h.get("금액") or {}).get("계"), "우리": ours})
return out
def of(book: dict[str, Any], no: int, linker: hfix.Linker | None = None) -> dict[str, Any]:
"""호표 하나 → `{번, 이름, 규격, 단위, 금액, 문서 {이름, 단위, 담은로직, 자재}, 줄 [표지]}` — 문서 줄 차례 = 엑셀 줄 차례."""
hopyo = next((h for h in book.get("호표") or [] if int(h["번"]) == int(no)), None)
@@ -205,6 +205,18 @@
flex-shrink: 0;
}
/* 두 금액(860-3) — 좁으면 이름이 먼저 줄어듦 · 다르면 경고 색 */
.m02-hopyo-sheet__money,
.m02-hopyo-sheet__item > .ui-text:last-child {
flex-shrink: 0;
white-space: nowrap;
font-variant-numeric: tabular-nums;
}
.m02-hopyo-sheet__item .ui-text.m02-hopyo-sheet__money.is-diff {
color: var(--color-warning);
}
/* 머리 글 ↔ [파일 업로드] — 구조물 조합 머리 ↔ 층 단추와 같은 12 px */
.m02-hopyo-side > .m02-side__row {
margin-top: var(--spacing-12);
@@ -114,6 +114,15 @@ export const listHopyo = async (scope: HopyoScope): Promise<HopyoFile[]> =>
export const readHopyo = (scope: HopyoScope, key: string): Promise<HopyoView> =>
call(at(scope, `/hopyo/${enc(key)}`));
/** 호표 목록 두 금액(860-3) — 엑셀 = 엑셀 호표 금액 · 우리 = [수정] 창 「우리 단가」 판과 같은 서버 셈 */
export interface HopyoSum {
번: number;
엑셀: number | null;
우리: number | null;
}
export const readHopyoSums = (scope: HopyoScope, key: string): Promise<{ 호표: HopyoSum[] }> =>
call(at(scope, `/hopyo-sums/${enc(key)}`));
/** 격자 — 없으면 404 「격자 없음 — 다시 올리면 보임」(옛 파일) */
export const readHopyoGrid = (scope: HopyoScope, key: string): Promise<HopyoGrid> =>
call(at(scope, `/hopyo-grid/${enc(key)}`));
@@ -19,9 +19,12 @@ import { createButton, el } from "@ui/ui_template_elements";
import { createInputField } from "@ui/ui_template_input";
import type { Sheet } from "../A00_Common/spreadsheet/spreadsheet_types";
import type { SpreadsheetHandle } from "../A00_Common/spreadsheet/spreadsheet";
import { formatPrice } from "../common_util/common_util_money";
import {
readHopyo,
readHopyoSums,
type HopyoBrief,
type HopyoSum,
type HopyoGrid,
type HopyoSpan,
type HopyoView,
@@ -121,6 +124,7 @@ export function buildHopyoSheet(opt: HopyoSheetOptions): HopyoSheetBody {
let detail = ""; // 단가산출 상세 시트 id
let closed = false;
let briefs: HopyoBrief[] = [];
let sums: Map<number, HopyoSum> | null = null; // 860-3 두 금액 — 목록 먼저 그리고 뒤에서 채움
let spans: HopyoSpan[] = [];
let ilwi = ""; // 일위대가 시트 id
let last = "O";
@@ -253,6 +257,7 @@ export function buildHopyoSheet(opt: HopyoSheetOptions): HopyoSheetBody {
el("span", { className: "m02-hopyo-sheet__no", text: `제${h.번}호표` }),
editButton(h),
el("span", { className: "m02-hopyo-sheet__name", text: `${h.이름} ${h.규격}`.trim() }),
money(h),
linked,
],
});
@@ -261,7 +266,21 @@ export function buildHopyoSheet(opt: HopyoSheetOptions): HopyoSheetBody {
return row;
}),
);
count.textContent = q ? `${shown.length} / ${briefs.length}` : `호표 ${briefs.length}`;
const head = q ? `${shown.length} / ${briefs.length}` : `호표 ${briefs.length}`;
count.textContent = `${head} · 금액 = 엑셀 · 우리`; // 860-3 줄 금액 글 짧게(좁은 폭)
}
/** 엑셀 금액 · 우리 금액(860-3 · 꼬리표는 목록 머리) — 우리 = 읽는 중 「…」 · 못 셈 「—」 · 다르면 경고 색 */
function money(h: HopyoBrief): HTMLElement {
const won = (v: number | null | undefined): string => (v == null ? "—" : formatPrice(v));
const got = sums?.get(h.번);
const xl = got ? got.엑셀 : h.금액?.계;
const ours = sums ? won(got?.우리) : "…";
const span = note(`${won(xl)} · ${ours}`);
span.classList.add("m02-hopyo-sheet__money");
span.title = `엑셀 ${won(xl)} · 우리 ${ours}`;
span.classList.toggle("is-diff", got?.우리 != null && xl != null && got.우리 !== xl);
return span;
}
async function mountSheet(grid: HopyoGrid): Promise<void> {
@@ -318,6 +337,14 @@ export function buildHopyoSheet(opt: HopyoSheetOptions): HopyoSheetBody {
spans = grid instanceof Error ? [] : grid.호표;
paintHead(file);
paintList();
if (file.호표수)
void readHopyoSums(opt.scope, opt.key).then(
(got) => {
sums = new Map(got.호표.map((x) => [x.번, x]));
if (!closed) paintList();
},
() => (sums = new Map()), // 못 읽음 = 「—」(목록은 그대로)
);
if (grid instanceof Error) return void left.replaceChildren(note(grid.message));
await mountSheet(grid);
const rows = opt.단산행 === undefined ? null : rowsText(opt.단산행);
+24 -1
View File
@@ -21,6 +21,7 @@ from M02_MasterTemplete import M02_Hopyo_Store as hs
from M02_MasterTemplete import M02_MasterTemplete_Store as store
from M02_MasterTemplete import M02_San_MatPick as mp
from M02_MasterTemplete import M02_Sangeun_FromHopyo as fh
from resources.tester.test_m02_hopyo_excel import client # noqa: F401 — 임시 층 앱
from resources.tester.test_m02_labor_ref import world # noqa: F401 — 같은 임시 층
@@ -66,8 +67,30 @@ def test_가져온_식_이름_꼬리_뗌() -> None:
"""⑥ STmate 엑셀 머리 글 「이름 규격 / 단위」 — 꼬리가 단위와 같을 때만 뗌 · 겹 띄움 하나 · 가운데 / 그대로."""
assert fh.trim("글자새김 자당 6*6 / 자", "자") == "글자새김 자당 6*6"
assert fh.trim("레미콘타설(장비) 무근,소형 / m3", "m3") == "레미콘타설(장비) 무근,소형"
assert fh.trim("노선굴진보조원 위험요소 파악 전파", "km") == "노선굴진보조원 위험요소 파악 전파"
assert (
fh.trim("노선굴진보조원 위험요소 파악 전파", "km") == "노선굴진보조원 위험요소 파악 전파"
)
assert fh.trim("A/B 운반", "m3") == "A/B 운반"
assert fh.trim("터파기 / m2", "m3") == "터파기 / m2" # 단위와 다른 꼬리 = 그대로
out = {"로직": {"이름": "무대처리 / M3", "결과단위": "원/M3"}}
assert fh._title(out, 1, "") == "무대처리" and fh._title(out, 1, " 내 이름 ") == "내 이름"
def test_호표_목록_두_금액_엑셀_값_우리_수정창_판(client) -> None: # noqa: F811
"""⑩ 목록 엑셀 = 엑셀 호표 금액 · 우리 = [수정] 창 길(hopyo-view 문서 → 판 「우리」 → labor calc 반영 합)."""
from resources.tester.test_m02_hopyo_excel import NORTH, URL, _post
assert _post(client, data=NORTH.read_bytes(), name=NORTH.name).status_code == 200
base = URL.format("personal")
got = client.get(f"{base}-sums/HP-000001")
assert got.status_code == 200, got.text
rows = {r["번"]: r for r in got.json()["호표"]}
book = client.get(f"{base}/HP-000001").json()["호표"]
assert len(rows) == len(book) == 68
assert all(rows[h["번"]]["엑셀"] == (h.get("금액") or {}).get("계") for h in book)
for no in (1, 3, 33): # 창 길 그대로 — 우리 금액을 고정 수로 묶지 않음
doc = client.get(f"{base}-view/HP-000001/{no}").json()["문서"]
doc["본뜬"]["단가기준"] = "우리"
calc = client.post(f"/api/m02/layers/personal/labor/제{no}호표/calc", json={"doc": doc})
assert calc.status_code == 200, calc.text
assert rows[no]["우리"] == calc.json()["반영합"]["계"]