adding revenue handlers and shell

This commit is contained in:
samantha42
2026-03-24 12:09:19 +01:00
parent 33b100f325
commit 1a9fe3adc7
13 changed files with 688 additions and 37 deletions

View File

@@ -53,7 +53,28 @@ func InitDB(db *sql.DB) {
value REAL NOT NULL,
FOREIGN KEY (report_id) REFERENCES revenue_reports(id),
FOREIGN KEY (currency_id) REFERENCES currencies(id)
);`
);
-- one row per category type per company
-- e.g. Apple has "product" and "location"
CREATE TABLE IF NOT EXISTS category_defs (
id INTEGER PRIMARY KEY AUTOINCREMENT,
company_id INTEGER NOT NULL,
name TEXT NOT NULL,
FOREIGN KEY (company_id) REFERENCES companies(id),
UNIQUE(company_id, name)
);
-- the actual labels belonging to each category
-- e.g. category_def "product" → "iPhone", "Mac", "Services"
CREATE TABLE IF NOT EXISTS category_labels (
id INTEGER PRIMARY KEY AUTOINCREMENT,
category_def_id INTEGER NOT NULL,
label TEXT NOT NULL,
FOREIGN KEY (category_def_id) REFERENCES category_defs(id),
UNIQUE(category_def_id, label)
);
`
if _, err := db.Exec(schema); err != nil {
log.Fatal("Failed to create tables:", err)