added dividend db table and insert by trade

This commit is contained in:
samantha42
2026-04-06 07:36:45 +02:00
parent 31108a16d0
commit 57ae3cfb06
7 changed files with 120 additions and 48 deletions

View File

@@ -17,14 +17,26 @@ func InitDB(db *sql.DB) {
);
CREATE TABLE IF NOT EXISTS trades (
id INTEGER PRIMARY KEY AUTOINCREMENT,
symbol TEXT NOT NULL,
currency_code TEXT NOT NULL,
shares INTEGER NOT NULL,
product INTEGER NOT NULL CHECK(product IN (0, 1, 2, 3)),
type INTEGER NOT NULL CHECK(type IN (0, 1)),
price REAL NOT NULL,
traded_at DATETIME NOT NULL
id INTEGER PRIMARY KEY AUTOINCREMENT,
symbol TEXT NOT NULL,
currency_code TEXT NOT NULL,
shares INTEGER NOT NULL,
product INTEGER NOT NULL CHECK(product IN (0, 1, 2, 3, 4)), -- added 4 for BondTrade
type INTEGER NOT NULL CHECK(type IN (0, 1)), -- Buy=0, Sell=1 only; Dividend has its own table
price REAL NOT NULL,
traded_at DATETIME NOT NULL
);
CREATE TABLE IF NOT EXISTS dividends (
id INTEGER PRIMARY KEY AUTOINCREMENT,
symbol TEXT NOT NULL,
currency_code TEXT NOT NULL,
product INTEGER NOT NULL CHECK(product IN (0, 1, 2, 3, 4)),
value REAL NOT NULL,
tax_amount REAL NOT NULL DEFAULT 0,
tax_rate REAL NOT NULL DEFAULT 0,
net_value REAL NOT NULL,
payment_date DATETIME NOT NULL
);
CREATE TABLE IF NOT EXISTS position (