aboutsummaryrefslogtreecommitdiffstats
path: root/update_db.py
diff options
context:
space:
mode:
Diffstat (limited to 'update_db.py')
-rw-r--r--update_db.py28
1 files changed, 25 insertions, 3 deletions
diff --git a/update_db.py b/update_db.py
index 43dac45..df844f6 100644
--- a/update_db.py
+++ b/update_db.py
@@ -239,9 +239,11 @@ def find_spolecnik(c, ICO, elem2, conn, primary_sql_key, element):
spolecnik_id = c.fetchone()[0]
insert_podily(c, elem, spolecnik_id)
elif spolecnik_kod == "SPOLECNIK_OSOBA" and spolecnik_typ == "SPOLECNY_PODIL":
- pass
- # text_spolecnik = str(get_prop(elem, "hodnotaUdaje/textZaOsobu/value"))
- # print(text_spolecnik)
+ text_spolecny_podil = str(get_prop(elem, "hodnotaUdaje/textZaOsobu/value"))
+ c.execute("INSERT INTO spolecnici_spolecny_podil (company_id, zapis_datum, vymaz_datum, text_spolecny_podil) VALUES (?, ?, ?, ?)", (primary_sql_key, zapis_datum, vymaz_datum, text_spolecny_podil,))
+ c.execute ("SELECT last_insert_rowid()")
+ uvolneny_op_id = c.fetchone()[0]
+ insert_common_podily(c, elem, uvolneny_op_id)
elif spolecnik_kod == "SPOLECNIK_OSOBA" and spolecnik_typ == "UVOLNENY_PODIL":
text_uvolneny_podil = str(get_prop(elem, "hodnotaUdaje/textZaOsobu/value"))
c.execute("INSERT INTO spolecnici_uvolneny_podil (company_id, zapis_datum, vymaz_datum, text_uvolneny_podil) VALUES (?, ?, ?, ?)", (primary_sql_key, zapis_datum, vymaz_datum, text_uvolneny_podil,))
@@ -618,6 +620,7 @@ def find_clen_dr(c, ICO, elem, conn, relationship_table_key, element):
except Exception as f:
print(f)
+# TODO MERGE THESE THREE FUNCTIONS INTO ONE
def insert_podily(c, elem, spolecnik_id):
try:
podil_iter = elem.findall("podudaje/Udaj")
@@ -652,6 +655,25 @@ def insert_vacant_podily(c, elem, vacant_id):
except Exception as f:
print(f)
+def insert_common_podily(c, elem, common_id):
+ try:
+ podil_iter = elem.findall("podudaje/Udaj")
+ for podil_elem in podil_iter:
+ if str(get_prop(podil_elem, "udajTyp/kod")) == "SPOLECNIK_PODIL":
+ 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 (spolecny_podil_id, zapis_datum, vymaz_datum, druh_podilu_id, vklad_typ, vklad_text, souhrn_typ, souhrn_text, splaceni_typ, splaceni_text) VALUES (?,?,?,?,?,?,?,?,?,?)", (common_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"))