|
@@ -1,7 +1,7 @@
|
|
|
-from datetime import timedelta, date
|
|
|
|
|
|
|
+import re
|
|
|
|
|
+from datetime import date, timedelta
|
|
|
|
|
|
|
|
from db import get_session
|
|
from db import get_session
|
|
|
-import re
|
|
|
|
|
from sqlalchemy import text
|
|
from sqlalchemy import text
|
|
|
|
|
|
|
|
|
|
|
|
@@ -25,6 +25,46 @@ def main():
|
|
|
db.commit()
|
|
db.commit()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+def get_details_from_comments():
|
|
|
|
|
+ db = next(get_session())
|
|
|
|
|
+ q = db.execute(text("SELECT * FROM dbo.Forderungen_Kommentar_Rohdaten"))
|
|
|
|
|
+
|
|
|
|
|
+ for row in q.fetchall():
|
|
|
|
|
+ data = {}
|
|
|
|
|
+
|
|
|
|
|
+ az = re.search(r"^AZ\:?\s(\d+\/\d+)", row.Kommentar)
|
|
|
|
|
+ if az:
|
|
|
|
|
+ data["Rechtsanwalt_Aktenzeichen"] = az[1]
|
|
|
|
|
+
|
|
|
|
|
+ if "HP Schaden" in row.Kommentar:
|
|
|
|
|
+ data["Versicherung_Typ"] = "Haftpflicht"
|
|
|
|
|
+ if "Haftpflicht" in row.Kommentar:
|
|
|
|
|
+ data["Versicherung_Typ"] = "Haftpflicht"
|
|
|
|
|
+ if "VK Schaden" in row.Kommentar:
|
|
|
|
|
+ data["Versicherung_Typ"] = "Vollkasko"
|
|
|
|
|
+ if "VK-Schaden" in row.Kommentar:
|
|
|
|
|
+ data["Versicherung_Typ"] = "Vollkasko"
|
|
|
|
|
+ if "TK Schaden" in row.Kommentar:
|
|
|
|
|
+ data["Versicherung_Typ"] = "Teilkasko"
|
|
|
|
|
+ if "TK-Schaden" in row.Kommentar:
|
|
|
|
|
+ data["Versicherung_Typ"] = "Teilkasko"
|
|
|
|
|
+
|
|
|
|
|
+ s = re.search(r"Schaden (.*) bei (.*) eingereicht", row.Kommentar)
|
|
|
|
|
+ if s:
|
|
|
|
|
+ data["Schadennummer"] = s[1]
|
|
|
|
|
+ data["Vers_Adresse_ID"] = s[2].replace("'", "").lower()[:25]
|
|
|
|
|
+
|
|
|
|
|
+ if data:
|
|
|
|
|
+ db.execute(
|
|
|
|
|
+ text(
|
|
|
|
|
+ "UPDATE dbo.Forderungen_Details SET "
|
|
|
|
|
+ + ", ".join([f"{k} = '{v}'" for k, v in data.items()])
|
|
|
|
|
+ + f" WHERE Client_DB = '{row.Client_DB}' AND Beleg_Nr = '{row.Beleg_Nr}'"
|
|
|
|
|
+ )
|
|
|
|
|
+ )
|
|
|
|
|
+ db.commit()
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
def get_date_and_user_from_comment(r: str) -> tuple[date, str]:
|
|
def get_date_and_user_from_comment(r: str) -> tuple[date, str]:
|
|
|
m = re.search(r"(\d\d\.\d\d?)\.?[\/\s](\w+)", r)
|
|
m = re.search(r"(\d\d\.\d\d?)\.?[\/\s](\w+)", r)
|
|
|
if m:
|
|
if m:
|
|
@@ -41,4 +81,4 @@ def get_date_and_user_from_comment(r: str) -> tuple[date, str]:
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
if __name__ == "__main__":
|
|
|
- main()
|
|
|
|
|
|
|
+ get_details_from_comments()
|