Files
Aislo/B08_wf5_Quantity/B08_wf5_Quantity_UI_Tab_Aggregation.ts
T

32 lines
1.0 KiB
TypeScript

import { money, section, table } from "./B08_wf5_Quantity_UI_Dom";
import { TabContext } from "./B08_wf5_Quantity_Types";
export function renderAggregation(ctx: TabContext) {
const root = section(
"집계·총괄설계내역",
"계산 실행 스냅샷의 재료·노무·경비를 공종별로 집계합니다.",
);
const groups = new Map<string, any>();
for (const x of ctx.state.data.latest?.lines ?? []) {
const g = groups.get(x.wbs_id) ?? { labor: 0, material: 0, expense: 0, total: 0 };
g.labor += x.labor_amount;
g.material += x.material_amount;
g.expense += x.expense_amount;
g.total += x.total_amount;
groups.set(x.wbs_id, g);
}
const wbs = ctx.state.data.quantities.work_breakdown;
root.append(
table(
["공종", "노무비", "재료비", "경비", "합계"],
[...groups].map(([id, x]) => [
wbs.find((w: any) => w.id === id)?.name ?? id,
money(x.labor),
money(x.material),
money(x.expense),
money(x.total),
]),
),
);
return root;
}