aboutsummaryrefslogtreecommitdiffstats
path: root/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'models.py')
-rw-r--r--models.py237
1 files changed, 198 insertions, 39 deletions
diff --git a/models.py b/models.py
index 42c77f2..7a9160c 100644
--- a/models.py
+++ b/models.py
@@ -5,7 +5,6 @@ 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:
@@ -69,6 +68,24 @@ def convert_soud_to_string(my_soud):
else:
return "podivného soudu"
+def convert_currency(my_currency):
+ if my_currency == "KORUNY":
+ return "Kč"
+ elif my_currency == "EURA":
+ return "Euro"
+ else:
+ return ""
+
+def convert_contribution(my_contribution):
+ if my_contribution == "KORUNY":
+ return "Kč"
+ elif my_contribution == "PROCENTA":
+ return "%"
+ elif my_contribution == "EURA":
+ return "Euro"
+ else:
+ return ""
+
class MyType(types.TypeDecorator):
impl = types.Unicode
@@ -89,11 +106,31 @@ class MySoud(types.TypeDecorator):
def copy(self, **kw):
return MySoud(self.impl.length)
+class MyCurrency(types.TypeDecorator):
+
+ impl = types.Unicode
+
+ def process_result_value(self, value, dialect):
+ return convert_currency(value)
+
+ def copy(self, **kw):
+ return MyCurrency(self.impl.length)
+
+class MyContribution(types.TypeDecorator):
+
+ impl = types.Unicode
+
+ def process_result_value(self, value, dialect):
+ return convert_contribution(value)
+
+ def copy(self, **kw):
+ return MyContribution(self.impl.length)
+
class Predmety_Podnikani_Association(db.Model):
__tablename__ = 'predmety_podnikani_relation'
- id = db.Column(db.Integer)
+ id = db.Column(db.Integer, primary_key=True)
company_id = db.Column(db.Integer, db.ForeignKey('companies.id'))
- predmet_podnikani_id = db.Column(db.Integer, db.ForeignKey('predmety_podnikani.id'), primary_key=True)
+ predmet_podnikani_id = db.Column(db.Integer, db.ForeignKey('predmety_podnikani.id'))
zapis_datum = db.Column(MyType)
vymaz_datum = db.Column(MyType)
predmet_podnikani = db.relationship("Predmet_Podnikani", back_populates="company_predmet_podnikani")
@@ -101,14 +138,24 @@ class Predmety_Podnikani_Association(db.Model):
class Predmety_Cinnosti_Association(db.Model):
__tablename__ = 'predmety_cinnosti_relation'
- id = db.Column(db.Integer)
+ id = db.Column(db.Integer, primary_key=True)
company_id = db.Column(db.Integer, db.ForeignKey('companies.id'))
- predmet_cinnosti_id = db.Column(db.Integer, db.ForeignKey('predmety_cinnosti.id'), primary_key=True)
+ predmet_cinnosti_id = db.Column(db.Integer, db.ForeignKey('predmety_cinnosti.id'))
zapis_datum = db.Column(MyType)
vymaz_datum = db.Column(MyType)
predmet_cinnosti = db.relationship("Predmet_Cinnosti")
company = db.relationship("Company")
+class Ucel_Association(db.Model):
+ __tablename__ = 'ucel_relation'
+ id = db.Column(db.Integer, primary_key=True)
+ company_id = db.Column(db.Integer, db.ForeignKey('companies.id'))
+ ucel_id = db.Column(db.Integer, db.ForeignKey('ucel.id'))
+ zapis_datum = db.Column(MyType)
+ vymaz_datum = db.Column(MyType)
+ ucel = db.relationship("Ucel")
+ company = db.relationship("Company")
+
class Sidlo_Association(db.Model):
__tablename__ = 'sidlo_relation'
id = db.Column(db.Integer, primary_key=True)
@@ -129,11 +176,21 @@ class Pravni_Forma_Association_v2(db.Model):
pravni_forma_text = db.relationship("Pravni_Formy")
company = db.relationship("Company")
+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'))
+ zapis_datum = db.Column(MyType)
+ vymaz_datum = db.Column(MyType)
+ company = db.relationship("Company")
+ pocet_clenu = db.relationship("Pocty_Clenu_DR")
+ clenove = db.relationship("Dozorci_Rada_Clen_Association")
+
class Statutarni_Organ_Association(db.Model):
__tablename__ = 'statutarni_organ_relation'
- id = db.Column(db.Integer)
+ id = db.Column(db.Integer, primary_key=True)
company_id = db.Column(db.Integer, db.ForeignKey('companies.id'))
- statutarni_organ_id = db.Column(db.Integer, db.ForeignKey('statutarni_organy.id'), primary_key=True)
+ statutarni_organ_id = db.Column(db.Integer, db.ForeignKey('statutarni_organy.id'))
zapis_datum = db.Column(MyType)
vymaz_datum = db.Column(MyType)
statutarni_organ_text = db.relationship("Statutarni_Organy")
@@ -142,20 +199,12 @@ class Statutarni_Organ_Association(db.Model):
zpusoby_jednani = db.relationship("Zpusob_Jednani_Association")
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'))
- zapis_datum = db.Column(MyType)
- vymaz_datum = db.Column(MyType)
- pocet_clenu = db.relationship("Pocty_Clenu_DR")
- 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'))
osoba_id = db.Column(db.Integer, db.ForeignKey('fyzicke_osoby.id'))
+ prav_osoba_id = db.Column(db.Integer, db.ForeignKey('pravnicke_osoby.id'))
adresa_id = db.Column(db.Integer, db.ForeignKey('adresy_v2.id'))
zapis_datum = db.Column(MyType)
vymaz_datum = db.Column(MyType)
@@ -166,12 +215,58 @@ class Statutarni_Organ_Clen_Association(db.Model):
funkce = db.Column(db.String)
adresa = db.relationship("Adresy_v2")
jmeno = db.relationship("Fyzicka_Osoba")
+ jmeno_po = db.relationship("Pravnicka_Osoba")
+ statutarni_organ = db.relationship("Statutarni_Organ_Association")
+
+class Pravnicka_Osoba(db.Model):
+ __tablename__ = "pravnicke_osoby"
+ id = db.Column(db.Integer, primary_key=True)
+ ico = db.Column(db.String)
+ reg_cislo = db.Column(db.String)
+ nazev = db.Column(db.String)
+ spolecnik_association = db.relationship("Spolecnici_Association")
+ sole_shareholder_association = db.relationship("Jediny_Akcionar_Association")
+ statut_org_association = db.relationship("Statutarni_Organ_Clen_Association")
+ supervisory_board_member_association = db.relationship("Dozorci_Rada_Clen_Association")
+
+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)
+ statut_org_association = db.relationship("Statutarni_Organ_Clen_Association")
+ spolecnik_association = db.relationship("Spolecnici_Association")
+ prokurista_association = db.relationship("Prokurista_Association")
+ sole_shareholder_association = db.relationship("Jediny_Akcionar_Association")
+ supervisory_board_member_association = db.relationship("Dozorci_Rada_Clen_Association")
+
+ def get_name(self):
+ joined_name = ""
+ if self.titul_pred != "0" and self.titul_pred != None:
+ joined_name += self.titul_pred + " "
+ if self.jmeno != "0" and self.jmeno != None:
+ joined_name += self.jmeno + " "
+ if self.prijmeni != "0" and self.prijmeni != None:
+ joined_name += self.prijmeni
+ if self.titul_za != "0" and self.titul_za != None:
+ joined_name += ", " + self.titul_za
+ return joined_name
+
+ def __repr__(self):
+ joined_name = self.get_name()
+ if self.datum_naroz != 0 and self.datum_naroz != None and self.datum_naroz != "":
+ joined_name += ", nar. " + self.datum_naroz
+ return joined_name
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'))
osoba_id = db.Column(db.Integer, db.ForeignKey('fyzicke_osoby.id'))
+ pravnicka_osoba_id = db.Column(db.Integer, db.ForeignKey('pravnicke_osoby.id'))
adresa_id = db.Column(db.Integer, db.ForeignKey('adresy_v2.id'))
zapis_datum = db.Column(MyType)
vymaz_datum = db.Column(MyType)
@@ -182,6 +277,8 @@ class Dozorci_Rada_Clen_Association(db.Model):
funkce = db.Column(db.String)
adresa = db.relationship("Adresy_v2")
jmeno = db.relationship("Fyzicka_Osoba")
+ jmeno_po = db.relationship("Pravnicka_Osoba")
+ dozorci_rada = db.relationship("Dozorci_Rada_Association")
class Spolecnici_Association(db.Model):
__tablename__ = "spolecnici"
@@ -194,9 +291,10 @@ class Spolecnici_Association(db.Model):
adresa_id = db.Column(db.Integer, db.ForeignKey('adresy_v2.id'))
text_spolecnik = db.Column(db.String)
adresa = db.relationship("Adresy_v2")
- jmeno = db.relationship("Fyzicka_Osoba")
+ jmeno = db.relationship("Fyzicka_Osoba", back_populates="spolecnik_association")
oznaceni_po = db.relationship("Pravnicka_Osoba")
podily = db.relationship("Podily_Association")
+ company = db.relationship("Company")
class Prokurista_Association(db.Model):
__tablename__ = "prokuriste"
@@ -209,6 +307,7 @@ class Prokurista_Association(db.Model):
adresa = db.relationship("Adresy_v2")
jmeno = db.relationship("Fyzicka_Osoba")
text_prokurista = db.Column(db.String)
+ company = db.relationship("Company")
class Prokura_Common_Text_Association(db.Model):
__tablename__ = "prokura_common_texts"
@@ -231,6 +330,7 @@ class Jediny_Akcionar_Association(db.Model):
adresa = db.relationship("Adresy_v2")
jmeno = db.relationship("Fyzicka_Osoba")
oznaceni_po = db.relationship("Pravnicka_Osoba")
+ company = db.relationship("Company")
class Podily_Association(db.Model):
__tablename__ = "podily"
@@ -239,13 +339,25 @@ class Podily_Association(db.Model):
zapis_datum = db.Column(MyType)
vymaz_datum = db.Column(MyType)
druh_podilu_id = db.Column(db.Integer, db.ForeignKey('druhy_podilu.id'))
- vklad_typ = db.Column(db.String)
+ # vklad_typ = db.Column(db.String)
+ vklad_typ = db.Column(MyCurrency)
vklad_text = db.Column(db.String)
- souhrn_typ = db.Column(db.String)
+ souhrn_typ = db.Column(MyContribution)
souhrn_text = db.Column(db.String)
- splaceni_typ = db.Column(db.String)
+ splaceni_typ = db.Column(MyContribution)
splaceni_text = db.Column(db.String)
druh_podilu = db.relationship("Druhy_Podilu")
+
+ def my_rep(self):
+ podil_descr = "Vklad: " + self.vklad_text + " " + self.vklad_typ + "\n"
+ podil_descr += "Splaceno: " + self.splaceni_text + " " + self.splaceni_typ
+ if self.souhrn_text != "0":
+ podil_descr += "\n" + "Podíl: " + self.souhrn_text + self.souhrn_typ
+ if self.druh_podilu.druh_podilu != "0":
+ podil_descr += "\n" + "Druh podílu: " + self.druh_podilu.druh_podilu
+ return podil_descr.split("\n")
+
+
class Zpusob_Jednani_Association(db.Model):
__tablename__ = 'zpusoby_jednani_relation'
@@ -270,6 +382,7 @@ class Company(db.Model):
konkurz = db.relationship("Konkurz_Events")
predmet_podnikani = db.relationship("Predmety_Podnikani_Association")
predmet_cinnosti = db.relationship("Predmety_Cinnosti_Association")
+ ucel = db.relationship("Ucel_Association")
zakladni_kapital = db.relationship("Zakladni_Kapital")
ostatni_skutecnosti = db.relationship("Ostatni_Skutecnosti")
akcie = db.relationship("Akcie")
@@ -304,12 +417,12 @@ class Adresy_v2(db.Model):
joined_address = ""
if self.komplet_adresa != "0":
return self.komplet_adresa
- if self.ulice != "0":
+ if self.ulice != "0" and self.ulice != None:
joined_address += self.ulice + " "
if self.cisloText != "0" and self.cisloText != None:
joined_address += self.cisloText + ", "
if self.cisloPo != 0:
- if self.ulice == "0":
+ if self.ulice == "0" and self.ulice != None:
joined_address += "č.p. "
joined_address += str(self.cisloPo)
if self.cisloOr != 0:
@@ -320,11 +433,11 @@ class Adresy_v2(db.Model):
joined_address += str(self.cisloOr) + ", "
if self.cisloEv != 0:
joined_address += str(self.cisloEv) + ", "
- if (self.castObce != "0") and (self.castObce != self.obec):
+ if (self.castObce != "0") and (self.castObce != self.obec) and self.castObce != None:
joined_address += self.castObce + ", "
if self.psc != "0" and self.psc != None:
joined_address += self.psc + " "
- if self.obec != "0":
+ if self.obec != "0" and self.obec != None:
joined_address += self.obec
if (self.stat != "Česká republika") and (self.stat != "Česká republika - neztotožněno"):
joined_address += ", " + self.stat
@@ -356,6 +469,27 @@ class Zakladni_Kapital(db.Model):
vklad_hodnota = db.Column(db.String)
splaceni_typ = db.Column(db.String)
splaceni_hodnota = db.Column(db.String)
+
+ # def __repr__(self):
+ def my_rep(self):
+ joined_zk = ""
+ joined_zk += self.vklad_hodnota + " "
+
+ if self.vklad_typ == "KORUNY":
+ joined_zk += "Kč "
+ elif self.vklad_typ == "EURA":
+ joined_zk += "euro "
+
+ if self.splaceni_hodnota != "0":
+ joined_zk += "\n"
+ joined_zk += "Splaceno: " + self.splaceni_hodnota + " "
+ if self.splaceni_typ == "KORUNY":
+ joined_zk += "Kč "
+ elif self.splaceni_typ == "PROCENTA":
+ joined_zk += "% "
+ elif self.splaceni_typ == "EURA":
+ joined_zk += "euro "
+ return joined_zk.split("\n")
class Predmet_Podnikani(db.Model):
__tablename__ = "predmety_podnikani"
@@ -369,6 +503,12 @@ class Predmet_Cinnosti(db.Model):
predmet_cinnosti = db.Column(db.String)
company_predmet_cinnosti = db.relationship("Predmety_Cinnosti_Association")
+class Ucel(db.Model):
+ __tablename__ = "ucel"
+ id = db.Column(db.Integer, primary_key=True)
+ ucel = db.Column(db.String)
+ company_ucel = db.relationship("Ucel_Association")
+
class Sidlo(db.Model):
__tablename__ = "adresy"
id = db.Column(db.Integer, primary_key=True)
@@ -406,6 +546,40 @@ class Akcie(db.Model):
akcie_hodnota_typ = db.Column(db.String)
akcie_hodnota_value = db.Column(db.String)
akcie_text = db.Column(db.String)
+ def __repr__(self):
+ joined_share_descr = "" + self.akcie_pocet + " ks "
+
+ if self.akcie_typ == "KMENOVE_NA_JMENO":
+ joined_share_descr += "kmenové akcie na jméno "
+ elif self.akcie_typ == "KMENOVE_NA_MAJITELE":
+ joined_share_descr += "kmenové akcie na majitele "
+ elif self.akcie_typ == "KUSOVE_NA_JMENO":
+ joined_share_descr += "kusové akcie "
+ elif self.akcie_typ == "NA_JMENO":
+ joined_share_descr += "akcie na jméno "
+ elif self.akcie_typ == "NA_MAJITELE":
+ joined_share_descr += "akcie na majitele "
+ elif self.akcie_typ == "PRIORITNI_NA_JMENO":
+ joined_share_descr += "prioritní akcie na jméno "
+ elif self.akcie_typ == "ZAMESTNANECKE_NA_JMENO":
+ joined_share_descr += "zaměstnanecké akcie na jméno "
+ elif self.akcie_typ == "ZVLASTNI_PRAVA":
+ joined_share_descr += "akcie se zvláštními právy "
+
+ if self.akcie_podoba == "LISTINNA":
+ joined_share_descr += "v listinné podobě "
+ elif self.akcie_podoba == "ZAKNIHOVANA":
+ joined_share_descr += "v zaknihované podobě "
+ elif self.akcie_podoba == "IMOBILIZOVANA":
+ joined_share_descr += "v imobilizované podobě "
+
+ joined_share_descr += "ve jmenovité hodnotě " + self.akcie_hodnota_value
+
+ if self.akcie_hodnota_typ == "KORUNY":
+ joined_share_descr += "Kč"
+ elif self.akcie_hodnota_typ == "EURA":
+ joined_share_descr += "euro"
+ return joined_share_descr
class Nazvy(db.Model):
__tablename__ = "nazvy"
@@ -452,18 +626,3 @@ class Druhy_Podilu(db.Model):
id = db.Column(db.Integer, primary_key=True)
druh_podilu = db.Column(db.String)
-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)
-
-class Pravnicka_Osoba(db.Model):
- __tablename__ = "pravnicke_osoby"
- id = db.Column(db.Integer, primary_key=True)
- ico = db.Column(db.String)
- reg_cislo = db.Column(db.String)
- nazev = db.Column(db.String) \ No newline at end of file