diff --git a/src/core/extra.ts b/src/core/extra.ts index 6c561d9e..fcff8acd 100644 --- a/src/core/extra.ts +++ b/src/core/extra.ts @@ -33,6 +33,8 @@ export type { SheetData, SheetCell, Mapping, ColumnMap, ProgramField, ImportLine export { buildProgramReport } from "../export/programReport"; export { openingSchedule, buildOpeningReport, roomsText, externalText, swingText } from "../export/openingSchedule"; export type { OpeningScheduleRow } from "../export/openingSchedule"; +export { revealColumns, revealArea } from "../export/openingSchedule"; +export type { RevealArea } from "../export/openingSchedule"; export { elementSchedule, uValueOf, uValueText, buildElementReport } from "../export/elementSchedule"; export type { ElementScheduleRow, UValueResult, ElementKind } from "../export/elementSchedule"; export { sheetTables, createTable, drawTablesPdf, tableCatalog, tableLabels, tableSourceLabel, TABLE_SOURCES } from "../export/sheetTable"; diff --git a/src/export/openingSchedule.test.ts b/src/export/openingSchedule.test.ts index b6a2fc9d..0bd3d144 100644 --- a/src/export/openingSchedule.test.ts +++ b/src/export/openingSchedule.test.ts @@ -29,6 +29,22 @@ describe("Fenster- und Türliste", () => { expect(all.length).toBe((p.openings ?? []).length); expect(all.some((r) => r[0] === "T-Haus" && r.includes('Eingang; mit "Zusatz"'))).toBe(true); }); + it("[106] Leibungsflächen je Schicht als optionale Spalten", () => { + const plain = buildOpeningReport(p); + const o0 = p.openings![0]!; + const withRev: Project = { ...p, openings: p.openings!.map((o) => (o.id === o0.id ? { ...o, layerReveals: [{ layer: 0, mode: "zurueck" as const }] } : o)) }; + const rows = openingSchedule(withRev); + const r0 = rows.find((r) => r.id === o0.id)!; + expect(r0.revealAreas.length).toBe(1); + expect(r0.revealAreas[0]!.area).toBeGreaterThan(0); + for (const r of rows.filter((r) => r.id !== o0.id)) expect(r.revealAreas).toEqual([]); + const rep = buildOpeningReport(withRev); + const sec = rep.sections.find((s) => s.rows.some((row) => row.cells[0] === "T-Haus"))!; + const plainSec = plain.sections.find((s) => s.heading === sec.heading)!; + expect(sec.columns.length).toBe(plainSec.columns.length + 1); + expect(sec.widths.length).toBe(sec.columns.length); + expect(rep.notes.length).toBe(plain.notes.length + 1); + }); it("leeres Projekt: kein Abschnitt", () => { expect(buildOpeningReport({ ...p, openings: [] }).sections).toEqual([]); }); diff --git a/src/export/openingSchedule.ts b/src/export/openingSchedule.ts index b00a43c3..13fc72f4 100644 --- a/src/export/openingSchedule.ts +++ b/src/export/openingSchedule.ts @@ -41,6 +41,17 @@ export interface OpeningScheduleRow { /** `null` = nicht bestimmbar. */ external: boolean | null; notes: string; + /** Leibungsflächen je Wandschicht mit Schichteinzug ([106]), m²; leer ohne Regeln. */ + revealAreas: RevealArea[]; +} + +/** Leibungsfläche einer Wandschicht (Form wie `RevealArea` im Kern). */ +export interface RevealArea { + /** Schicht-Index ab aussen. */ + layer: number; + /** Bauteil-Name der Schicht (leer ohne Bauteil). */ + name: string; + area: number; } /** Alle Fenster und Türen des Projekts (Kern-Abfrage). */ @@ -66,7 +77,45 @@ export function swingText(r: Pick return `${t(`openings.hinge.${r.hinge}`)} · ${t(`openings.swing.${r.swing}`)} · ${t(`openings.dir.${r.dir}`)}`; } +/** Spaltenschlüssel einer Leibungsfläche: Bauteil-Name, sonst „Schicht n". */ +export function revealKey(a: RevealArea): string { + return a.name || t("openings.layerN", { n: a.layer + 1 }); +} + +/** Optionale Spalten „Leibung m²" ([106]): ein Schlüssel je vorkommender Schicht (Reihenfolge des ersten Auftretens). */ +export function revealColumns(rows: OpeningScheduleRow[]): string[] { + const keys: string[] = []; + for (const r of rows) for (const a of r.revealAreas ?? []) if (!keys.includes(revealKey(a))) keys.push(revealKey(a)); + return keys; +} + +/** Fläche einer Zeile für den Spaltenschlüssel (`null` = keine). */ +export function revealArea(r: OpeningScheduleRow, key: string): number | null { + const hits = (r.revealAreas ?? []).filter((a) => revealKey(a) === key); + return hits.length ? hits.reduce((s, a) => s + a.area, 0) : null; +} + +/** Hängt die Leibungs-Spalten an einen Abschnitt an (nur wenn es Flächen gibt). */ +function withReveals(sec: ReportSection, rows: OpeningScheduleRow[]): ReportSection { + const keys = revealColumns(rows); + if (!keys.length) return sec; + return { + ...sec, + columns: [...sec.columns, ...keys.map((name) => t("openings.col.reveal", { name }))], + widths: [...sec.widths, ...keys.map(() => 1.4)], + rows: sec.rows.map((row, i) => ({ ...row, cells: [...row.cells, ...keys.map((k) => num(revealArea(rows[i]!, k), 2))] })), + }; +} + function windowSection(rows: OpeningScheduleRow[]): ReportSection { + return withReveals(windowBase(rows), rows); +} + +function doorSection(rows: OpeningScheduleRow[]): ReportSection { + return withReveals(doorBase(rows), rows); +} + +function windowBase(rows: OpeningScheduleRow[]): ReportSection { return { heading: t("openings.windows"), columns: [t("openings.col.mark"), t("openings.col.type"), t("openings.col.floor"), t("openings.col.rooms"), t("openings.col.width"), t("openings.col.height"), t("openings.col.sill"), t("openings.col.sound"), t("openings.col.u"), t("openings.col.rc"), t("openings.col.ext"), t("openings.col.notes")], @@ -75,7 +124,7 @@ function windowSection(rows: OpeningScheduleRow[]): ReportSection { }; } -function doorSection(rows: OpeningScheduleRow[]): ReportSection { +function doorBase(rows: OpeningScheduleRow[]): ReportSection { return { heading: t("openings.doors"), columns: [t("openings.col.mark"), t("openings.col.type"), t("openings.col.floor"), t("openings.col.rooms"), t("openings.col.width"), t("openings.col.height"), t("openings.col.clearWidth"), t("openings.col.clearHeight"), t("openings.col.swing"), t("openings.col.fire"), t("openings.col.sound"), t("openings.col.u"), t("openings.col.rc"), t("openings.col.ext"), t("openings.col.notes")], @@ -92,5 +141,5 @@ export function buildOpeningReport(project: Project): AreaReport { const doors = rows.filter((r) => r.kind === "door"); if (windows.length) sections.push(windowSection(windows)); if (doors.length) sections.push(doorSection(doors)); - return { title: t("openings.title"), projectName: project.name ?? "", sections, notes: [t("openings.foot")] }; + return { title: t("openings.title"), projectName: project.name ?? "", sections, notes: rows.some((r) => r.revealAreas?.length) ? [t("openings.foot"), t("openings.revealFoot")] : [t("openings.foot")] }; } diff --git a/src/i18n/de.ts b/src/i18n/de.ts index 5036f989..a5e01c03 100644 --- a/src/i18n/de.ts +++ b/src/i18n/de.ts @@ -3208,6 +3208,9 @@ export const de = { "openings.col.rc": "Einbruch", "openings.col.ext": "Aussen/innen", "openings.col.notes": "Bemerkung", + "openings.col.reveal": "Leibung {name} m²", + "openings.layerN": "Schicht {n}", + "openings.revealFoot": "Leibungsflächen je Wandschicht mit Schichteinzug: zur Öffnung gewandte Stirn der Schicht, Leibungen links/rechts × Höhe, Sturz und Brüstung × Breite (Türen ohne Brüstung).", "openings.exportCsv": "CSV", "openings.exportPdf": "PDF", "openings.exportPdf.fail": "PDF konnte nicht erstellt werden.", diff --git a/src/i18n/en.ts b/src/i18n/en.ts index fb1ce97e..58695475 100644 --- a/src/i18n/en.ts +++ b/src/i18n/en.ts @@ -3194,6 +3194,9 @@ export const en: Record = { "openings.col.rc": "Burglary", "openings.col.ext": "Ext./int.", "openings.col.notes": "Notes", + "openings.col.reveal": "Reveal {name} m²", + "openings.layerN": "Layer {n}", + "openings.revealFoot": "Reveal areas per wall layer with layer reveal: face of the layer towards the opening, jambs × height, head and sill × width (doors without sill).", "openings.exportCsv": "CSV", "openings.exportPdf": "PDF", "openings.exportPdf.fail": "Could not create the PDF.", diff --git a/src/panels/OpeningScheduleSection.tsx b/src/panels/OpeningScheduleSection.tsx index ea429264..31b1de5b 100644 --- a/src/panels/OpeningScheduleSection.tsx +++ b/src/panels/OpeningScheduleSection.tsx @@ -7,7 +7,7 @@ import { useMemo } from "react"; import { t } from "../i18n"; import { usePanelHost } from "./host"; -import { areaReportToCsv, buildAreaReportPdf, buildOpeningReport, externalText, openingSchedule, patchItem, roomsText, swingText } from "../core"; +import { areaReportToCsv, buildAreaReportPdf, buildOpeningReport, externalText, openingSchedule, patchItem, revealArea, revealColumns, roomsText, swingText } from "../core"; import type { OpeningScheduleRow } from "../core"; import type { Opening, Project } from "../model/types"; import { downloadCsv } from "./downloadFile"; @@ -23,6 +23,8 @@ export function OpeningScheduleSection() { const applyChange = useStore((s) => s.applyChange); const notify = useStore((s) => s.notify); const rows = useMemo(() => openingSchedule(project), [project]); + // [106] Leibungsflächen je Schicht: Spalten nur, wenn eine Öffnung Schichteinzug hat. + const reveals = useMemo(() => revealColumns(rows), [rows]); const stem = `${project.name || "projekt"}-fenster-tueren`; const patch = (id: string, change: Partial, field: string) => @@ -84,6 +86,11 @@ export function OpeningScheduleSection() { {t("openings.col.rc")} {t("openings.col.ext")} {t("openings.col.notes")} + {reveals.map((k) => ( + + {t("openings.col.reveal", { name: k })} + + ))} @@ -132,6 +139,14 @@ export function OpeningScheduleSection() { {textInput(r, "notes", r.notes)} + {reveals.map((k) => { + const a = revealArea(r, k); + return ( + + {a === null ? "" : m2(a)} + + ); + })} ); })} @@ -141,6 +156,7 @@ export function OpeningScheduleSection() { )}
  • {t("openings.foot")}
  • + {reveals.length > 0 &&
  • {t("openings.revealFoot")}
  • }
);