51 lines
2.3 KiB
SQL
51 lines
2.3 KiB
SQL
-- ============================================================================
|
|
-- Copyright (C) 2026 Eduard Wisch <data@data-it-solution.de>
|
|
--
|
|
-- This program is free software: you can redistribute it and/or modify
|
|
-- it under the terms of the GNU General Public License as published by
|
|
-- the Free Software Foundation, either version 3 of the License, or
|
|
-- (at your option) any later version.
|
|
-- ============================================================================
|
|
|
|
CREATE TABLE IF NOT EXISTS llx_facture_lines_manager (
|
|
rowid INTEGER AUTO_INCREMENT PRIMARY KEY,
|
|
|
|
-- Verknüpfung mit dem Elterndokument (nur eines davon ist gesetzt)
|
|
fk_facture INTEGER DEFAULT NULL, -- Rechnung
|
|
fk_propal INTEGER DEFAULT NULL, -- Angebot
|
|
fk_commande INTEGER DEFAULT NULL, -- Kundenauftrag
|
|
|
|
-- Dokumenttyp zur einfachen Unterscheidung
|
|
document_type VARCHAR(20) DEFAULT 'invoice', -- 'invoice', 'propal', 'order'
|
|
|
|
-- Zeilentyp
|
|
line_type VARCHAR(20) NOT NULL, -- 'section', 'product', 'text', 'subtotal'
|
|
|
|
-- Verknüpfung zur Detail-Tabelle (facturedet, propaldet, commandedet)
|
|
fk_facturedet INTEGER DEFAULT NULL, -- für Rechnungen
|
|
fk_propaldet INTEGER DEFAULT NULL, -- für Angebote
|
|
fk_commandedet INTEGER DEFAULT NULL, -- für Kundenaufträge
|
|
|
|
-- Section-Eigenschaften
|
|
title VARCHAR(255) DEFAULT NULL,
|
|
parent_section INTEGER DEFAULT NULL, -- FK zu rowid dieser Tabelle
|
|
|
|
-- Sortierung und Status
|
|
line_order INTEGER DEFAULT 0,
|
|
show_subtotal TINYINT DEFAULT 0, -- Zwischensumme anzeigen?
|
|
collapsed TINYINT DEFAULT 0, -- Section eingeklappt?
|
|
in_facturedet TINYINT DEFAULT 0, -- In der Detail-Tabelle vorhanden?
|
|
|
|
-- Zeitstempel
|
|
date_creation DATETIME DEFAULT NULL,
|
|
tms TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
|
|
|
-- Indizes
|
|
INDEX idx_flm_fk_facture (fk_facture),
|
|
INDEX idx_flm_fk_propal (fk_propal),
|
|
INDEX idx_flm_fk_commande (fk_commande),
|
|
INDEX idx_flm_document_type (document_type),
|
|
INDEX idx_flm_line_type (line_type),
|
|
INDEX idx_flm_parent_section (parent_section),
|
|
INDEX idx_flm_line_order (line_order)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|