Files
Betriebsf-hrungssoftware/src/server/migrations/015_mengenblatt.sql
Claude 0bbb756b98
Some checks failed
Prüfung / tests (push) Has been cancelled
Prüfung / container (push) Has been cancelled
Neue Angebotsmaske: Mengenblatt mit Formeln, Musterpositionen und Mengenvorlagen im Katalog, Kostenzeilen mit Bezug, Subunternehmer (0.17.0)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AmyPfuNc4sCRfaF3oURXZz
2026-10-21 08:23:55 +00:00

45 lines
2.3 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- Neue Angebotsmaske (Henning, 21.10.2026): Schalter Aufmaß und Kalkulation je Position, Mengenblatt mit Kürzeln,
-- Kostenzeilen mit Bezug auf das Mengenblatt (Bezug × Ansatz × Personen), Subunternehmer als eigene Kostenart,
-- Textzeilen im Leistungsverzeichnis und eigene Mengenvorlagen und Musterpositionen.
alter table angebot_position
add column mit_kalkulation boolean not null default true,
add column mit_aufmass boolean not null default false,
add column aufmass jsonb,
add column textzeile boolean not null default false,
add column markiert boolean not null default false;
-- bisher: ohne Kostenzeilen galt der feste Preis
update angebot_position p set mit_kalkulation = exists (select 1 from angebot_kosten k where k.position_id = p.id);
alter table angebot_kosten drop constraint angebot_kosten_kostenart_check;
alter table angebot_kosten add constraint angebot_kosten_kostenart_check
check (kostenart in ('lohn', 'material', 'geraet', 'subunternehmer', 'sonstiges'));
alter table angebot_kosten
-- Kürzel oder Formel aus dem Mengenblatt; leer = Menge der Position (menge ist dann je Einheit)
add column bezug text,
add column personen numeric(8, 2) not null default 1 check (personen > 0),
-- „notwendig“ wie in der Urkalk: abgewählte Zeilen bleiben sichtbar und zählen nicht
add column aktiv boolean not null default true,
-- beim Wechsel der Vorlage werden diese Zeilen ersetzt
add column aus_vorlage boolean not null default false;
create table mengenvorlage (
id uuid primary key default gen_random_uuid(),
-- mengen: nur Mengenblatt; muster: Musterposition mit Texten und Kalkulation
art text not null default 'mengen' check (art in ('mengen', 'muster')),
gruppe text not null,
name text not null,
beschreibung text,
kurztext text,
langtext text,
einheit text,
-- Mengenblatt (Werte, Listen, Aufmaßzeilen, Menge) und Zeitansätze/Material
inhalt jsonb not null default '{"werte": [], "listen": [], "zeilen": [], "ansaetze": []}',
reihenfolge integer not null default 0,
angelegt_am timestamptz not null default now(),
geaendert_am timestamptz not null default now(),
geaendert_von text not null default 'system'
);
create trigger mengenvorlage_protokoll before insert or update or delete on mengenvorlage
for each row execute function stempel_und_protokoll();