summaryrefslogtreecommitdiff
path: root/app/model.py
blob: 1cf59d8026b465e91bb9a6ac63c4939e7918e812 (plain)
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# import SQLAlchemy
from flask_sqlalchemy import SQLAlchemy
from datetime import datetime

db = SQLAlchemy()


class Module(db.Model):
    name = db.Column(
        "Name", db.String(20), unique=True, nullable=False, primary_key=True
    )
    description = db.Column("Description", db.String(50), nullable=False)

    def __repr__(self):
        return f"<Module {self.name}>"


class Customer(db.Model):
    primary_key = db.Column("CustomerId", db.Integer, nullable=False, primary_key=True)
    name = db.Column("Name", db.String(20), nullable=False)
    name_alternative = db.Column("NameAlternative", db.String(20))
    date_time_created = db.Column("DateTimeCreated", db.String(20), nullable=False)
    date_time_updated = db.Column("DateTimeUpdated", db.String(20), nullable=False)
    code_customer = db.Column("CodeCustomer", db.String(20), unique=True)
    code_accounting = db.Column("CodeAccounting", db.String(20), unique=True)
    address = db.Column("Address", db.String(20))
    postal_code = db.Column("PostalCode", db.Integer)
    city = db.Column("City", db.String(20))
    country = db.Column("Country", db.String(20))
    phone = db.Column("Phone", db.String(20))
    website = db.Column("Website", db.String(20))
    email = db.Column("Email", db.String(20))
    professional_id_1 = db.Column("ProfessionalId1", db.String(20), unique=True)
    professional_id_2 = db.Column("ProfessionalId2", db.String(20), unique=True)
    tax_id = db.Column("TaxId", db.String(20), unique=True)
    payment_terms = db.Column("PaymentTerms", db.String(20), unique=True)

    def __repr__(self):
        return f"<Customer {self.name}>"


class Product(db.Model):
    primary_key = db.Column("ProductId", db.Integer, primary_key=True)
    name = db.Column("Name", db.String(20), nullable=False, unique=True)
    code_accounting = db.Column("CodeAccounting", db.String(20))
    unit_weight = db.Column("UnitWeight", db.Float)
    price_net = db.Column("PriceNet", db.Float)
    price_gross = db.Column("PriceGross", db.Float)
    tax_rate = db.Column("TaxRate", db.Float)
    date_time_created = db.Column(
        "DateTimeCreated",
        db.String,
        default=datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
    )
    date_time_updated = db.Column(
        "DateTimeUpdated",
        db.String,
        default=datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
    )

    def __init__(
        self,
        name,
        code_accounting,
        unit_weight,
        price_net,
        price_gross,
        tax_rate,
    ):
        self.name = name
        self.code_accounting = code_accounting
        self.unit_weight = unit_weight
        self.price_net = price_net
        self.price_gross = price_gross
        self.tax_rate = tax_rate

    def __repr__(self):
        return f"<Product {self.name}>"


class Log(db.Model):
    primary_key = db.Column("LogId", db.Integer, primary_key=True)
    target = db.Column("Target", db.String, default="False")
    nno3 = db.Column("NNO3", db.Float, default=0)
    p = db.Column("P", db.Float, default=0)
    k = db.Column("K", db.Float, default=0)
    ca = db.Column("Ca", db.Float, default=0)
    mg = db.Column("Mg", db.Float, default=0)
    s = db.Column("S", db.Float, default=0)
    na = db.Column("Na", db.Float, default=0)
    cl = db.Column("Cl", db.Float, default=0)
    fe = db.Column("Fe", db.Float, default=0)
    zn = db.Column("Zn", db.Float, default=0)
    b = db.Column("B", db.Float, default=0)
    mn = db.Column("Mn", db.Float, default=0)
    cu = db.Column("Cu", db.Float, default=0)
    mo = db.Column("Mo", db.Float, default=0)
    si = db.Column("Si", db.Float, default=0)
    nnh4 = db.Column("NNH4", db.Float, default=0)
    date_time_created = db.Column(
        "DateTimeCreated",
        db.String,
        default=datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
    )
    date_time_updated = db.Column(
        "DateTimeUpdated",
        db.String,
        default=datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
    )

    def __init__(
        self, target, nno3, p, k, ca, mg, s, na, cl, fe, zn, b, mn, cu, mo, si, nnh4
    ):
        self.target = target
        self.nno3 = nno3
        self.p = p
        self.k = k
        self.ca = ca
        self.mg = mg
        self.s = s
        self.na = na
        self.cl = cl
        self.fe = fe
        self.zn = zn
        self.b = b
        self.mn = mn
        self.cu = cu
        self.mo = mo
        self.si = si
        self.nnh4 = nnh4
        self.date_time_created = datetime.now().strftime("%Y-%m-%d %H:%M:%S")

    def __repr__(self):
        return f"<Log from {self.date_time_created} updated {self.date_time_updated}>"


# Everything after here is garbage


class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name_first = db.Column(db.String(20), nullable=False)
    name_last = db.Column(db.String(20), nullable=False)
    email = db.Column(db.String(20), nullable=False)
    phone_mobile = db.Column(db.Integer, nullable=False)
    phone_alternative = db.Column(db.Integer)
    updated = db.Column(db.String)

    def __repr__(self):
        return f"<User {self.name_first} {self.name_last}>"


class Order(db.Model):  # TODO
    id = db.Column(db.Integer, primary_key=True)
    date = db.Column(db.String(20), nullable=False)
    customer = db.Column(db.String(20), nullable=False)
    content = db.Column(db.String(10), nullable=False)
    updated = db.Column(db.String)

    def __repr__(self):
        return f"<Order {self.name} at {self.updated}>"
Copyright 2019--2024 Marius PETER