diff options
author | Ekaitz Zarraga <ekaitz@elenq.tech> | 2020-08-08 14:48:10 +0200 |
---|---|---|
committer | Ekaitz Zarraga <ekaitz@elenq.tech> | 2020-08-08 14:48:10 +0200 |
commit | 2ccbf8b690c4ea052ec3388bfabeb4b6943a74db (patch) | |
tree | 1be225f631fa600592f0ffcf957a95cabd79bf8a /fracture/db.py | |
parent | af0515ac909db46ec1fedc8f3cf9d884ff21ce31 (diff) |
Basic output control: summary, latex and json
Diffstat (limited to 'fracture/db.py')
-rw-r--r-- | fracture/db.py | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/fracture/db.py b/fracture/db.py index 1e90727..9ac0341 100644 --- a/fracture/db.py +++ b/fracture/db.py @@ -5,26 +5,23 @@ def create(dbname): c = conn.cursor() c.execute('''CREATE TABLE products - ( invoice_id INTEGER, + ( invoice_id TEXT, invoice_type TEXT, - invoice_series INTEGER, description TEXT NOT NULL, units REAL NOT NULL, price_unit REAL NOT NULL, vat REAL, PRIMARY KEY(description, invoice_id, - invoice_type, - invoice_series) + invoice_type) FOREIGN KEY(invoice_id) REFERENCES invoices(id) FOREIGN KEY(invoice_type) REFERENCES invoices(type) - FOREIGN KEY(invoice_series) REFERENCES invoices(series) ON DELETE CASCADE )''') # date is %Y-%m-%d c.execute('''CREATE TABLE invoices - ( id INTEGER NOT NULL, - id_repr TEXT NOT NULL, + ( number INTEGER NOT NULL, + id TEXT NOT NULL, type TEXT NOT NULL, series INTEGER NOT NULL, date TEXT NOT NULL, @@ -34,22 +31,19 @@ def create(dbname): customer_name TEXT, customer_address TEXT, PRIMARY KEY(type, series, id), - UNIQUE (id_repr, type) + UNIQUE (id, type) )''') c.execute('''CREATE TABLE taxes ( name TEXT NOT NULL, - invoice_id INTEGER, + invoice_id TEXT, invoice_type TEXT, - invoice_series INTEGER, ratio REAL, PRIMARY KEY(name, invoice_id, - invoice_type, - invoice_series) + invoice_type) FOREIGN KEY(invoice_id) REFERENCES invoices(id) FOREIGN KEY(invoice_type) REFERENCES invoices(type) - FOREIGN KEY(invoice_series) REFERENCES invoices(series) ON DELETE CASCADE )''') conn.commit() |