Added categories and Filter widget

This commit is contained in:
Florian "flowdy" Heß
2017-01-29 15:57:34 +01:00
parent 6f19437901
commit d7db9a2eb1
23 changed files with 167 additions and 40 deletions

View File

@@ -5,6 +5,12 @@ CREATE TABLE Account (
IBAN -- target account for returned payments (set '' to enable
-- outgoing bank transfers to commercial partners from that account).
);
CREATE TABLE Category (
ID INTEGER PRIMARY KEY,
label
);
CREATE TABLE Debit (
billId PRIMARY KEY NOT NULL,
debtor NOT NULL, -- Account charged
@@ -13,10 +19,12 @@ CREATE TABLE Debit (
-- NULL when debit is a bank transfer from the club account
date DATE NOT NULL,
purpose NOT NULL, -- description of receipt
category,
value INTEGER NOT NULL, -- Euro-Cent
paid INTEGER DEFAULT 0, -- Euro-Cent, set and changed automatically (Cache)
FOREIGN KEY (debtor) REFERENCES Account(ID),
FOREIGN KEY (targetCredit) REFERENCES Credit(credId),
FOREIGN KEY (category) REFERENCES Category(ID),
CHECK ( abs(cast(value as integer)) == value
AND abs(cast( paid as integer)) == paid
AND value > 0 AND value >= paid
@@ -28,11 +36,13 @@ CREATE TABLE Credit (
account NOT NULL, -- Account des Begünstigten
date DATE NOT NULL,
purpose NOT NULL, -- as originally indicated in statement of bank account
category,
value INTEGER NOT NULL, -- Euro-Cent. Caution, two distinct cases need to be considered:
-- Either deposit by bank transfer (>0) or target of internal payments (=0)
spent INTEGER DEFAULT 0, -- Euro-Cent, set and changed automatically (Cache)
-- for later traceability, necessary when revoking transfers
FOREIGN KEY (account) REFERENCES Account(ID),
FOREIGN KEY (category) REFERENCES Category(ID),
CHECK ( abs(cast(value as integer)) == value
AND abs(cast(spent as integer)) == spent
AND value >= spent

View File

@@ -4,6 +4,7 @@ CREATE VIEW History AS
-- internal transfers with account as source
SELECT DATE(timestamp) AS date,
d.purpose AS purpose,
d.category AS category,
d.debtor AS account,
t.credId AS credId,
t.amount AS debit,
@@ -17,6 +18,7 @@ CREATE VIEW History AS
UNION
SELECT DATE(timestamp) AS date,
d.purpose AS purpose,
d.category AS category,
c.account AS account,
d.targetCredit AS credId,
NULL AS debit,

View File

@@ -2,6 +2,7 @@ DROP VIEW IF EXISTS ReconstructedBankStatement;
CREATE VIEW ReconstructedBankStatement AS
SELECT c.date AS date,
c.purpose AS purpose,
c.category AS category,
account,
c.value AS credit,
NULL AS debit
@@ -12,6 +13,7 @@ CREATE VIEW ReconstructedBankStatement AS
UNION
SELECT date,
purpose,
category AS category,
debtor AS account,
NULL AS credit,
value AS debit