Files
Aislo/resources/tester/print_cost/print_cost_entry.ts
T

45 lines
2.1 KiB
TypeScript

/* =============================================================================
* print_cost_entry.ts (PLAN 302-4 시험 진입)
* 원가계산 인쇄 쪽(`B09_Draft_Print_Cost.costSheetsOf`)을 화면 표 짜기(`tabTableOf`)와 대조.
* vite `--ssr` 로 번들해 node 로 실행 — 인자 = payload JSON 경로 · 출력 = 쪽마다 대조 JSON.
* ========================================================================== */
import { readFileSync } from "node:fs";
import { costSheetsOf } from "../../../B09_Estimation/draft/B09_Draft_Print_Cost";
import { tabTableOf } from "../../../B09_Estimation/B09_Estimation_UI_Builders";
import { computeSheets } from "../../../B09_Estimation/B09_Estimation_UI_Shell";
import type { TabId } from "../../../B09_Estimation/B09_Estimation_UI_Tabs";
const payload = JSON.parse(readFileSync(process.argv[2], "utf-8"));
const user = payload.user ?? {};
const ctx = { sheets: computeSheets(payload, user), payload, user, setUser: () => {} };
const out = costSheetsOf(payload, user).map((sheet) => {
const spec = tabTableOf(sheet.id as TabId, ctx);
const screen = !spec || typeof spec === "string" ? null : spec;
const t = sheet.table;
const n = t.rows.length;
return {
id: sheet.id,
name: sheet.name,
orientation: sheet.orientation,
rows: n,
screenRows: screen ? screen.rows.length : 0,
sameRows: JSON.stringify(t.rows) === JSON.stringify(screen?.rows ?? []),
total: t.total ?? null,
screenTotal: screen?.total ?? null,
columns: t.columns.map((c) => c.key),
screenColumns: screen ? screen.columns.map((c) => c.key) : [],
groups: t.columns.filter((c) => c.group?.length).length,
level: t.level ? { key: t.level.key, tree: t.level.tree ?? false } : null,
levels: t.level ? Array.from({ length: n }, (_, i) => t.level?.of(i) ?? null) : [],
rowClass: t.rowClass ? Array.from({ length: n }, (_, i) => t.rowClass?.(i) ?? null) : [],
mergeSame: t.mergeSame ?? [],
caption: t.caption,
interactive: ["editable", "onEdit", "onCellClick", "onRowClick", "cellClass", "focus"].filter(
(k) => k in t,
),
};
});
process.stdout.write(JSON.stringify(out));