Rough power balance module for early design phases #17

Closed
Grovy311 wants to merge 0 commits from feature/estimate-balance into main
Collaborator

Umsetzung von #7: grobe Leistungsbilanz für LPH 2/3 nach Kostengruppen (KG 400) als separates Modul.

  • Eigene Tabellen (Migration 0010), keine Verknüpfung in die Stromkreisstruktur.
  • Schreiben über Projektbefehle estimate-balance.* mit ganzen Dokumenten (Revision, Undo/Redo). Nicht in Snapshot/Transfer; das ist eine offene Frage im Issue.
  • Rechnung wie in der kbp-Excel-Vorlage (Test rechnet das Beispiel exakt nach: 143,24 kW / 148,48 kVA, 235,75 A).
  • Vergleich geschätzt ↔ detailliert über die Kostengruppe der Gerätezeilen.
  • Editor mit Autosave, AMEV-Picker, Versorgung als Auswahl mit freier Eingabe (ELT/MSR …), Farbdruck im kbp-Design der Seitenansicht.
  • Doku: docs/estimate-balance.md.

Basis: feature/building-structure (Migrationen, Seitenleiste) und fix/client-id-insecure-context (ist enthalten), bitte zuletzt mergen.

Geprüft auf dem Branch allein: alle drei tsc-Konfigurationen, npm test 479/479, Produktions-Build (build:api + build:web). Zusammen mit allen anderen Branches: 509/509 Tests, konfliktfrei in jeder Merge-Reihenfolge.

Merge-Reihenfolge aller Branches:

  1. fix/client-id-insecure-context (#9)
  2. feature/editor-ui (#10)
  3. feature/cable-sizing (#11)
  4. feature/overview-filters (#12)
  5. feature/circuit-list-usability (#13)
  6. feature/card-look (#14)
  7. feature/print-view (#15)
  8. feature/building-structure (#16)
  9. feature/estimate-balance (#17)

🤖 Generated with Claude Code

Umsetzung von #7: grobe Leistungsbilanz für LPH 2/3 nach Kostengruppen (KG 400) als separates Modul. - Eigene Tabellen (Migration `0010`), keine Verknüpfung in die Stromkreisstruktur. - Schreiben über Projektbefehle `estimate-balance.*` mit ganzen Dokumenten (Revision, Undo/Redo). **Nicht** in Snapshot/Transfer; das ist eine offene Frage im Issue. - Rechnung wie in der kbp-Excel-Vorlage (Test rechnet das Beispiel exakt nach: 143,24 kW / 148,48 kVA, 235,75 A). - Vergleich geschätzt ↔ detailliert über die Kostengruppe der Gerätezeilen. - Editor mit Autosave, AMEV-Picker, Versorgung als Auswahl mit freier Eingabe (ELT/MSR …), Farbdruck im kbp-Design der Seitenansicht. - Doku: `docs/estimate-balance.md`. **Basis:** `feature/building-structure` (Migrationen, Seitenleiste) und `fix/client-id-insecure-context` (ist enthalten), bitte zuletzt mergen. Geprüft auf dem Branch allein: alle drei `tsc`-Konfigurationen, `npm test` 479/479, Produktions-Build (`build:api` + `build:web`). Zusammen mit allen anderen Branches: 509/509 Tests, konfliktfrei in jeder Merge-Reihenfolge. Merge-Reihenfolge aller Branches: 1. `fix/client-id-insecure-context` (#9) 2. `feature/editor-ui` (#10) 3. `feature/cable-sizing` (#11) 4. `feature/overview-filters` (#12) 5. `feature/circuit-list-usability` (#13) 6. `feature/card-look` (#14) 7. `feature/print-view` (#15) 8. `feature/building-structure` (#16) 9. `feature/estimate-balance` (#17) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Grovy311 added 10 commits 2026-09-26 20:14:47 +02:00
- Seitenansicht (/projects/:projectId/print): tabular cover page, board
  overview with supply structure and power sums, one plan per board with a
  repeating title block; PDF via the browser print dialog with named @page
  rules (A4 portrait cover, A4/A3 landscape plans, page x of y).
- Distribution-board info card (board number, location, fed-from, remark)
  in the board edit dialog, persisted through the additively extended
  distribution-board.update command (migration 0008, snapshot schema 6,
  legacy subtree commands normalized).
- Global document logo upload (PNG/JPEG/SVG, max 2 MB) outside project
  revisions and snapshots.
- fed-from stays free text; the overview hierarchy and cumulated sums are
  preliminary until the feed link is modeled.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Project settings gain siteAddress, workStage, projectLead and
  projectEditor (project.update-settings schema version 3, migration 0009);
  versions 2 and 1 stay executable and keep the current cover values.
  Snapshot schema 6 carries the fields; older versions upgrade with null.
- Global office profile (office name/address) next to the document logo:
  table document_branding_settings, PUT /api/document-branding/office,
  editable from the print view toolbar.
- Cover page reads all fields; empty values show the "[ergänzen]" marker.
  The Planstände editor column shows the project editor.
- Shared logo constants moved to a dependency-free module so the Next.js
  bundler can import them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
crypto.randomUUID() is only defined in secure contexts (HTTPS or
localhost). Opened over plain HTTP from another machine in the LAN, the
circuit list editor failed with "crypto.randomUUID is not a function"
whenever it created a circuit, device row, circuit group or distribution
board component, including typing into the -frei- row.

createClientId() uses crypto.randomUUID() where available and otherwise
builds an RFC 4122 version 4 UUID from crypto.getRandomValues(), which
works in every context. AGENTS.md notes the rule.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Projects with several buildings could not be structured: floors and rooms
hung directly off the project. Floors can now belong to a building
(migration 0009: table buildings, nullable floors.building_id). Rooms and
distribution boards keep their floor; their building follows from it.
Existing floors stay without a building.

Buildings use the location-structure command store with
project-building.insert/.update/.delete, inverses and persistent Undo/Redo;
deleting a building with assigned floors is rejected. Floor commands carry
buildingId since command version 2. Version 1 floor commands from existing
history predate buildings and are upgraded with buildingId = null before
they are executed and persisted, so forward and inverse keep one version.

Project snapshot schema 7 stores buildings and floor.buildingId; versions
1-6 are upgraded without buildings. Restore and portable transfer include
buildings, and the transfer remaps building ids.

Buildings, floors and rooms move from the project overview to their own
page /projects/:id/struktur with three columns (Gebäude -> Etagen -> Räume)
that filter each other, and a sidebar entry. Floor selects in the board and
room dialogs are grouped by building. Unchanged dialogs close without a
command. Details in docs/building-structure.md; see issue #6.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AppShell showed the sidebar only on the project list and overview, so it
disappeared on the building structure page and in the circuit list
editor. It is collapsible, so it now stays on every page. Only the print
view, a stand-alone document opened in its own tab and printed as PDF,
keeps the full width.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
In LPH 2/3 there are no circuits yet, but the office needs a power
balance by DIN 276 cost group, as in the Excel template "Leistungsbilanz -
KG400": each trade enters consumers by piece or by area (W/m²) with GLF
and cos phi; the balance sums AV and SV per cost group, adds a reserve and
derives the maximum current.

The module is separate from the circuit structure: own tables
(migration 0010), own folder src/estimate-balance and an import-free
shared calculation used by API and UI. Writes go through project commands
(estimate-balance.insert/.update/.delete with complete documents), so
revision checks and Undo/Redo apply; it is not part of project snapshots
or transfer yet. A comparison endpoint sums the device rows of all circuit
lists by cost group (longest prefix) against the estimate.

The UI adds a sidebar entry, a list of Stände (template KG 400, empty or
copy) and a spreadsheet-like editor with autosave, AMEV picker for the
GLF, totals, reserve, maximum current, comparison table and print layout.
The tests reproduce the template example exactly (143.24 kW, 148.48 kVA,
157.56 kW / 163.33 kVA with 10 % reserve, 235.75 A). See
docs/estimate-balance.md and issue #7.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The print of the rough power balance was plain grey. It now follows the
kbp design of the print view: a title block with office logo, stand,
project, number, owner, address, work stage, date, editor and office;
header row in kbp blue, cost-group rows tinted with a lilac rule, bold
subtotals, the total including reserve as a blue band, colored
deviations in the comparison, Arial, exact print colors, and a footer
with project, stand and "Seite x von y" on every page.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Versorgung field suggests ELT and MSR (plus values already used in
the balance) through a datalist and still accepts free text. The circuit
number column is not needed in early design phases; it is removed from
the data model, the regenerated migration 0010, the editor and the
print. All cells are centered except "Verbraucher / Flächen", group
titles and total labels.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The printed page kept the dark app background in the page margins, the
consumer column wrapped while the empty remark column took the space, an
empty "bearbeitet von" label was printed, and numbers were printed as
typed (11200). Print margins are white now, the consumer column is wider,
empty editors are omitted and numbers print with thousands separators
(11.200) like the template.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jappel closed this pull request 2026-09-27 12:42:01 +02:00
Owner

Abschluss der Integration

Der PR wurde wegen der manuellen Integration in den inzwischen weiterentwickelten main geschlossen und deshalb von Forgejo nicht als regulär gemergt markiert.

Gegenüber dem ursprünglichen PR-Stand wurden bei der Durchsicht folgende Entscheidungen berücksichtigt:

  • Der portable Projektexport enthält Grobbilanzen im Transferformat 2. Beim Ersetzen werden sie atomar und mit Undo/Redo übernommen; beim Duplizieren erhalten Bilanz, Gruppen und Zeilen neue IDs. Transferformat 1 bleibt importierbar.
  • Benannte und automatische Snapshots sowie Snapshot-Restore enthalten keine Grobbilanzen und lassen vorhandene Grobbilanzen unverändert.
  • Stände bleiben bearbeitbar; ein Einfrieren oder zusätzlicher Status wurde nicht ergänzt.
  • Die Zuordnung detaillierter Gerätezeilen bleibt ein längster Kostengruppen-Präfixvergleich.
  • Der Vergleich zeigt zunächst die AV-Wirkleistung in kW. SV- und kVA-Vergleiche bleiben eine mögliche spätere Erweiterung.
  • Es gibt keine Stromkreisnummer und keine Übernahme in Stromkreise oder Projektgeräte, da die Grobbilanz eine eigenständige frühe Abschätzung bleibt.

Geprüft wurden 70 fokussierte Tests, die vollständige Suite mit 499 Tests, API- und Web-Produktionsbuild, beide TypeScript-Prüfungen sowie Migration, Transferformat 1/2, atomarer Import und Undo.

## Abschluss der Integration Der PR wurde wegen der manuellen Integration in den inzwischen weiterentwickelten `main` geschlossen und deshalb von Forgejo nicht als regulär gemergt markiert. - überprüftes Implementierungspaket: [`5734876`](https://git.jappel.io/jappel/leistungsbilanz-ts/commit/5734876) - Merge in `main`: [`060a203`](https://git.jappel.io/jappel/leistungsbilanz-ts/commit/060a203) - zugehöriges Issue: [#7](https://git.jappel.io/jappel/leistungsbilanz-ts/issues/7) - aktuelle Dokumentation: [`docs/estimate-balance.md`](https://git.jappel.io/jappel/leistungsbilanz-ts/src/branch/main/docs/estimate-balance.md) Gegenüber dem ursprünglichen PR-Stand wurden bei der Durchsicht folgende Entscheidungen berücksichtigt: - Der portable Projektexport enthält Grobbilanzen im Transferformat 2. Beim Ersetzen werden sie atomar und mit Undo/Redo übernommen; beim Duplizieren erhalten Bilanz, Gruppen und Zeilen neue IDs. Transferformat 1 bleibt importierbar. - Benannte und automatische Snapshots sowie Snapshot-Restore enthalten keine Grobbilanzen und lassen vorhandene Grobbilanzen unverändert. - Stände bleiben bearbeitbar; ein Einfrieren oder zusätzlicher Status wurde nicht ergänzt. - Die Zuordnung detaillierter Gerätezeilen bleibt ein längster Kostengruppen-Präfixvergleich. - Der Vergleich zeigt zunächst die AV-Wirkleistung in kW. SV- und kVA-Vergleiche bleiben eine mögliche spätere Erweiterung. - Es gibt keine Stromkreisnummer und keine Übernahme in Stromkreise oder Projektgeräte, da die Grobbilanz eine eigenständige frühe Abschätzung bleibt. Geprüft wurden 70 fokussierte Tests, die vollständige Suite mit 499 Tests, API- und Web-Produktionsbuild, beide TypeScript-Prüfungen sowie Migration, Transferformat 1/2, atomarer Import und Undo.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: jappel/leistungsbilanz-ts#17
No description provided.