[158] Raumbuch: Nutzung und Oberflächen je Raum (Boden/Wand/Decke, Aufbau), Raum-Belag im Grundriss statt Deckenbelag, Nassraum aus Nutzung, Belagszeile im Stempel, Objekt-Info, Liste/Blatt-Tabelle/CSV, Mengen, IFC-Psets mit Rundreise

This commit is contained in:
Claude committed 2026-11-07 16:31:05 +00:00
1 parent 58fd92b6ce
commit ef9a651781
27 files changed
+1406 -26

No files matched your search

+75
View File
@@ -0,0 +1,75 @@
// [158] Raumbuch: Zeilen aus dem Kern, Bericht (CSV-Rundreise) und Blatt-Tabelle.
import { describe, expect, it } from "vitest";
import { sampleProject } from "../model/sampleProject";
import type { Layout, Project, Room } from "../model/types";
import { areaReportToCsv, parseAreaReportCsv } from "./areaReport";
import { buildRoomBookReport, roomBook, usageLabel } from "./roomBook";
import { sheetTables, tableLabels } from "./sheetTable";
import { t } from "../i18n/translate";
const base = sampleProject.rooms![0]!;
const bad: Room = {
...base,
id: "R-bad",
name: "Bad",
usage: "bath",
floorFinish: "Feinsteinzeug 30×60",
wallFinish: "Plattenbelag",
ceilingFinish: "Weissputz",
boundary: [
{ x: 6, y: 0 },
{ x: 8, y: 0 },
{ x: 8, y: 2 },
{ x: 6, y: 2 },
],
stamp: { number: "0.02", name: "Bad", showFloorArea: true, showUsage: false },
};
const p: Project = {
...sampleProject,
name: "Test",
rooms: [
{ ...base, usage: "living", floorFinish: sampleProject.components[0]!.id, ceilingFinish: "Weissputz", stamp: { number: "0.01", name: "Wohnen", showFloorArea: true, showUsage: true } },
bad,
],
};
describe("Raumbuch ([158])", () => {
it("eine Zeile je Raum mit Oberflächen, Nassraum aus der Nutzung, Mengen je Material", () => {
const b = roomBook(p);
expect(b.rows.map((r) => r.number)).toEqual(["0.01", "0.02"]);
const w = b.rows[0]!;
expect(w).toMatchObject({ usage: "living", wet: false, floorFinish: sampleProject.components[0]!.name, ceilingFinish: "Weissputz" });
expect(w.wallArea).toBeGreaterThan(0);
expect(w.wallArea).toBeLessThan(w.perimeter * w.clearHeight);
expect(b.rows[1]).toMatchObject({ wet: true, floorFinish: "Feinsteinzeug 30×60", area: 4 });
const ceil = b.quantities.find((q) => q.surface === "ceiling" && q.finish === "Weissputz")!;
expect(ceil.rooms).toBe(2);
expect(ceil.area).toBeCloseTo(w.area + 4, 9);
});
it("Bericht: Raumbuch und Mengen, CSV-Rundreise", () => {
const rep = buildRoomBookReport(p);
expect(rep.sections.map((s) => s.heading)).toEqual([t("roomBook.title"), t("roomBook.quantities")]);
const parsed = parseAreaReportCsv(areaReportToCsv(rep));
const rows = parsed.sections[0]!.rows;
expect(rows.length).toBe(2);
expect(rows[1]).toContain("Feinsteinzeug 30×60");
expect(rows[1]).toContain(usageLabel("bath"));
expect(parsed.sections[1]!.rows.some((r) => r.includes("Weissputz"))).toBe(true);
});
it("ohne Räume: leerer Bericht ohne Abschnitte", () => {
expect(buildRoomBookReport({ ...p, rooms: [] }).sections).toEqual([]);
});
it("als Tabelle auf dem Blatt", () => {
const layout: Layout = { id: "L1", name: "Blatt", paper: "a3", orientation: "landscape", viewports: [], tables: [{ id: "rb", source: "roomBook", xMm: 10, yMm: 20, widthMm: 260 }] };
const q: Project = { ...p, layouts: [layout] };
const [tb] = sheetTables(q, "L1");
expect(tb!.total).toBe(2);
const texts = tb!.prims.filter((x) => x.k === "text").map((x) => (x as { s: string }).s);
expect(texts).toContain(tableLabels(q)["roomBook.col.floorFinish"]);
expect(texts).toContain("0.02");
expect(texts).toContain(usageLabel("bath"));
});
});
+103
View File
@@ -0,0 +1,103 @@
// [158] Raumbuch: Oberflächen je Raum (Boden, Wand, Decke), Nutzung, Bodenaufbau und die Mengen daraus.
// Gerechnet wird im Rust-Kern (`src-tauri/core/src/room_book.rs`, Abfrage `roomBook`); hier nur die
// Beschriftung mit `t()` und der Berichtsaufbau, damit CSV, SVG und PDF dieselbe Quelle haben wie die
// Fenster-/Türliste (`openingSchedule.ts`). Die Blatt-Tabelle (Quelle `roomBook`) rechnet der Kern selbst.
import type { Project, RoomUsage } from "../model/types";
import { t } from "../i18n/translate";
import type { TranslationKey } from "../i18n/translate";
import { documentFor } from "../core/document";
import type { AreaReport, Cell, ReportSection } from "./areaReport";
/** Eine Zeile des Raumbuchs (Form wie `RoomBookRow` im Kern). */
export interface RoomBookRow {
id: string;
floor: string;
floorId: string;
number: string;
name: string;
/** Nettofläche (m²) = Boden- und Deckenfläche. */
area: number;
perimeter: number;
/** Lichte Höhe (m) aus den Decken, sonst Geschosshöhe. */
clearHeight: number;
/** Nutzungs-Kennung, leer ohne Angabe. */
usage: RoomUsage | "";
wet: boolean;
/** Anzeigetexte (Material-Name oder Freitext). */
floorFinish: string;
wallFinish: string;
ceilingFinish: string;
floorBuildUp: string;
/** Wandfläche netto: Umfang × lichte Höhe − Öffnungen (m²). */
wallArea: number;
openingArea: number;
}
/** Menge einer Oberfläche je Material/Freitext. */
export interface FinishQty {
surface: "floor" | "wall" | "ceiling";
finish: string;
area: number;
rooms: number;
}
export interface RoomBook {
rows: RoomBookRow[];
quantities: FinishQty[];
}
/** Wählbare Nutzungen (Reihenfolge der Auswahl, wie `RoomUsage::ALL` im Kern). */
export const ROOM_USAGES: readonly RoomUsage[] = ["living", "sleeping", "kitchen", "dining", "bath", "wc", "shower", "laundry", "circulation", "technical", "storage", "office", "other"];
export function usageLabel(u: RoomUsage | ""): string {
return u ? t(`roomBook.usage.${u}` as TranslationKey) : "";
}
/** Raumbuch des Projekts (Kern-Abfrage). */
export function roomBook(project: Project): RoomBook {
return documentFor(project).query<RoomBook>("roomBook");
}
const num = (n: number, d: number): Cell => ({ n: Number.isFinite(n) ? n : null, d });
function roomSection(rows: RoomBookRow[]): ReportSection {
return {
heading: t("roomBook.title"),
columns: [
t("openings.col.floor"),
t("roomBook.col.number"),
t("sheetTable.col.room"),
t("sheetTable.col.area"),
t("roomBook.col.usage"),
t("roomBook.col.floorFinish"),
t("roomBook.col.wallFinish"),
t("roomBook.col.ceilingFinish"),
t("roomBook.col.buildUp"),
t("roomBook.col.clearHeight"),
t("roomBook.col.wallArea"),
],
widths: [1.2, 1, 2.4, 1.2, 1.6, 2.4, 2.4, 2.4, 3, 1.2, 1.3],
rows: rows.map((r) => ({
cells: [r.floor, r.number, r.name, num(r.area, 2), usageLabel(r.usage), r.floorFinish, r.wallFinish, r.ceilingFinish, r.floorBuildUp, num(r.clearHeight, 2), num(r.wallArea, 2)],
})),
};
}
function quantitySection(qs: FinishQty[]): ReportSection {
return {
heading: t("roomBook.quantities"),
columns: [t("roomBook.col.surface"), t("roomBook.col.finish"), t("roomBook.col.rooms"), t("sheetTable.col.area")],
widths: [1.6, 4, 1.2, 1.4],
rows: qs.map((q) => ({ cells: [t(`roomBook.surface.${q.surface}`), q.finish, num(q.rooms, 0), num(q.area, 2)] })),
};
}
/** Bericht „Raumbuch": Räume und (falls Oberflächen angegeben) die Mengen je Material. */
export function buildRoomBookReport(project: Project): AreaReport {
const b = roomBook(project);
const sections: ReportSection[] = [];
if (b.rows.length) sections.push(roomSection(b.rows));
if (b.quantities.length) sections.push(quantitySection(b.quantities));
return { title: t("roomBook.title"), projectName: project.name ?? "", sections, notes: [t("roomBook.foot")] };
}
+3 -3
View File
@@ -55,10 +55,10 @@ describe("Tabellen auf dem Blatt ([111])", () => {
it("alle Quellen liefern Primitive; Katalog nennt die Spalten", () => {
const cat = tableCatalog(sampleProject);
expect(Object.keys(cat.sources).sort()).toEqual(["areas", "earthworks", "elements", "openings", "rooms"]);
const p = withTables((["openings", "areas", "rooms", "elements", "earthworks"] as const).map((source) => table({ id: source, source })));
expect(Object.keys(cat.sources).sort()).toEqual(["areas", "earthworks", "elements", "openings", "roomBook", "rooms"]);
const p = withTables((["openings", "areas", "rooms", "elements", "earthworks", "roomBook"] as const).map((source) => table({ id: source, source })));
const out = sheetTables(p, "L1");
expect(out.map((o) => o.id)).toEqual(["openings", "areas", "rooms", "elements", "earthworks"]);
expect(out.map((o) => o.id)).toEqual(["openings", "areas", "rooms", "elements", "earthworks", "roomBook"]);
for (const o of out) expect(o.prims.some((x) => x.k === "text")).toBe(true);
});
+1 -1
View File
@@ -38,7 +38,7 @@ interface Catalog {
valueKeys: string[];
}
export const TABLE_SOURCES: readonly LayoutTableSource[] = ["openings", "areas", "rooms", "elements", "earthworks"];
export const TABLE_SOURCES: readonly LayoutTableSource[] = ["openings", "areas", "rooms", "elements", "earthworks", "roomBook"];
export function tableSourceLabel(s: LayoutTableSource): string {
return t(`sheetTable.source.${s}`);