diff options
author | Petr Šmerkl <46304018+SveterCZE@users.noreply.github.com> | 2021-04-04 13:50:15 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-04 13:50:15 +0200 |
commit | eabfee5453029c58dfc1316e088368a925dd7c1a (patch) | |
tree | c0e0d1dfb229dbb4157a63bd32d4d4a3c73e0647 | |
parent | 0fd9e0b55ceb1582549cb49b96d03c671cc4407c (diff) | |
parent | ecc371c16005650d6d623125f407d44b362b7054 (diff) | |
download | justice-eabfee5453029c58dfc1316e088368a925dd7c1a.tar.gz |
Merge pull request #2 from SveterCZE/feature_branchg
Feature branch
-rw-r--r-- | .gitignore | 245 | ||||
-rw-r--r-- | app.py | 4 | ||||
-rw-r--r-- | db_creation | 31 | ||||
-rw-r--r-- | db_creation.py | 715 | ||||
-rw-r--r-- | download_files.py | 74 | ||||
-rw-r--r-- | forms.py | 31 | ||||
-rw-r--r-- | justice_main.py | 540 | ||||
-rw-r--r-- | main.py | 159 | ||||
-rw-r--r-- | models.py | 535 | ||||
-rw-r--r-- | templates/extract-actual.html | 539 | ||||
-rw-r--r-- | templates/extract.html | 636 | ||||
-rw-r--r-- | templates/results2.html | 86 | ||||
-rw-r--r-- | templates/search_form.html | 27 | ||||
-rw-r--r-- | templates/search_parser.html | 72 | ||||
-rw-r--r-- | todolist.html | 8 | ||||
-rw-r--r-- | update_db.py | 623 |
16 files changed, 3613 insertions, 712 deletions
@@ -153,3 +153,248 @@ __pycache__/models.cpython-38.pyc __pycache__/tables.cpython-38.pyc pyvenv.cfg pyvenv.cfg +justice-testing.db +as-actual-ostrava-2021.xml +as-actual-ostrava-2021-test.xml +Scripts/_asyncio.pyd +Scripts/_bz2.pyd +Scripts/_ctypes_test.pyd +Scripts/_ctypes.pyd +Scripts/_decimal.pyd +Scripts/_elementtree.pyd +Scripts/_hashlib.pyd +Scripts/_lzma.pyd +Scripts/_msi.pyd +Scripts/_multiprocessing.pyd +Scripts/_overlapped.pyd +Scripts/_queue.pyd +Scripts/_socket.pyd +Scripts/_sqlite3.pyd +Scripts/_ssl.pyd +Scripts/_testbuffer.pyd +Scripts/_testcapi.pyd +Scripts/_testconsole.pyd +Scripts/_testimportmultiple.pyd +Scripts/_testinternalcapi.pyd +Scripts/_testmultiphase.pyd +Scripts/_tkinter.pyd +Scripts/activate +Scripts/activate_this.py +Scripts/activate.bat +Scripts/activate.fish +Scripts/activate.ps1 +Scripts/activate.xsh +Scripts/api-ms-win-core-console-l1-1-0.dll +Scripts/api-ms-win-core-datetime-l1-1-0.dll +Scripts/api-ms-win-core-debug-l1-1-0.dll +Scripts/api-ms-win-core-errorhandling-l1-1-0.dll +Scripts/api-ms-win-core-file-l1-1-0.dll +Scripts/api-ms-win-core-file-l1-2-0.dll +Scripts/api-ms-win-core-file-l2-1-0.dll +Scripts/api-ms-win-core-handle-l1-1-0.dll +Scripts/api-ms-win-core-heap-l1-1-0.dll +Scripts/api-ms-win-core-interlocked-l1-1-0.dll +Scripts/api-ms-win-core-libraryloader-l1-1-0.dll +Scripts/api-ms-win-core-localization-l1-2-0.dll +Scripts/api-ms-win-core-memory-l1-1-0.dll +Scripts/api-ms-win-core-namedpipe-l1-1-0.dll +Scripts/api-ms-win-core-processenvironment-l1-1-0.dll +Scripts/api-ms-win-core-processthreads-l1-1-0.dll +Scripts/api-ms-win-core-processthreads-l1-1-1.dll +Scripts/api-ms-win-core-profile-l1-1-0.dll +Scripts/api-ms-win-core-rtlsupport-l1-1-0.dll +Scripts/api-ms-win-core-string-l1-1-0.dll +Scripts/api-ms-win-core-synch-l1-1-0.dll +Scripts/api-ms-win-core-synch-l1-2-0.dll +Scripts/api-ms-win-core-sysinfo-l1-1-0.dll +Scripts/api-ms-win-core-timezone-l1-1-0.dll +Scripts/api-ms-win-core-util-l1-1-0.dll +Scripts/api-ms-win-crt-conio-l1-1-0.dll +Scripts/api-ms-win-crt-convert-l1-1-0.dll +Scripts/api-ms-win-crt-environment-l1-1-0.dll +Scripts/api-ms-win-crt-filesystem-l1-1-0.dll +Scripts/api-ms-win-crt-heap-l1-1-0.dll +Scripts/api-ms-win-crt-locale-l1-1-0.dll +Scripts/api-ms-win-crt-math-l1-1-0.dll +Scripts/api-ms-win-crt-multibyte-l1-1-0.dll +Scripts/api-ms-win-crt-private-l1-1-0.dll +Scripts/api-ms-win-crt-process-l1-1-0.dll +Scripts/api-ms-win-crt-runtime-l1-1-0.dll +Scripts/api-ms-win-crt-stdio-l1-1-0.dll +Scripts/api-ms-win-crt-string-l1-1-0.dll +Scripts/api-ms-win-crt-time-l1-1-0.dll +Scripts/api-ms-win-crt-utility-l1-1-0.dll +Scripts/concrt140.dll +Scripts/deactivate.bat +Scripts/libffi-7.dll +Scripts/msvcp140_1.dll +Scripts/msvcp140_2.dll +Scripts/msvcp140.dll +Scripts/pip-3.8.exe +Scripts/pip.exe +Scripts/pip3.8.exe +Scripts/pip3.exe +Scripts/pydoc.bat +Scripts/pyexpat.pyd +Scripts/python.exe +Scripts/python3.dll +Scripts/python38.dll +Scripts/pythonw.exe +Scripts/select.pyd +Scripts/tcl86t.dll +Scripts/tk86t.dll +Scripts/ucrtbase.dll +Scripts/unicodedata.pyd +Scripts/vccorlib140.dll +Scripts/vcomp140.dll +Scripts/vcruntime140.dll +Scripts/wheel-3.8.exe +Scripts/wheel.exe +Scripts/wheel3.8.exe +Scripts/wheel3.exe +Scripts/winsound.pyd +Scripts/xlwings32-0.20.7.dll +Scripts/xlwings64-0.20.7.dll +data/as-full-brno-2021.xml +data/as-full-ceske_budejovice-2021.xml +data/as-full-hradec_kralove-2021.xml +data/as-full-ostrava-2021.xml +data/as-full-plzen-2021.xml +data/as-full-praha-2021.xml +data/as-full-usti_nad_labem-2021.xml +data/dr-full-brno-2021.xml +data/dr-full-ceske_budejovice-2021.xml +data/dr-full-hradec_kralove-2021.xml +data/dr-full-ostrava-2021.xml +data/dr-full-plzen-2021.xml +data/dr-full-praha-2021.xml +data/dr-full-usti_nad_labem-2021.xml +data/evrdrspol-full-ostrava-2021.xml +data/evrdrspol-full-praha-2021.xml +data/evrhzs-full-hradec_kralove-2021.xml +data/evrhzs-full-ostrava-2021.xml +data/evrhzs-full-praha-2021.xml +data/evrhzs-full-usti_nad_labem-2021.xml +data/evrspol-full-brno-2021.xml +data/evrspol-full-ceske_budejovice-2021.xml +data/evrspol-full-hradec_kralove-2021.xml +data/evrspol-full-ostrava-2021.xml +data/evrspol-full-plzen-2021.xml +data/evrspol-full-praha-2021.xml +data/evrspol-full-usti_nad_labem-2021.xml +data/ks-full-brno-2021.xml +data/ks-full-ceske_budejovice-2021.xml +data/ks-full-hradec_kralove-2021.xml +data/ks-full-ostrava-2021.xml +data/ks-full-plzen-2021.xml +data/ks-full-praha-2021.xml +data/ks-full-usti_nad_labem-2021.xml +data/nad-full-brno-2021.xml +data/nad-full-ceske_budejovice-2021.xml +data/nad-full-hradec_kralove-2021.xml +data/nad-full-ostrava-2021.xml +data/nad-full-plzen-2021.xml +data/nad-full-praha-2021.xml +data/nad-full-usti_nad_labem-2021.xml +data/nadf-full-brno-2021.xml +data/nadf-full-ceske_budejovice-2021.xml +data/nadf-full-hradec_kralove-2021.xml +data/nadf-full-ostrava-2021.xml +data/nadf-full-plzen-2021.xml +data/nadf-full-praha-2021.xml +data/nadf-full-usti_nad_labem-2021.xml +data/odbororg-full-brno-2021.xml +data/odbororg-full-ceske_budejovice-2021.xml +data/odbororg-full-hradec_kralove-2021.xml +data/odbororg-full-ostrava-2021.xml +data/odbororg-full-plzen-2021.xml +data/odbororg-full-praha-2021.xml +data/odbororg-full-usti_nad_labem-2021.xml +data/orgzam-full-brno-2021.xml +data/orgzam-full-ceske_budejovice-2021.xml +data/orgzam-full-hradec_kralove-2021.xml +data/orgzam-full-ostrava-2021.xml +data/orgzam-full-plzen-2021.xml +data/orgzam-full-praha-2021.xml +data/orgzam-full-usti_nad_labem-2021.xml +data/osznad-full-praha-2021.xml +data/osznad-full-usti_nad_labem-2021.xml +data/osznadf-full-plzen-2021.xml +data/osznadf-full-praha-2021.xml +data/oszpo-full-brno-2021.xml +data/oszpo-full-ceske_budejovice-2021.xml +data/oszpo-full-hradec_kralove-2021.xml +data/oszpo-full-ostrava-2021.xml +data/oszpo-full-plzen-2021.xml +data/oszpo-full-praha-2021.xml +data/oszpo-full-usti_nad_labem-2021.xml +data/pobspolek-full-brno-2021.xml +data/pobspolek-full-ceske_budejovice-2021.xml +data/pobspolek-full-hradec_kralove-2021.xml +data/pobspolek-full-ostrava-2021.xml +data/pobspolek-full-plzen-2021.xml +data/pobspolek-full-praha-2021.xml +data/pobspolek-full-usti_nad_labem-2021.xml +data/prisp-full-brno-2021.xml +data/prisp-full-ceske_budejovice-2021.xml +data/prisp-full-hradec_kralove-2021.xml +data/prisp-full-ostrava-2021.xml +data/prisp-full-plzen-2021.xml +data/prisp-full-praha-2021.xml +data/prisp-full-usti_nad_labem-2021.xml +data/spolek-full-brno-2021.xml +data/spolek-full-ceske_budejovice-2021.xml +data/spolek-full-hradec_kralove-2021.xml +data/spolek-full-ostrava-2021.xml +data/spolek-full-plzen-2021.xml +data/spolek-full-praha-2021.xml +data/spolek-full-usti_nad_labem-2021.xml +data/sro-full-brno-2021.xml +data/sro-full-ceske_budejovice-2021.xml +data/sro-full-hradec_kralove-2021.xml +data/sro-full-ostrava-2021.xml +data/sro-full-plzen-2021.xml +data/sro-full-praha-2021.xml +data/sro-full-usti_nad_labem-2021.xml +data/svj-full-brno-2021.xml +data/svj-full-ceske_budejovice-2021.xml +data/svj-full-hradec_kralove-2021.xml +data/svj-full-ostrava-2021.xml +data/svj-full-plzen-2021.xml +data/svj-full-praha-2021.xml +data/svj-full-usti_nad_labem-2021.xml +data/ustav-full-brno-2021.xml +data/ustav-full-ceske_budejovice-2021.xml +data/ustav-full-hradec_kralove-2021.xml +data/ustav-full-ostrava-2021.xml +data/ustav-full-plzen-2021.xml +data/ustav-full-praha-2021.xml +data/ustav-full-usti_nad_labem-2021.xml +data/vos-full-brno-2021.xml +data/vos-full-ceske_budejovice-2021.xml +data/vos-full-hradec_kralove-2021.xml +data/vos-full-ostrava-2021.xml +data/vos-full-plzen-2021.xml +data/vos-full-praha-2021.xml +data/vos-full-usti_nad_labem-2021.xml +data/zahrfos-full-brno-2021.xml +data/zahrfos-full-ceske_budejovice-2021.xml +data/zahrfos-full-ostrava-2021.xml +data/zahrfos-full-plzen-2021.xml +data/zahrfos-full-praha-2021.xml +data/zahrfos-full-usti_nad_labem-2021.xml +data/zajzdrpo-full-brno-2021.xml +data/zajzdrpo-full-ceske_budejovice-2021.xml +data/zajzdrpo-full-hradec_kralove-2021.xml +data/zajzdrpo-full-ostrava-2021.xml +data/zajzdrpo-full-plzen-2021.xml +data/zajzdrpo-full-praha-2021.xml +data/zajzdrpo-full-usti_nad_labem-2021.xml +as-full-ostrava-2021.xml +sro-full-ceske_budejovice-2021.xml +sro-full-ostrava-2021.xml +sro-full-praha-2021.xml +templates/extract.html +__pycache__/db_creation.cpython-38.pyc +__pycache__/download_files.cpython-38.pyc +__pycache__/update_db.cpython-38.pyc @@ -8,9 +8,13 @@ Created on Sun Jan 17 09:38:19 2021 # app.py from flask import Flask +from flask_debugtoolbar import DebugToolbarExtension from flask_sqlalchemy import SQLAlchemy app = Flask(__name__) app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///justice.db' +app.config["SQLALCHEMY_ECHO"] = True app.secret_key = "123456" +app.debug = True +toolbar = DebugToolbarExtension(app) db = SQLAlchemy(app)
\ No newline at end of file diff --git a/db_creation b/db_creation index f2976b4..9fc44e0 100644 --- a/db_creation +++ b/db_creation @@ -64,3 +64,34 @@ CREATE TABLE "ulice_relation" ( FOREIGN KEY("company_id") REFERENCES "companies"("id"), FOREIGN KEY("ulice_id") REFERENCES "ulice"("id") ) + +CREATE TABLE "predmety_cinnosti_relation" ( + "company_id" INTEGER NOT NULL, + "predmet_cinnosti_id" INTEGER NOT NULL, + "zapis_datum" DATE, + "vymaz_datum" DATE, + FOREIGN KEY("company_id") REFERENCES "companies"("id"), + FOREIGN KEY("predmet_cinnosti_id") REFERENCES "predmety_cinnosti"("id") +) + +CREATE TABLE "predmety_podnikani_relation" ( + "company_id" INTEGER NOT NULL, + "predmet_podnikani_id" INTEGER NOT NULL, + "zapis_datum" DATE, + "vymaz_datum" DATE, + FOREIGN KEY("company_id") REFERENCES "companies"("id"), + FOREIGN KEY("predmet_podnikani_id") REFERENCES "predmety_podnikani"("id") +) + +CREATE TABLE "predmety_cinnosti" ( + "id" INTEGER NOT NULL, + "predmet_cinnosti" TEXT NOT NULL UNIQUE, + PRIMARY KEY("id" AUTOINCREMENT) +) + +CREATE TABLE "predmety_podnikani" ( + "id" INTEGER NOT NULL, + "predmet_podnikani" TEXT NOT NULL UNIQUE, + PRIMARY KEY("id" AUTOINCREMENT) +) + diff --git a/db_creation.py b/db_creation.py new file mode 100644 index 0000000..a704a85 --- /dev/null +++ b/db_creation.py @@ -0,0 +1,715 @@ +import sqlite3 + +def create_DB(db_file): + create_DB_file(db_file) + conn = create_connection(db_file) + create_tables(conn) + create_indices(conn) + conn.commit() + conn.close() + +def create_DB_file(db_file): + conn = None + try: + conn = sqlite3.connect(db_file) + except Exception as e: + print(e) + finally: + if conn: + conn.close() + +def create_connection(db_file): + conn = None + try: + conn = sqlite3.connect(db_file) + return conn + except Exception as e: + print(e) + return conn + +def create_tables(conn): + companies = """ CREATE TABLE "companies" ( + "id" INTEGER, + "ico" TEXT NOT NULL UNIQUE, + "nazev" TEXT, + "zapis" DATE, + "oddil" TEXT, + "vlozka" TEXT, + "soud" TEXT, + PRIMARY KEY("id" AUTOINCREMENT) + ); """ + + adresy_v2 = """ CREATE TABLE "adresy_v2" ( + "id" INTEGER NOT NULL UNIQUE, + "stat" TEXT, + "obec" TEXT, + "ulice" TEXT, + "castObce" TEXT, + "cisloPo" INTEGER, + "cisloOr" INTEGER, + "psc" TEXT, + "okres" TEXT, + "komplet_adresa" TEXT, + "cisloEv" INTEGER, + "cisloText" TEXT, + "company_id" INTEGER, + PRIMARY KEY("id" AUTOINCREMENT), + UNIQUE("stat","obec","ulice","castObce","cisloPo","cisloOr","psc","okres","komplet_adresa","cisloEv","cisloText") + ); """ + + akcie = """ CREATE TABLE "akcie" ( + "id" INTEGER NOT NULL UNIQUE, + "company_id" INTEGER NOT NULL, + "zapis_datum" DATE, + "vymaz_datum" DATE, + "akcie_podoba" TEXT, + "akcie_typ" TEXT, + "akcie_pocet" TEXT, + "akcie_hodnota_typ" TEXT, + "akcie_hodnota_value" TEXT, + "akcie_text" TEXT, + PRIMARY KEY("id" AUTOINCREMENT), + FOREIGN KEY("company_id") REFERENCES "companies"("id") +); """ + + dr_relation = """ CREATE TABLE "dozorci_rada_relation" ( + "id" INTEGER NOT NULL UNIQUE, + "company_id" INTEGER NOT NULL, + "zapis_datum" DATE, + "vymaz_datum" DATE, + FOREIGN KEY("company_id") REFERENCES "companies"("id"), + PRIMARY KEY("id" AUTOINCREMENT) +); """ + + dr_organ_clen_relation = """ CREATE TABLE "dr_organ_clen_relation" ( + "id" INTEGER NOT NULL UNIQUE, + "dozorci_rada_id" INTEGER NOT NULL, + "osoba_id" INTEGER NOT NULL, + "adresa_id" INTEGER, + "zapis_datum" DATE, + "vymaz_datum" DATE, + "funkce_od" DATE, + "funkce_do" DATE, + "clenstvi_od" DATE, + "clenstvi_do" DATE, + "funkce" TEXT, + FOREIGN KEY("adresa_id") REFERENCES "adresy"("id"), + FOREIGN KEY("dozorci_rada_id") REFERENCES "dozorci_rada_relation"("id"), + FOREIGN KEY("osoba_id") REFERENCES "fyzicke_osoby"("id"), + PRIMARY KEY("id" AUTOINCREMENT) +); """ + + druhy_podilu = """ CREATE TABLE "druhy_podilu" ( + "id" INTEGER NOT NULL UNIQUE, + "druh_podilu" TEXT NOT NULL UNIQUE, + PRIMARY KEY("id" AUTOINCREMENT) +); """ + + fyzicke_osoby = """ CREATE TABLE "fyzicke_osoby" ( + "id" INTEGER NOT NULL UNIQUE, + "titul_pred" TEXT, + "jmeno" TEXT, + "prijmeni" TEXT, + "titul_za" TEXT, + "datum_naroz" TEXT, + UNIQUE("titul_pred","jmeno","prijmeni","titul_za","datum_naroz"), + PRIMARY KEY("id" AUTOINCREMENT) +); """ + + insolvency_events = """ CREATE TABLE "insolvency_events" ( + "id" INTEGER NOT NULL UNIQUE, + "company_id" TEXT NOT NULL, + "zapis_datum" DATE NOT NULL, + "vymaz_datum" DATE, + "insolvency_event" TEXT UNIQUE, + PRIMARY KEY("id" AUTOINCREMENT), + FOREIGN KEY("company_id") REFERENCES "companies"("id") +); """ + + jediny_akcionar = """ CREATE TABLE "jediny_akcionar" ( + "id" INTEGER NOT NULL UNIQUE, + "company_id" INTEGER NOT NULL, + "zapis_datum" DATE, + "vymaz_datum" DATE, + "text_akcionar" TEXT, + "akcionar_po_id" INTEGER, + "akcionar_fo_id" INTEGER, + "adresa_id" INTEGER, + FOREIGN KEY("adresa_id") REFERENCES "adresy"("id"), + FOREIGN KEY("company_id") REFERENCES "companies"("id"), + FOREIGN KEY("akcionar_po_id") REFERENCES "pravnicke_osoby"("id"), + FOREIGN KEY("akcionar_fo_id") REFERENCES "fyzicke_osoby"("id"), + PRIMARY KEY("id" AUTOINCREMENT) +); """ + + konkurz_events = """ CREATE TABLE "konkurz_events" ( + "id" INTEGER NOT NULL UNIQUE, + "company_id" TEXT NOT NULL, + "zapis_datum" DATE NOT NULL, + "vymaz_datum" DATE, + "konkurz_event" TEXT UNIQUE, + PRIMARY KEY("id" AUTOINCREMENT), + FOREIGN KEY("company_id") REFERENCES "companies"("id") +); """ + + nazvy = """ CREATE TABLE "nazvy" ( + "id" INTEGER NOT NULL UNIQUE, + "company_id" INTEGER NOT NULL, + "zapis_datum" DATE, + "vymaz_datum" DATE, + "nazev_text" TEXT, + FOREIGN KEY("company_id") REFERENCES "companies"("id"), + PRIMARY KEY("id" AUTOINCREMENT) +); """ + + ostatni_skutecnosti = """ CREATE TABLE "ostatni_skutecnosti" ( + "id" INTEGER NOT NULL UNIQUE, + "company_id" INTEGER NOT NULL, + "zapis_datum" DATE NOT NULL, + "vymaz_datum" DATE, + "ostatni_skutecnost" TEXT, + FOREIGN KEY("company_id") REFERENCES "companies"("id"), + PRIMARY KEY("id" AUTOINCREMENT) +); """ + + pocty_clenu_DR = """ CREATE TABLE "pocty_clenu_DR" ( + "id" INTEGER NOT NULL UNIQUE, + "organ_id" INTEGER NOT NULL, + "pocet_clenu_value" INTEGER, + "zapis_datum" DATE, + "vymaz_datum" DATE, + FOREIGN KEY("organ_id") REFERENCES "dozorci_rada_relation"("id"), + PRIMARY KEY("id" AUTOINCREMENT) +); """ + + pocty_clenu_organu = """ CREATE TABLE "pocty_clenu_organu" ( + "id" INTEGER NOT NULL UNIQUE, + "organ_id" INTEGER NOT NULL, + "pocet_clenu_value" INTEGER NOT NULL, + "zapis_datum" DATE NOT NULL, + "vymaz_datum" DATE, + FOREIGN KEY("organ_id") REFERENCES "statutarni_organ_relation"("id"), + PRIMARY KEY("id" AUTOINCREMENT) +); """ + + podily = """ CREATE TABLE "podily" ( + "id" INTEGER NOT NULL UNIQUE, + "spolecnik_id" INTEGER NOT NULL, + "zapis_datum" DATE, + "vymaz_datum" DATE, + "druh_podilu_id" INTEGER, + "vklad_typ" TEXT, + "vklad_text" TEXT, + "souhrn_typ" TEXT, + "souhrn_text" TEXT, + "splaceni_typ" TEXT, + "splaceni_text" TEXT, + FOREIGN KEY("druh_podilu_id") REFERENCES "druhy_podilu"("id"), + FOREIGN KEY("spolecnik_id") REFERENCES "spolecnici"("id"), + PRIMARY KEY("id" AUTOINCREMENT) +); """ + + pravni_formy = """ CREATE TABLE "pravni_formy" ( + "id" INTEGER NOT NULL, + "pravni_forma" TEXT NOT NULL UNIQUE, + PRIMARY KEY("id" AUTOINCREMENT) +); """ + + pravni_formy_relation = """ CREATE TABLE "pravni_formy_relation" ( + "id" INTEGER NOT NULL UNIQUE, + "company_id" INTEGER NOT NULL, + "pravni_forma_id" INTEGER NOT NULL, + "zapis_datum" DATE NOT NULL, + "vymaz_datum" DATE, + PRIMARY KEY("id" AUTOINCREMENT), + FOREIGN KEY("pravni_forma_id") REFERENCES "pravni_formy"("id"), + FOREIGN KEY("company_id") REFERENCES "companies"("id") +); """ + + pravnicke_osoby = """ CREATE TABLE "pravnicke_osoby" ( + "id" INTEGER NOT NULL UNIQUE, + "ico" INTEGER, + "reg_cislo" INTEGER, + "nazev" TEXT, + UNIQUE("ico","reg_cislo","nazev"), + PRIMARY KEY("id" AUTOINCREMENT) +); """ + + predmety_cinnosti = """ CREATE TABLE "predmety_cinnosti" ( + "id" INTEGER NOT NULL, + "predmet_cinnosti" TEXT NOT NULL UNIQUE, + PRIMARY KEY("id" AUTOINCREMENT) +); """ + + predmety_cinnosti_relation = """ CREATE TABLE "predmety_cinnosti_relation" ( + "id" INTEGER NOT NULL UNIQUE, + "company_id" INTEGER NOT NULL, + "predmet_cinnosti_id" INTEGER NOT NULL, + "zapis_datum" DATE, + "vymaz_datum" DATE, + FOREIGN KEY("company_id") REFERENCES "companies"("id"), + FOREIGN KEY("predmet_cinnosti_id") REFERENCES "predmety_cinnosti"("id"), + PRIMARY KEY("id" AUTOINCREMENT) +); """ + + prdmety_podnikani = """ CREATE TABLE "predmety_podnikani" ( + "id" INTEGER NOT NULL, + "predmet_podnikani" TEXT NOT NULL UNIQUE, + PRIMARY KEY("id" AUTOINCREMENT) +); """ + + predmety_podnikani_relation = """ CREATE TABLE "predmety_podnikani_relation" ( + "id" INTEGER NOT NULL UNIQUE, + "company_id" INTEGER NOT NULL, + "predmet_podnikani_id" INTEGER NOT NULL, + "zapis_datum" DATE, + "vymaz_datum" DATE, + PRIMARY KEY("id" AUTOINCREMENT), + FOREIGN KEY("company_id") REFERENCES "companies"("id"), + FOREIGN KEY("predmet_podnikani_id") REFERENCES "predmety_podnikani"("id") +); """ + + prokura_common_texts = """ CREATE TABLE "prokura_common_texts" ( + "id" INTEGER NOT NULL UNIQUE, + "company_id" INTEGER NOT NULL, + "zapis_datum" DATE, + "vymaz_datum" DATE, + "prokura_text" TEXT, + FOREIGN KEY("company_id") REFERENCES "companies"("id"), + PRIMARY KEY("id" AUTOINCREMENT) +); """ + + prokuriste = """ CREATE TABLE "prokuriste" ( + "id" INTEGER NOT NULL UNIQUE, + "company_id" INTEGER NOT NULL, + "zapis_datum" DATE, + "vymaz_datum" DATE, + "prokurista_fo_id" INTEGER, + "adresa_id" INTEGER, + "text_prokurista" TEXT, + FOREIGN KEY("adresa_id") REFERENCES "adresy"("id"), + FOREIGN KEY("prokurista_fo_id") REFERENCES "fyzicke_osoby"("id"), + FOREIGN KEY("company_id") REFERENCES "companies"("id"), + PRIMARY KEY("id" AUTOINCREMENT) +); """ + + sidlo_relation = """ CREATE TABLE "sidlo_relation" ( + "id" INTEGER NOT NULL UNIQUE, + "company_id" INTEGER NOT NULL, + "sidlo_id" INTEGER NOT NULL, + "zapis_datum" DATE, + "vymaz_datum" DATE, + FOREIGN KEY("company_id") REFERENCES "companies"("id"), + FOREIGN KEY("sidlo_id") REFERENCES "adresy_v2"("id"), + PRIMARY KEY("id" AUTOINCREMENT) +); """ + + spolecnici = """ CREATE TABLE "spolecnici" ( + "id" INTEGER NOT NULL UNIQUE, + "company_id" INTEGER NOT NULL, + "spolecnik_fo_id" INTEGER, + "spolecnik_po_id" INTEGER, + "zapis_datum" DATE, + "vymaz_datum" DATE, + "adresa_id" INTEGER, + "text_spolecnik" TEXT, + FOREIGN KEY("adresa_id") REFERENCES "adresy"("id"), + PRIMARY KEY("id" AUTOINCREMENT), + FOREIGN KEY("spolecnik_fo_id") REFERENCES "fyzicke_osoby"("id"), + FOREIGN KEY("company_id") REFERENCES "companies"("id") +); """ + + statutarni_organ_clen_relation = """ CREATE TABLE "statutarni_organ_clen_relation" ( + "id" INTEGER NOT NULL UNIQUE, + "statutarni_organ_id" INTEGER NOT NULL, + "osoba_id" INTEGER, + "adresa_id" INTEGER, + "zapis_datum" DATE, + "vymaz_datum" DATE, + "funkce_od" DATE, + "funkce_do" DATE, + "clenstvi_od" DATE, + "clenstvi_do" DATE, + "funkce" TEXT, + FOREIGN KEY("osoba_id") REFERENCES "fyzicke_osoby"("id"), + FOREIGN KEY("statutarni_organ_id") REFERENCES "statutarni_organ_relation"("id"), + FOREIGN KEY("adresa_id") REFERENCES "adresy"("id"), + PRIMARY KEY("id" AUTOINCREMENT) +); """ + + statutarni_organ_relation = """ CREATE TABLE "statutarni_organ_relation" ( + "id" INTEGER NOT NULL UNIQUE, + "company_id" INTEGER NOT NULL, + "statutarni_organ_id" INTEGER NOT NULL, + "zapis_datum" DATE, + "vymaz_datum" DATE, + FOREIGN KEY("statutarni_organ_id") REFERENCES "statutarni_organy"("id"), + FOREIGN KEY("company_id") REFERENCES "companies"("id"), + PRIMARY KEY("id" AUTOINCREMENT) +); """ + + statutarni_organy = """ CREATE TABLE "statutarni_organy" ( + "id" INTEGER NOT NULL UNIQUE, + "statutarni_organ_text" TEXT NOT NULL UNIQUE, + PRIMARY KEY("id" AUTOINCREMENT) +); """ + + zakladni_kapital = """ CREATE TABLE "zakladni_kapital" ( + "id" INTEGER NOT NULL UNIQUE, + "company_id" INTEGER NOT NULL, + "zapis_datum" DATE NOT NULL, + "vymaz_datum" DATE, + "vklad_typ" TEXT, + "vklad_hodnota" TEXT, + "splaceni_typ" TEXT, + "splaceni_hodnota" TEXT, + PRIMARY KEY("id" AUTOINCREMENT), + FOREIGN KEY("company_id") REFERENCES "companies"("id") +); """ + + zapis_soudy = """ CREATE TABLE "zapis_soudy" ( + "id" INTEGER NOT NULL UNIQUE, + "company_id" INTEGER NOT NULL, + "zapis_datum" DATE, + "vymaz_datum" DATE, + "oddil" TEXT, + "vlozka" TEXT, + "soud" TEXT, + PRIMARY KEY("id" AUTOINCREMENT), + FOREIGN KEY("company_id") REFERENCES "companies"("id") +); """ + + zpusoby_jednani = """ CREATE TABLE "zpusoby_jednani" ( + "id" INTEGER NOT NULL UNIQUE, + "zpusob_jednani_text" TEXT NOT NULL UNIQUE, + PRIMARY KEY("id" AUTOINCREMENT) +); """ + + zpusoby_jednani_relation = """ CREATE TABLE "zpusoby_jednani_relation" ( + "id" INTEGER NOT NULL UNIQUE, + "statutarni_organ_id" INTEGER NOT NULL, + "zpusob_jednani_id" INTEGER NOT NULL, + "zapis_datum" DATE NOT NULL, + "vymaz_datum" DATE, + PRIMARY KEY("id" AUTOINCREMENT), + FOREIGN KEY("zpusob_jednani_id") REFERENCES "zpusoby_jednani"("id"), + FOREIGN KEY("statutarni_organ_id") REFERENCES "statutarni_organ_relation"("id") +); """ + + list_of_tables = [companies, adresy_v2, akcie, dr_relation, dr_organ_clen_relation, druhy_podilu, fyzicke_osoby, insolvency_events, + jediny_akcionar, konkurz_events, nazvy, ostatni_skutecnosti, pocty_clenu_DR, pocty_clenu_organu, podily, pravni_formy, + pravni_formy_relation, pravnicke_osoby, predmety_cinnosti, predmety_cinnosti_relation, prdmety_podnikani, predmety_podnikani_relation, + prokura_common_texts, prokuriste, sidlo_relation, spolecnici, statutarni_organ_clen_relation, statutarni_organ_relation, statutarni_organy, + zakladni_kapital, zapis_soudy, zpusoby_jednani, zpusoby_jednani_relation] + for elem in list_of_tables: + try: + c = conn.cursor() + c.execute(elem) + except Exception as e: + print(e) + +def create_indices(conn): + companies1 = """ CREATE INDEX "index companies1" ON "companies" ( + "id" +); """ + + companies2 = """ CREATE INDEX "index companies2" ON "companies" ( + "ico" +); """ + + companies3 = """ CREATE INDEX "index companies3" ON "companies" ( + "nazev" +); """ + + companies4 = """ CREATE INDEX "index companies4" ON "companies" ( + "oddil" +); """ + + companies5 = """ CREATE INDEX "index companies5" ON "companies" ( + "vlozka" +); """ + + adresy1 = """ CREATE INDEX "index adresy1" ON "adresy_v2" ( + "id" +); """ + + adresy2 = """ CREATE INDEX "index adresy2" ON "adresy_v2" ( + "obec" +); """ + + adresy3 = """ CREATE INDEX "index adresy3" ON "adresy_v2" ( + "ulice" +); """ + + akcie = """ CREATE INDEX "index akcie1" ON "akcie" ( + "id" +); """ + + akcie2 = """ CREATE INDEX "index akcie2" ON "akcie" ( + "company_id" +); """ + + akcionari1 = """ CREATE INDEX "index akcionari1" ON "jediny_akcionar" ( + "id" +); """ + + akcionari2 = """ CREATE INDEX "index akcionari2" ON "jediny_akcionar" ( + "company_id" +); """ + + dr_clen_relation1 = """ CREATE INDEX "index dr clen relation1" ON "dr_organ_clen_relation" ( + "dozorci_rada_id" +); """ + + dr_clen_relation2 = """ CREATE INDEX "index dr clen relation2" ON "dr_organ_clen_relation" ( + "id" +); """ + + dr_relation = """ CREATE INDEX "index dr relation1" ON "dozorci_rada_relation" ( + "id" +); """ + + dr_relation2 = """ CREATE INDEX "index dr relation2" ON "dozorci_rada_relation" ( + "company_id" +); """ + + insolvency1 = """ CREATE INDEX "index insolvency1" ON "insolvency_events" ( + "id" +); """ + + insolvency2 = """ CREATE INDEX "index insolvency2" ON "insolvency_events" ( + "company_id" +); """ + + konkurz1 = """CREATE INDEX "index konkurz1" ON "konkurz_events" ( + "company_id" +); """ + + konkurz2 = """CREATE INDEX "index konkurz2" ON "konkurz_events" ( + "id" +); """ + + nazvy1 = """ CREATE INDEX "index nazvy1" ON "nazvy" ( + "nazev_text" +); """ + + nazvy2 = """ CREATE INDEX "index nazvy2" ON "nazvy" ( + "company_id" +); """ + + nazvy3 = """ CREATE INDEX "index nazvy3" ON "nazvy" ( + "id" +); """ + + ostatni_skutecnosti = """ CREATE INDEX "index ostatni skutecnosti1" ON "ostatni_skutecnosti" ( + "company_id" +); """ + + ostatni_skutecnosti2 = """ CREATE INDEX "index ostatni skutecnosti2" ON "ostatni_skutecnosti" ( + "id" +); """ + + pocty_clenu_organ1 = """ CREATE INDEX "index pocty clenu org1" ON "pocty_clenu_organu" ( + "organ_id" +); """ + + pocty_clenu_organ2 = """ CREATE INDEX "index pocty clenu org2" ON "pocty_clenu_organu" ( + "id" +); """ + + podily1 = """ CREATE INDEX "index podily1" ON "podily" ( + "id" +); """ + + podily2 = """ CREATE INDEX "index podily2" ON "podily" ( + "spolecnik_id" +); """ + + pravni_formy = """ CREATE INDEX "index pravni_formy" ON "pravni_formy" ( + "pravni_forma" +); """ + + pravni_formy_relation1 = """ CREATE INDEX "index pravni_formy_relation1" ON "pravni_formy_relation" ( + "company_id" +); """ + + pravni_formy_relation2 = """ CREATE INDEX "index pravni_formy_relation2" ON "pravni_formy_relation" ( + "id" +); """ + + predmety_cinnosti_relation1 = """ CREATE INDEX "index predmety cinnosti relation1" ON "predmety_cinnosti_relation" ( + "company_id" +); """ + + predmety_cinnosti_relation2 = """ CREATE INDEX "index predmety cinnosti relation2" ON "predmety_cinnosti_relation" ( + "id" +); """ + + predmety_cinnosti_relation3 = """ CREATE INDEX "index predmety cinnosti relation3" ON "predmety_cinnosti_relation" ( + "predmet_cinnosti_id" +); """ + + predmety_podnikani_relation1 = """ CREATE INDEX "index predmety podnikani relation1" ON "predmety_podnikani_relation" ( + "company_id" +); """ + + predmety_podnikani_relation2 = """ CREATE INDEX "index predmety podnikani relation2" ON "predmety_podnikani_relation" ( + "id" +); """ + + predmety_podnikani_relation3 = """ CREATE INDEX "index predmety podnikani relation3" ON "predmety_podnikani_relation" ( + "prdemet_podnikani_id" +); """ + + predmety_cinnosti1 = """ CREATE INDEX "index predmety_cinnosti1" ON "predmety_cinnosti" ( + "predmet_cinnosti" +); """ + + predmety_cinnosti2 = """ CREATE INDEX "index predmety_cinnosti2" ON "predmety_cinnosti" ( + "id" +); """ + + predmety_podnikani1 = """ CREATE INDEX "index predmety_podnikani1" ON "predmety_podnikani" ( + "predmet_podnikani" +); """ + + predmety_podnikani2 = """ CREATE INDEX "index predmety_podnikani2" ON "predmety_podnikani" ( + "id" +); """ + + prokuriste1 = """ CREATE INDEX "index prokuriste1" ON "prokuriste" ( + "id" +); """ + + prokuriste2 = """ CREATE INDEX "index prokuriste2" ON "prokuriste" ( + "company_id" +); """ + + prokuriste3 = """ CREATE INDEX "index prokuriste3" ON "prokuriste" ( + "prokurista_fo_id" +); """ + + prokuriste4 = """ CREATE INDEX "index prokuriste4" ON "prokuriste" ( + "adresa_id" +); """ + + sidlo_relation1 = """ CREATE INDEX "index sidlo relation1" ON "sidlo_relation" ( + "id" +); """ + + sidlo_relation_2 = """ CREATE INDEX "index sidlo relation2" ON "sidlo_relation" ( + "company_id" +); """ + + sidlo_relation_3 = """ CREATE INDEX "index sidlo relation3" ON "sidlo_relation" ( + "sidlo_id" +); """ + + soudni_zapis1 = """ CREATE INDEX "index soudni_zapis1" ON "zapis_soudy" ( + "company_id" +); """ + + soudni_zapis2 = """ CREATE INDEX "index soudni_zapis2" ON "zapis_soudy" ( + "id" +); """ + + spolecnici1 = """ CREATE INDEX "index spolecnici1" ON "spolecnici" ( + "id" +); """ + + spolecnici2 = """ CREATE INDEX "index spolecnici2" ON "spolecnici" ( + "company_id" +); """ + + spolecnici3 = """ CREATE INDEX "index spolecnici3" ON "spolecnici" ( + "spolecnik_fo_id" +); """ + + spolecnici4 = """ CREATE INDEX "index spolecnici4" ON "spolecnici" ( + "spolecnik_po_id" +); """ + + spolecnici5 = """ CREATE INDEX "index spolecnici5" ON "spolecnici" ( + "adresa_id" +); """ + + statutarni_organy = """ CREATE INDEX "index statutarn_organy" ON "statutarni_organy" ( + "id", + "statutarni_organ_text" +); """ + + statutarni_organy_relation1 = """ CREATE INDEX "index statutarni organ relation1" ON "statutarni_organ_relation" ( + "id" +); """ + + statutarni_organy_relation2 = """ CREATE INDEX "index statutarni organ relation2" ON "statutarni_organ_clen_relation" ( + "statutarni_organ_id" +); """ + + statutarni_organy_relation_3 = """ CREATE INDEX "index statutarni organ relation 3" ON "statutarni_organ_relation" ( + "company_id" +); """ + + zakladni_kapital1 = """ CREATE INDEX "index zakladni kapital1" ON "zakladni_kapital" ( + "company_id" +); """ + + zakladni_kapital2 = """ CREATE INDEX "index zakladni kapital2" ON "zakladni_kapital" ( + "id" +); """ + + zpusob_jednani = """ CREATE INDEX "index zpusob_jednani" ON "zpusoby_jednani" ( + "id" +); """ + + zpusob_jednani_relation1 = """ CREATE INDEX "index zpusob_jednani_relation" ON "zpusoby_jednani_relation" ( + "id" +); """ + + zpusob_jednani_relation2 = """ CREATE INDEX "index zpusob jednani relation2" ON "zpusoby_jednani_relation" ( + "statutarni_organ_id" +); """ + + zpusob_jednani_relation3 = """ CREATE INDEX "index zpusob jednani relation3" ON "zpusoby_jednani_relation" ( + "zpusob_jednani_id" +); """ + + pravnicke_osoby1 = """ CREATE INDEX "pravnicke_osoby1" ON "pravnicke_osoby" ( + "ico" +); """ + + pravnicke_osoby2 = """ CREATE INDEX "pravnicke_osoby2" ON "pravnicke_osoby" ( + "id" +); """ + + pravnicke_osoby3 = """ CREATE INDEX "pravnicke_osoby3" ON "pravnicke_osoby" ( + "reg_cislo" +); """ + + pravnicke_osoby4 = """ CREATE INDEX "pravnicke_osoby4" ON "pravnicke_osoby" ( + "nazev" +); """ + + fyzicke_osoby1 = """ CREATE INDEX "fyzicke_osoby1" ON "fyzicke_osoby" ( + "id" +); """ + + list_of_indices = [companies1, companies2, companies3, companies4, companies5, adresy1, adresy2, adresy3, + akcie, akcie2, akcionari1, akcionari2, dr_clen_relation1, dr_clen_relation2, dr_relation, dr_relation2, + insolvency1, insolvency2, konkurz1, konkurz2, nazvy1, nazvy2, nazvy3, ostatni_skutecnosti, ostatni_skutecnosti2, + pocty_clenu_organ1, pocty_clenu_organ2, podily1, podily2, pravni_formy, pravni_formy_relation1, pravni_formy_relation2, + predmety_cinnosti_relation1, predmety_cinnosti_relation2, predmety_cinnosti_relation3, predmety_podnikani_relation1, predmety_podnikani_relation2, + predmety_podnikani_relation3, predmety_cinnosti1, predmety_cinnosti2, predmety_podnikani1, predmety_podnikani2, prokuriste1, + prokuriste2, prokuriste3, prokuriste4, sidlo_relation1, sidlo_relation_2, sidlo_relation_3, soudni_zapis1, soudni_zapis2, spolecnici1, + spolecnici2, spolecnici3, spolecnici4, spolecnici5, statutarni_organy, statutarni_organy_relation1, statutarni_organy_relation2, + statutarni_organy_relation_3, zakladni_kapital1, zakladni_kapital2, zpusob_jednani, zpusob_jednani_relation1, zpusob_jednani_relation2, + zpusob_jednani_relation3, pravnicke_osoby1, pravnicke_osoby2, pravnicke_osoby3, pravnicke_osoby4, fyzicke_osoby1] + i = 0 + for elem in list_of_indices: + i += 1 + try: + c = conn.cursor() + c.execute(elem) + except Exception as e: + print(i) + print(e)
\ No newline at end of file diff --git a/download_files.py b/download_files.py new file mode 100644 index 0000000..16b9be3 --- /dev/null +++ b/download_files.py @@ -0,0 +1,74 @@ +from datetime import datetime +import os +import requests +import gzip +import shutil +import send2trash +from lxml import etree + +def download_data(typy_po, soudy): + rok = str(datetime.now().year) + for osoba in typy_po: + for soud in soudy: + update_data(osoba + "-full-" + soud + "-" + rok + ".xml.gz") + +def update_data(filename): + source = "https://dataor.justice.cz/api/file/" + filename + # temp_file = "D:\\Programovani\\Moje vymysly\\Justice\\data\\temp-" + filename + temp_file = os.path.join(str(os.getcwd()), "data", "temp-" + filename) + # temp_file = str(os.getcwd()) + "\\data\\temp-" + filename + downloaded_OR = downloadOR(source) + if downloaded_OR != None: + save_temp_file(downloaded_OR, temp_file) + unzip_file(filename[:-3], temp_file) + delete_archive(temp_file) + parse_check = parseOR(temp_file[:-3]) + if parse_check == True: + update_main_file(filename[:-3], temp_file[:-3]) + # delete_archive(temp_file[:-3]) + else: + delete_archive(temp_file[:-3]) + +def downloadOR(source): + download = requests.get(source, stream = True) + try: + print("Downloading file ", source) + download.raise_for_status() + except Exception as exc: + print("There was a problem: %s" % (exc)) + return None + return download + +def parseOR(download): + print("Parsing the file!") + try: + for event, element in etree.iterparse(download): + element.clear() + print("Parsing succsessful!") + except: + print("Parsing failed!") + return False + return True + +def save_temp_file(download, temp_file): + temp_file = open(temp_file, "wb") + for chunk in download.iter_content(1000000): + temp_file.write(chunk) + temp_file.close() + +def update_main_file(filename, temp_file): + shutil.move(temp_file, os.path.join(str(os.getcwd()), "data", filename)) + +def delete_temp_file(temp_file): + temp_file = open(temp_file, "w") + temp_file.write("0") + temp_file.close() + +def unzip_file(filename, temp_file): + with gzip.open(temp_file, 'rb') as f_in: + with open(os.path.join(str(os.getcwd()), "data", "temp-" + filename), "wb") as f_out: + # with open(str(os.getcwd()) + "\\data\\temp-" + filename, 'wb') as f_out: + shutil.copyfileobj(f_in, f_out) + +def delete_archive(file): + send2trash.send2trash(file)
\ No newline at end of file @@ -20,18 +20,31 @@ class JusticeSearchForm(Form): ("text_beginning","Začátek výrazu"), ("text_exact","Přesný výraz"), ] + actual_options = [("actual_results","Jen platné"), + ("complete_results","Platné i neplatné"),] nazev_subjektu = StringField(u'Název subjektu:') nazev_subjektu_selection = SelectField('', choices=search_options) + nazev_search_actual = SelectField('', choices=actual_options) + ico_search = StringField(u'Identifikační číslo:') ico_search_selection = SelectField('', choices=search_options) + obec_search = StringField(u'Obec:') - obec_search_selection = SelectField('', choices=search_options) + obec_search_selection = SelectField('', choices=search_options) + obec_search_actual = SelectField('', choices=actual_options) + ulice_search = StringField(u'Ulice:') - ulice_search_selection = SelectField('', choices=search_options) + ulice_search_selection = SelectField('', choices=search_options) + ulice_search_actual = SelectField('', choices=actual_options) + oddil_search = StringField(u'Oddíl:') oddil_search_selection = SelectField('', choices=search_options) + oddil_search_actual = SelectField('', choices=actual_options) + vlozka_search = StringField(u'Vložka:') - vlozka_search_selection = SelectField('', choices=search_options) + vlozka_search_selection = SelectField('', choices=search_options) + vlozka_search_actual = SelectField('', choices=actual_options) + formy = [ ("",""), ('Akciová společnost', 'Akciová společnost'), ('Společnost s ručením omezeným', 'Společnost s ručením omezeným'), @@ -57,6 +70,8 @@ class JusticeSearchForm(Form): ('Evropská družstevní společnost', 'Evropská družstevní společnost'), ] pravni_forma_search = SelectField(u'Právní forma:', choices=formy) + pravni_forma_actual = SelectField('', choices=actual_options) + soudy = [("",""), ("MSPH","Městský soud v Praze"), ("KSCB","Krajský soud v Českých Budějovicích"), @@ -66,14 +81,13 @@ class JusticeSearchForm(Form): ("KSBR","Krajský soud v Brně"), ("KSOS","Krajský soud v Ostravě"), ] - soud_search = SelectField(u'Rejstříkjový soud:', choices=soudy) + soud_search = SelectField(u'Rejstříkjový soud:', choices=soudy) + soud_search_actual = SelectField('', choices=actual_options) + insolvent_only_search = BooleanField("Pouze společnosti s insolvenčním zápisem") zapis_do = DateField(u'Zapsáno do:', format='%Y-%m-%d') zapis_od = DateField(u'Zapsáno od:', format='%Y-%m-%d') - - - class CompanyForm(Form): oddil = [('A', 'A'), ('B', 'B'), @@ -86,5 +100,6 @@ class CompanyForm(Form): oddil = SelectField('oddil', choices=oddil) vlozka = StringField('vlozka') soud = StringField('soud') - + +
\ No newline at end of file diff --git a/justice_main.py b/justice_main.py index f7eb673..348ee59 100644 --- a/justice_main.py +++ b/justice_main.py @@ -1,532 +1,14 @@ -import requests
-import shutil
-from lxml import etree
-import sqlite3
-import gzip
-import send2trash
-import os
-from datetime import datetime
+from db_creation import create_DB
+from download_files import download_data
+from update_db import update_DB
-# The function opens a file and parses the extracted data into the database
-def parse_to_DB(file):
- print("Processing ", str(file))
- conn = sqlite3.connect('justice.db')
- c = conn.cursor()
- for event, element in etree.iterparse(file, tag="Subjekt"):
- # Bugfix for companies which have been deleted but appear in the list of existing companies
- if ([element.find('vymazDatum')][0]) != None:
- continue
- else:
- ICO = get_ICO(element)
- # Vlozit prazdny radek s ICO
- insert_new_ICO(c, ICO, conn)
- primary_sql_key = get_primary_sql_key(c, ICO)
- # Vlozit jednolive parametry
- insert_primary_company_figures(c, ICO, element, conn)
- insert_company_relations(c, ICO, element, conn, primary_sql_key)
- # insert_obec_relation(c, conn, ICO, element, primary_sql_key)
- find_other_properties(c, ICO, element, conn, primary_sql_key)
- element.clear()
-
- # subjekt_udaje.clear()
-
- # purge_DB(c)
- conn.commit()
- conn.close()
- return 0
-
-def purge_DB(c):
- c.execute("DELETE FROM companies")
- c.execute("DELETE FROM obce")
- c.execute("DELETE FROM ulice")
- c.execute("DELETE FROM ulice_relation")
- c.execute("DELETE FROM osoby")
- c.execute("DELETE FROM obce_relation")
- c.execute("DELETE FROM sqlite_sequence")
- c.execute("DELETE FROM pravni_formy")
- c.execute("DELETE FROM pravni_formy_relation")
-
-def find_other_properties(c, ICO, element, conn, primary_sql_key):
- try:
- my_iter = element.iter("udaje")
- for elem in my_iter:
- my_iter2 = elem.iter("Udaj")
- for elem2 in my_iter2:
- # print(ICO, str(get_prop(elem2, ".//udajTyp/kod")))
- if str(get_prop(elem2, ".//udajTyp/kod")) == "INSOLVENCE_SEKCE":
- # print("INSOLVENCY:", ICO)
- find_active_insolvency(c, ICO, elem2, conn, primary_sql_key)
- elif str(get_prop(elem2, ".//udajTyp/kod")) == "KONKURS_SEKCE":
- find_active_insolvency(c, ICO, elem2, conn, primary_sql_key)
- except:
- pass
-
-def find_active_insolvency(c, ICO, insolvency_elem, conn, primary_sql_key):
- try:
- my_iter = insolvency_elem.findall("podudaje")
- for elem in my_iter:
- my_iter2 = elem.iter("Udaj")
- for elem2 in my_iter2:
- if (str(get_prop(elem2, ".//vymazDatum"))) == "0":
- insolvency_text = str(get_prop(elem2, ".//text"))
- if insolvency_text != "0":
- insert_insolvency_text(c, conn, insolvency_text, primary_sql_key)
- # print(insolvency_text)
- # print(ICO, str(get_prop(elem2, ".//zapisDatum")), str(get_prop(elem2, ".//text")))
- # my_iter3 = elem2.iterfind()
- # for elem3 in my_iter3:
- # print(str(get_prop(elem2, ".//hlavicka")))
- # print(str(get_prop(elem2, ".//zapisDatum")))
- # print(str(get_prop(elem2, ".//vymazDatum")))
- except:
- pass
-
-def insert_insolvency_text(c, conn, insolvency_text, primary_sql_key):
- try:
- c.execute("INSERT INTO insolvency_events (company_id, insolvency_event) VALUES(?, ?)", (primary_sql_key, insolvency_text,))
- except:
- pass
-
-
-
-def get_primary_sql_key(c, ICO):
- try:
- primary_key = c.execute("SELECT id FROM companies WHERE ico = (?)", (ICO,))
- primary_key = c.fetchone()
- return primary_key[0]
- except:
- return 0
-
- return
-
-def insert_primary_company_figures(c, ICO, element, conn):
- insert_instructions = [("nazev","nazev"), ("zapisDatum","zapis"), (".//udaje/Udaj/spisZn/oddil","oddil"),
- (".//udaje/Udaj/spisZn/vlozka","vlozka"),(".//udaje/Udaj/spisZn/soud/kod","soud"),(str(adresa(get_SIDLO_v2(element))),"sidlo")]
- for elem in insert_instructions[:-1]:
- insert_prop(c, get_prop(element, elem[0]), conn, ICO, elem[1])
- # Override to insert the address
- insert_prop(c, insert_instructions[-1][0], conn, ICO, insert_instructions[-1][1])
- return 0
-
-def insert_company_relations(c, ICO, element, conn, primary_sql_key):
- insert_instructions = [(".//udaje/Udaj/adresa/obec","obce", "obec_jmeno", "obce_relation"), (".//udaje/Udaj/adresa/ulice","ulice", "ulice_jmeno", "ulice_relation"),
- (".//udaje/Udaj/pravniForma/nazev","pravni_formy", "pravni_forma", "pravni_formy_relation")]
- for elem in insert_instructions:
- insert_individual_relations(c, ICO, element, conn, primary_sql_key, elem)
- return 0
-
-def insert_individual_relations(c, ICO, element, conn, primary_sql_key, elem):
- inserted_figure = str(get_prop(element, elem[0]))
- insert_into_ancillary_table(c, elem, inserted_figure)
- ancillary_table_key = get_anciallary_table_key(c, elem, inserted_figure)
- insert_relation_information(c, elem, primary_sql_key, ancillary_table_key)
- return 0
-
-def insert_into_ancillary_table(c, elem, inserted_figure):
- try:
- c.execute("INSERT INTO " + elem[1] + "(" + elem[2] + ") VALUES(?)", (inserted_figure,))
- except:
- pass
-
-def get_anciallary_table_key(c, elem, inserted_figure):
- try:
- anciallary_table_key = c.execute("SELECT id FROM " + elem[1] + " WHERE " + elem[2] + " = (?)", (inserted_figure,))
- anciallary_table_key = c.fetchone()[0]
- return anciallary_table_key
- except:
- print("Nepovedlo se")
- return 0
-
-def insert_relation_information(c, elem, primary_sql_key, ancillary_table_key):
- try:
- c.execute("INSERT INTO " + elem[3] + " VALUES(?, ?)", (primary_sql_key, ancillary_table_key,))
- except:
- pass
- return 0
-
-def insert_obec_relation(c, conn, ICO, element, primary_sql_key):
- obec = str(get_prop(element, ".//udaje/Udaj/adresa/obec"))
- # Insert a municipality into a table with municipalites
- try:
- c.execute("INSERT INTO obce (obec_jmeno) VALUES(?)", (obec,))
- except:
- pass
- # Get municipality sql_id
- try:
- municipality_key = c.execute("SELECT id FROM obce WHERE obec_jmeno = (?)", (obec,))
- municipality_key = c.fetchone()[0]
- except:
- print("Nepovedlo se")
- # Establish a relational link
- try:
- c.execute("INSERT INTO obec_relation VALUES(?, ?)", (primary_sql_key, municipality_key,))
- except:
- pass
-
- return
-
-def zkusit_najit_vsechny_osoby(element):
- stat_list = element.iter('osoba')
- temp_osoby = []
- for elem in stat_list:
- try:
- osoba_temp = ""
- osoba_temp += get_prop(element, ".//jmeno") + " "
- osoba_temp += get_prop(element, ".//prijmeni") + ", nar. "
- osoba_temp += get_prop(element, ".//narozDatum")
- temp_osoby.append(osoba_temp)
- except:
- pass
- return temp_osoby
-
-
-def zkusit_najit_vsechny_adresy(element):
- stat_list = element.iter('adresa')
- temp_adresy = []
- for elem in stat_list:
- temp_adresy.append(str(adresa(get_SIDLO_v3(elem))))
- return temp_adresy
-
-def find_business(element):
- subjekt_udaje = element.findall('.//Udaj')
- for udaj in subjekt_udaje:
- udaje_spolecnosti = udaj.findall(".//kod")
- if "PREDMET_PODNIKANI_SEKCE" in udaje_spolecnosti[0].text:
- predmety2 = [elem.text.replace(u'\xa0', u' ') for elem in udaj.iterfind(".//hodnotaText")]
- return predmety2
- # TODO - Filter areas that are no longer relevant
-
-def insert_obec(c, obec, conn, ICO, sql_id):
- try:
- c.execute("INSERT INTO obce (obec_jmeno) VALUES(?)", (obec,))
- except:
- pass
-
-def insert_adresa(c, adresa, conn, ICO, sql_id):
- try:
- c.execute("INSERT INTO adresy (adresa_jmeno) VALUES(?)", (adresa,))
- except:
- pass
-
-def insert_osoba(c, osoba, conn, ICO, sql_id):
- try:
- c.execute("INSERT INTO osoby (osoba_jmeno) VALUES(?)", (osoba,))
- except:
- pass
-
-
-def insert_ulice(c, ulice, conn, ICO, sql_id):
- try:
- c.execute("INSERT INTO ulice (ulice_jmeno) VALUES(?)", (ulice,))
- except:
- pass
-
-def insert_prop_v2(c, prop, conn, ICO, column, table, sql_id):
- # print(column, prop, ICO)
- # c.execute("UPDATE companies SET (" + column + ") = (?) WHERE ico = (?)", (prop, ICO,))
- if prop != None:
- for elem in prop:
- # print(sql_id)
- c.execute("INSERT INTO predmety_podnikani (company_id, predmet_podnikani) VALUES(?,?)", (sql_id, elem,))
- # c.execute("UPDATE (%s) SET (%s, %s) = (?)" % (table, sql_id, elem), (prop, ICO,))
-
-
-# Function to attempt to insert a placeholder for a new company based on ICO
-def insert_new_ICO(c, ICO, conn):
-
- try:
- c.execute("INSERT INTO companies (ico) VALUES (?);", (ICO,))
- return c.lastrowid
-
- # c.execute("INSERT INTO companies VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", (ICO, "", "", "", "", "", "", "", "", "", ""))
-
- # # conn.commit()
- except:
- pass
-
-def get_ICO(element):
- try:
- return element.find('ico').text
- # return [element.find('ico')][0].text
- except:
- return "00000000"
-
-def get_prop(element, prop):
- try:
- return element.find(prop).text
- except:
- return "0"
-
- # return [element.find(prop)][0].text
-
-def insert_prop(c, prop, conn, ICO, column):
- # print(column, prop, ICO)
- # c.execute("UPDATE companies SET (" + column + ") = (?) WHERE ico = (?)", (prop, ICO,))
- try:
- c.execute("UPDATE companies SET (%s) = (?) WHERE ico = (?)" % (column), (prop, ICO,))
- except Exception as e:
- print(e)
-
-# def insert_prop(c, prop, conn, ICO, column):
-# # print(column, prop, ICO)
-# # c.execute("UPDATE companies SET (" + column + ") = (?) WHERE ico = (?)", (prop, ICO,))
-# try:
-# c.execute("UPDATE companies SET (%s) = (?) WHERE ico = (?)" % (column), (prop, ICO,))
-# except:
-# pass
-
-def get_SIDLO_v2(element):
- address_field = []
- address_field.append(get_prop(element, ".//udaje/Udaj/adresa/statNazev"))
- address_field.append(get_prop(element, ".//udaje/Udaj/adresa/obec"))
- address_field.append(get_prop(element, ".//udaje/Udaj/adresa/ulice"))
- address_field.append(get_prop(element, ".//udaje/Udaj/adresa/castObce"))
- address_field.append(get_prop(element, ".//udaje/Udaj/adresa/cisloPo"))
- address_field.append(get_prop(element, ".//udaje/Udaj/adresa/cisloOr"))
- address_field.append(get_prop(element, ".//udaje/Udaj/adresa/psc"))
- address_field.append(get_prop(element, ".//udaje/Udaj/adresa/okres"))
- address_field.append(get_prop(element, ".//udaje/Udaj/adresa/adresaText"))
- address_field.append(get_prop(element, ".//udaje/Udaj/adresa/cisloEv"))
- address_field.append(get_prop(element, ".//udaje/Udaj/adresa/cisloText"))
- if address_field[0] == "Česká republika - neztotožněno":
- address_field[0] = "Česká republika"
- for i in range(len(address_field)):
- if address_field[i] == "0":
- address_field[i] = None
- return address_field
-
-def get_SIDLO_v3(element):
- address_field = []
- address_field.append(get_prop(element, ".//statNazev"))
- address_field.append(get_prop(element, ".//obec"))
- address_field.append(get_prop(element, ".//ulice"))
- address_field.append(get_prop(element, ".//castObce"))
- address_field.append(get_prop(element, ".//cisloPo"))
- address_field.append(get_prop(element, ".//cisloOr"))
- address_field.append(get_prop(element, ".//psc"))
- address_field.append(get_prop(element, ".//okres"))
- address_field.append(get_prop(element, ".//adresaText"))
- address_field.append(get_prop(element, ".//cisloEv"))
- address_field.append(get_prop(element, ".//cisloText"))
- if address_field[0] == "Česká republika - neztotožněno":
- address_field[0] = "Česká republika"
- for i in range(len(address_field)):
- if address_field[i] == "0":
- address_field[i] = None
- return address_field
-
-
-class adresa(object):
- def __init__(self, adresa):
- self.stat = adresa[0]
- self.obec = adresa[1]
- self.ulice = adresa[2]
- self.castObce = adresa[3]
- self.cisloPo = adresa[4]
- self.cisloOr = adresa[5]
- self.psc = adresa[6]
- self.okres = adresa[7]
- self.komplet_adresa = adresa[8]
- self.cisloEv = adresa[9]
- self.cisloText = adresa[10]
-
- def __str__ (self):
- try:
- # if self.obec == "-":
- # return("Neznama adresa")
- if self.komplet_adresa != None:
- if self.stat != None:
- return str(self.komplet_adresa + " " + self.stat)
- else:
- return str(self.komplet_adresa)
- # if self.obec == None:
- # return("Neznama adresa")
- if self.cisloText != None:
- if self.ulice == None:
- if self.psc != None:
- return str(self.cisloText + srovnat_obec_cast(self.obec, self.castObce) + ", " + self.psc + " " + self.obec + ", " + self.stat)
- else:
- return str(self.cisloText + srovnat_obec_cast(self.obec, self.castObce) + ", " + self.obec + ", " + self.stat)
- if self.okres == None and self.castObce != None:
- if self.psc != None:
- return str(self.obec + " - " + self.castObce + ", " + self.ulice + " " + self.cisloText + ", PSČ " + self.psc)
- else:
- return str(self.obec + " - " + self.castObce + ", " + self.ulice + " " + self.cisloText)
- if self.okres == None and self.castObce == None and self.psc != None:
- return str(self.obec + ", " + self.ulice + " " + self.cisloText + ", PSČ " + self.psc)
- if self.castObce == None and self.psc == None:
- return str(self.obec + ", " + self.ulice + " " + self.cisloText)
- else:
- if self.psc != None:
- return str(self.obec + " " + self.cisloText + " " + "okres " + self.okres + ", PSČ " + self.psc)
- else:
- return str(self.obec + " " + self.cisloText + " " + "okres " + self.okres)
- if self.ulice != None :
- if self.cisloOr != None:
- if self.cisloPo == None:
- return str(self.ulice + " " + self.cisloOr + srovnat_obec_cast(self.obec, self.castObce) + ", " + self.psc + " " + self.obec + ", " + self.stat)
- elif self.psc != None:
- return str(self.ulice + " " + self.cisloPo + "/" + self.cisloOr + srovnat_obec_cast(self.obec, self.castObce) + ", " + self.psc + " " + self.obec + ", " + self.stat)
- else:
- return str(self.ulice + " " + self.cisloPo + "/" + self.cisloOr + srovnat_obec_cast(self.obec, self.castObce) + ", " + self.obec + ", " + self.stat)
- if self.cisloPo == None:
- if self.cisloEv == None:
- if self.psc != None:
- return str(self.obec + ", " + self.ulice + "" + srovnat_obec_cast(self.obec, self.castObce) + ", PSČ" + self.psc + " " + self.stat)
- else:
- return str(self.obec + ", " + self.ulice + "" + srovnat_obec_cast(self.obec, self.castObce) + ", " + self.stat)
- else:
- return str(self.ulice + " č.ev. " + self.cisloEv + srovnat_obec_cast(self.obec, self.castObce) + ", " + self.psc + " " + self.obec + ", " + self.stat)
- else:
- if self.psc != None:
- return str(self.ulice + " " + self.cisloPo + "" + srovnat_obec_cast(self.obec, self.castObce) + ", " + self.psc + " " + self.obec + ", " + self.stat)
- else:
- return str(self.ulice + " " + self.cisloPo + "" + srovnat_obec_cast(self.obec, self.castObce) + ", " + self.obec + ", " + self.stat)
-
- if self.cisloPo == None and self.cisloEv != None:
- return str(self.obec + " č.ev. " + self.cisloEv + ", " + self.psc + srovnat_obec_cast(self.obec, self.castObce) + ", " + self.obec + ", " + self.stat)
-
- if self.cisloPo != None:
- return str("č.p. " + self.cisloPo + ", " + self.psc + srovnat_obec_cast(self.obec, self.castObce) + ", " + self.obec + ", " + self.stat)
-
- if self.cisloPo == None and self.cisloEv == None and self.ulice == None:
- return (self.obec + " " + self.stat)
-
- except TypeError:
- temp_adr = []
- if self.ulice != None:
- temp_adr.append(self.ulice)
-
- if self.obec != None:
- temp_adr.append(self.obec)
-
- if self.castObce != None:
- temp_adr.append(self.castObce)
-
- if self.cisloPo != None:
- temp_adr.append(self.cisloPo)
-
- if self.cisloOr != None:
- temp_adr.append(self.cisloOr)
-
- if self.psc != None:
- temp_adr.append(self.psc)
-
- if self.okres != None:
- temp_adr.append(self.okres)
-
- if self.cisloEv != None:
- temp_adr.append(self.cisloEv)
-
- if self.cisloText != None:
- temp_adr.append(self.cisloText)
-
- if self.stat != None:
- temp_adr.append(self.stat)
-
- listToStr = ' '.join([str(elem) for elem in temp_adr])
-
- return listToStr
-
-def srovnat_obec_cast(obec, cast_obce):
- if obec == cast_obce:
- return str("")
- elif cast_obce == None:
- return str("")
- else:
- return str(", " + cast_obce)
-
-def general_update(method):
- typy_po = ["as", "sro", "vos", "ks", "dr", "zajzdrpo", "zahrfos", "ustav", "svj", "spolek", "prisp", "pobspolek",
- "oszpo", "osznadf", "osznad", "orgzam", "odbororg", "nadf", "nad", "evrspol", "evrhzs", "evrdrspol"]
+def main():
+ typy_po = ["as", "sro", "vos", "ks", "dr", "zajzdrpo", "zahrfos", "ustav", "svj", "spolek", "prisp", "pobspolek",
+ "oszpo", "osznadf", "osznad", "orgzam", "odbororg", "nadf", "nad", "evrspol", "evrhzs", "evrdrspol"]
soudy = ["praha", "plzen", "brno", "ceske_budejovice", "hradec_kralove", "ostrava", "usti_nad_labem"]
- # typy_po = ["as"]
- # soudy = ["ostrava"]
-
- rok = str(datetime.now().year)
- for osoba in typy_po:
- for soud in soudy:
- if method == "down":
- update_data(osoba + "-actual-" + soud + "-" + rok + ".xml.gz")
- elif method == "db_update":
- try:
- parse_to_DB(os.path.join(str(os.getcwd()), "data", osoba) + "-actual-" + soud + "-" + rok + ".xml")
- except:
- pass
-
-def update_data(filename):
- source = "https://dataor.justice.cz/api/file/" + filename
- # temp_file = "D:\\Programovani\\Moje vymysly\\Justice\\data\\temp-" + filename
- temp_file = os.path.join(str(os.getcwd()), "data", "temp-" + filename)
- # temp_file = str(os.getcwd()) + "\\data\\temp-" + filename
- downloaded_OR = downloadOR(source)
- if downloaded_OR != None:
- save_temp_file(downloaded_OR, temp_file)
- unzip_file(filename[:-3], temp_file)
- delete_archive(temp_file)
- parse_check = parseOR(temp_file[:-3])
- if parse_check == True:
- update_main_file(filename[:-3], temp_file[:-3])
- # delete_archive(temp_file[:-3])
- else:
- delete_archive(temp_file[:-3])
-
-
-def downloadOR(source):
- download = requests.get(source, stream = True)
- try:
- print("Downloading file ", source)
- download.raise_for_status()
- except Exception as exc:
- print("There was a problem: %s" % (exc))
- return None
- return download
-
-def parseOR(download):
- print("Parsing the file!")
- try:
- for event, element in etree.iterparse(download):
- element.clear()
- print("Parsing succsessful!")
- except:
- print("Parsing failed!")
- return False
- return True
-
-def save_temp_file(download, temp_file):
- temp_file = open(temp_file, "wb")
- for chunk in download.iter_content(1000000):
- temp_file.write(chunk)
- temp_file.close()
-
-def update_main_file(filename, temp_file):
- shutil.move(temp_file, os.path.join(str(os.getcwd()), "data", filename))
-
-def delete_temp_file(temp_file):
- temp_file = open(temp_file, "w")
- temp_file.write("0")
- temp_file.close()
-
-def unzip_file(filename, temp_file):
- with gzip.open(temp_file, 'rb') as f_in:
- with open(os.path.join(str(os.getcwd()), "data", "temp-" + filename), "wb") as f_out:
- # with open(str(os.getcwd()) + "\\data\\temp-" + filename, 'wb') as f_out:
- shutil.copyfileobj(f_in, f_out)
-
-def delete_archive(file):
- send2trash.send2trash(file)
-
-
-# parse_to_DB("as-full-praha-2021.xml")
-
-# parse_to_DB("ks-actual-ostrava-2021.xml")
-
-# parse_to_DB("sro-actual-praha-2020.xml")
-
-def do_both():
- general_update("down")
- general_update("db_update")
-
-do_both()
+ DB_name = "justice.db"
+ create_DB(DB_name)
+ download_data(typy_po, soudy)
+ update_DB(typy_po, soudy, DB_name)
-# cProfile.run('do_both()')
+main()
\ No newline at end of file @@ -4,7 +4,11 @@ from db_setup import init_db, db_session from forms import JusticeSearchForm, CompanyForm from flask import flash, render_template, request, redirect # from models import Company, Soud -from models import Company, Obce, Ulice, Pravni_Forma, Insolvency_Events +from models import Company, Insolvency_Events, Konkurz_Events, Predmet_Podnikani, Predmety_Podnikani_Association, Predmet_Cinnosti, Predmety_Cinnosti_Association +from models import Zakladni_Kapital, Akcie, Nazvy, Sidlo, Sidlo_Association, Pravni_Forma_Association_v2, Pravni_Formy, Statutarni_Organ_Association, Statutarni_Organy, Pocty_Clenu_Organu +from models import Zpusob_Jednani_Association, Zpusob_Jednani, Statutarni_Organ_Clen_Association, Fyzicka_Osoba, Spolecnici_Association, Podily_Association, Druhy_Podilu, Pravnicka_Osoba +from models import Prokurista_Association, Jediny_Akcionar_Association, Prokura_Common_Text_Association, Soudni_Zapisy +from models import Adresy_v2 from tables import Results init_db() @@ -21,27 +25,51 @@ def index(): @app.route('/results') def search_results(search): results = [] + ico = search.ico_search.data ico_search_method = search.ico_search_selection.data + nazev = search.nazev_subjektu.data nazev_search_method = search.nazev_subjektu_selection.data + nazev_actual_or_full = search.nazev_search_actual.data + oddil = search.oddil_search.data oddil_search_method = search.oddil_search_selection.data + oddil_actual_or_full = search.oddil_search_actual.data + vlozka = search.vlozka_search.data vlozka_search_method = search.vlozka_search_selection.data + vlozka_actual_or_full = search.vlozka_search_actual.data + obec = search.obec_search.data obec_search_method = search.obec_search_selection.data + obec_actual_or_full = search.obec_search_actual.data + ulice = search.ulice_search.data - ulice_search_method = search.ulice_search_selection.data - pravni_forma = search.pravni_forma_search.data + ulice_search_method = search.ulice_search_selection.data + ulice_actual_or_full = search.ulice_search_actual.data + + pravni_forma = search.pravni_forma_search.data + pravni_forma_actual_or_full = search.pravni_forma_actual.data + soud = search.soud_search.data + soud_actual_or_full = search.soud_search_actual.data + insolvent_only = search.insolvent_only_search.data + zapsano_od = search.zapis_od.data zapsano_do = search.zapis_do.data - if insolvent_only == False: - qry = Company.query.join(Obce, Company.obec).join(Ulice, Company.ulice).join(Pravni_Forma, Company.pravni_forma).join(Insolvency_Events, isouter=True) - else: - qry = Company.query.join(Obce, Company.obec).join(Ulice, Company.ulice).join(Pravni_Forma, Company.pravni_forma).join(Insolvency_Events) + + qry = Company.query + + if insolvent_only: + qry = qry.join(Insolvency_Events, Company.insolvence) + qry = qry.filter(Insolvency_Events.vymaz_datum == 0) + qry_konkurz = Company.query + qry_konkurz = qry_konkurz.join(Konkurz_Events, Company.konkurz) + qry_konkurz = qry_konkurz.filter(Konkurz_Events.vymaz_datum == 0) + qry = qry.union(qry_konkurz) + if ico: if ico_search_method == "text_anywhere": qry = qry.filter(Company.ico.contains(ico)) @@ -49,54 +77,92 @@ def search_results(search): qry = qry.filter(Company.ico.like(f'{ico}%')) elif ico_search_method == "text_exact": qry = qry.filter(Company.ico == ico) + if nazev: + qry = qry.join(Nazvy, Company.obchodni_firma) + if nazev_actual_or_full == "actual_results": + qry = qry.filter(Nazvy.vymaz_datum == 0) if nazev_search_method == "text_anywhere": - qry = qry.filter(Company.nazev.contains(nazev)) + qry = qry.filter(Nazvy.nazev_text.contains(nazev)) elif nazev_search_method == "text_beginning": - qry = qry.filter(Company.nazev.like(f'{nazev}%')) + qry = qry.filter(Nazvy.nazev_text.like(f'{nazev}%')) elif nazev_search_method == "text_exact": - qry = qry.filter(Company.nazev == nazev) + qry = qry.filter(Nazvy.nazev_text == nazev) + if oddil: + qry = qry.join(Soudni_Zapisy, Company.soudni_zapis) + if oddil_actual_or_full == "actual_results": + qry = qry.filter(Soudni_Zapisy.vymaz_datum == 0) if oddil_search_method == "text_anywhere": qry = qry.filter(Company.oddil.contains(oddil)) elif oddil_search_method == "text_beginning": qry = qry.filter(Company.oddil.like(f'{oddil}%')) elif oddil_search_method == "text_exact": - qry = qry.filter(Company.oddil == oddil) - # qry = qry.filter(Company.oddil.contains(oddil)) + qry = qry.filter(Company.oddil == oddil) + if vlozka: + qry = qry.join(Soudni_Zapisy, Company.soudni_zapis) + if vlozka_actual_or_full == "actual_results": + qry = qry.filter(Soudni_Zapisy.vymaz_datum == 0) if vlozka_search_method == "text_anywhere": - qry = qry.filter(Company.vlozka.contains(vlozka)) + qry = qry.filter(Soudni_Zapisy.vlozka.contains(vlozka)) elif vlozka_search_method == "text_beginning": - qry = qry.filter(Company.vlozka.like(f'{vlozka}%')) + qry = qry.filter(Soudni_Zapisy.vlozka.like(f'{vlozka}%')) elif vlozka_search_method == "text_exact": - qry = qry.filter(Company.vlozka == vlozka) - - # qry = qry.filter(Company.vlozka.contains(vlozka)) + qry = qry.filter(Soudni_Zapisy.vlozka == vlozka) + if obec: - if obec_search_method == "text_anywhere": - qry = qry.filter(Obce.obec_jmeno.contains(obec)) - elif obec_search_method == "text_beginning": - qry = qry.filter(Obce.obec_jmeno.like(f'{obec}%')) - elif obec_search_method == "text_exact": - qry = qry.filter(Obce.obec_jmeno == obec) - # qry = qry.filter(Obce.obec_jmeno.contains(obec)) + qry = qry.join(Sidlo_Association, Company.sidlo_text) + if obec_actual_or_full == "actual_results": + qry = qry.filter(Sidlo_Association.vymaz_datum == 0) + qry = qry.join(Adresy_v2, Sidlo_Association.sidlo_text) + qry = qry.filter(Adresy_v2.obec == obec) + if ulice: - if ulice_search_method == "text_anywhere": - qry = qry.filter(Ulice.ulice_jmeno.contains(ulice)) - elif ulice_search_method == "text_beginning": - qry = qry.filter(Ulice.ulice_jmeno.like(f'{ulice}%')) - elif ulice_search_method == "text_exact": - qry = qry.filter(Ulice.ulice_jmeno == ulice) - # qry = qry.filter(Ulice.ulice_jmeno.contains(ulice)) + qry = qry.join(Sidlo_Association, Company.sidlo_text) + if ulice_actual_or_full == "actual_results": + qry = qry.filter(Sidlo_Association.vymaz_datum == 0) + qry = qry.join(Adresy_v2, Sidlo_Association.sidlo_text) + qry = qry.filter(Adresy_v2.ulice == ulice) + + # if obec: + # qry = qry.join(Obce, Company.obec) + # if obec_search_method == "text_anywhere": + # qry = qry.filter(Obce.obec_jmeno.contains(obec)) + # elif obec_search_method == "text_beginning": + # qry = qry.filter(Obce.obec_jmeno.like(f'{obec}%')) + # elif obec_search_method == "text_exact": + # qry = qry.filter(Obce.obec_jmeno == obec) + + # if ulice: + # qry = qry.join(Ulice, Company.ulice) + # if ulice_search_method == "text_anywhere": + # qry = qry.filter(Ulice.ulice_jmeno.contains(ulice)) + # elif ulice_search_method == "text_beginning": + # qry = qry.filter(Ulice.ulice_jmeno.like(f'{ulice}%')) + # elif ulice_search_method == "text_exact": + # qry = qry.filter(Ulice.ulice_jmeno == ulice) + if pravni_forma: - qry = qry.filter(Pravni_Forma.pravni_forma.contains(pravni_forma)) + qry = qry.join(Pravni_Forma_Association_v2, Company.pravni_forma_text) + if pravni_forma_actual_or_full == "actual_results": + qry = qry.filter(Pravni_Forma_Association_v2.vymaz_datum == 0) + qry = qry.join(Pravni_Formy, Pravni_Forma_Association_v2.pravni_forma_text) + qry = qry.filter(Pravni_Formy.pravni_forma == pravni_forma) + if soud: - qry = qry.filter(Company.soud.contains(soud)) + qry = qry.join(Soudni_Zapisy, Company.soudni_zapis) + if soud_actual_or_full == "actual_results": + qry = qry.filter(Soudni_Zapisy.vymaz_datum == 0) + qry = qry.filter(Soudni_Zapisy.soud == soud) + + # qry = qry.filter(Company.soud.contains(soud)) + if zapsano_od: qry = qry.filter(Company.zapis >= zapsano_od) if zapsano_do: qry = qry.filter(Company.zapis <= zapsano_do) + results = qry.all() # else: # qry = db_session.query(Company) @@ -104,11 +170,11 @@ def search_results(search): # else: # qry = db_session.query(Company) # results = qry.all() - + if not results: flash('No results found!') return redirect('/') - + else: table = Results(results) table.border = True @@ -118,7 +184,7 @@ def search_results(search): def search_results_BACKUP(search): results = [] search_string = search.data['search'] - + if search_string: # if search.data['select'] == 'soud': # qry = db_session.query(Company, Soud).filter( @@ -139,16 +205,29 @@ def search_results_BACKUP(search): else: qry = db_session.query(Company) results = qry.all() - + if not results: flash('No results found!') return redirect('/') - + else: table = Results(results) table.border = True return render_template('results.html', table=table) +@app.route("/<int:ico>", methods=['GET', 'POST']) +def extract(ico): + qry = Company.query + qry = qry.filter(Company.ico == ico) + results = qry.all() + return render_template("extract.html", ico = ico, results = results) + +@app.route("/<int:ico>-actual", methods=['GET', 'POST']) +def extract_actual(ico): + qry = Company.query + qry = qry.filter(Company.ico == ico) + results = qry.all() + return render_template("extract-actual.html", ico = ico, results = results) @app.route('/new_company', methods=['GET', 'POST']) def new_company(): @@ -156,7 +235,7 @@ def new_company(): Add a new company """ form = CompanyForm(request.form) - + if request.method == 'POST' and form.validate(): # save the album company = Company() @@ -173,7 +252,7 @@ def save_changes(company, form, new=False): # of the SQLAlchemy table object # soud = Soud() # soud.name = form.soud.data - + # company.soud = soud company.soud = form.soud.data company.ico = form.ico.data @@ -1,93 +1,492 @@ #!/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 -# class Soud(db.Model): -# __tablename__ = "soudy" -# id = db.Column(db.Integer, primary_key=True) -# name = db.Column(db.String) - -# def __repr__(self): -# # return "<soud: {}="">".format(self.name) -# return self.name - -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), - ) -class Company(db.Model): +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_result_value(self, value, dialect): + return convert_date_to_string(value) + + def copy(self, **kw): + return MyType(self.impl.length) + +class MySoud(types.TypeDecorator): + + impl = types.Unicode + + def process_result_value(self, value, dialect): + 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), +# ) + +# 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), +# ) + +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')) + predmet_podnikani_id = db.Column(db.Integer, db.ForeignKey('predmety_podnikani.id'), 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')) + predmet_cinnosti_id = db.Column(db.Integer, db.ForeignKey('predmety_cinnosti.id'), primary_key=True) + zapis_datum = db.Column(MyType) + vymaz_datum = db.Column(MyType) + predmet_cinnosti = db.relationship("Predmet_Cinnosti") + company = db.relationship("Company") + +class Sidlo_Association(db.Model): + __tablename__ = 'sidlo_relation' + id = db.Column(db.Integer, primary_key=True) + company_id = db.Column(db.Integer, db.ForeignKey('companies.id')) + sidlo_id = db.Column(db.Integer, db.ForeignKey('adresy_v2.id')) + zapis_datum = db.Column(MyType) + vymaz_datum = db.Column(MyType) + sidlo_text = db.relationship("Adresy_v2") + company = db.relationship("Company") + +class Pravni_Forma_Association_v2(db.Model): + __tablename__ = 'pravni_formy_relation' + id = db.Column(db.Integer, primary_key=True) + company_id = db.Column(db.Integer, db.ForeignKey('companies.id')) + pravni_forma_id = db.Column(db.Integer, db.ForeignKey('pravni_formy.id')) + zapis_datum = db.Column(MyType) + vymaz_datum = db.Column(MyType) + pravni_forma_text = db.relationship("Pravni_Formy") + company = db.relationship("Company") - __tablename__ = "companies" +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')) + statutarni_organ_id = db.Column(db.Integer, db.ForeignKey('statutarni_organy.id'), primary_key=True) + zapis_datum = db.Column(MyType) + vymaz_datum = db.Column(MyType) + statutarni_organ_text = db.relationship("Statutarni_Organy") + company = db.relationship("Company") + pocet_clenu = db.relationship("Pocty_Clenu_Organu") + 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')) + adresa_id = db.Column(db.Integer, db.ForeignKey('adresy_v2.id')) + 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("Adresy_v2") + 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')) + osoba_id = db.Column(db.Integer, db.ForeignKey('fyzicke_osoby.id')) + adresa_id = db.Column(db.Integer, db.ForeignKey('adresy_v2.id')) + 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("Adresy_v2") + jmeno = db.relationship("Fyzicka_Osoba") + +class Spolecnici_Association(db.Model): + __tablename__ = "spolecnici" + id = db.Column(db.Integer, primary_key=True) + company_id = db.Column(db.Integer, db.ForeignKey('companies.id')) + spolecnik_fo_id = db.Column(db.Integer, db.ForeignKey('fyzicke_osoby.id')) + spolecnik_po_id = db.Column(db.Integer, db.ForeignKey('pravnicke_osoby.id')) + zapis_datum = db.Column(MyType) + vymaz_datum = db.Column(MyType) + 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") + oznaceni_po = db.relationship("Pravnicka_Osoba") + podily = db.relationship("Podily_Association") + +class Prokurista_Association(db.Model): + __tablename__ = "prokuriste" + 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) + prokurista_fo_id = db.Column(db.Integer, db.ForeignKey('fyzicke_osoby.id')) + adresa_id = db.Column(db.Integer, db.ForeignKey('adresy_v2.id')) + adresa = db.relationship("Adresy_v2") + jmeno = db.relationship("Fyzicka_Osoba") + text_prokurista = db.Column(db.String) + +class Prokura_Common_Text_Association(db.Model): + __tablename__ = "prokura_common_texts" + 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) + prokura_text = db.Column(db.String) + +class Jediny_Akcionar_Association(db.Model): + __tablename__ = "jediny_akcionar" + 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) + text_akcionar = db.Column(db.String) + akcionar_fo_id = db.Column(db.Integer, db.ForeignKey('fyzicke_osoby.id')) + akcionar_po_id = db.Column(db.Integer, db.ForeignKey('pravnicke_osoby.id')) + adresa_id = db.Column(db.Integer, db.ForeignKey('adresy_v2.id')) + adresa = db.relationship("Adresy_v2") + jmeno = db.relationship("Fyzicka_Osoba") + oznaceni_po = db.relationship("Pravnicka_Osoba") + +class Podily_Association(db.Model): + __tablename__ = "podily" + id = db.Column(db.Integer, primary_key=True) + spolecnik_id = db.Column(db.Integer, db.ForeignKey('spolecnici.id')) + 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_text = db.Column(db.String) + souhrn_typ = db.Column(db.String) + souhrn_text = db.Column(db.String) + splaceni_typ = db.Column(db.String) + splaceni_text = db.Column(db.String) + druh_podilu = db.relationship("Druhy_Podilu") + +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')) + zpusob_jednani_id = db.Column(db.Integer, db.ForeignKey('zpusoby_jednani.id')) + zapis_datum = db.Column(MyType) + vymaz_datum = db.Column(MyType) + zpusob_jednani = relationship("Zpusob_Jednani") + statutarni_organ = relationship("Statutarni_Organ_Association") + +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) + zapis = db.Column(MyType) 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") - - -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" + soud = db.Column(MySoud) + insolvence = db.relationship("Insolvency_Events") + konkurz = db.relationship("Konkurz_Events") + predmet_podnikani = db.relationship("Predmety_Podnikani_Association") + predmet_cinnosti = db.relationship("Predmety_Cinnosti_Association") + zakladni_kapital = db.relationship("Zakladni_Kapital") + ostatni_skutecnosti = db.relationship("Ostatni_Skutecnosti") + akcie = db.relationship("Akcie") + obchodni_firma = db.relationship("Nazvy") + soudni_zapis = db.relationship("Soudni_Zapisy") + pravni_forma_text = db.relationship("Pravni_Forma_Association_v2") + statutarni_organ_text = db.relationship("Statutarni_Organ_Association") + dozorci_rada_text = db.relationship("Dozorci_Rada_Association") + spolecnici = db.relationship("Spolecnici_Association") + prokurista = db.relationship("Prokurista_Association") + prokura_common_text = db.relationship("Prokura_Common_Text_Association") + jediny_akcionar = db.relationship("Jediny_Akcionar_Association") + sidlo_text = db.relationship("Sidlo_Association") + +class Adresy_v2(db.Model): + __tablename__ = "adresy_v2" id = db.Column(db.Integer, primary_key=True) - pravni_forma = db.Column(db.String) - company_pravni_forma = db.relationship("Company", secondary=pravni_forma_association) + stat = db.Column(db.String) + obec = db.Column(db.String) + ulice = db.Column(db.String) + castObce = db.Column(db.String) + cisloPo = db.Column(db.Integer) + cisloOr = db.Column(db.Integer) + psc = db.Column(db.String) + okres = db.Column(db.String) + komplet_adresa = db.Column(db.String) + cisloEv = db.Column(db.Integer) + cisloText = db.Column(db.String) + company_sidlo = db.relationship("Sidlo_Association") + + def __repr__(self): + joined_address = "" + if self.komplet_adresa != "0": + return self.komplet_adresa + if self.ulice != "0": + joined_address += self.ulice + " " + if self.cisloText != "0": + joined_address += self.cisloText + ", " + if self.cisloPo != 0: + if self.ulice == "0": + joined_address += "č.p. " + joined_address += str(self.cisloPo) + if self.cisloOr != 0: + joined_address += "/" + else: + joined_address += ", " + if self.cisloOr != 0: + joined_address += str(self.cisloOr) + ", " + if self.cisloEv != 0: + joined_address += str(self.cisloEv) + ", " + if (self.castObce != "0") and (self.castObce != self.obec): + joined_address += self.castObce + ", " + if self.psc != "0" and self.psc != None: + joined_address += self.psc + " " + if self.obec != "0": + joined_address += self.obec + if (self.stat != "Česká republika") and (self.stat != "Česká republika - neztotožněno"): + joined_address += ", " + self.stat + return joined_address + +# 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 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")) - company = relationship("Company", backref="insolvency_events") + zapis_datum = db.Column(MyType) + vymaz_datum = db.Column(MyType) 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) + konkurz_event = db.Column(db.String) -# class Association(db.Model): -# __tablename__ = "obce_relation" -# company_id = db.Column(db.Integer, db.ForeignKey('companies.id'), primary_key=True) -# obec_id = db.Column(db.Integer, db.ForeignKey('obce.id')) - -# company = relationship("Company", back_populates = "Obce") -# obec = relationship("Obce", back_populates = "Company") - +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") +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") -# </soud:>
\ No newline at end of file +class Sidlo(db.Model): + __tablename__ = "adresy" + id = db.Column(db.Integer, primary_key=True) + adresa_text = db.Column(db.String) + +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") + +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") + +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") + +class Druhy_Podilu(db.Model): + __tablename__ = "druhy_podilu" + 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 diff --git a/templates/extract-actual.html b/templates/extract-actual.html new file mode 100644 index 0000000..ab19efc --- /dev/null +++ b/templates/extract-actual.html @@ -0,0 +1,539 @@ +{% include 'header.html' %} + +{% for row in results %} + +{% set insolvency_notes = [] %} +{% for elem in row.insolvence %} + {% set insolvency_notes = insolvency_notes.append(elem.insolvency_event) %} +{% endfor %} + +{% set predmety_podnikani_notes = [] %} +{% for i in range (row.predmet_podnikani|length) %} + {% if row.predmet_podnikani[i].vymaz_datum == 0 %} + {% set predmety_podnikani_notes = predmety_podnikani_notes.append(row.predmet_podnikani[i].predmet_podnikani.predmet_podnikani) %} + {% endif %} +{% endfor %} + +{% set predmety_cinnosti_notes = [] %} +{% for i in range (row.predmet_cinnosti|length) %} + {% if row.predmet_cinnosti[i].vymaz_datum == 0 %} + {% set predmety_cinnosti_notes = predmety_cinnosti_notes.append(row.predmet_cinnosti[i].predmet_cinnosti.predmet_cinnosti) %} + {% endif %} +{% endfor %} + +{% set zakladni_kapital_notes = [] %} +{% for i in range (row.zakladni_kapital|length) %} + {% if row.zakladni_kapital[i].vymaz_datum == 0 %} + {% set zakladni_kapital_notes = zakladni_kapital_notes.append(row.zakladni_kapital[i]) %} + {% endif %} +{% endfor %} + +{% set statutarni_organ_notes = [] %} +{% for i in range (row.statutarni_organ_text|length) %} + {% if row.statutarni_organ_text[i].vymaz_datum == 0 %} + {% set statutarni_organ_notes = statutarni_organ_notes.append(row.statutarni_organ_text[i]) %} + {% endif %} +{% endfor %} + +{% set spolecnici_notes = [] %} +{% for i in range (row.spolecnici|length) %} + {% if row.spolecnici[i].vymaz_datum == 0 %} + {% set spolecnici_notes = spolecnici_notes.append(row.spolecnici[i]) %} + {% endif %} +{% endfor %} + +{% set sole_shareholder_notes = [] %} +{% for i in range (row.jediny_akcionar|length) %} + {% if row.jediny_akcionar[i].vymaz_datum == 0 %} + {% set sole_shareholder_notes = sole_shareholder_notes.append(row.jediny_akcionar[i]) %} + {% endif %} +{% endfor %} + +{% set shares_notes = [] %} +{% for i in range (row.akcie|length) %} + {% if row.akcie[i].vymaz_datum == 0 %} + {% set shares_notes = shares_notes.append(row.akcie[i]) %} + {% endif %} +{% endfor %} + +{% set dozorci_rada_notes = [] %} +{% for i in range (row.dozorci_rada_text|length) %} + {% if row.dozorci_rada_text[i].vymaz_datum == 0 %} + {% set dozorci_rada_notes = dozorci_rada_notes.append(row.dozorci_rada_text[i]) %} + {% endif %} +{% endfor %} + +{% set prokurist_notes = [] %} +{% for i in range (row.prokurista|length) %} + {% if row.prokurista[i].vymaz_datum == 0 %} + {% set prokurist_notes = prokurist_notes.append(row.prokurista[i]) %} + {% endif %} +{% endfor %} + +{% set prokurist_common_text_notes = [] %} +{% for i in range (row.prokura_common_text|length) %} + {% if row.prokura_common_text[i].vymaz_datum == 0 %} + {% set prokurist_common_text_notes = prokurist_common_text_notes.append(row.prokura_common_text[i]) %} + {% endif %} +{% endfor %} + +{% set ostatni_skutecnosti_notes = [] %} +{% for i in range (row.ostatni_skutecnosti|length) %} + {% if row.ostatni_skutecnosti[i].vymaz_datum == 0 %} + {% set ostatni_skutecnosti_notes = ostatni_skutecnosti_notes.append(row.ostatni_skutecnosti[i]) %} + {% endif %} +{% endfor %} + +{% set insolvency_notes = [] %} +{% for i in range (row.insolvence|length) %} + {% if row.insolvence[i].vymaz_datum == 0 %} + {% set insolvency_notes = insolvency_notes.append(row.insolvence[i].insolvency_event) %} + {% endif %} +{% endfor %} + +{% set konkurz_notes = [] %} +{% for i in range (row.konkurz|length) %} + {% if row.konkurz[i].vymaz_datum == 0 %} + {% set konkurz_notes = konkurz_notes.append(row.konkurz[i].konkurz_event) %} + {% endif %} +{% endfor %} + +{% if row.soud == "MSPH" %} + {% set soud = "Městského soudu v Praze" %} +{% elif row.soud == "KSCB" %} + {% set soud = "Krajského soudu v Českých Budějovicích" %} +{% elif row.soud == "KSOS" %} + {% set soud = "Krajského soudu v Ostravě" %} +{% elif row.soud == "KSPL" %} + {% set soud = "Krajského soudu v Plzni" %} +{% elif row.soud == "KSBR" %} + {% set soud = "Krajského soudu v Brně" %} +{% elif row.soud == "KSHK" %} + {% set soud = "Krajského soudu v Hradci Králové" %} +{% elif row.soud == "KSUL" %} + {% set soud = "Krajského soudu v Ústí nad Labem" %} +{% endif %} + +{% if insolvency_notes|length > 0 %} + {% set table_style = "table table-danger" %} +{% elif loop.index % 2 == 0 %} + {% set table_style = "table table-light" %} +{% else %} + {% set table_style = "table table-secondary" %} +{% endif %} + +{% if row.ico|length != 8 %} + {% set ico_buffer = [] %} + {% for i in range (8 - row.ico|length) %} + {% set ico_buffer = ico_buffer.append("0") %} + {% endfor %} + +{% else %} + {% set ico_buffer = "" %} +{% endif %} + +<h1>Výpis z obchodního rejstříku</h1> +{% for i in range (row.soudni_zapis|length) %} + {% if row.soudni_zapis[i].vymaz_datum == 0 %} +<h2>{{ row.nazev }}, {{ row.soudni_zapis[i].oddil }} {{ row.soudni_zapis[i].vlozka }} vedená u {{ row.soudni_zapis[i].soud }}</h2> +{% endif %} +{% endfor %} +<p><a href="/">Zpět na vyhledání</a></p> + +<table class= "table" style="width: 100%"> + <!-- Display registration date --> + <tr> + <td style="width:15%">Datum vzniku a zápisu:</td> + <td style="width:85%">{{row.zapis}}</td> + </tr> + <!-- END Display registration date --> + + <!-- Display court registration --> + <tr> + <td>Spisová značka:</td> + {% for i in range (row.soudni_zapis|length) %} + {% if row.soudni_zapis[i].vymaz_datum == 0 %} + <td>{{ row.soudni_zapis[i].oddil }} {{ row.soudni_zapis[i].vlozka }} vedená u {{ row.soudni_zapis[i].soud }}</td> + {% endif %} + {% endfor %} + </tr> + <!-- END Display court registrations --> + + <!-- Display business names --> + <tr> + <td>Obchodní firma:</td> + {% for i in range (row.obchodni_firma|length) %} + {% if row.obchodni_firma[i].vymaz_datum == 0 %} + <td>{{ row.obchodni_firma[i].nazev_text }}</td> + {% endif %} + {% endfor %} + </tr> + <!-- END Display business names --> + + <!-- Display registered office --> + <tr> + <td>Sídlo:</td> + {% for i in range (row.sidlo_text|length) %} + {% if row.sidlo_text[i].vymaz_datum == 0 %} + <td>{{ row.sidlo_text[i].sidlo_text }}</td> + {% endif %} + {% endfor %} + </tr> + <!-- END Display registered office --> + + <!-- Display ICO --> + <tr> + <td>Identifikační číslo:</td> + <td>{{ ico_buffer|join("") }}{{ row.ico }}</td> + </tr> + <!-- END Display ICO --> + + <!-- Display legal form --> + <tr> + <td>Právní forma:</td> + {% for i in range (row.pravni_forma_text|length) %} + {% if row.pravni_forma_text[i].vymaz_datum == 0 %} + <td>{{ row.pravni_forma_text[i].pravni_forma_text.pravni_forma }}</td> + {% endif %} + {% endfor %} + </tr> + <!-- END Display legal form --> + + <!-- Display registered capital --> + {% if zakladni_kapital_notes|length > 0 %} + <tr> + {% if zakladni_kapital_notes[0].vklad_typ == "KORUNY" %} + {% set vklad_typ_symbol = "Kč" %} + {% set vklad_typ_description = zakladni_kapital_notes[0].vklad_hodnota %} + {% elif zakladni_kapital_notes[0].vklad_typ == "EURA" %} + {% set vklad_typ_symbol = "euro" %} + {% set vklad_typ_description = zakladni_kapital_notes[0].vklad_hodnota %} + {% else %} + {% set vklad_typ_symbol = "" %} + {% set vklad_typ_description = zakladni_kapital_notes[0].vklad_hodnota %} + {% endif %} + + {% if zakladni_kapital_notes[0].splaceni_typ == "KORUNY" %} + {% set splaceni_typ_symbol = "Kč" %} + {% set splaceni_typ_description = zakladni_kapital_notes[0].splaceni_hodnota %} + {% elif zakladni_kapital_notes[0].splaceni_typ == "PROCENTA" %} + {% set splaceni_typ_symbol = "%" %} + {% set splaceni_typ_description = zakladni_kapital_notes[0].splaceni_hodnota %} + {% elif zakladni_kapital_notes[0].splaceni_typ == "EURA" %} + {% set splaceni_typ_symbol = "euro" %} + {% set splaceni_typ_description = zakladni_kapital_notes[0].splaceni_hodnota %} + {% else %} + {% set splaceni_typ_symbol = "" %} + {% set splaceni_typ_description = zakladni_kapital_notes[0].splaceni_hodnota %} + {% endif %} + + <td>Základní kapitál:</td> + <td>{{ underlne_style_open|safe }} {{ vklad_typ_description }} {{ vklad_typ_symbol }} {% if splaceni_typ_description != "0" %} <br> Splaceno: {{ splaceni_typ_description }} {{ splaceni_typ_symbol }} {% endif %} {{ underlne_style_close|safe }}</td> + </tr> + {% endif %} + <!-- END Display registered capital --> + + <!-- Display area of business --> + {% if predmety_podnikani_notes|length > 0 %} + {% for i in range (predmety_podnikani_notes|length) %} + <tr> + <td>{% if i == 0%}Předmět podnikání:{% endif %}</td> + <td>{{ predmety_podnikani_notes[i] }}</td> + </tr> + {% endfor %} + {% endif %} + <!-- END Display area of business --> + + <!-- Display areas of activities --> + {% if predmety_cinnosti_notes|length > 0 %} + {% for i in range (predmety_cinnosti_notes|length) %} + <tr> + <td>{% if i == 0%}Předmět činnosti:{% endif %}</td> + <td>{{ predmety_cinnosti_notes[i] }}</td> + </tr> + {% endfor %} + {% endif %} + <!-- END Display areas of activities --> + + <!-- Display statutory bodies --> + {% if statutarni_organ_notes|length > 0 %} + {% for i in range (statutarni_organ_notes|length) %} + <tr> + <td>{{ statutarni_organ_notes[i].statutarni_organ_text.statutarni_organ_text }}:</td> + <td></td> + </tr> + + <!-- Display individual members --> + {% if statutarni_organ_notes[i].clenove|length > 0 %} + {% for j in range (statutarni_organ_notes[i].clenove|length) %} + {% if statutarni_organ_notes[i].clenove[j].vymaz_datum == 0 %} + <tr> + <td style = padding-left:2em>{% if statutarni_organ_notes[i].clenove[j].funkce != "0" %} {{ statutarni_organ_notes[i].clenove[j].funkce }} {% endif %}</td> + <td>{% if statutarni_organ_notes[i].clenove[j].jmeno.jmeno != "0" %}{{ statutarni_organ_notes[i].clenove[j].jmeno.jmeno }} {% endif %} + {{ statutarni_organ_notes[i].clenove[j].jmeno.prijmeni }}{% if statutarni_organ_notes[i].clenove[j].jmeno.datum_naroz != "" %}, nar. {{ statutarni_organ_notes[i].clenove[j].jmeno.datum_naroz }}{% endif %} <br> + {{ statutarni_organ_notes[i].clenove[j].adresa }} + {% if statutarni_organ_notes[i].clenove[j].funkce_od != 0 %}<br>Den vzniku funkce: {{ statutarni_organ_notes[i].clenove[j].funkce_od}}{% endif %} + {% if statutarni_organ_notes[i].clenove[j].clenstvi_od != 0 %}<br>Den vzniku členství: {{ statutarni_organ_notes[i].clenove[j].clenstvi_od}}{% endif %}</td> + </tr> + {% endif %} + {% endfor %} + {% endif %} + <!-- END Display individual members --> + + <!-- Display number of members --> + {% if statutarni_organ_notes[i].pocet_clenu|length > 0 %} + {% for j in range (statutarni_organ_notes[i].pocet_clenu|length) %} + {% if statutarni_organ_notes[i].pocet_clenu[j].vymaz_datum == 0 %} + <tr> + <td style = padding-left:2em>Počet členů:</td> + <td>{{ statutarni_organ_notes[i].pocet_clenu[j].pocet_clenu_value }}</td> + </tr> + {% endif %} + {% endfor %} + {% endif %} + <!-- END Display number of members --> + + <!-- Display method of representation --> + {% if statutarni_organ_notes[i].zpusoby_jednani|length > 0 %} + {% for j in range (statutarni_organ_notes[i].zpusoby_jednani|length) %} + {% if statutarni_organ_notes[i].zpusoby_jednani[j].vymaz_datum == 0 %} + <tr> + <td style = padding-left:2em>Způsob jednání:</td> + <td>{{ statutarni_organ_notes[i].zpusoby_jednani[j].zpusob_jednani.zpusob_jednani_text }}</td> + </tr> + {% endif %} + {% endfor %} + {% endif %} + <!-- END Display method of representation --> + + {% endfor %} + {% endif %} + <!-- END Display statutory bodies --> + + <!-- Display supervisory board--> + {% if dozorci_rada_notes|length > 0 %} + {% for i in range (dozorci_rada_notes|length) %} + <tr> + <td>Dozorčí rada:</td> + <td></td> + </tr> + <!-- Display individual supervisory board members --> + {% if dozorci_rada_notes[i].clenove|length > 0 %} + {% for j in range (dozorci_rada_notes[i].clenove|length) %} + {% if dozorci_rada_notes[i].clenove[j].vymaz_datum == 0 %} + <tr> + <td style = padding-left:2em>{% if dozorci_rada_notes[i].clenove[j].funkce != "0" %} {{dozorci_rada_notes[i].clenove[j].funkce }} {% endif %}</td> + <td>{% if dozorci_rada_notes[i].clenove[j].jmeno.jmeno != 0 %}{{ dozorci_rada_notes[i].clenove[j].jmeno.jmeno }} {% endif %} + {{ dozorci_rada_notes[i].clenove[j].jmeno.prijmeni }}{% if dozorci_rada_notes[i].clenove[j].jmeno.datum_naroz != "" %}, nar. {{ dozorci_rada_notes[i].clenove[j].jmeno.datum_naroz }}{% endif %} <br> + {{ dozorci_rada_notes[i].clenove[j].adresa }} + {% if dozorci_rada_notes[i].clenove[j].funkce_od != 0 %}<br>Den vzniku funkce: {{ dozorci_rada_notes[i].clenove[j].funkce_od}}{% endif %} + {% if dozorci_rada_notes[i].clenove[j].clenstvi_od != 0 %}<br>Den vzniku členství: {{ dozorci_rada_notes[i].clenove[j].clenstvi_od}}{% endif %}</td> + </tr> + {% endif %} + {% endfor %} + {% endif %} + <!-- END Display individual supervisory board members --> + {% if dozorci_rada_notes[i].pocet_clenu|length > 0 %} + {% for j in range (dozorci_rada_notes[i].pocet_clenu|length) %} + {% if dozorci_rada_notes[i].pocet_clenu[j].vymaz_datum == 0 %} + <tr> + <td style = padding-left:2em>Počet členů:</td> + <td>{{ dozorci_rada_notes[i].pocet_clenu[j].pocet_clenu_value }}</td> + </tr> + {% endif %} + {% endfor %} + {% endif %} + + {% endfor %} + {% endif %} + + <!-- END Display supervisory board--> + + <!-- Display prokurist --> + {% if prokurist_notes|length > 0 %} + {% for i in range (prokurist_notes|length) %} + <tr> + <td>{% if i == 0%}Prokura:{% endif %}</td> + <td>{% if prokurist_notes[i].jmeno.jmeno != "0" %}{{ prokurist_notes[i].jmeno.jmeno }} {% endif %} + {{ prokurist_notes[i].jmeno.prijmeni }}{% if prokurist_notes[i].jmeno.datum_naroz != "" %}, nar. {{ prokurist_notes[i].jmeno.datum_naroz }}{% endif %}<br> + {{ prokurist_notes[i].adresa }}{% if prokurist_notes[i].text_prokurista != "0" %}<br>{{ prokurist_notes[i].text_prokurista }}{% endif %}</td> + </tr> + {% endfor %} + {% if prokurist_common_text_notes|length > 0 %} + <tr> + {% for i in range (prokurist_common_text_notes|length) %} + <td></td> + <td>{{ prokurist_common_text_notes[i].prokura_text }}</td> + {% endfor %} + </tr> + {% endif %} + {% endif %} + <!-- END Display prokurist --> + + <!-- Display sole shareholder --> + {% if sole_shareholder_notes|length > 0 %} + {% for i in range (sole_shareholder_notes|length) %} + <tr> + <td>{% if i == 0%}Jediný akcionář:{% endif %}</td> + <td>{% if sole_shareholder_notes[i].akcionar_po_id == None %} + {% if sole_shareholder_notes[i].jmeno.jmeno != "0" %}{{ sole_shareholder_notes[i].jmeno.jmeno }} {% endif %} + {{ sole_shareholder_notes[i].jmeno.prijmeni }}{% if sole_shareholder_notes[i].jmeno.datum_naroz != "" %}, nar. {{ sole_shareholder_notes[i].jmeno.datum_naroz }}{% endif %} {% endif %} + {% if sole_shareholder_notes[i].akcionar_fo_id == None %} {{ sole_shareholder_notes[i].oznaceni_po.nazev }}{% if sole_shareholder_notes[i].oznaceni_po.reg_cislo != 0 %}, reg č. {{ sole_shareholder_notes[i].oznaceni_po.reg_cislo }}{% endif %}{% if sole_shareholder_notes[i].oznaceni_po.ico != 0 %}, IČ <a href="/{{ sole_shareholder_notes[i].oznaceni_po.ico }}-actual">{{ sole_shareholder_notes[i].oznaceni_po.ico }}</a>{% endif %} {% endif %} + <br>{{sole_shareholder_notes[i].adresa}}</td> + </tr> + {% endfor %} + {% endif %} + <!-- END Display sole shareholder --> + + <!-- Display shareholders --> + {% if spolecnici_notes|length > 0 %} + <tr> + <td>Společníci:</td> + <td></td> + </tr> + {% for i in range (spolecnici_notes|length) %} + <tr> + <td style = padding-left:2em>Společník:</td> + <td>{% if spolecnici_notes[i].spolecnik_po_id == None %} + {% if spolecnici_notes[i].jmeno.jmeno != "0" %}{{ spolecnici_notes[i].jmeno.jmeno }} {% endif %} + {{ spolecnici_notes[i].jmeno.prijmeni }}{% if spolecnici_notes[i].jmeno.datum_naroz != "" %}, nar. {{ spolecnici_notes[i].jmeno.datum_naroz }}{% endif %} {% endif %} + {% if spolecnici_notes[i].spolecnik_fo_id == None %} {{ spolecnici_notes[i].oznaceni_po.nazev }}{% if spolecnici_notes[i].oznaceni_po.reg_cislo != 0 %}, reg č. {{ spolecnici_notes[i].oznaceni_po.reg_cislo }}{% endif %}{% if spolecnici_notes[i].oznaceni_po.ico != 0 %}, IČ <a href="/{{ spolecnici_notes[i].oznaceni_po.ico }}-actual">{{ spolecnici_notes[i].oznaceni_po.ico }}</a>{% endif %} {% endif %} + <br>{{spolecnici_notes[i].adresa}}</td> + </tr> + {% set spolecnik_podily = [] %} + {% for j in range (spolecnici_notes[i].podily|length) %} + {% if spolecnici_notes[i].podily[j].vymaz_datum == 0 %} + {% set spolecnik_podily = spolecnik_podily.append(spolecnici_notes[i].podily[j]) %} + {% endif %} + {% endfor %} + + {% for k in range (spolecnik_podily|length) %} + <tr> + <td style = padding-left:4em>Podíl:</td> + <!-- Set type of deposit --> + {% if spolecnik_podily[k].vklad_typ == "KORUNY" %} + {% set vklad_typ_string = "Kč" %} + {% elif spolecnik_podily[k].vklad_typ == "EURA" %} + {% set vklad_typ_string = "Euro" %} + {% else %} + {% set vklad_typ_string = "" %} + {% endif %} + + <!-- Set type of repaid contribution --> + {% if spolecnik_podily[k].splaceni_typ == "KORUNY" %} + {% set splaceni_typ_string = "Kč" %} + {% elif spolecnik_podily[k].splaceni_typ == "PROCENTA" %} + {% set splaceni_typ_string = "%" %} + {% elif spolecnik_podily[k].splaceni_typ == "EURA" %} + {% set splaceni_typ_string = "Euro" %} + {% else %} + {% set splaceni_typ_string = "" %} + {% endif %} + + <!-- Set type of share --> + {% if spolecnik_podily[k].souhrn_typ == "PROCENTA" %} + {% set souhrn_typ_string = "%" %} + {% else %} + {% set souhrn_typ_string = "" %} + {% endif %} + <td>Vklad: {{ spolecnik_podily[k].vklad_text }} {{ vklad_typ_string }}<br> + Splaceno: {{ spolecnik_podily[k].splaceni_text }} {{ splaceni_typ_string }}<br> + {% if spolecnik_podily[k].souhrn_text != "0"%}Podíl: {{ spolecnik_podily[k].souhrn_text }} {{ souhrn_typ_string }}{% endif %} + {% if spolecnik_podily[k].druh_podilu.druh_podilu != "0" %}<br>Druh podílu: {{ spolecnik_podily[k].druh_podilu.druh_podilu }}{% endif %} + </td> + </tr> + {% endfor %} + {% endfor %} + {% endif %} + <!-- END Display shareholders --> + + <!-- Display shares --> + {% if shares_notes|length > 0 %} + {% for i in range (shares_notes|length) %} + <tr> + <td>{% if i == 0%}Akcie:{% endif %}</td> + {% if shares_notes[i].akcie_podoba == "LISTINNA" %} + {% set akcie_podoba_description = "v listinné podobě" %} + {% elif shares_notes[i].akcie_podoba == "ZAKNIHOVANA" %} + {% set akcie_podoba_description = "v zaknihované podobě" %} + {% elif shares_notes[i].akcie_podoba == "IMOBILIZOVANA" %} + {% set akcie_podoba_description = "v imobilizované podobě" %} + {% else %} + {% set akcie_podoba_description = "" %} + {% endif %} + + {% if shares_notes[i].akcie_typ == "KMENOVE_NA_JMENO" %} + {% set akcie_typ_description = "kmenové akcie na jméno" %} + {% elif shares_notes[i].akcie_typ == "KMENOVE_NA_MAJITELE" %} + {% set akcie_typ_description = "kmenové akcie na majitele" %} + {% elif shares_notes[i].akcie_typ == "KUSOVE_NA_JMENO" %} + {% set akcie_typ_description = "kusové akcie" %} + {% elif shares_notes[i].akcie_typ == "NA_JMENO" %} + {% set akcie_typ_description = "akcie na jméno" %} + {% elif shares_notes[i].akcie_typ == "NA_MAJITELE" %} + {% set akcie_typ_description = "akcie na majitele" %} + {% elif shares_notes[i].akcie_typ == "PRIORITNI_NA_JMENO" %} + {% set akcie_typ_description = "prioritní akcie na jméno" %} + {% elif shares_notes[i].akcie_typ == "ZAMESTNANECKE_NA_JMENO" %} + {% set akcie_typ_description = "zaměstnanecké akcie na jméno" %} + {% elif shares_notes[i].akcie_typ == "ZVLASTNI_PRAVA" %} + {% set akcie_typ_description = "akcie se zvláštními právy" %} + {% else %} + {% set akcie_typ_description = "" %} + {% endif %} + + {% if shares_notes[i].akcie_hodnota_typ == "KORUNY" %} + {% set akcie_hodnota_typ_symbol = "Kč" %} + {% elif shares_notes[i].akcie_hodnota_typ == "EURA" %} + {% set akcie_hodnota_typ_symbol = "euro" %} + {% else %} + {% set akcie_hodnota_typ_symbol = "" %} + {% endif %} + <td>{{ shares_notes[i].akcie_pocet }} ks {{ akcie_typ_description }} {{ akcie_podoba_description }} ve jmenovité hodnotě {{ shares_notes[i].akcie_hodnota_value }} {{ akcie_hodnota_typ_symbol }} {% if shares_notes[i].akcie_text != "0" %} <br> {{ shares_notes[i].akcie_text }} {% endif %}</td> + </tr> + {% endfor %} + {% endif %} + <!-- END Display shares --> + + <!-- Insolvency Events --> + {% if insolvency_notes|length > 0 %} + {% for i in range (insolvency_notes|length) %} + <tr> + <td>{% if i == 0%}Údaje o insolvencích:{% endif %}</td> + <td>{{ insolvency_notes[i] }}</td> + </tr> + {% endfor %} + {% endif %} + <!-- END Insolvency Events --> + + <!-- Konkurz Events --> + {% if konkurz_notes|length > 0 %} + {% for i in range (konkurz_notes|length) %} + <tr> + <td>{% if i == 0%}Údaje o konkurzech:{% endif %}</td> + <td>{{ konkurz_notes[i] }}</td> + </tr> + {% endfor %} + {% endif %} + <!-- END Konkurz Events --> + + <!-- Ostatni skutecnosti --> + {% if ostatni_skutecnosti_notes|length > 0 %} + {% for i in range (ostatni_skutecnosti_notes|length) %} + <tr> + <td>{% if i == 0%}Ostatní skutečnosti:{% endif %}</td> + <td>{{ ostatni_skutecnosti_notes[i].ostatni_skutecnost }}</td> + </tr> + {% endfor %} + {% endif %} + <!-- END Ostatni skutecnosti --> + +</table> + +{% endfor %} + +{% if results|length == 0 %} +<p>Nothing found here. <a href = "/">Back to search.</a></p> +{% endif %} + +{% include 'footer.html' %}
\ No newline at end of file diff --git a/templates/extract.html b/templates/extract.html new file mode 100644 index 0000000..2bacb06 --- /dev/null +++ b/templates/extract.html @@ -0,0 +1,636 @@ +{% include 'header.html' %} +{% for row in results %} +<!-- DO I NEED THIS HERE? --> +{% if insolvency_notes|length > 0 %} + {% set table_style = "table table-danger" %} +{% elif loop.index % 2 == 0 %} + {% set table_style = "table table-light" %} +{% else %} + {% set table_style = "table table-secondary" %} +{% endif %} + +{% if row.ico|length != 8 %} + {% set ico_buffer = [] %} + {% for i in range (8 - row.ico|length) %} + {% set ico_buffer = ico_buffer.append("0") %} + {% endfor %} + +{% else %} + {% set ico_buffer = "" %} +{% endif %} + +{% set undedrline_open_deleted = "<u>" %} +{% set undedrline_closed_deleted = "</u>" %} + +<h1>Výpis z obchodního rejstříku</h1> +{% for i in range (row.soudni_zapis|length) %} + {% if row.soudni_zapis[i].vymaz_datum == 0 %} +<h2>{{ row.nazev }}, {{ row.soudni_zapis[i].oddil }} {{ row.soudni_zapis[i].vlozka }} vedená u {{ row.soudni_zapis[i].soud }}</h2> +{% endif %} +{% endfor %} + +<p><a href="/">Zpět na vyhledání</a></p> + +<table class= "table" style="width: 100%"> + <!-- Display registration date --> + <tr> + <td style="width:15%">Datum vzniku a zápisu:</td> + <td style="width:60%">{{row.zapis}}</td> + <td style="width:25%"></td> + </tr> + <!-- END Display registration date --> + + <!-- Display court registration --> + {% if row.soudni_zapis|length > 0 %} + {% for i in range (row.soudni_zapis|length) %} + <tr> + <td>{% if i == 0%}Spisová značka:{% endif %}</td> + {% if row.soudni_zapis[i].vymaz_datum != 0 %} + {% set underlne_style_open = undedrline_open_deleted %} + {% set underlne_style_close = undedrline_closed_deleted %} + {% else %} + {% set underlne_style_open = "" %} + {% set underlne_style_close = "" %} + {% endif %} + <td>{{ underlne_style_open|safe }} {{ row.soudni_zapis[i].oddil }} {{ row.soudni_zapis[i].vlozka }} vedená u {{ row.soudni_zapis[i].soud }} {{ underlne_style_close|safe }}</td> + <td>{{ underlne_style_open|safe }} Zapsáno: {{ row.soudni_zapis[i].zapis_datum }} {% if row.soudni_zapis[i].vymaz_datum != 0 %} <br> Vymazáno: {{ row.soudni_zapis[i].vymaz_datum }} {% endif %} {{ underlne_style_close|safe }}</td> + </tr> + {% endfor %} + {% endif %} + <!-- END Display court registrations --> + + <!-- Display business names --> + {% if row.obchodni_firma|length > 0 %} + {% for i in range (row.obchodni_firma|length) %} + <tr> + <td>{% if i == 0%}Obchodní firma:{% endif %}</td> + {% if row.obchodni_firma[i].vymaz_datum != 0 %} + {% set underlne_style_open = undedrline_open_deleted %} + {% set underlne_style_close = undedrline_closed_deleted %} + {% else %} + {% set underlne_style_open = "" %} + {% set underlne_style_close = "" %} + {% endif %} + <td>{{ underlne_style_open|safe }} {{ row.obchodni_firma[i].nazev_text }} {{ underlne_style_close|safe }}</td> + <td>{{ underlne_style_open|safe }} Zapsáno: {{ row.obchodni_firma[i].zapis_datum }} {% if row.obchodni_firma[i].vymaz_datum != 0 %} <br> Vymazáno: {{ row.obchodni_firma[i].vymaz_datum }} {% endif %} {{ underlne_style_close|safe }}</td> + </tr> + {% endfor %} + {% endif %} + <!-- END Display business names --> + + <!-- Display registered office --> + {% if row.sidlo_text|length > 0 %} + {% for i in range (row.sidlo_text|length) %} + <tr> + <td>{% if i == 0%}Sídlo:{% endif %}</td> + {% if row.sidlo_text[i].vymaz_datum != 0 %} + {% set underlne_style_open = undedrline_open_deleted %} + {% set underlne_style_close = undedrline_closed_deleted %} + {% else %} + {% set underlne_style_open = "" %} + {% set underlne_style_close = "" %} + {% endif %} + <td>{{ underlne_style_open|safe }} {{ row.sidlo_text[i].sidlo_text }} {{ underlne_style_close|safe }}</td> + <td>{{ underlne_style_open|safe }} Zapsáno: {{ row.sidlo_text[i].zapis_datum }} {% if row.sidlo_text[i].vymaz_datum != 0 %} <br> Vymazáno: {{ row.sidlo_text[i].vymaz_datum }} {% endif %} {{ underlne_style_close|safe }}</td> + </tr> + {% endfor %} + {% endif %} + <!-- END Display registered office --> + + <!-- Display ICO --> + <tr> + <td>Identifikační číslo:</td> + <td>{{ ico_buffer|join("") }}{{ row.ico }}</td> + <td>Zapsáno: {{row.zapis}}</td> + </tr> + <!-- END Display ICO --> + + <!-- Display legal form --> + {% if row.pravni_forma_text|length > 0 %} + {% for i in range (row.pravni_forma_text|length) %} + <tr> + <td>{% if i == 0%}Právní forma:{% endif %}</td> + {% if row.pravni_forma_text[i].vymaz_datum != 0 %} + {% set underlne_style_open = undedrline_open_deleted %} + {% set underlne_style_close = undedrline_closed_deleted %} + {% else %} + {% set underlne_style_open = "" %} + {% set underlne_style_close = "" %} + {% endif %} + <td>{{ underlne_style_open|safe }} {{ row.pravni_forma_text[i].pravni_forma_text.pravni_forma }} {{ underlne_style_close|safe }}</td> + <td>{{ underlne_style_open|safe }} Zapsáno: {{ row.pravni_forma_text[i].zapis_datum }} {% if row.pravni_forma_text[i].vymaz_datum != 0 %} <br> Vymazáno: {{ row.pravni_forma_text[i].vymaz_datum }} {% endif %} {{ underlne_style_close|safe }}</td> + </tr> + {% endfor %} + {% endif %} + <!-- END Display legal form --> + + <!-- Display registered capital --> + {% if row.zakladni_kapital|length > 0 %} + {% for i in range (row.zakladni_kapital|length) %} + <tr> + <td>{% if i == 0%}Základní kapitál:{% endif %}</td> + {% if row.zakladni_kapital[i].vymaz_datum != 0 %} + {% set underlne_style_open = undedrline_open_deleted %} + {% set underlne_style_close = undedrline_closed_deleted %} + {% else %} + {% set underlne_style_open = "" %} + {% set underlne_style_close = "" %} + {% endif %} + + <!-- TODO: Have backend handle this --> + {% if row.zakladni_kapital[i].vklad_typ == "KORUNY" %} + {% set vklad_typ_symbol = "Kč" %} + {% set vklad_typ_description = row.zakladni_kapital[i].vklad_hodnota %} + {% elif row.zakladni_kapital[i].vklad_typ == "EURA" %} + {% set vklad_typ_symbol = "euro" %} + {% set vklad_typ_description = row.zakladni_kapital[i].vklad_hodnota %} + {% else %} + {% set vklad_typ_symbol = "" %} + {% set vklad_typ_description = row.zakladni_kapital[i].vklad_hodnota %} + {% endif %} + + {% if row.zakladni_kapital[i].splaceni_typ == "KORUNY" %} + {% set splaceni_typ_symbol = "Kč" %} + {% set splaceni_typ_description = row.zakladni_kapital[i].splaceni_hodnota %} + {% elif row.zakladni_kapital[i].splaceni_typ == "PROCENTA" %} + {% set splaceni_typ_symbol = "%" %} + {% set splaceni_typ_description = row.zakladni_kapital[i].splaceni_hodnota %} + {% elif row.zakladni_kapital[i].splaceni_typ == "EURA" %} + {% set splaceni_typ_symbol = "euro" %} + {% set splaceni_typ_description = row.zakladni_kapital[i].splaceni_hodnota %} + {% else %} + {% set splaceni_typ_symbol = "" %} + {% set splaceni_typ_description = row.zakladni_kapital[i].splaceni_hodnota %} + {% endif %} + + <td>{{ underlne_style_open|safe }} {{ vklad_typ_description }} {{ vklad_typ_symbol }} {% if splaceni_typ_description != "0" %} <br> Splaceno: {{ splaceni_typ_description }} {{ splaceni_typ_symbol }} {% endif %} {{ underlne_style_close|safe }}</td> + <td>{{ underlne_style_open|safe }} Zapsáno: {{ row.zakladni_kapital[i].zapis_datum }} {% if row.zakladni_kapital[i].vymaz_datum != 0 %} <br> Vymazáno: {{ row.zakladni_kapital[i].vymaz_datum }} {% endif %} {{ underlne_style_close|safe }}</td> + </tr> + {% endfor %} + {% endif %} + <!-- END Display registered capital --> + + <!-- Display area of business --> + {% if row.predmet_podnikani|length > 0 %} + {% for i in range (row.predmet_podnikani|length) %} + <tr> + <td>{% if i == 0%}Předmět podnikání:{% endif %}</td> + {% if row.predmet_podnikani[i].vymaz_datum != 0 %} + {% set underlne_style_open = undedrline_open_deleted %} + {% set underlne_style_close = undedrline_closed_deleted %} + {% else %} + {% set underlne_style_open = "" %} + {% set underlne_style_close = "" %} + {% endif %} + <td>{{ underlne_style_open|safe }} {{ row.predmet_podnikani[i].predmet_podnikani.predmet_podnikani }} {{ underlne_style_close|safe }}</td> + <td>{{ underlne_style_open|safe }} Zapsáno: {{ row.predmet_podnikani[i].zapis_datum }} {% if row.predmet_podnikani[i].vymaz_datum != 0 %} <br> Vymazáno: {{ row.predmet_podnikani[i].vymaz_datum }} {% endif %} {{ underlne_style_close|safe }}</td> + </tr> + {% endfor %} + {% endif %} + <!-- END Display area of business --> + + <!-- Display areas of activities --> + {% if row.predmet_cinnosti|length > 0 %} + {% for i in range (row.predmet_cinnosti|length) %} + <tr> + <td>{% if i == 0%}Předmět činnosti:{% endif %}</td> + {% if row.predmet_cinnosti[i].vymaz_datum != 0 %} + {% set underlne_style_open = undedrline_open_deleted %} + {% set underlne_style_close = undedrline_closed_deleted %} + {% else %} + {% set underlne_style_open = "" %} + {% set underlne_style_close = "" %} + {% endif %} + <td>{{ underlne_style_open|safe }} {{ row.predmet_cinnosti[i].predmet_cinnosti.predmet_cinnosti }} {{ underlne_style_close|safe }}</td> + <td>{{ underlne_style_open|safe }} Zapsáno: {{ row.predmet_cinnosti[i].zapis_datum }} {% if row.predmet_cinnosti[i].vymaz_datum != 0 %} <br> Vymazáno: {{ row.predmet_cinnosti[i].vymaz_datum }} {% endif %} {{ underlne_style_close|safe }}</td> + </tr> + {% endfor %} + {% endif %} + <!-- END Display areas of activities --> + + <!-- Display statutory bodies --> + {% if row.statutarni_organ_text|length > 0 %} + {% for i in range (row.statutarni_organ_text|length) %} + <tr> + <td>{{ row.statutarni_organ_text[i].statutarni_organ_text.statutarni_organ_text }}:</td> + {% if row.statutarni_organ_text[i].vymaz_datum != 0 %} + {% set underlne_style_open = undedrline_open_deleted %} + {% set underlne_style_close = undedrline_closed_deleted %} + {% else %} + {% set underlne_style_open = "" %} + {% set underlne_style_close = "" %} + {% endif %} + <td>{{ underlne_style_open|safe }} {{ underlne_style_close|safe }}</td> + <td>{{ underlne_style_open|safe }} Zapsáno: {{ row.statutarni_organ_text[i].zapis_datum }} {% if row.statutarni_organ_text[i].vymaz_datum != 0 %} <br> Vymazáno: {{ row.statutarni_organ_text[i].vymaz_datum }} {% endif %} {{ underlne_style_close|safe }}</td> + </tr> + + <!-- Insert Board Members --> + {% if row.statutarni_organ_text[i].clenove|length > 0 %} + {% for j in range (row.statutarni_organ_text[i].clenove|length) %} + <tr> + <td style = padding-left:2em>{% if row.statutarni_organ_text[i].clenove[j].funkce != "0" %} {{ row.statutarni_organ_text[i].clenove[j].funkce }} {% endif %}</td> + {% if row.statutarni_organ_text[i].clenove[j].vymaz_datum != 0 %} + {% set underlne_style_open = undedrline_open_deleted %} + {% set underlne_style_close = undedrline_closed_deleted %} + {% else %} + {% set underlne_style_open = "" %} + {% set underlne_style_close = "" %} + {% endif %} + <td>{{ underlne_style_open|safe }} + {% if row.statutarni_organ_text[i].clenove[j].jmeno.jmeno != "0" %}{{ row.statutarni_organ_text[i].clenove[j].jmeno.jmeno }} {% endif %} + {{ row.statutarni_organ_text[i].clenove[j].jmeno.prijmeni }}{% if row.statutarni_organ_text[i].clenove[j].jmeno.datum_naroz != "" %}, nar. {{ row.statutarni_organ_text[i].clenove[j].jmeno.datum_naroz }}{% endif %} <br> + {{ row.statutarni_organ_text[i].clenove[j].adresa }} + {% if row.statutarni_organ_text[i].clenove[j].funkce_od != 0 %}<br>Den vzniku funkce: {{ row.statutarni_organ_text[i].clenove[j].funkce_od}}{% endif %} + {% if row.statutarni_organ_text[i].clenove[j].funkce_do != 0 %}<br>Den zániku funkce: {{ row.statutarni_organ_text[i].clenove[j].funkce_do}}{% endif %} + {% if row.statutarni_organ_text[i].clenove[j].clenstvi_od != 0 %}<br>Den vzniku členství: {{ row.statutarni_organ_text[i].clenove[j].clenstvi_od}}{% endif %} + {% if row.statutarni_organ_text[i].clenove[j].clenstvi_do != 0 %}<br>Den zániku členství: {{ row.statutarni_organ_text[i].clenove[j].clenstvi_do}}{% endif %} + {{ underlne_style_close|safe }}</td> + <td>{{ underlne_style_open|safe }} Zapsáno: {{ row.statutarni_organ_text[i].clenove[j].zapis_datum }} {% if row.statutarni_organ_text[i].clenove[j].vymaz_datum != 0 %} <br> Vymazáno: {{ row.statutarni_organ_text[i].clenove[j].vymaz_datum }} {% endif %} {{ underlne_style_close|safe }}</td> + </tr> + {% endfor %} + {% endif %} + <!-- End Insert of Board Members --> + + <!-- Insert Number of Members --> + {% if row.statutarni_organ_text[i].pocet_clenu|length > 0 %} + {% for j in range (row.statutarni_organ_text[i].pocet_clenu|length) %} + <tr> + <td style = padding-left:2em>{% if j == 0%}Počet členů:{% endif %}</td> + {% if row.statutarni_organ_text[i].pocet_clenu[j].vymaz_datum != 0 %} + {% set underlne_style_open = undedrline_open_deleted %} + {% set underlne_style_close = undedrline_closed_deleted %} + {% else %} + {% set underlne_style_open = "" %} + {% set underlne_style_close = "" %} + {% endif %} + <td>{{ underlne_style_open|safe }} {{ row.statutarni_organ_text[i].pocet_clenu[j].pocet_clenu_value }} {{ underlne_style_close|safe }}</td> + <td>{{ underlne_style_open|safe }} Zapsáno: {{ row.statutarni_organ_text[i].pocet_clenu[j].zapis_datum }} {% if row.statutarni_organ_text[i].pocet_clenu[j].vymaz_datum != 0 %} <br> Vymazáno: {{ row.statutarni_organ_text[i].pocet_clenu[j].vymaz_datum }} {% endif %} {{ underlne_style_close|safe }}</td> + </tr> + {% endfor %} + {% endif %} + <!-- END Insert Number of Members --> + + <!-- Display method of representation --> + {% if row.statutarni_organ_text[i].zpusoby_jednani|length > 0 %} + {% for j in range (row.statutarni_organ_text[i].zpusoby_jednani|length) %} + <tr> + <td style = padding-left:2em>{% if j == 0%}Způsob jednání:{% endif %}</td> + {% if row.statutarni_organ_text[i].zpusoby_jednani[j].vymaz_datum != 0 %} + {% set underlne_style_open = undedrline_open_deleted %} + {% set underlne_style_close = undedrline_closed_deleted %} + {% else %} + {% set underlne_style_open = "" %} + {% set underlne_style_close = "" %} + {% endif %} + <td>{{ underlne_style_open|safe }} {{ row.statutarni_organ_text[i].zpusoby_jednani[j].zpusob_jednani.zpusob_jednani_text }} {{ underlne_style_close|safe }}</td> + <td>{{ underlne_style_open|safe }} Zapsáno: {{ row.statutarni_organ_text[i].zpusoby_jednani[j].zapis_datum }} {% if row.statutarni_organ_text[i].zpusoby_jednani[j].vymaz_datum != 0 %} <br> Vymazáno: {{ row.statutarni_organ_text[i].zpusoby_jednani[j].vymaz_datum }} {% endif %} {{ underlne_style_close|safe }}</td> + </tr> + {% endfor %} + {% endif %} + <!-- END Display method of representation --> + + {% endfor %} + {% endif %} + <!-- END Display statutory bodies --> + + <!--Display supervisory board--> + {% if row.dozorci_rada_text|length > 0 %} + {% for i in range (row.dozorci_rada_text|length) %} + <tr> + <td>Dozorčí rada:</td> + {% if row.dozorci_rada_text[i].vymaz_datum != 0 %} + {% set underlne_style_open = undedrline_open_deleted %} + {% set underlne_style_close = undedrline_closed_deleted %} + {% else %} + {% set underlne_style_open = "" %} + {% set underlne_style_close = "" %} + {% endif %} + <td>{{ underlne_style_open|safe }} {{ underlne_style_close|safe }}</td> + <td>{{ underlne_style_open|safe }} Zapsáno: {{ row.dozorci_rada_text[i].zapis_datum }} {% if row.dozorci_rada_text[i].vymaz_datum != 0 %} <br> Vymazáno: {{ row.dozorci_rada_text[i].vymaz_datum }} {% endif %} {{ underlne_style_close|safe }}</td> + </tr> + + <!-- Display Supervisory Board Members --> + {% if row.dozorci_rada_text[i].clenove|length > 0 %} + {% for j in range (row.dozorci_rada_text[i].clenove|length) %} + <tr> + <td style = padding-left:2em>{% if row.dozorci_rada_text[i].clenove[j].funkce != "0" %} {{ row.dozorci_rada_text[i].clenove[j].funkce }} {% endif %}</td> + {% if row.dozorci_rada_text[i].clenove[j].vymaz_datum != 0 %} + {% set underlne_style_open = undedrline_open_deleted %} + {% set underlne_style_close = undedrline_closed_deleted %} + {% else %} + {% set underlne_style_open = "" %} + {% set underlne_style_close = "" %} + {% endif %} + <td>{{ underlne_style_open|safe }} + {% if row.dozorci_rada_text[i].clenove[j].jmeno.jmeno != "0" %}{{ row.dozorci_rada_text[i].clenove[j].jmeno.jmeno }} {% endif %} + {{ row.dozorci_rada_text[i].clenove[j].jmeno.prijmeni }}{% if row.dozorci_rada_text[i].clenove[j].jmeno.datum_naroz != "" %}, nar. {{ row.dozorci_rada_text[i].clenove[j].jmeno.datum_naroz }}{% endif %} <br> + {{ row.dozorci_rada_text[i].clenove[j].adresa }} + {% if row.dozorci_rada_text[i].clenove[j].funkce_od != 0 %}<br>Den vzniku funkce: {{ row.dozorci_rada_text[i].clenove[j].funkce_od}}{% endif %} + {% if row.dozorci_rada_text[i].clenove[j].funkce_do != 0 %}<br>Den zániku funkce: {{ row.dozorci_rada_text[i].clenove[j].funkce_do}}{% endif %} + {% if row.dozorci_rada_text[i].clenove[j].clenstvi_od != 0 %}<br>Den vzniku členství: {{ row.dozorci_rada_text[i].clenove[j].clenstvi_od}}{% endif %} + {% if row.dozorci_rada_text[i].clenove[j].clenstvi_do != 0 %}<br>Den zániku členství: {{ row.dozorci_rada_text[i].clenove[j].clenstvi_do}}{% endif %} + {{ underlne_style_close|safe }}</td> + <td>{{ underlne_style_open|safe }} Zapsáno: {{ row.dozorci_rada_text[i].clenove[j].zapis_datum }} {% if row.dozorci_rada_text[i].clenove[j].vymaz_datum != 0 %} <br> Vymazáno: {{ row.dozorci_rada_text[i].clenove[j].vymaz_datum }} {% endif %} {{ underlne_style_close|safe }}</td> + </tr> + {% endfor %} + {% endif %} + <!-- End Display Supervisory Board Members --> + + <!-- Display Number of Supervisory Board Members --> + {% if row.dozorci_rada_text[i].pocet_clenu|length > 0 %} + {% for j in range (row.dozorci_rada_text[i].pocet_clenu|length) %} + <tr> + <td style = padding-left:2em>{% if j == 0%}Počet členů:{% endif %}</td> + {% if row.dozorci_rada_text[i].pocet_clenu[j].vymaz_datum != 0 %} + {% set underlne_style_open = undedrline_open_deleted %} + {% set underlne_style_close = undedrline_closed_deleted %} + {% else %} + {% set underlne_style_open = "" %} + {% set underlne_style_close = "" %} + {% endif %} + <td>{{ underlne_style_open|safe }} {{ row.dozorci_rada_text[i].pocet_clenu[j].pocet_clenu_value }} {{ underlne_style_close|safe }}</td> + <td>{{ underlne_style_open|safe }} Zapsáno: {{ row.dozorci_rada_text[i].pocet_clenu[j].zapis_datum }} {% if row.dozorci_rada_text[i].pocet_clenu[j].vymaz_datum != 0 %} <br> Vymazáno: {{ row.dozorci_rada_text[i].pocet_clenu[j].vymaz_datum }} {% endif %} {{ underlne_style_close|safe }}</td> + </tr> + <!-- END Display Number of Supervisory Board Members --> + {% endfor %} + {% endif %} + + {% endfor %} + {% endif %} + + <!--END Display supervisory board--> + + <!-- Display prokurist --> + {% if row.prokurista|length > 0 %} + <tr> + <td>Prokura:</td> + <td></td> + <td></td> + </tr> + {% for i in range (row.prokurista|length) %} + <tr> + <td></td> + {% if row.prokurista[i].vymaz_datum != 0 %} + {% set underlne_style_open = undedrline_open_deleted %} + {% set underlne_style_close = undedrline_closed_deleted %} + {% else %} + {% set underlne_style_open = "" %} + {% set underlne_style_close = "" %} + {% endif %} + <td>{{ underlne_style_open|safe }} + {% if row.prokurista[i].jmeno.jmeno != "0" %}{{ row.prokurista[i].jmeno.jmeno }} {% endif %} + {{ row.prokurista[i].jmeno.prijmeni }}{% if row.prokurista[i].jmeno.datum_naroz != "" %}, nar. {{ row.prokurista[i].jmeno.datum_naroz }}{% endif %}<br> + {{ row.prokurista[i].adresa }}{% if row.prokurista[i].text_prokurista != "0" %}<br>{{ row.prokurista[i].text_prokurista }}{% endif %}{{ underlne_style_close|safe }}</td> + <td>{{ underlne_style_open|safe }} Zapsáno: {{ row.prokurista[i].zapis_datum }} {% if row.prokurista[i].vymaz_datum != 0 %} <br> Vymazáno: {{ row.prokurista[i].vymaz_datum }} {% endif %} {{ underlne_style_close|safe }}</td> + </tr> + {% endfor %} + <!-- Insert common text for prokura --> + {% for i in range (row.prokura_common_text|length) %} + <tr> + <td></td> + {% if row.prokura_common_text[i].vymaz_datum != 0 %} + {% set underlne_style_open = undedrline_open_deleted %} + {% set underlne_style_close = undedrline_closed_deleted %} + {% else %} + {% set underlne_style_open = "" %} + {% set underlne_style_close = "" %} + {% endif %} + <td>{{ underlne_style_open|safe }} {{ row.prokura_common_text[i].prokura_text }} {{ underlne_style_close|safe }}</td> + <td>{{ underlne_style_open|safe }} Zapsáno: {{ row.prokura_common_text[i].zapis_datum }} {% if row.prokura_common_text[i].vymaz_datum != 0 %} <br> Vymazáno: {{ row.prokura_common_text[i].vymaz_datum }} {% endif %} {{ underlne_style_close|safe }}</td> + </tr> + {% endfor %} + <!-- End of a common text for prokura --> + {% endif %} + <!-- END Display prokurist --> + + <!-- Display sole shareholder --> + {% if row.jediny_akcionar|length > 0 %} + <tr> + <td>Jediný akcionář:</td> + <td></td> + <td></td> + </tr> + {% for i in range (row.jediny_akcionar|length) %} + <tr> + <td></td> + {% if row.jediny_akcionar[i].vymaz_datum != 0 %} + {% set underlne_style_open = undedrline_open_deleted %} + {% set underlne_style_close = undedrline_closed_deleted %} + {% else %} + {% set underlne_style_open = "" %} + {% set underlne_style_close = "" %} + {% endif %} + <td>{{ underlne_style_open|safe }} {% if row.jediny_akcionar[i].akcionar_po_id == None %} + {% if row.jediny_akcionar[i].jmeno.jmeno != "0" %}{{ row.jediny_akcionar[i].jmeno.jmeno }} {% endif %} + {{ row.jediny_akcionar[i].jmeno.prijmeni }}{% if row.jediny_akcionar[i].jmeno.datum_naroz != "" %}, nar. {{ row.jediny_akcionar[i].jmeno.datum_naroz }}{% endif %} {% endif %} + {% if row.jediny_akcionar[i].akcionar_fo_id == None %} {{ row.jediny_akcionar[i].oznaceni_po.nazev }}{% if row.jediny_akcionar[i].oznaceni_po.reg_cislo != 0 %}, reg č. {{ row.jediny_akcionar[i].oznaceni_po.reg_cislo }}{% endif %}{% if row.jediny_akcionar[i].oznaceni_po.ico != 0 %}, IČ <a href="/{{ row.jediny_akcionar[i].oznaceni_po.ico }}">{{ row.jediny_akcionar[i].oznaceni_po.ico }}</a>{% endif %} {% endif %} + <br>{{row.jediny_akcionar[i].adresa}} {{ underlne_style_close|safe }}</td> + <td>{{ underlne_style_open|safe }} Zapsáno: {{ row.jediny_akcionar[i].zapis_datum }} {% if row.jediny_akcionar[i].vymaz_datum != 0 %} <br> Vymazáno: {{ row.jediny_akcionar[i].vymaz_datum }} {% endif %} {{ underlne_style_close|safe }}</td> + </tr> + {% endfor %} + {% endif %} + <!-- END Display sole shareholder --> + + <!-- Display shareholders --> + {% if row.spolecnici|length > 0 %} + <tr> + <td>Společníci:</td> + <td></td> + <td></td> + </tr> + {% for i in range (row.spolecnici|length) %} + <tr> + <td style = padding-left:2em>Společník:</td> + {% if row.spolecnici[i].vymaz_datum != 0 %} + {% set underlne_style_open = undedrline_open_deleted %} + {% set underlne_style_close = undedrline_closed_deleted %} + {% else %} + {% set underlne_style_open = "" %} + {% set underlne_style_close = "" %} + {% endif %} + <td>{{ underlne_style_open|safe }} {% if row.spolecnici[i].spolecnik_po_id == None %} + {% if row.spolecnici[i].jmeno.jmeno != "0" %}{{ row.spolecnici[i].jmeno.jmeno }} {% endif %} + {{ row.spolecnici[i].jmeno.prijmeni }}{% if row.spolecnici[i].jmeno.datum_naroz != "" %}, nar. {{ row.spolecnici[i].jmeno.datum_naroz }}{% endif %} {% endif %} + {% if row.spolecnici[i].spolecnik_fo_id == None %} {{ row.spolecnici[i].oznaceni_po.nazev }}{% if row.spolecnici[i].oznaceni_po.reg_cislo != 0 %}, reg č. {{ row.spolecnici[i].oznaceni_po.reg_cislo }}{% endif %}{% if row.spolecnici[i].oznaceni_po.ico != 0 %}, IČ <a href="/{{ row.spolecnici[i].oznaceni_po.ico }}">{{ row.spolecnici[i].oznaceni_po.ico }}</a>{% endif %} {% endif %} + <br>{{row.spolecnici[i].adresa}} {{ underlne_style_close|safe }}</td> + <td>{{ underlne_style_open|safe }} Zapsáno: {{ row.spolecnici[i].zapis_datum }} {% if row.spolecnici[i].vymaz_datum != 0 %} <br> Vymazáno: {{ row.spolecnici[i].vymaz_datum }} {% endif %} {{ underlne_style_close|safe }}</td> + <!-- Insert individual ownership interests --> + {% if row.spolecnici[i].podily|length > 0 %} + + {% for j in range (row.spolecnici[i].podily|length) %} + <!-- Set type of deposit --> + {% if row.spolecnici[i].podily[j].vklad_typ == "KORUNY" %} + {% set vklad_typ_string = "Kč" %} + {% elif row.spolecnici[i].podily[j].vklad_typ == "EURA" %} + {% set vklad_typ_string = "Euro" %} + {% else %} + {% set vklad_typ_string = "" %} + {% endif %} + + <!-- Set type of repaid contribution --> + {% if row.spolecnici[i].podily[j].splaceni_typ == "KORUNY" %} + {% set splaceni_typ_string = "Kč" %} + {% elif row.spolecnici[i].podily[j].splaceni_typ == "PROCENTA" %} + {% set splaceni_typ_string = "%" %} + {% elif row.spolecnici[i].podily[j].splaceni_typ == "EURA" %} + {% set splaceni_typ_string = "Euro" %} + {% else %} + {% set splaceni_typ_string = "" %} + {% endif %} + + <!-- Set type of share --> + {% if row.spolecnici[i].podily[j].souhrn_typ == "PROCENTA" %} + {% set souhrn_typ_string = "%" %} + {% else %} + {% set souhrn_typ_string = "" %} + {% endif %} + + + <tr> + <td style = padding-left:4em>Podíl:</td> + {% if row.spolecnici[i].podily[j].vymaz_datum != 0 %} + {% set underlne_style_open = undedrline_open_deleted %} + {% set underlne_style_close = undedrline_closed_deleted %} + {% else %} + {% set underlne_style_open = "" %} + {% set underlne_style_close = "" %} + {% endif %} + <td>{{ underlne_style_open|safe }}Vklad: {{ row.spolecnici[i].podily[j].vklad_text }} {{ vklad_typ_string }}<br> + Splaceno: {{ row.spolecnici[i].podily[j].splaceni_text }} {{ splaceni_typ_string }}<br> + {% if row.spolecnici[i].podily[j].souhrn_text != "0"%}Podíl: {{ row.spolecnici[i].podily[j].souhrn_text }} {{ souhrn_typ_string }}{% endif %} + {% if row.spolecnici[i].podily[j].druh_podilu.druh_podilu != "0" %}<br>Druh podílu: {{ row.spolecnici[i].podily[j].druh_podilu.druh_podilu }}{% endif %}{{ underlne_style_close|safe }} + </td> + <td>{{ underlne_style_open|safe }}Zapsáno: {{ row.spolecnici[i].podily[j].zapis_datum }} {% if row.spolecnici[i].podily[j].vymaz_datum != 0 %}<br>Vymazáno: {{ row.spolecnici[i].podily[j].vymaz_datum }}{% endif %}{{ underlne_style_close|safe }}</td> + </tr> + {% endfor %} + {% endif %} + <!-- END of individual ownership interests --> + + </tr> + {% endfor %} + {% endif %} + <!-- END Display shareholders --> + + <!-- Display shares --> + {% if row.akcie|length > 0 %} + {% for i in range (row.akcie|length) %} + <tr> + <td>{% if i == 0%}Akcie:{% endif %}</td> + {% if row.akcie[i].vymaz_datum != 0 %} + {% set underlne_style_open = undedrline_open_deleted %} + {% set underlne_style_close = undedrline_closed_deleted %} + {% else %} + {% set underlne_style_open = "" %} + {% set underlne_style_close = "" %} + {% endif %} + + {% if row.akcie[i].akcie_podoba == "LISTINNA" %} + {% set akcie_podoba_description = "v listinné podobě" %} + {% elif row.akcie[i].akcie_podoba == "ZAKNIHOVANA" %} + {% set akcie_podoba_description = "v zaknihované podobě" %} + {% elif row.akcie[i].akcie_podoba == "IMOBILIZOVANA" %} + {% set akcie_podoba_description = "v imobilizované podobě" %} + {% else %} + {% set akcie_podoba_description = "" %} + {% endif %} + + {% if row.akcie[i].akcie_typ == "KMENOVE_NA_JMENO" %} + {% set akcie_typ_description = "kmenové akcie na jméno" %} + {% elif row.akcie[i].akcie_typ == "KMENOVE_NA_MAJITELE" %} + {% set akcie_typ_description = "kmenové akcie na majitele" %} + {% elif row.akcie[i].akcie_typ == "KUSOVE_NA_JMENO" %} + {% set akcie_typ_description = "kusové akcie" %} + {% elif row.akcie[i].akcie_typ == "NA_JMENO" %} + {% set akcie_typ_description = "akcie na jméno" %} + {% elif row.akcie[i].akcie_typ == "NA_MAJITELE" %} + {% set akcie_typ_description = "akcie na majitele" %} + {% elif row.akcie[i].akcie_typ == "PRIORITNI_NA_JMENO" %} + {% set akcie_typ_description = "prioritní akcie na jméno" %} + {% elif row.akcie[i].akcie_typ == "ZAMESTNANECKE_NA_JMENO" %} + {% set akcie_typ_description = "zaměstnanecké akcie na jméno" %} + {% elif row.akcie[i].akcie_typ == "ZVLASTNI_PRAVA" %} + {% set akcie_typ_description = "akcie se zvláštními právy" %} + {% else %} + {% set akcie_typ_description = "" %} + {% endif %} + + {% if row.akcie[i].akcie_hodnota_typ == "KORUNY" %} + {% set akcie_hodnota_typ_symbol = "Kč" %} + {% elif row.akcie[i].akcie_hodnota_typ == "EURA" %} + {% set akcie_hodnota_typ_symbol = "euro" %} + {% else %} + {% set akcie_hodnota_typ_symbol = "" %} + {% endif %} + + <td>{{ underlne_style_open|safe }} {{ row.akcie[i].akcie_pocet }} ks {{ akcie_typ_description }} {{ akcie_podoba_description }} ve jmenovité hodnotě {{ row.akcie[i].akcie_hodnota_value }} {{ akcie_hodnota_typ_symbol }} {% if row.akcie[i].akcie_text != "0" %} <br> {{ row.akcie[i].akcie_text }} {% endif %} {{ underlne_style_close|safe }}</td> + <td>{{ underlne_style_open|safe }} Zapsáno: {{ row.akcie[i].zapis_datum }} {% if row.akcie[i].vymaz_datum != 0 %} <br> Vymazáno: {{ row.akcie[i].vymaz_datum }} {% endif %} {{ underlne_style_close|safe }}</td> + </tr> + {% endfor %} + {% endif %} + <!-- END Display shares --> + + <!-- Description of insolvency event --> + {% if row.insolvence|length > 0 %} + {% for i in range (row.insolvence|length) %} + <tr> + <td>{% if i == 0%}Údaje o insolvencích:{% endif %}</td> + {% if row.insolvence[i].vymaz_datum != 0 %} + {% set underlne_style_open = undedrline_open_deleted %} + {% set underlne_style_close = undedrline_closed_deleted %} + {% else %} + {% set underlne_style_open = "" %} + {% set underlne_style_close = "" %} + {% endif %} + <td>{{ underlne_style_open|safe }} {{ row.insolvence[i].insolvency_event }} {{ underlne_style_close|safe }}</td> + <td>{{ underlne_style_open|safe }} Zapsáno: {{ row.insolvence[i].zapis_datum }} {% if row.insolvence[i].vymaz_datum != 0 %} <br> Vymazáno: {{ row.insolvence[i].vymaz_datum }} {% endif %} {{ underlne_style_close|safe }}</td> + </tr> + {% endfor %} + {% endif %} + <!-- END Description of insolvency event --> + +<!-- Description of bankruptcy event --> + {% if row.konkurz|length > 0 %} + {% for i in range (row.konkurz|length) %} + <tr> + <td>{% if i == 0%}Údaje o konkurzech:{% endif %}</td> + {% if row.konkurz[i].vymaz_datum != 0 %} + {% set underlne_style_open = undedrline_open_deleted %} + {% set underlne_style_close = undedrline_closed_deleted %} + {% else %} + {% set underlne_style_open = "" %} + {% set underlne_style_close = "" %} + {% endif %} + <td>{{ underlne_style_open|safe }} {{ row.konkurz[i].konkurz_event }} {{ underlne_style_close|safe }}</td> + <td>{{ underlne_style_open|safe }} Zapsáno: {{ row.konkurz[i].zapis_datum }} {% if row.konkurz[i].vymaz_datum != 0 %} <br> Vymazáno: {{ row.konkurz[i].vymaz_datum }} {% endif %} {{ underlne_style_close|safe }}</td> + </tr> + {% endfor %} + {% endif %} +<!-- END Description of bankruptcy event --> + +<!-- Insert other information --> + {% if row.ostatni_skutecnosti|length > 0 %} + {% for i in range (row.ostatni_skutecnosti|length) %} + <tr> + <td>{% if i == 0%}Ostatní skutečnosti:{% endif %}</td> + {% if row.ostatni_skutecnosti[i].vymaz_datum != 0 %} + {% set underlne_style_open = undedrline_open_deleted %} + {% set underlne_style_close = undedrline_closed_deleted %} + {% else %} + {% set underlne_style_open = "" %} + {% set underlne_style_close = "" %} + {% endif %} + <td>{{ underlne_style_open|safe }} {{ row.ostatni_skutecnosti[i].ostatni_skutecnost }} {{ underlne_style_close|safe }}</td> + <td>{{ underlne_style_open|safe }} Zapsáno: {{ row.ostatni_skutecnosti[i].zapis_datum }} {% if row.ostatni_skutecnosti[i].vymaz_datum != 0 %} <br> Vymazáno: {{ row.ostatni_skutecnosti[i].vymaz_datum }} {% endif %} {{ underlne_style_close|safe }}</td> + </tr> + {% endfor %} + {% endif %} +<!-- END Insert other information --> +</table> + +{% endfor %} + +{% if results|length == 0 %} +<p>Nothing found here. <a href = "/">Back to search.</a></p> +{% endif %} + +{% include 'footer.html' %}
\ No newline at end of file diff --git a/templates/results2.html b/templates/results2.html index b7de3fc..edef06a 100644 --- a/templates/results2.html +++ b/templates/results2.html @@ -6,59 +6,17 @@ {% for row in results %} {% set insolvency_notes = [] %} - {% for elem in row.insolvence %} - {% set insolvency_notes = insolvency_notes.append(elem.insolvency_event) %} + {% for i in range (row.insolvence|length) %} + {% if row.insolvence[i].vymaz_datum == 0 %} + {% set insolvency_notes = insolvency_notes.append(row.insolvence[i].insolvency_event) %} + {% endif %} {% endfor %} - - {% set zapis_split = row.zapis.split("-") %} - {% if zapis_split[1] == "01" %} - {% set mesic = "ledna" %} - {% elif zapis_split[1] == "02" %} - {% set mesic = "února" %} - {% elif zapis_split[1] == "03" %} - {% set mesic = "března" %} - {% elif zapis_split[1] == "04" %} - {% set mesic = "dubna" %} - {% elif zapis_split[1] == "05" %} - {% set mesic = "května" %} - {% elif zapis_split[1] == "06" %} - {% set mesic = "června" %} - {% elif zapis_split[1] == "07" %} - {% set mesic = "července" %} - {% elif zapis_split[1] == "08" %} - {% set mesic = "srpna" %} - {% elif zapis_split[1] == "09" %} - {% set mesic = "září" %} - {% elif zapis_split[1] == "10" %} - {% set mesic = "října" %} - {% elif zapis_split[1] == "11" %} - {% set mesic = "listopadu" %} - {% elif zapis_split[1] == "12" %} - {% set mesic = "prosince" %} - {% endif %} - - {% if zapis_split[2][0] == "0" %} - {% set den = zapis_split[2][1] %} - {% else %} - {% set den = zapis_split[2] %} - {% endif %} - - {% if row.soud == "MSPH" %} - {% set soud = "Městského soudu v Praze" %} - {% elif row.soud == "KSCB" %} - {% set soud = "Krajského soudu v Českých Budějovicích" %} - {% elif row.soud == "KSOS" %} - {% set soud = "Krajského soudu v Ostravě" %} - {% elif row.soud == "KSPL" %} - {% set soud = "Krajského soudu v Plzni" %} - {% elif row.soud == "KSBR" %} - {% set soud = "Krajského soudu v Brně" %} - {% elif row.soud == "KSHK" %} - {% set soud = "Krajského soudu v Hradci Králové" %} - {% elif row.soud == "KSUL" %} - {% set soud = "Krajského soudu v Ústí nad Labem" %} - {% endif %} - + {% for i in range (row.konkurz|length) %} + {% if row.konkurz[i].vymaz_datum == 0 %} + {% set insolvency_notes = insolvency_notes.append(row.konkurz[i].konkurz_event) %} + {% endif %} + {% endfor %} + {% if insolvency_notes|length > 0 %} {% set table_style = "table table-danger" %} {% elif loop.index % 2 == 0 %} @@ -76,10 +34,16 @@ {% else %} {% set ico_buffer = "" %} {% endif %} - - - + {% set current_seat = [] %} + {% for i in range (row.sidlo_text|length) %} + {% if row.sidlo_text[i].vymaz_datum == 0 %} + {% set current_seat = current_seat.append(row.sidlo_text[i]) %} + {% endif %} + {% endfor %} + + + <table class= "{{table_style}}" style="width: 100%"> <p></p> <tr> @@ -90,16 +54,18 @@ </tr> <tr> <td>Spisová značka:</td> - <td>{{ row.oddil }} {{ row.vlozka }} vedená u {{ soud }}</td> + <!-- <td>{{ oddil|join("") }} {{ vlozka|join("") }} vedená u {{ soud|join("") }}</td> --> + <td>{{row.oddil}} {{row.vlozka}} vedená u {{row.soud}}</td> <td>Den zápisu:</td> - <td>{{den}}. {{mesic}} {{zapis_split[0]}}</td> + <td>{{row.zapis}}</td> </tr> <tr> <td>Sídlo:</td> - <td>{{ row.sidlo }}</td> - <td></td> - <td></td> + <td>{{ current_seat[0].sidlo_text }} </td> + <td><a href="/{{ row.ico }}">Úplný výpis</a></td> + <td><a href="/{{ row.ico }}-actual">Aktuální výpis</a></td> </tr> + {% if insolvency_notes|length > 0 %} {% for i in range (insolvency_notes|length) %} <tr> diff --git a/templates/search_form.html b/templates/search_form.html index cd483e2..1832f87 100644 --- a/templates/search_form.html +++ b/templates/search_form.html @@ -23,7 +23,7 @@ {{ form.nazev_subjektu.label }} </div> <div class="col-sm"> - {{ form.nazev_subjektu()|safe }} {{ form.nazev_subjektu_selection }} + {{ form.nazev_subjektu()|safe }} {{ form.nazev_subjektu_selection }} {{ form.nazev_search_actual }} </div> </div> @@ -41,7 +41,7 @@ {{ form.obec_search.label }} </div> <div class="col-sm"> - {{ form.obec_search()|safe }} {{ form.obec_search_selection }} + {{ form.obec_search()|safe }} {{ form.obec_search_selection }} {{ form.obec_search_actual }} </div> </div> @@ -50,7 +50,7 @@ {{ form.ulice_search.label }} </div> <div class="col-sm"> - {{ form.ulice_search()|safe }} {{ form.ulice_search_selection }} + {{ form.ulice_search()|safe }} {{ form.ulice_search_selection }} {{ form.ulice_search_actual }} </div> </div> @@ -59,7 +59,7 @@ {{ form.oddil_search.label }} </div> <div class="col-sm"> - {{ form.oddil_search()|safe }} {{ form.oddil_search_selection }} + {{ form.oddil_search()|safe }} {{ form.oddil_search_selection }} {{ form.oddil_search_actual }} </div> </div> @@ -68,15 +68,28 @@ {{ form.vlozka_search.label }} </div> <div class="col-sm"> - {{ form.vlozka_search()|safe }} {{ form.vlozka_search_selection }} + {{ form.vlozka_search()|safe }} {{ form.vlozka_search_selection }} {{ form.vlozka_search_actual }} </div> </div> + <div class="row g-2"> - {{ render_field(form.pravni_forma_search) }} + <div class="col-sm-3"> + {{ form.pravni_forma_search.label }} + </div> + <div class="col-sm"> + {{ form.pravni_forma_search()|safe }} {{ form.pravni_forma_actual }} + </div> </div> + <div class="row g-2"> - {{ render_field(form.soud_search) }} + <div class="col-sm-3"> + {{ form.soud_search.label }} + </div> + <div class="col-sm"> + {{ form.soud_search()|safe }} {{ form.soud_search_actual }} + </div> </div> + <div class="row g-2"> {{ render_field(form.insolvent_only_search) }} </div> diff --git a/templates/search_parser.html b/templates/search_parser.html new file mode 100644 index 0000000..569812c --- /dev/null +++ b/templates/search_parser.html @@ -0,0 +1,72 @@ +{% set insolvency_notes = [] %} +{% for elem in row.insolvence %} + {% set insolvency_notes = insolvency_notes.append(elem.insolvency_event) %} +{% endfor %} + +{% set zapis_split = row.zapis.split("-") %} +{% if zapis_split[1] == "01" %} + {% set mesic = "ledna" %} +{% elif zapis_split[1] == "02" %} + {% set mesic = "února" %} +{% elif zapis_split[1] == "03" %} + {% set mesic = "března" %} +{% elif zapis_split[1] == "04" %} + {% set mesic = "dubna" %} +{% elif zapis_split[1] == "05" %} + {% set mesic = "května" %} +{% elif zapis_split[1] == "06" %} + {% set mesic = "června" %} +{% elif zapis_split[1] == "07" %} + {% set mesic = "července" %} +{% elif zapis_split[1] == "08" %} + {% set mesic = "srpna" %} +{% elif zapis_split[1] == "09" %} + {% set mesic = "září" %} +{% elif zapis_split[1] == "10" %} + {% set mesic = "října" %} +{% elif zapis_split[1] == "11" %} + {% set mesic = "listopadu" %} +{% elif zapis_split[1] == "12" %} + {% set mesic = "prosince" %} +{% endif %} + +{% if zapis_split[2][0] == "0" %} + {% set den = zapis_split[2][1] %} +{% else %} + {% set den = zapis_split[2] %} +{% endif %} + +{% if row.soud == "MSPH" %} + {% set soud = "Městského soudu v Praze" %} +{% elif row.soud == "KSCB" %} + {% set soud = "Krajského soudu v Českých Budějovicích" %} +{% elif row.soud == "KSOS" %} + {% set soud = "Krajského soudu v Ostravě" %} +{% elif row.soud == "KSPL" %} + {% set soud = "Krajského soudu v Plzni" %} +{% elif row.soud == "KSBR" %} + {% set soud = "Krajského soudu v Brně" %} +{% elif row.soud == "KSHK" %} + {% set soud = "Krajského soudu v Hradci Králové" %} +{% elif row.soud == "KSUL" %} + {% set soud = "Krajského soudu v Ústí nad Labem" %} +{% endif %} + +{% if insolvency_notes|length > 0 %} + {% set table_style = "table table-danger" %} +{% elif loop.index % 2 == 0 %} + {% set table_style = "table table-light" %} +{% else %} + {% set table_style = "table table-secondary" %} +{% endif %} + +{% if row.ico|length != 8 %} + {% set ico_buffer = [] %} + {% for i in range (8 - row.ico|length) %} + {% set ico_buffer = ico_buffer.append("0") %} + {% endfor %} + +{% else %} + {% set ico_buffer = "" %} +{% endif %} + diff --git a/todolist.html b/todolist.html new file mode 100644 index 0000000..8b83207 --- /dev/null +++ b/todolist.html @@ -0,0 +1,8 @@ +<ol> + <li>Add a feature to display legal entities as members of corporate bodies.</li> + <li>Add a feature to display other types of ownerhsip interests (joint onwership interest, vacant ownership interest).</li> + <li>Refactor excessive duplications in the main code.</li> + <li>Add some other minor data to the databases - especially those relating to non-profit companies.</li> + <li>Check how to make diacritics work in searches.</li> + <li>Write some documentation :)</li> +</ol>
\ No newline at end of file diff --git a/update_db.py b/update_db.py new file mode 100644 index 0000000..1dcb09a --- /dev/null +++ b/update_db.py @@ -0,0 +1,623 @@ +from datetime import datetime +import os +from lxml import etree +import sqlite3 + +def update_DB(typy_po, soudy, DB_name): + rok = str(datetime.now().year) + for osoba in typy_po: + for soud in soudy: + try: + parse_to_DB(os.path.join(str(os.getcwd()), "data", osoba) + "-full-" + soud + "-" + rok + ".xml", DB_name) + except: + pass + +# The function opens a file and parses the extracted data into the database +def parse_to_DB(file, DB_name): + print("Processing ", str(file)) + conn = sqlite3.connect(DB_name) + c = conn.cursor() + for event, element in etree.iterparse(file, tag="Subjekt"): + # Bugfix for companies which have been deleted but appear in the list of existing companies + if ([element.find('vymazDatum')][0]) != None: + continue + else: + ICO = get_ICO(element) + # Vlozit prazdny radek s ICO + insert_new_ICO(c, ICO, conn, element) + primary_sql_key = get_primary_sql_key(c, ICO) + # Vlozit jednolive parametry + insert_company_relations(c, ICO, element, conn, primary_sql_key) + find_other_properties(c, ICO, element, conn, primary_sql_key) + element.clear() + conn.commit() + conn.close() + return 0 + +def get_ICO(element): + try: + return element.find('ico').text + except: + return "00000000" + +# Function to attempt to insert a placeholder for a new company based on ICO +def insert_new_ICO(c, ICO, conn, element): + try: + datum_zapis = str(get_prop(element, "zapisDatum")) + nazev = str(get_prop(element, "nazev")) + c.execute("INSERT INTO companies (ico, zapis, nazev) VALUES (?,?,?);", (ICO,datum_zapis,nazev,)) + return c.lastrowid + except: + pass + +def get_primary_sql_key(c, ICO): + try: + primary_key = c.execute("SELECT id FROM companies WHERE ico = (?)", (ICO,)) + primary_key = c.fetchone() + return primary_key[0] + except: + return 0 + +def insert_company_relations(c, ICO, element, conn, primary_sql_key): + insert_instructions = [(".//udaje/Udaj/pravniForma/nazev","pravni_formy", "pravni_forma", "pravni_formy_relation")] + for elem in insert_instructions: + insert_individual_relations(c, ICO, element, conn, primary_sql_key, elem) + return 0 + +def insert_individual_relations(c, ICO, element, conn, primary_sql_key, elem): + inserted_figure = str(get_prop(element, elem[0])) + insert_into_ancillary_table(c, elem, inserted_figure) + ancillary_table_key = get_anciallary_table_key(c, elem, inserted_figure) + insert_relation_information(c, elem, primary_sql_key, ancillary_table_key) + return ancillary_table_key + +def insert_relation_information(c, elem, primary_sql_key, ancillary_table_key): + try: + c.execute("INSERT INTO " + elem[3] + " VALUES(?, ?)", (primary_sql_key, ancillary_table_key,)) + except: + pass + return 0 + + +def find_other_properties(c, ICO, element, conn, primary_sql_key): + try: + # my_iter = element.iter("udaje") + my_iter = element.findall("udaje") + for elem in my_iter: + # my_iter2 = elem.iter("Udaj") + my_iter2 = elem.findall("Udaj") + for elem2 in my_iter2: + udajTyp_name = str(get_prop(elem2, ".//udajTyp/kod")) + if udajTyp_name == "SIDLO": + find_registered_office(c, ICO, elem2, conn, primary_sql_key, element) + elif udajTyp_name == "NAZEV": + find_nazev(c, ICO, elem2, conn, primary_sql_key, element) + elif udajTyp_name == "SPIS_ZN": + find_sp_zn(c, ICO, elem2, conn, primary_sql_key, element) + elif udajTyp_name == "PRAVNI_FORMA": + find_pravni_forma(c, ICO, elem2, conn, primary_sql_key, element) + elif udajTyp_name == "STATUTARNI_ORGAN": + find_statutar(c, ICO, elem2, conn, primary_sql_key, element) + elif udajTyp_name == "SPOLECNIK": + find_spolecnik(c, ICO, elem2, conn, primary_sql_key, element) + elif udajTyp_name == "PREDMET_PODNIKANI_SEKCE": + find_predmet_podnikani(c, ICO, elem2, conn, primary_sql_key, element) + elif udajTyp_name == "PREDMET_CINNOSTI_SEKCE": + find_predmet_cinnosti(c, ICO, elem2, conn, primary_sql_key, element) + elif udajTyp_name == "ZAKLADNI_KAPITAL": + find_zakladni_kapital(c, ICO, elem2, conn, primary_sql_key, element) + elif udajTyp_name == "OST_SKUTECNOSTI_SEKCE": + find_ostatni_skutecnosti(c, ICO, elem2, conn, primary_sql_key, element) + elif udajTyp_name == "AKCIE_SEKCE": + find_akcie(c, ICO, elem2, conn, primary_sql_key, element) + elif udajTyp_name == "DOZORCI_RADA": + find_dozorci_rada(c, ICO, elem2, conn, primary_sql_key, element) + elif udajTyp_name == "PROKURA": + find_prokura(c, ICO, elem2, conn, primary_sql_key, element) + elif udajTyp_name == "AKCIONAR_SEKCE": + find_sole_shareholder(c, ICO, elem2, conn, primary_sql_key, element) + elif udajTyp_name == "INSOLVENCE_SEKCE": + find_insolvency(c, ICO, elem2, conn, primary_sql_key) + elif udajTyp_name == "KONKURS_SEKCE": + find_konkurz(c, ICO, elem2, conn, primary_sql_key) + except: + pass + +def find_registered_office(c, ICO, elem2, conn, primary_sql_key, element): + try: + zapis_datum = str(get_prop(elem2, ".//zapisDatum")) + vymaz_datum = str(get_prop(elem2, ".//vymazDatum")) + sidlo_id = sidlo3(c, elem2, primary_sql_key) + insert_instructions = [None,"adresy", "adresa_text", "sidlo_relation"] + insert_relation_information_v2(c, insert_instructions, primary_sql_key, sidlo_id, zapis_datum, vymaz_datum) + except Exception as f: + print(f) + +def find_nazev(c, ICO, elem2, conn, primary_sql_key, element): + try: + zapis_datum = str(get_prop(elem2, ".//zapisDatum")) + vymaz_datum = str(get_prop(elem2, ".//vymazDatum")) + nazev = str(get_prop(elem2, ".//hodnotaText")) + c.execute("INSERT INTO nazvy (company_id, zapis_datum, vymaz_datum, nazev_text) VALUES(?, ?, ?, ?)", (primary_sql_key, zapis_datum, vymaz_datum, nazev,)) + except: + pass + +def find_sp_zn(c, ICO, elem2, conn, primary_sql_key, element): + try: + zapis_datum = str(get_prop(elem2, ".//zapisDatum")) + vymaz_datum = str(get_prop(elem2, ".//vymazDatum")) + soud = str(get_prop(elem2, ".//spisZn/soud/kod")) + oddil = str(get_prop(elem2, ".//spisZn/oddil")) + vlozka = str(get_prop(elem2, ".//spisZn/vlozka")) + c.execute("INSERT INTO zapis_soudy (company_id, zapis_datum, vymaz_datum, oddil, vlozka, soud) VALUES(?, ?, ?, ?, ?, ?)", (primary_sql_key, zapis_datum, vymaz_datum, oddil, vlozka, soud,)) + if vymaz_datum == "0": + c.execute("UPDATE companies SET oddil = (?), vlozka = (?), soud = (?) WHERE id = (?)",(oddil,vlozka,soud,primary_sql_key,)) + except: + pass + +def find_pravni_forma(c, ICO, elem2, conn, primary_sql_key, element): + try: + zapis_datum = str(get_prop(elem2, ".//zapisDatum")) + vymaz_datum = str(get_prop(elem2, ".//vymazDatum")) + pravni_forma = str(get_prop(elem2, ".//pravniForma/nazev")) + insert_instructions = [(pravni_forma,"pravni_formy", "pravni_forma", "pravni_formy_relation")] + for elem in insert_instructions: + insert_into_ancillary_table(c, elem, pravni_forma) + ancillary_table_key = get_anciallary_table_key(c, elem, pravni_forma) + insert_relation_information_v2(c, elem, primary_sql_key, ancillary_table_key, zapis_datum, vymaz_datum) + except: + pass + +def find_statutar(c, ICO, elem2, conn, primary_sql_key, element): + try: + zapis_datum = str(get_prop(elem2, "zapisDatum")) + vymaz_datum = str(get_prop(elem2, "vymazDatum")) + oznaceni_statutar_organu = str(get_prop(elem2, ".//hlavicka")) + insert_instructions = [(oznaceni_statutar_organu,"statutarni_organy", "statutarni_organ_text", "statutarni_organ_relation")] + for elem in insert_instructions: + insert_into_ancillary_table(c, elem, oznaceni_statutar_organu) + ancillary_table_key = get_anciallary_table_key(c, elem, oznaceni_statutar_organu) + insert_relation_information_v2(c, elem, primary_sql_key, ancillary_table_key, zapis_datum, vymaz_datum) + relationship_table_key = get_relationship_table_key(c, primary_sql_key, ancillary_table_key) + my_iter = elem2.findall("podudaje/Udaj") + for elem in my_iter: + udajTyp_name = str(get_prop(elem, "udajTyp/kod")) + if udajTyp_name == "POCET_CLENU": + find_pocet_clenu(c, ICO, elem, conn, relationship_table_key, element) + elif udajTyp_name == "ZPUSOB_JEDNANI": + find_zpusob_jednani(c, ICO, elem, conn, relationship_table_key, element) + elif udajTyp_name == "STATUTARNI_ORGAN_CLEN": + find_clen_statut_org(c, ICO, elem, conn, relationship_table_key, element) + else: + # print(str(get_prop(elem, "udajTyp/kod"))) + pass + except Exception as f: + print(f) + +def find_spolecnik(c, ICO, elem2, conn, primary_sql_key, element): + try: + my_iter = elem2.findall("podudaje/Udaj") + for elem in my_iter: + spolecnik_type = str(get_prop(elem, "udajTyp/kod")) + zapis_datum = str(get_prop(elem, "zapisDatum")) + vymaz_datum = str(get_prop(elem, "vymazDatum")) + spolecnik_typ = str(get_prop(elem, "hodnotaUdaje/typ")) + # TODO Chech these conditions, they sometimes cause a person not being stored (IC 27650081) + # if spolecnik_type == "SPOLECNIK_OSOBA" and spolecnik_oznaceni == "Společník": + if spolecnik_type == "SPOLECNIK_OSOBA" and spolecnik_typ == "OSOBA": + # TODO alternativy pro None, Spolecny podil a Uvolneny podil + text_spolecnik = str(get_prop(elem, "hodnotaUdaje/textZaOsobu/value")) + nazev = str(get_prop(elem, "osoba/nazev")) + # TODO Fix - make reference to type of person - some foreign persons have no ico or regCo, so they are assigned a number for a natural person + # if spol_ico == "0" and regCislo == "0": + if nazev == "0": + # I probably do not need the primary sql key + spolecnik_fo_id = find_fyzicka_osoba(c, ICO, elem, conn, primary_sql_key, element) + # adresa_id = find_and_store_address(c, elem) + adresa_id = sidlo3(c, elem, primary_sql_key) + c.execute("INSERT INTO spolecnici (company_id, spolecnik_fo_id, zapis_datum, vymaz_datum, adresa_id, text_spolecnik) VALUES (?, ?, ?, ?, ?, ?)", (primary_sql_key, spolecnik_fo_id, zapis_datum, vymaz_datum, adresa_id, text_spolecnik,)) + c.execute ("SELECT last_insert_rowid()") + spolecnik_id = c.fetchone()[0] + # print(ICO, spolecnik_fo_id, adresa_id) + else: + spol_ico = str(get_prop(elem, "osoba/ico")) + regCislo = str(get_prop(elem, "osoba/regCislo")) + spolecnik_po_id = find_pravnicka_osoba(c, elem, spol_ico, regCislo) + # adresa_id = find_and_store_address(c, elem) + adresa_id = sidlo3(c, elem, primary_sql_key) + c.execute("INSERT INTO spolecnici (company_id, spolecnik_po_id, zapis_datum, vymaz_datum, adresa_id, text_spolecnik) VALUES (?, ?, ?, ?, ?, ?)", (primary_sql_key, spolecnik_po_id, zapis_datum, vymaz_datum, adresa_id, text_spolecnik,)) + c.execute ("SELECT last_insert_rowid()") + spolecnik_id = c.fetchone()[0] + insert_podily(c, elem, spolecnik_id) + except Exception as f: + print(f) + +def find_predmet_podnikani(c, ICO, predmet_podnikani_elem, conn, primary_sql_key, element): + try: + my_iter = predmet_podnikani_elem.findall("podudaje") + for elem in my_iter: + my_iter2 = elem.iter("Udaj") + for elem2 in my_iter2: + zapis_datum = str(get_prop(elem2, ".//zapisDatum")) + vymaz_datum = str(get_prop(elem2, ".//vymazDatum")) + insert_instructions = [(".//hodnotaText","predmety_podnikani", "predmet_podnikani", "predmety_podnikani_relation")] + for elem in insert_instructions: + inserted_figure = str(get_prop(elem2, ".//hodnotaText")) + insert_into_ancillary_table(c, elem, inserted_figure) + ancillary_table_key = get_anciallary_table_key(c, elem, inserted_figure) + insert_relation_information_v2(c, elem, primary_sql_key, ancillary_table_key, zapis_datum, vymaz_datum) + except: + pass + +def find_predmet_cinnosti(c, ICO, predmet_cinnosti_elem, conn, primary_sql_key, element): + try: + my_iter = predmet_cinnosti_elem.findall("podudaje") + for elem in my_iter: + my_iter2 = elem.iter("Udaj") + for elem2 in my_iter2: + zapis_datum = str(get_prop(elem2, ".//zapisDatum")) + vymaz_datum = str(get_prop(elem2, ".//vymazDatum")) + insert_instructions = [(".//hodnotaText","predmety_cinnosti", "predmet_cinnosti", "predmety_cinnosti_relation")] + for elem in insert_instructions: + inserted_figure = str(get_prop(elem2, ".//hodnotaText")) + insert_into_ancillary_table(c, elem, inserted_figure) + ancillary_table_key = get_anciallary_table_key(c, elem, inserted_figure) + insert_relation_information_v2(c, elem, primary_sql_key, ancillary_table_key, zapis_datum, vymaz_datum) + except: + pass + +def find_zakladni_kapital(c, ICO, elem2, conn, primary_sql_key, element): + try: + zapis_datum = str(get_prop(elem2, ".//zapisDatum")) + vymaz_datum = str(get_prop(elem2, ".//vymazDatum")) + vklad_typ = str(get_prop(elem2, ".//hodnotaUdaje/vklad/typ")) + vklad_hodnota = str(get_prop(elem2, ".//hodnotaUdaje/vklad/textValue")) + splaceni_typ = str(get_prop(elem2, ".//hodnotaUdaje/splaceni/typ")) + splaceni_hodnota = str(get_prop(elem2, ".//hodnotaUdaje/splaceni/textValue")) + c.execute("INSERT INTO zakladni_kapital (company_id, zapis_datum, vymaz_datum, vklad_typ, vklad_hodnota, splaceni_typ, splaceni_hodnota) VALUES(?, ?, ?, ?, ?, ?, ?)", (primary_sql_key, zapis_datum, vymaz_datum, vklad_typ, vklad_hodnota, splaceni_typ, splaceni_hodnota,)) + except: + pass + +def find_ostatni_skutecnosti(c, ICO, ostatni_skutecnosti_elem, conn, primary_sql_key, element): + try: + my_iter = ostatni_skutecnosti_elem.findall("podudaje") + for elem in my_iter: + my_iter2 = elem.iter("Udaj") + for elem2 in my_iter2: + zapis_datum = str(get_prop(elem2, ".//zapisDatum")) + vymaz_datum = str(get_prop(elem2, ".//vymazDatum")) + inserted_figure = str(get_prop(elem2, ".//hodnotaText")) + c.execute("INSERT INTO ostatni_skutecnosti (company_id, zapis_datum, vymaz_datum, ostatni_skutecnost) VALUES(?, ?, ?, ?)", (primary_sql_key, zapis_datum, vymaz_datum, inserted_figure,)) + except: + pass + +def find_akcie(c, ICO, ostatni_akcie_elem, conn, primary_sql_key, element): + try: + my_iter = ostatni_akcie_elem.findall("podudaje") + for elem in my_iter: + my_iter2 = elem.iter("Udaj") + for elem2 in my_iter2: + zapis_datum = str(get_prop(elem2, ".//zapisDatum")) + vymaz_datum = str(get_prop(elem2, ".//vymazDatum")) + akcie_podoba = str(get_prop(elem2, ".//hodnotaUdaje/podoba")) + akcie_typ = str(get_prop(elem2, ".//hodnotaUdaje/typ")) + akcie_pocet = str(get_prop(elem2, ".//hodnotaUdaje/pocet")) + akcie_hodnota_typ = str(get_prop(elem2, ".//hodnotaUdaje/hodnota/typ")) + akcie_hodnota_value = str(get_prop(elem2, ".//hodnotaUdaje/hodnota/textValue")) + akcie_text = str(get_prop(elem2, ".//hodnotaUdaje/text")) + c.execute("INSERT INTO akcie (company_id, zapis_datum, vymaz_datum, akcie_podoba, akcie_typ, akcie_pocet, akcie_hodnota_typ, akcie_hodnota_value, akcie_text) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)", (primary_sql_key, zapis_datum, vymaz_datum, akcie_podoba, akcie_typ, akcie_pocet, akcie_hodnota_typ, akcie_hodnota_value,akcie_text,)) + except: + pass + +def find_dozorci_rada(c, ICO, elem2, conn, primary_sql_key, element): + try: + zapis_datum = str(get_prop(elem2, "zapisDatum")) + vymaz_datum = str(get_prop(elem2, "vymazDatum")) + c.execute("INSERT into dozorci_rada_relation (company_id, zapis_datum, vymaz_datum) VALUES (?, ?, ?)", (primary_sql_key, zapis_datum, vymaz_datum,)) + c.execute("SELECT id FROM dozorci_rada_relation WHERE company_id = (?) and zapis_datum = (?)", (primary_sql_key,zapis_datum,)) + relationship_table_key = c.fetchone()[0] + my_iter = elem2.findall("podudaje/Udaj") + for elem in my_iter: + udajTyp_name = str(get_prop(elem, "udajTyp/kod")) + if udajTyp_name == "POCET_CLENU_DOZORCI_RADA": + find_pocet_clenu_dr(c, ICO, elem, conn, relationship_table_key, element) + elif udajTyp_name == "DOZORCI_RADA_CLEN": + find_clen_dr(c, ICO, elem, conn, relationship_table_key, element) + # find_clen_dr(c, ICO, elem, conn, relationship_table_key, element) + except Exception as f: + print(f) + +def find_prokura(c, ICO, elem2, conn, primary_sql_key, element): + try: + my_iter = elem2.findall("podudaje/Udaj") + for elem in my_iter: + typ_zapis = str(get_prop(elem, "udajTyp/kod")) + if typ_zapis == "PROKURA_OSOBA": + zapis_datum = str(get_prop(elem, "zapisDatum")) + vymaz_datum = str(get_prop(elem, "vymazDatum")) + text_prokurista = str(get_prop(elem, "hodnotaUdaje/textZaOsobu/value")) + prokurista_fo_id = find_fyzicka_osoba(c, ICO, elem, conn, primary_sql_key, element) + # adresa_id = find_and_store_address(c, elem) + adresa_id = sidlo3(c, elem, primary_sql_key) + c.execute("INSERT INTO prokuriste (company_id, zapis_datum, vymaz_datum, prokurista_fo_id, adresa_id, text_prokurista) VALUES (?, ?, ?, ?, ?, ?)", (primary_sql_key, zapis_datum, vymaz_datum, prokurista_fo_id, adresa_id, text_prokurista,)) + else: + zapis_datum = str(get_prop(elem, "zapisDatum")) + vymaz_datum = str(get_prop(elem, "vymazDatum")) + prokura_text = str(get_prop(elem, "hodnotaText")) + c.execute("INSERT INTO prokura_common_texts (company_id, zapis_datum, vymaz_datum, prokura_text) VALUES (?, ?, ?, ?)", (primary_sql_key, zapis_datum, vymaz_datum, prokura_text,)) + except Exception as f: + print(f) + +def find_sole_shareholder(c, ICO, elem2, conn, primary_sql_key, element): + try: + my_iter = elem2.findall("podudaje/Udaj") + for elem in my_iter: + zapis_datum = str(get_prop(elem, "zapisDatum")) + vymaz_datum = str(get_prop(elem, "vymazDatum")) + text_akcionar = str(get_prop(elem, "hodnotaUdaje/textZaOsobu/value")) + typ_akcionar = str(get_prop(elem, "hodnotaUdaje/T")) + if typ_akcionar == "P": + spol_ico = str(get_prop(elem, "osoba/ico")) + regCislo = str(get_prop(elem, "osoba/regCislo")) + akcionar_po_id = find_pravnicka_osoba(c, elem, spol_ico, regCislo) + # adresa_id = find_and_store_address(c, elem) + adresa_id = sidlo3(c, elem, primary_sql_key) + c.execute("INSERT into jediny_akcionar (company_id, zapis_datum, vymaz_datum, text_akcionar, akcionar_po_id, adresa_id) VALUES (?, ?, ?, ?, ?, ?)", (primary_sql_key, zapis_datum, vymaz_datum, text_akcionar, akcionar_po_id, adresa_id,)) + elif typ_akcionar == "F": + akcionar_fo_id = find_fyzicka_osoba(c, ICO, elem, conn, primary_sql_key, element) + # adresa_id = find_and_store_address(c, elem) + adresa_id = sidlo3(c, elem, primary_sql_key) + c.execute("INSERT into jediny_akcionar (company_id, zapis_datum, vymaz_datum, text_akcionar, akcionar_fo_id, adresa_id) VALUES (?, ?, ?, ?, ?, ?)", (primary_sql_key, zapis_datum, vymaz_datum, text_akcionar, akcionar_fo_id, adresa_id,)) + except Exception as f: + print(f) + +def find_insolvency(c, ICO, insolvency_elem, conn, primary_sql_key): + try: + my_iter = insolvency_elem.findall("podudaje") + for elem in my_iter: + my_iter2 = elem.iter("Udaj") + for elem2 in my_iter2: + insolvency_text = str(get_prop(elem2, ".//text")) + zapis_datum = str(get_prop(elem2, ".//zapisDatum")) + vymaz_datum = str(get_prop(elem2, ".//vymazDatum")) + if insolvency_text != "0": + try: + c.execute("INSERT INTO insolvency_events (company_id, zapis_datum, vymaz_datum, insolvency_event) VALUES(?, ?, ?, ?)", (primary_sql_key, zapis_datum, vymaz_datum, insolvency_text,)) + except: + pass + except: + pass + +def find_konkurz(c, ICO, konkurz_elem, conn, primary_sql_key): + try: + my_iter = konkurz_elem.findall("podudaje") + for elem in my_iter: + my_iter2 = elem.iter("Udaj") + for elem2 in my_iter2: + konkurz_text = str(get_prop(elem2, ".//text")) + zapis_datum = str(get_prop(elem2, ".//zapisDatum")) + vymaz_datum = str(get_prop(elem2, ".//vymazDatum")) + if konkurz_text != "0": + try: + c.execute("INSERT INTO konkurz_events (company_id, zapis_datum, vymaz_datum, konkurz_event) VALUES(?, ?, ?, ?)", (primary_sql_key, zapis_datum, vymaz_datum, konkurz_text,)) + except: + pass + except: + pass + +def sidlo3(c, elem, primary_sql_key): + try: + statNazev = get_prop(elem, ".//statNazev") + obec = get_prop(elem, ".//obec") + ulice = get_prop(elem, ".//ulice") + castObce = get_prop(elem, ".//castObce") + cisloPo = get_prop(elem, ".//cisloPo") + cisloOr = get_prop(elem, ".//cisloOr") + psc = get_prop(elem, ".//psc") + okres = get_prop(elem, ".//okres") + adresaText = get_prop(elem, ".//adresaText") + cisloEv = get_prop(elem, ".//cisloEv") + cisloText = get_prop(elem, ".//cisloText") + c.execute("SELECT * FROM adresy_v2 WHERE stat = (?) and obec = (?) and ulice = (?) and castObce = (?) and cisloPo = (?) and cisloOr = (?) and psc = (?) and okres = (?) and komplet_adresa = (?) and cisloEv = (?) and cisloText = (?)", (statNazev, obec, ulice, castObce, cisloPo, cisloOr, psc, okres, adresaText, cisloEv, cisloText,)) + sidlo_id = c.fetchone() + if sidlo_id == None: + c.execute("INSERT INTO adresy_v2 (stat, obec, ulice, castObce, cisloPo, cisloOr, psc, okres, komplet_adresa, cisloEv, cisloText) VALUES (?,?,?,?,?,?,?,?,?,?,?)", (statNazev, obec, ulice, castObce, cisloPo, cisloOr, psc, okres, adresaText, cisloEv, cisloText)) + address_key = c.lastrowid + else: + address_key = sidlo_id[0] + return address_key + # print(address_key) + except Exception as e: + print(e) + +def insert_relation_information_v2(c, elem, primary_sql_key, ancillary_table_key, zapis_datum, vymaz_datum): + try: + c.execute("INSERT INTO " + elem[3] + " VALUES(NULL, ?, ?, ?, ?)", (primary_sql_key, ancillary_table_key,zapis_datum, vymaz_datum,)) + except Exception as f: + print(f) + return 0 + +def insert_into_ancillary_table(c, elem, inserted_figure): + try: + c.execute("INSERT INTO " + elem[1] + "(" + elem[2] + ") VALUES(?)", (inserted_figure,)) + except: + pass + +def get_anciallary_table_key(c, elem, inserted_figure): + try: + anciallary_table_key = c.execute("SELECT id FROM " + elem[1] + " WHERE " + elem[2] + " = (?)", (inserted_figure,)) + anciallary_table_key = c.fetchone()[0] + return anciallary_table_key + except Exception as f: + print(f) + +def get_relationship_table_key(c, primary_sql_key, ancillary_table_key): + c.execute("SELECT id FROM statutarni_organ_relation WHERE company_id = (?) and statutarni_organ_id = (?)", (primary_sql_key,ancillary_table_key,)) + return c.fetchone()[0] + +def find_pocet_clenu(c, ICO, elem, conn, relationship_table_key, element): + try: + zapis_datum = str(get_prop(elem, "zapisDatum")) + vymaz_datum = str(get_prop(elem, "vymazDatum")) + pocet_clenu_number = str(get_prop(elem, "hodnotaText")) + c.execute("INSERT into pocty_clenu_organu (organ_id, pocet_clenu_value, zapis_datum, vymaz_datum) VALUES (?,?,?,?)", (relationship_table_key, pocet_clenu_number, zapis_datum, vymaz_datum,)) + except Exception as f: + print(f) + +def find_zpusob_jednani(c, ICO, elem, conn, relationship_table_key, element): + try: + zapis_datum = str(get_prop(elem, "zapisDatum")) + vymaz_datum = str(get_prop(elem, "vymazDatum")) + zpusob_jednani = str(get_prop(elem, "hodnotaText")) + insert_instructions = [(zpusob_jednani,"zpusoby_jednani", "zpusob_jednani_text", "zpusoby_jednani_relation")] + for elem in insert_instructions: + insert_into_ancillary_table(c, elem, zpusob_jednani) + ancillary_table_key = get_anciallary_table_key(c, elem, zpusob_jednani) + insert_relation_information_v2(c, elem, relationship_table_key, ancillary_table_key, zapis_datum, vymaz_datum) + except Exception as f: + print(f) + +def find_clen_statut_org(c, ICO, elem, conn, relationship_table_key, element): + try: + zapis_datum = str(get_prop(elem, "zapisDatum")) + vymaz_datum = str(get_prop(elem, "vymazDatum")) + funkce_statutar_organu = str(get_prop(elem, "funkce")) + typ_osoby = str(get_prop(elem, "hodnotaText")) + funkceOd = str(get_prop(elem, "funkceOd")) + clenstviOd = str(get_prop(elem, "clenstviOd")) + funkceDo = str(get_prop(elem, "funkceDo")) + clenstviDo = str(get_prop(elem, "clenstviDo")) + if typ_osoby == "AngazmaFyzicke": + osoba_id = find_fyzicka_osoba(c, ICO, elem, conn, relationship_table_key, element) + # adresa_id = find_and_store_address(c, elem) + adresa_id = sidlo3(c, elem, relationship_table_key) + c.execute("INSERT into statutarni_organ_clen_relation (statutarni_organ_id, osoba_id, adresa_id, zapis_datum, vymaz_datum, funkce_od, funkce_do, clenstvi_od, clenstvi_do, funkce) VALUES (?,?,?,?,?,?,?,?,?,?)", (relationship_table_key, osoba_id, adresa_id, zapis_datum, vymaz_datum, funkceOd, funkceDo, clenstviOd, clenstviDo, funkce_statutar_organu,)) + except Exception as f: + print(f) + +def insert_individual_relations_v2(c, ICO, conn, primary_sql_key, zapis_datum, vymaz_datum, hodnota_text): + insert_into_ancillary_table(c, elem, inserted_figure) + return 0 + +def find_fyzicka_osoba(c, ICO, elem, conn, relationship_table_key, element): + try: + jmeno = str(get_prop(elem, "osoba/jmeno")) + prijmeni = str(get_prop(elem, "osoba/prijmeni")) + datum_narozeni = str(get_prop(elem, "osoba/narozDatum")) + titulPred = str(get_prop(elem, "osoba/titulPred")) + titulZa = str(get_prop(elem, "osoba/titulZa")) + insert_fyzicka_osoba(c, titulPred, jmeno, prijmeni, titulZa, datum_narozeni) + osoba_id = find_osoba_id(c, titulPred, jmeno, prijmeni, titulZa, datum_narozeni) + return osoba_id + except: + pass + +def insert_fyzicka_osoba(c, titulPred, jmeno, prijmeni, titulZa, datum_narozeni): + try: + c.execute("INSERT into fyzicke_osoby (titul_pred, jmeno, prijmeni, titul_za, datum_naroz) VALUES (?,?,?,?,?)", (titulPred, jmeno, prijmeni, titulZa, datum_narozeni,)) + except: + pass + +def find_osoba_id(c, titulPred, jmeno, prijmeni, titulZa, datum_narozeni): + try: + anciallary_table_key = c.execute("SELECT id FROM fyzicke_osoby WHERE titul_pred = (?) and jmeno = (?) and prijmeni = (?) and titul_za = (?) and datum_naroz = (?)", (titulPred, jmeno, prijmeni, titulZa, datum_narozeni,)) + anciallary_table_key = c.fetchone()[0] + return anciallary_table_key + except Exception as f: + print(f) + +def find_pravnicka_osoba(c, elem, spol_ico, regCislo): + try: + nazev = str(get_prop(elem, "osoba/nazev")) + insert_pravnicka_osoba(c, elem, spol_ico, regCislo, nazev) + osoba_id = find_pravnicka_osoba_id(c, spol_ico, regCislo, nazev) + return osoba_id + except Exception as f: + print(f) + +def find_pocet_clenu_dr(c, ICO, elem, conn, relationship_table_key, element): + try: + zapis_datum = str(get_prop(elem, "zapisDatum")) + vymaz_datum = str(get_prop(elem, "vymazDatum")) + pocet_clenu_number = str(get_prop(elem, "hodnotaText")) + c.execute("INSERT into pocty_clenu_DR (organ_id, pocet_clenu_value, zapis_datum, vymaz_datum) VALUES (?,?,?,?)", (relationship_table_key, pocet_clenu_number, zapis_datum, vymaz_datum,)) + except Exception as f: + print(f) + +def find_clen_dr(c, ICO, elem, conn, relationship_table_key, element): + try: + zapis_datum = str(get_prop(elem, "zapisDatum")) + vymaz_datum = str(get_prop(elem, "vymazDatum")) + funkce_statutar_organu = str(get_prop(elem, "funkce")) + typ_osoby = str(get_prop(elem, "hodnotaText")) + funkceOd = str(get_prop(elem, "funkceOd")) + clenstviOd = str(get_prop(elem, "clenstviOd")) + funkceDo = str(get_prop(elem, "funkceDo")) + clenstviDo = str(get_prop(elem, "clenstviDo")) + if typ_osoby == "AngazmaFyzicke": + osoba_id = find_fyzicka_osoba(c, ICO, elem, conn, relationship_table_key, element) + # adresa_id = find_and_store_address(c, elem) + adresa_id = sidlo3(c, elem, relationship_table_key) + c.execute("INSERT into dr_organ_clen_relation (dozorci_rada_id, osoba_id, adresa_id, zapis_datum, vymaz_datum, funkce_od, funkce_do, clenstvi_od, clenstvi_do, funkce) VALUES (?,?,?,?,?,?,?,?,?,?)", (relationship_table_key, osoba_id, adresa_id, zapis_datum, vymaz_datum, funkceOd, funkceDo, clenstviOd, clenstviDo, funkce_statutar_organu,)) + except Exception as f: + print(f) + +def insert_podily(c, elem, spolecnik_id): + try: + podil_iter = elem.findall("podudaje/Udaj") + for podil_elem in podil_iter: + zapisDatum = str(get_prop(podil_elem, "zapisDatum")) + vymazDatum = str(get_prop(podil_elem, "vymazDatum")) + druh_podilu_id = get_druh_podilu_id(c, podil_elem) + vklad_typ = str(get_prop(podil_elem, "hodnotaUdaje/vklad/typ")) + vklad_text = str(get_prop(podil_elem, "hodnotaUdaje/vklad/textValue")) + souhrn_typ = str(get_prop(podil_elem, "hodnotaUdaje/souhrn/typ")) + souhrn_text = str(get_prop(podil_elem, "hodnotaUdaje/souhrn/textValue")) + splaceni_typ = str(get_prop(podil_elem, "hodnotaUdaje/splaceni/typ")) + splaceni_text = str(get_prop(podil_elem, "hodnotaUdaje/splaceni/textValue")) + c.execute("INSERT INTO podily (spolecnik_id, zapis_datum, vymaz_datum, druh_podilu_id, vklad_typ, vklad_text, souhrn_typ, souhrn_text, splaceni_typ, splaceni_text) VALUES (?,?,?,?,?,?,?,?,?,?)", (spolecnik_id, zapisDatum, vymazDatum, druh_podilu_id, vklad_typ, vklad_text, souhrn_typ, souhrn_text, splaceni_typ, splaceni_text,)) + except Exception as f: + print(f) + +def get_druh_podilu_id(c, podil_elem): + try: + druhPodilu = str(get_prop(podil_elem, "hodnotaUdaje/druhPodilu")) + insert_druh_podilu(c, podil_elem, druhPodilu) + druh_podilu_id = find_druh_podilu_id(c, druhPodilu) + return druh_podilu_id + except Exception as f: + print(f) + +def insert_druh_podilu(c, podil_elem, druhPodilu): + try: + c.execute("INSERT INTO druhy_podilu (druh_podilu) VALUES (?)", (druhPodilu,)) + except: + pass + +def find_druh_podilu_id(c, druhPodilu): + try: + druh_podilu_id = c.execute("SELECT id FROM druhy_podilu WHERE druh_podilu = (?)", (druhPodilu,)) + druh_podilu_id = c.fetchone()[0] + return druh_podilu_id + except Exception as f: + print(f) + +def find_pravnicka_osoba_id(c, spol_ico, regCislo, nazev): + try: + anciallary_table_key = c.execute("SELECT id FROM pravnicke_osoby WHERE ico = (?) and reg_cislo = (?) and nazev = (?)", (spol_ico, regCislo, nazev,)) + anciallary_table_key = c.fetchone()[0] + return anciallary_table_key + except Exception as f: + print(f) + +def insert_pravnicka_osoba(c, elem, spol_ico, regCislo, nazev): + try: + c.execute("INSERT into pravnicke_osoby (ico, reg_cislo, nazev) VALUES (?,?,?)", (spol_ico, regCislo, nazev,)) + except: + pass + +def get_prop(element, prop): + try: + return element.find(prop).text + except: + return "0"
\ No newline at end of file |