mirror of
https://github.com/fhswf/aki_prj23_transparenzregister.git
synced 2025-04-25 00:22:34 +02:00
checkpoint: First iteration of fixed mapping
This commit is contained in:
parent
9d7bb07989
commit
2d9e3f19f9
@ -63,13 +63,20 @@ def parse_date_of_birth(data: dict) -> str | None:
|
||||
Returns:
|
||||
str | None: date of birth or None if not found
|
||||
"""
|
||||
if "tns:geburt" in (base := data["tns:beteiligter"]["tns:auswahl_beteililgter"]["tns:natuerlichePerson"]):
|
||||
if "tns:geburt" in (base := data["tns:beteiligter"]["tns:auswahl_beteiligter"]["tns:natuerlichePerson"]):
|
||||
base = base["tns:geburt"]["tns:geburtsdatum"]
|
||||
if isinstance(base, str):
|
||||
return base
|
||||
return None
|
||||
|
||||
# def map_role_id_to_enum(role_id: str) -> RelationshipRoleEnum:
|
||||
def map_role_id_to_enum(role_id: str) -> RelationshipRoleEnum:
|
||||
match role_id:
|
||||
case "086":
|
||||
return RelationshipRoleEnum.GESCHAEFTSFUEHRER
|
||||
case "285":
|
||||
return RelationshipRoleEnum.PROKURIST
|
||||
case _:
|
||||
raise KeyError(f'Uknown role_id: {role_id}')
|
||||
|
||||
|
||||
def parse_stakeholder(data: dict) -> CompanyRelationship | None:
|
||||
@ -138,8 +145,8 @@ def parse_stakeholder(data: dict) -> CompanyRelationship | None:
|
||||
}
|
||||
),
|
||||
# TODO get role via ID
|
||||
"role": RelationshipRoleEnum(
|
||||
data["Rolle"]["Rollenbezeichnung"]["content"]
|
||||
"role": map_role_id_to_enum(
|
||||
data["tns:rolle"]["tns:rollenbezeichnung"]["code"]
|
||||
),
|
||||
"type": CompanyRelationshipEnum.PERSON,
|
||||
}
|
||||
@ -606,13 +613,13 @@ def map_unternehmensregister_json(data: dict) -> Company:
|
||||
result["founding_date"] = map_founding_date(data)
|
||||
|
||||
# TODO adapt...
|
||||
# for i in range(
|
||||
# 2, len(data["tns:grunddaten"]["tns:verfahrensdaten"]["tns:beteiligung"])
|
||||
# ):
|
||||
# people = parse_stakeholder(
|
||||
# data["tns:grunddaten"]["tns:verfahrensdaten"]["tns:beteiligung"][i]
|
||||
# )
|
||||
# result["relationships"].append(people)
|
||||
for i in range(
|
||||
2, len(data["tns:grunddaten"]["tns:verfahrensdaten"]["tns:beteiligung"])
|
||||
):
|
||||
people = parse_stakeholder(
|
||||
data["tns:grunddaten"]["tns:verfahrensdaten"]["tns:beteiligung"][i]
|
||||
)
|
||||
result["relationships"].append(people)
|
||||
result = map_co_relation(result)
|
||||
return Company(**result)
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user