summaryrefslogtreecommitdiff
path: root/fracture/db.py
diff options
context:
space:
mode:
Diffstat (limited to 'fracture/db.py')
-rw-r--r--fracture/db.py20
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()