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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
|
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Jan 17 09:56:14 2021
@author: sveter
"""
from app import db
from sqlalchemy.orm import relationship, backref
import sqlalchemy.types as types
def convert_date_to_string(converted_date):
try:
if converted_date == 0:
return converted_date
else:
separated_string = converted_date.split("-")
converted_string = "".join([strip_zero_from_date(separated_string[2]), ". ", convert_month_to_string(separated_string[1]), " ", separated_string[0]])
return converted_string
except:
return ""
def strip_zero_from_date(converted_date):
if converted_date[0] == "0":
return converted_date[1]
else:
return converted_date
def convert_month_to_string(my_month):
if my_month == "01":
return "ledna"
elif my_month == "02":
return "února"
elif my_month == "03":
return "března"
elif my_month == "04":
return "dubna"
elif my_month == "05":
return "května"
elif my_month == "06":
return "června"
elif my_month == "07":
return "července"
elif my_month == "08":
return "srpna"
elif my_month == "09":
return "září"
elif my_month == "10":
return "října"
elif my_month == "11":
return "listopadu"
elif my_month == "12":
return "prosince"
else:
return "podivného měsíce"
def convert_soud_to_string(my_soud):
if my_soud == "MSPH":
return "Městského soudu v Praze"
elif my_soud == "KSCB":
return "Krajského soudu v Českých Budějovicích"
elif my_soud == "KSPL":
return "Krajského soudu v Plzni"
elif my_soud == "KSUL":
return "Krajského soudu v Ústí nad Labem"
elif my_soud == "KSHK":
return "Krajského soudu v Hradci Králové"
elif my_soud == "KSBR":
return "Krajského soudu v Brně"
elif my_soud == "KSOS":
return "Krajského soudu v Ostravě"
else:
return "podivného soudu"
class MyType(types.TypeDecorator):
impl = types.Unicode
def process_bind_param(self, value, dialect):
return convert_date_to_string(value)
def process_result_value(self, value, dialect):
# return "PREFIX:" + value
return convert_date_to_string(value)
def copy(self, **kw):
return MyType(self.impl.length)
class MySoud(types.TypeDecorator):
impl = types.Unicode
# def process_bind_param(self, value, dialect):
# return convert_soud_to_string(value)
def process_result_value(self, value, dialect):
# return "PREFIX:" + value
return convert_soud_to_string(value)
def copy(self, **kw):
return MySoud(self.impl.length)
association_table = db.Table("obce_relation",
db.Column("company_id", db.Integer, db.ForeignKey("companies.id"), primary_key=True, nullable=False),
db.Column("obec_id", db.Integer, db.ForeignKey("obce.id"), nullable=False),
# db.PrimaryKeyConstraint('company_id', 'obec_id')
)
ulice_association = db.Table("ulice_relation",
db.Column("company_id", db.Integer, db.ForeignKey("companies.id"), primary_key=True, nullable=False),
db.Column("ulice_id", db.Integer, db.ForeignKey("ulice.id"), nullable=False),
# db.PrimaryKeyConstraint('company_id', 'obec_id')
)
# pravni_forma_association=db.Table("pravni_formy_relation",
# db.Column("company_id", db.Integer, db.ForeignKey("companies.id"), primary_key=True, nullable=False),
# db.Column("pravni_forma_id", db.Integer, db.ForeignKey("pravni_formy.id"), nullable=False),
# )
# predmety_podnikani_association = db.Table("predmety_podnikani_relation",
# db.Column("company_id", db.Integer, db.ForeignKey("companies.id"), primary_key=True, nullable=False),
# db.Column("predmet_podnikani_id", db.Integer, db.ForeignKey("predmety_podnikani.id"), nullable=False),
# db.Column("zapis_datum", db.String),
# db.Column("vymaz_datum", db.String),
# )
class Predmety_Podnikani_Association(db.Model):
__tablename__ = 'predmety_podnikani_relation'
id = db.Column(db.Integer)
company_id = db.Column(db.Integer, db.ForeignKey('companies.id'), nullable=False)
predmet_podnikani_id = db.Column(db.Integer, db.ForeignKey('predmety_podnikani.id'), nullable=False, primary_key=True)
zapis_datum = db.Column(MyType)
vymaz_datum = db.Column(MyType)
predmet_podnikani = db.relationship("Predmet_Podnikani", back_populates="company_predmet_podnikani")
company = db.relationship("Company", back_populates="predmet_podnikani")
class Predmety_Cinnosti_Association(db.Model):
__tablename__ = 'predmety_cinnosti_relation'
id = db.Column(db.Integer)
company_id = db.Column(db.Integer, db.ForeignKey('companies.id'), nullable=False)
predmet_cinnosti_id = db.Column(db.Integer, db.ForeignKey('predmety_cinnosti.id'), nullable=False, primary_key=True)
zapis_datum = db.Column(MyType)
vymaz_datum = db.Column(MyType)
predmet_cinnosti = db.relationship("Predmet_Cinnosti", back_populates="company_predmet_cinnosti")
company = db.relationship("Company", back_populates="predmet_cinnosti")
class Sidlo_Association(db.Model):
__tablename__ = 'sidlo_relation'
id = db.Column(db.Integer)
company_id = db.Column(db.Integer, db.ForeignKey('companies.id'), nullable=False)
sidlo_id = db.Column(db.Integer, db.ForeignKey('adresy.id'), nullable=False, primary_key=True)
zapis_datum = db.Column(MyType)
vymaz_datum = db.Column(MyType)
sidlo_text = db.relationship("Sidlo", back_populates="company_sidlo")
company = db.relationship("Company", back_populates="sidlo_text")
class Pravni_Forma_Association_v2(db.Model):
__tablename__ = 'pravni_formy_relation'
id = db.Column(db.Integer)
company_id = db.Column(db.Integer, db.ForeignKey('companies.id'), nullable=False)
pravni_forma_id = db.Column(db.Integer, db.ForeignKey('pravni_formy.id'), nullable=False, primary_key=True)
zapis_datum = db.Column(MyType)
vymaz_datum = db.Column(MyType)
pravni_forma_text = db.relationship("Pravni_Formy", back_populates="company_pravni_forma")
company = db.relationship("Company", back_populates="pravni_forma_text")
class Statutarni_Organ_Association(db.Model):
__tablename__ = 'statutarni_organ_relation'
id = db.Column(db.Integer)
company_id = db.Column(db.Integer, db.ForeignKey('companies.id'), nullable=False)
statutarni_organ_id = db.Column(db.Integer, db.ForeignKey('statutarni_organy.id'), nullable=False, primary_key=True)
zapis_datum = db.Column(MyType)
vymaz_datum = db.Column(MyType)
statutarni_organ_text = db.relationship("Statutarni_Organy", back_populates="company_statutarni_organ")
company = db.relationship("Company", back_populates="statutarni_organ_text")
pocet_clenu = db.relationship("Pocty_Clenu_Organu", backref="statutarni_organ_relation")
zpusoby_jednani = db.relationship("Zpusob_Jednani_Association", back_populates="statutarni_organ")
clenove = db.relationship("Statutarni_Organ_Clen_Association")
class Dozorci_Rada_Association(db.Model):
__tablename__ = 'dozorci_rada_relation'
id = db.Column(db.Integer, primary_key=True)
company_id = db.Column(db.Integer, db.ForeignKey('companies.id'), nullable=False)
# statutarni_organ_id = db.Column(db.Integer, db.ForeignKey('statutarni_organy.id'), nullable=False, primary_key=True)
zapis_datum = db.Column(MyType)
vymaz_datum = db.Column(MyType)
# statutarni_organ_text = db.relationship("Statutarni_Organy", back_populates="company_statutarni_organ")
# company = db.relationship("Company", back_populates="statutarni_organ_text")
pocet_clenu = db.relationship("Pocty_Clenu_DR", backref="dozorci_rada_relation")
# zpusoby_jednani = db.relationship("Zpusob_Jednani_Association", back_populates="statutarni_organ")
clenove = db.relationship("Dozorci_Rada_Clen_Association")
class Statutarni_Organ_Clen_Association(db.Model):
__tablename__ = 'statutarni_organ_clen_relation'
id = db.Column(db.Integer, primary_key=True)
statutarni_organ_id = db.Column(db.Integer, db.ForeignKey('statutarni_organ_relation.id'), nullable=False)
osoba_id = db.Column(db.Integer, db.ForeignKey('fyzicke_osoby.id'), nullable=False)
adresa_id = db.Column(db.Integer, db.ForeignKey('adresy.id'), nullable=False)
zapis_datum = db.Column(MyType)
vymaz_datum = db.Column(MyType)
funkce_od = db.Column(MyType)
funkce_do = db.Column(MyType)
clenstvi_od = db.Column(MyType)
clenstvi_do = db.Column(MyType)
funkce = db.Column(db.String)
adresa = db.relationship("Sidlo")
jmeno = db.relationship("Fyzicka_Osoba")
class Dozorci_Rada_Clen_Association(db.Model):
__tablename__ = 'dr_organ_clen_relation'
id = db.Column(db.Integer, primary_key=True)
dozorci_rada_id = db.Column(db.Integer, db.ForeignKey('dozorci_rada_relation.id'), nullable=False)
osoba_id = db.Column(db.Integer, db.ForeignKey('fyzicke_osoby.id'), nullable=False)
adresa_id = db.Column(db.Integer, db.ForeignKey('adresy.id'), nullable=False)
zapis_datum = db.Column(MyType)
vymaz_datum = db.Column(MyType)
funkce_od = db.Column(MyType)
funkce_do = db.Column(MyType)
clenstvi_od = db.Column(MyType)
clenstvi_do = db.Column(MyType)
funkce = db.Column(db.String)
adresa = db.relationship("Sidlo")
jmeno = db.relationship("Fyzicka_Osoba")
class Zpusob_Jednani_Association(db.Model):
__tablename__ = 'zpusoby_jednani_relation'
id = db.Column(db.Integer, primary_key=True)
statutarni_organ_id = db.Column(db.Integer, db.ForeignKey('statutarni_organ_relation.id'), nullable=False)
zpusob_jednani_id = db.Column(db.Integer, db.ForeignKey('zpusoby_jednani.id'), nullable=False)
zapis_datum = db.Column(MyType)
vymaz_datum = db.Column(MyType)
zpusob_jednani = relationship("Zpusob_Jednani", back_populates="zpusob_jednani_rship")
statutarni_organ = relationship("Statutarni_Organ_Association", back_populates="zpusoby_jednani")
class Company(db.Model):
__tablename__ = "companies"
id = db.Column(db.Integer, primary_key=True)
ico = db.Column(db.String)
nazev = db.Column(db.String)
zapis = db.Column(db.String)
sidlo = db.Column(db.String)
oddil = db.Column(db.String)
vlozka = db.Column(db.String)
soud = db.Column(db.String)
obec = db.relationship("Obce", secondary=association_table, backref="companies")
ulice = db.relationship("Ulice", secondary=ulice_association, backref="companies")
# pravni_forma = db.relationship("Pravni_Forma", secondary=pravni_forma_association, backref="companies")
insolvence = db.relationship("Insolvency_Events", backref="companies")
konkurz = db.relationship("Konkurz_Events", backref="companies")
predmet_podnikani = db.relationship("Predmety_Podnikani_Association", back_populates="company")
predmet_cinnosti = db.relationship("Predmety_Cinnosti_Association", back_populates="company")
zakladni_kapital = db.relationship("Zakladni_Kapital", backref="companies")
ostatni_skutecnosti = db.relationship("Ostatni_Skutecnosti", backref="companies")
akcie = db.relationship("Akcie", backref="companies")
obchodni_firma = db.relationship("Nazvy", backref="companies")
soudni_zapis = db.relationship("Soudni_Zapisy", backref="companies")
sidlo_text = db.relationship("Sidlo_Association", back_populates="company")
pravni_forma_text = db.relationship("Pravni_Forma_Association_v2", back_populates="company")
statutarni_organ_text = db.relationship("Statutarni_Organ_Association", back_populates="company")
dozorci_rada_text = db.relationship("Dozorci_Rada_Association")
class Obce(db.Model):
__tablename__ = "obce"
id = db.Column(db.Integer, primary_key=True)
obec_jmeno = db.Column(db.String)
company_obec = db.relationship("Company", secondary=association_table, backref="obce")
class Ulice(db.Model):
__tablename__ = "ulice"
id = db.Column(db.Integer, primary_key=True)
ulice_jmeno = db.Column(db.String)
company_ulice = db.relationship("Company", secondary=ulice_association)
# class Pravni_Forma(db.Model):
# __tablename__ = "pravni_formy"
# id = db.Column(db.Integer, primary_key=True)
# pravni_forma = db.Column(db.String)
# company_pravni_forma = db.relationship("Company", secondary=pravni_forma_association)
class Insolvency_Events(db.Model):
__tablename__ = "insolvency_events"
id = db.Column(db.Integer, primary_key=True)
company_id = db.Column(db.String, db.ForeignKey("companies.id"))
zapis_datum = db.Column(MyType)
vymaz_datum = db.Column(MyType)
# company = db.relationship("Company", backref="insolvency_events")
insolvency_event = db.Column(db.String)
class Konkurz_Events(db.Model):
__tablename__ = "konkurz_events"
id = db.Column(db.Integer, primary_key=True)
company_id = db.Column(db.String, db.ForeignKey("companies.id"))
zapis_datum = db.Column(MyType)
vymaz_datum = db.Column(MyType)
# company = db.relationship("Company", backref="insolvency_events")
konkurz_event = db.Column(db.String)
class Zakladni_Kapital(db.Model):
__tablename__ = "zakladni_kapital"
id = db.Column(db.Integer, primary_key=True)
company_id = db.Column(db.String, db.ForeignKey("companies.id"))
zapis_datum = db.Column(MyType)
vymaz_datum = db.Column(MyType)
vklad_typ = db.Column(db.String)
vklad_hodnota = db.Column(db.String)
splaceni_typ = db.Column(db.String)
splaceni_hodnota = db.Column(db.String)
class Predmet_Podnikani(db.Model):
__tablename__ = "predmety_podnikani"
id = db.Column(db.Integer, primary_key=True)
predmet_podnikani = db.Column(db.String)
company_predmet_podnikani = db.relationship("Predmety_Podnikani_Association", back_populates="predmet_podnikani")
class Predmet_Cinnosti(db.Model):
__tablename__ = "predmety_cinnosti"
id = db.Column(db.Integer, primary_key=True)
predmet_cinnosti = db.Column(db.String)
company_predmet_cinnosti = db.relationship("Predmety_Cinnosti_Association", back_populates="predmet_cinnosti")
class Sidlo(db.Model):
__tablename__ = "adresy"
id = db.Column(db.Integer, primary_key=True)
adresa_text = db.Column(db.String)
company_sidlo = db.relationship("Sidlo_Association", back_populates="sidlo_text")
class Pravni_Formy(db.Model):
__tablename__ = "pravni_formy"
id = db.Column(db.Integer, primary_key=True)
pravni_forma = db.Column(db.String)
company_pravni_forma = db.relationship("Pravni_Forma_Association_v2", back_populates="pravni_forma_text")
class Statutarni_Organy(db.Model):
__tablename__ = "statutarni_organy"
id = db.Column(db.Integer, primary_key=True)
statutarni_organ_text = db.Column(db.String)
company_statutarni_organ = db.relationship("Statutarni_Organ_Association", back_populates="statutarni_organ_text")
class Ostatni_Skutecnosti(db.Model):
__tablename__ = "ostatni_skutecnosti"
id = db.Column(db.Integer, primary_key=True)
company_id = db.Column(db.String, db.ForeignKey("companies.id"))
zapis_datum = db.Column(MyType)
vymaz_datum = db.Column(MyType)
ostatni_skutecnost = db.Column(db.String)
class Akcie(db.Model):
__tablename__ = "akcie"
id = db.Column(db.Integer, primary_key=True)
company_id = db.Column(db.String, db.ForeignKey("companies.id"))
zapis_datum = db.Column(MyType)
vymaz_datum = db.Column(MyType)
akcie_podoba = db.Column(db.String)
akcie_typ = db.Column(db.String)
akcie_pocet = db.Column(db.String)
akcie_hodnota_typ = db.Column(db.String)
akcie_hodnota_value = db.Column(db.String)
akcie_text = db.Column(db.String)
class Nazvy(db.Model):
__tablename__ = "nazvy"
id = db.Column(db.Integer, primary_key=True)
company_id = db.Column(db.String, db.ForeignKey("companies.id"))
zapis_datum = db.Column(MyType)
vymaz_datum = db.Column(MyType)
nazev_text = db.Column(db.String)
class Soudni_Zapisy(db.Model):
__tablename__ = "zapis_soudy"
id = db.Column(db.Integer, primary_key=True)
company_id = db.Column(db.String, db.ForeignKey("companies.id"))
zapis_datum = db.Column(MyType)
vymaz_datum = db.Column(MyType)
oddil = db.Column(db.String)
vlozka = db.Column(db.String)
soud = db.Column(MySoud)
class Pocty_Clenu_Organu(db.Model):
__tablename__ = "pocty_clenu_organu"
id = db.Column(db.Integer, primary_key=True)
organ_id = db.Column(db.String, db.ForeignKey("statutarni_organ_relation.id"))
zapis_datum = db.Column(MyType)
vymaz_datum = db.Column(MyType)
pocet_clenu_value = db.Column(db.String)
class Pocty_Clenu_DR(db.Model):
__tablename__ = "pocty_clenu_DR"
id = db.Column(db.Integer, primary_key=True)
organ_id = db.Column(db.String, db.ForeignKey("dozorci_rada_relation.id"))
zapis_datum = db.Column(MyType)
vymaz_datum = db.Column(MyType)
pocet_clenu_value = db.Column(db.String)
class Zpusob_Jednani(db.Model):
__tablename__ = "zpusoby_jednani"
id = db.Column(db.Integer, primary_key=True)
zpusob_jednani_text = db.Column(db.String)
zpusob_jednani_rship = db.relationship("Zpusob_Jednani_Association", back_populates="zpusob_jednani")
class Fyzicka_Osoba(db.Model):
__tablename__ = "fyzicke_osoby"
id = db.Column(db.Integer, primary_key=True)
titul_pred = db.Column(db.String)
jmeno = db.Column(db.String)
prijmeni = db.Column(db.String)
titul_za = db.Column(db.String)
datum_naroz = db.Column(MyType)
|