// Inhalts-Panel „Flächenbilanz" — listet alle Räume gruppiert nach // ihrer Flächenart (SIA 416) mit Zwischen-/Gesamtsummen und bietet einen // CSV-Export, darüber die Kennzahlenleiste mit Parzelle und Raumprogramm // (KennzahlenSection). Fläche/Bilanz werden LIVE aus den Raum-Umrissen abgeleitet // (geometry/roomArea: evaluateRoom/balance/roomsToCsv) — nie gespeichert. // // Daten kommen aus dem Store (project.rooms). Bezeichner englisch, UI-Text // deutsch via t() (CONVENTIONS.md). import { t } from "../i18n"; import { useStore } from "../state/appStore"; import { balance, evaluateRoom, roomsToCsv, siaLabelFull } from "../core"; import type { Room } from "../model/types"; import { roomDisplayName } from "../model/roomStamp"; import { KennzahlenSection } from "./KennzahlenSection"; import { AreaTableSection } from "./AreaTableSection"; import { UnitsSection } from "./UnitsSection"; import { CostEstimateSection } from "./CostEstimateSection"; import { OpeningScheduleSection } from "./OpeningScheduleSection"; import { ElementScheduleSection } from "./ElementScheduleSection"; import { RoomBookSection } from "./RoomBookSection"; import { downloadCsv } from "./downloadFile"; import { runWithAnonymityGate } from "../state/anonymityGate"; /** Löst je Raum die anrechenbare (Netto-)Fläche + Kategorie auf. */ function roomAreas(rooms: Room[]): { category: Room["siaCategory"]; area: number }[] { return rooms.map((r) => ({ category: r.siaCategory, area: evaluateRoom(r.boundary, r.siaCategory, { bulge: r.boundaryBulge }).netArea, })); } /** Löst den Anzeigenamen eines Geschosses (oder die ID) auf. */ function floorNameOf( levels: { id: string; name: string }[], floorId: string, ): string { return levels.find((z) => z.id === floorId)?.name ?? floorId; } export function RoomBalancePanel() { const project = useStore((s) => s.project); const rooms = project.rooms ?? []; const levels = project.drawingLevels; if (rooms.length === 0) { return (
{t("balance.empty")}
); } const bal = balance(roomAreas(rooms)); const onExport = () => { const csv = roomsToCsv( rooms.map((r) => ({ number: r.stamp?.number ?? r.id, name: roomDisplayName(r), level: floorNameOf(levels, r.floorId), category: r.siaCategory, area: evaluateRoom(r.boundary, r.siaCategory, { bulge: r.boundaryBulge }).netArea, })), ); runWithAnonymityGate(project, ["flaechenbilanz.csv"], () => downloadCsv("flaechenbilanz.csv", csv)); }; return (
{t("balance.title")}
{/* Kennzahlenleiste, Parzelle und Raumprogramm. */} {/* Flächentabelle und IVHB-Kennziffern. */} {/* Nutzungseinheiten und Wohnungsspiegel ([278]). */} {/* Kostenschätzung grob ([209]). */} {/* Fenster- und Türliste. */} {/* Bauteilliste mit U-Werten ([71]). */} {/* Raumbuch: Oberflächen je Raum ([158]). */} {/* Raumliste (je Raum: Name · Geschoss · SIA · Fläche). */}
{t("balance.rooms")}
{rooms.map((r) => { const res = evaluateRoom(r.boundary, r.siaCategory, { bulge: r.boundaryBulge }); return (
{roomDisplayName(r)} {r.siaCategory} {res.netArea.toFixed(2)} m²
); })}
{/* SIA-416-Bilanz (Blatt-Kategorien + Zwischensummen NF/NGF + Gesamt GF). */}
{t("balance.summary")}
{bal.rows.map((row) => (
{row.key} · {row.label} {row.count} {row.area.toFixed(2)} m²
))}
); }