-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
models.py
81 lines (71 loc) · 2.64 KB
/
models.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import datetime
import os
import shutil
from pony import orm
db = orm.Database();
class Configuration(db.Entity):
id = orm.PrimaryKey(int, auto=True);
name = orm.Required(str, unique=True);
value = orm.Required(str);
class Companies(db.Entity):
id = orm.PrimaryKey(int, auto=True);
name = orm.Required(str, unique=True);
dni_cif = orm.Required(str, unique=True);
email = orm.Optional(str, nullable=True);
phone = orm.Optional(str, nullable=True);
date = orm.Required(datetime.date);
modification_date = orm.Required(datetime.date);
address = orm.Required(str);
postal_code = orm.Required(str);
city = orm.Required(str);
province = orm.Required(str);
country = orm.Required(str);
notes = orm.Optional(str, nullable=True)
income_invoice = orm.Set("IncomeInvoice");
expense_invoice = orm.Set("ExpenseInvoice");
class IncomeInvoice(db.Entity):
id = orm.PrimaryKey(int, auto=True);
identifier = orm.Required(str, unique=True);
date = orm.Required(datetime.date);
modification_date = orm.Required(datetime.date);
expiration_date = orm.Required(datetime.date);
status = orm.Required(str);
irpf = orm.Required(float);
iva = orm.Required(float);
irpf_money = orm.Required(float);
iva_money = orm.Required(float);
total = orm.Required(float);
notes = orm.Optional(str, nullable=True);
company = orm.Required(Companies);
products = orm.Set("IncomeProducts");
class ExpenseInvoice(db.Entity):
id = orm.PrimaryKey(int, auto=True);
identifier = orm.Required(str, unique=True);
date = orm.Required(datetime.date);
modification_date = orm.Required(datetime.date);
expiration_date = orm.Required(datetime.date);
status = orm.Required(str);
irpf = orm.Required(float);
iva = orm.Required(float);
irpf_money = orm.Required(float);
iva_money = orm.Required(float);
total = orm.Required(float);
notes = orm.Optional(str, nullable=True);
company = orm.Required(Companies);
products = orm.Set("ExpenseProducts");
class IncomeProducts(db.Entity):
id = orm.PrimaryKey(int, auto=True);
description = orm.Required(str);
amount = orm.Required(float);
price = orm.Required(float);
invoice = orm.Required(IncomeInvoice);
class ExpenseProducts(db.Entity):
id = orm.PrimaryKey(int, auto=True);
description = orm.Required(str);
amount = orm.Required(float);
price = orm.Required(float);
invoice = orm.Required(ExpenseInvoice);
if not os.path.exists("user/data.db"):
shutil.copyfile("data.db.example", "user/data.db");
db.bind(provider="sqlite", filename="user/data.db");
db.generate_mapping();