Finanzmanager/migrations/021_depot_bankbestand.sql
fds2610-bot b4a1b0acbc Fix n.n.: Depotabruf per FinTS und Nachweis zur Überweisung
Depotaufstellung (HKWPD, Version 6) unter Wertpapiere mit Vergleich zum eigenen
Bestand; Prüfsumme und Textnachweis für das Übermittlungsprotokoll einer
Überweisung; phpFinTS v4.1.5.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-09-30 15:10:43 +02:00

31 lines
1.6 KiB
SQL
Raw Permalink 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.

-- Depotbestand laut Bank (FinTS-Depotaufstellung, HKWPD).
--
-- Je Depot bleibt nur der Stand des letzten Abrufs stehen; die vollständige
-- Bankantwort liegt im Übermittlungsprotokoll (`bank_protokolle`). Der Bestand
-- dient dem Vergleich mit den eigenen Depotbuchungen – gebucht wird daraus nichts.
CREATE TABLE IF NOT EXISTS depot_bankbestaende (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
benutzer_id INT UNSIGNED NOT NULL,
konto_id INT UNSIGNED NOT NULL,
isin VARCHAR(16) NOT NULL DEFAULT '',
wkn VARCHAR(16) NOT NULL DEFAULT '',
name VARCHAR(255) NOT NULL DEFAULT '',
stueck DECIMAL(18,6) NOT NULL DEFAULT 0,
einstiegskurs DECIMAL(18,6) NULL,
kurs DECIMAL(18,6) NULL,
wert DECIMAL(15,2) NULL,
waehrung CHAR(3) NOT NULL DEFAULT 'EUR',
stand DATE NULL,
abgerufen_am DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (id),
KEY idx_bankbestand_konto (konto_id),
CONSTRAINT fk_bankbestand_benutzer FOREIGN KEY (benutzer_id)
REFERENCES benutzer (id) ON DELETE CASCADE,
CONSTRAINT fk_bankbestand_konto FOREIGN KEY (konto_id)
REFERENCES konten (id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- Prüfsumme (SHA-256) des Protokolltextes, beim Speichern gebildet: Der
-- Nachweis-Export zeigt damit, ob das Protokoll seither unverändert ist.
ALTER TABLE bank_protokolle
ADD COLUMN IF NOT EXISTS pruefsumme CHAR(64) NULL AFTER protokoll;