Firmenbuch (JustizOnline HVD): register numbers and politicians' company functions

- firmenbuch.search: register number for companies linked to people/parties, only for
  one current register entry with the same name
- firmenbuch.extracts: current extracts; officers/shareholders who are politicians in
  the database (exact birth date + name, new person hint birth_date) become company_role
  claims; nobody else is stored, raw responses are not archived, addresses never read;
  the register's daily change list triggers re-extracts
- enrich.firmenbuch closes roles a newer extract no longer lists
- Request.data (raw body, part of the fingerprint); SOAP faults are not retried
- firmenbuch_number drops leading zeros; migration 0009 adds company_role and aligns
  stored numbers; internal politrack_org ids are no longer stored as identifiers
- company_role in API types, MCP docs, person money tab, connections, labels

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
simonandClaude Opus 5.5 committed 2026-11-19 11:33:01 +01:00
1 parent 68be25a953
commit 10c677ca70
30 files changed
+597 -20

No files matched your search

+16
View File
@@ -27,6 +27,7 @@
{
"__type__": "Request",
"conditional": true,
"data": null,
"headers": null,
"json": null,
"kind": "mep",
@@ -45,6 +46,7 @@
{
"__type__": "Request",
"conditional": true,
"data": null,
"headers": null,
"json": null,
"kind": "declarations",
@@ -89,6 +91,7 @@
{
"__type__": "Request",
"conditional": true,
"data": null,
"headers": null,
"json": null,
"kind": "mep",
@@ -107,6 +110,7 @@
{
"__type__": "Request",
"conditional": true,
"data": null,
"headers": null,
"json": null,
"kind": "declarations",
@@ -151,6 +155,7 @@
{
"__type__": "Request",
"conditional": true,
"data": null,
"headers": null,
"json": null,
"kind": "mep",
@@ -169,6 +174,7 @@
{
"__type__": "Request",
"conditional": true,
"data": null,
"headers": null,
"json": null,
"kind": "declarations",
@@ -213,6 +219,7 @@
{
"__type__": "Request",
"conditional": true,
"data": null,
"headers": null,
"json": null,
"kind": "mep",
@@ -231,6 +238,7 @@
{
"__type__": "Request",
"conditional": true,
"data": null,
"headers": null,
"json": null,
"kind": "declarations",
@@ -275,6 +283,7 @@
{
"__type__": "Request",
"conditional": true,
"data": null,
"headers": null,
"json": null,
"kind": "mep",
@@ -293,6 +302,7 @@
{
"__type__": "Request",
"conditional": true,
"data": null,
"headers": null,
"json": null,
"kind": "declarations",
@@ -337,6 +347,7 @@
{
"__type__": "Request",
"conditional": true,
"data": null,
"headers": null,
"json": null,
"kind": "mep",
@@ -355,6 +366,7 @@
{
"__type__": "Request",
"conditional": true,
"data": null,
"headers": null,
"json": null,
"kind": "declarations",
@@ -399,6 +411,7 @@
{
"__type__": "Request",
"conditional": true,
"data": null,
"headers": null,
"json": null,
"kind": "mep",
@@ -417,6 +430,7 @@
{
"__type__": "Request",
"conditional": true,
"data": null,
"headers": null,
"json": null,
"kind": "declarations",
@@ -461,6 +475,7 @@
{
"__type__": "Request",
"conditional": true,
"data": null,
"headers": null,
"json": null,
"kind": "mep",
@@ -479,6 +494,7 @@
{
"__type__": "Request",
"conditional": true,
"data": null,
"headers": null,
"json": null,
"kind": "declarations",
@@ -2,6 +2,7 @@
{
"__type__": "Request",
"conditional": true,
"data": null,
"headers": null,
"json": null,
"kind": "results",
@@ -22,6 +23,7 @@
{
"__type__": "Request",
"conditional": true,
"data": null,
"headers": null,
"json": null,
"kind": "results",
@@ -2,6 +2,7 @@
{
"__type__": "Request",
"conditional": true,
"data": null,
"headers": null,
"json": null,
"kind": "decisions",
@@ -2,6 +2,7 @@
{
"__type__": "Request",
"conditional": true,
"data": null,
"headers": null,
"json": null,
"kind": "immunity_report",
@@ -663,6 +663,7 @@
{
"__type__": "Request",
"conditional": true,
"data": null,
"headers": null,
"json": {
"PAD_INTERN": [
@@ -682,6 +683,7 @@
{
"__type__": "Request",
"conditional": true,
"data": null,
"headers": null,
"json": {
"PAD_INTERN": [
@@ -9,6 +9,7 @@
{
"__type__": "Request",
"conditional": false,
"data": null,
"headers": null,
"json": null,
"kind": "wayback",
+120
View File
@@ -0,0 +1,120 @@
"""Firmenbuch HVD parsers, on responses shaped like the real service (November 2026). The private co-director of
the real extract is replaced by a fictional person and the address is removed."""
from datetime import date
import pytest
from politrack.core import RunContext
from politrack.core.adapter import Request, StateStore
from politrack.sources import firmenbuch as F
from politrack.text import firmenbuch_number
NSDECL = ('xmlns:env="http://www.w3.org/2003/05/soap-envelope" '
'xmlns:ns6="ns://firmenbuch.justiz.gv.at/Abfrage/v2/AuszugResponse" '
'xmlns:ns14="ns://firmenbuch.justiz.gv.at/Abfrage/SucheFirmaResponse" '
'xmlns:ns9="ns://firmenbuch.justiz.gv.at/Abfrage/VeraenderungenFirmaResponse"')
EXTRACT = f"""<env:Envelope {NSDECL}><env:Header/><env:Body>
<ns6:AUSZUG_V2_RESPONSE ns6:FNR="306527 a" ns6:STICHTAG="2026-11-18" ns6:UMFANG="Kurzinformation">
<ns6:FIRMA>
<ns6:FI_DKZ02 ns6:AUFRECHT="false" ns6:VNR="000"><ns6:BEZEICHNUNG>Alter Name GmbH</ns6:BEZEICHNUNG></ns6:FI_DKZ02>
<ns6:FI_DKZ02 ns6:AUFRECHT="true" ns6:VNR="001"><ns6:BEZEICHNUNG>25 PersonaldienstleistungsgesmbH</ns6:BEZEICHNUNG>
</ns6:FI_DKZ02>
<ns6:FI_DKZ03 ns6:AUFRECHT="true" ns6:VNR="001"><ns6:STRASSE>Musterstraße</ns6:STRASSE><ns6:PLZ>1</ns6:PLZ>
</ns6:FI_DKZ03>
<ns6:FI_DKZ06 ns6:AUFRECHT="true" ns6:VNR="001"><ns6:SITZ>Salzburg</ns6:SITZ></ns6:FI_DKZ06>
<ns6:FI_DKZ07 ns6:AUFRECHT="true" ns6:VNR="001"><ns6:RECHTSFORM><ns6:CODE>GES</ns6:CODE>
<ns6:TEXT>Gesellschaft mit beschränkter Haftung</ns6:TEXT></ns6:RECHTSFORM></ns6:FI_DKZ07>
</ns6:FIRMA>
<ns6:FUN ns6:FKEN="GF" ns6:FKENTEXT="GESCHÄFTSFÜHRER/IN (handelsrechtlich)" ns6:PNR=" A">
<ns6:FU_DKZ10 ns6:AUFRECHT="true" ns6:VNR="001"><ns6:DATVON>20080215</ns6:DATVON>
<ns6:TEXT>vertritt seit 15.02.2008 selbständig</ns6:TEXT></ns6:FU_DKZ10></ns6:FUN>
<ns6:FUN ns6:FKEN="GF" ns6:FKENTEXT="GESCHÄFTSFÜHRER/IN (handelsrechtlich)" ns6:PNR=" C">
<ns6:FU_DKZ10 ns6:AUFRECHT="true" ns6:VNR="001"><ns6:DATVON>20080215</ns6:DATVON>
<ns6:TEXT>vertritt seit 15.02.2008 selbständig</ns6:TEXT></ns6:FU_DKZ10></ns6:FUN>
<ns6:FUN ns6:FKEN="GS" ns6:FKENTEXT="GESELLSCHAFTER/IN" ns6:PNR=" D">
<ns6:FU_DKZ10 ns6:AUFRECHT="true" ns6:VNR="002"><ns6:KAPITAL>35000</ns6:KAPITAL><ns6:WHR>EUR</ns6:WHR>
</ns6:FU_DKZ10></ns6:FUN>
<ns6:FUN ns6:FKEN="PR" ns6:FKENTEXT="PROKURIST/IN" ns6:PNR=" E">
<ns6:FU_DKZ10 ns6:AUFRECHT="false" ns6:VNR="001"><ns6:DATVON>20090101</ns6:DATVON></ns6:FU_DKZ10></ns6:FUN>
<ns6:PER ns6:PNR=" A"><ns6:PE_DKZ02 ns6:AUFRECHT="true" ns6:VNR="001"><ns6:VORNAME>Max</ns6:VORNAME>
<ns6:NACHNAME>Muster</ns6:NACHNAME><ns6:GEBURTSDATUM>19700101</ns6:GEBURTSDATUM></ns6:PE_DKZ02></ns6:PER>
<ns6:PER ns6:PNR=" C"><ns6:PE_DKZ02 ns6:AUFRECHT="true" ns6:VNR="003"><ns6:VORNAME>Tanja</ns6:VORNAME>
<ns6:NACHNAME>Graf</ns6:NACHNAME><ns6:GEBURTSDATUM>19750507</ns6:GEBURTSDATUM></ns6:PE_DKZ02></ns6:PER>
<ns6:PER ns6:PNR=" D"><ns6:PE_DKZ02 ns6:AUFRECHT="true" ns6:VNR="002">
<ns6:BEZEICHNUNG>Muster Holding GmbH</ns6:BEZEICHNUNG></ns6:PE_DKZ02></ns6:PER>
<ns6:PER ns6:PNR=" E"><ns6:PE_DKZ02 ns6:AUFRECHT="true" ns6:VNR="001"><ns6:VORNAME>Eva</ns6:VORNAME>
<ns6:NACHNAME>Ehemalig</ns6:NACHNAME><ns6:GEBURTSDATUM>19800202</ns6:GEBURTSDATUM></ns6:PE_DKZ02></ns6:PER>
</ns6:AUSZUG_V2_RESPONSE></env:Body></env:Envelope>""".encode()
SEARCH = f"""<env:Envelope {NSDECL}><env:Header/><env:Body><ns14:SUCHEFIRMARESPONSE>
<ns14:ERGEBNIS><ns14:FNR>068616g</ns14:FNR><ns14:STATUS/><ns14:NAME>Salzburger Parkgaragen Gesellschaft</ns14:NAME>
<ns14:NAME>m.b.H.</ns14:NAME><ns14:SITZ>Salzburg</ns14:SITZ><ns14:RECHTSFORM><ns14:CODE>GES</ns14:CODE>
<ns14:TEXT>Gesellschaft mit beschränkter Haftung</ns14:TEXT></ns14:RECHTSFORM></ns14:ERGEBNIS>
<ns14:ERGEBNIS><ns14:FNR>1a</ns14:FNR><ns14:STATUS>gelöscht</ns14:STATUS>
<ns14:NAME>Salzburger Parkgaragen Gesellschaft m.b.H.</ns14:NAME></ns14:ERGEBNIS>
<ns14:ERGEBNIS><ns14:FNR>2b</ns14:FNR><ns14:STATUS/><ns14:NAME>Salzburger Parkgaragen Betriebs GmbH</ns14:NAME>
</ns14:ERGEBNIS></ns14:SUCHEFIRMARESPONSE></env:Body></env:Envelope>""".encode()
FAULT = b"""<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"><env:Body><env:Fault>
<env:Code><env:Value>env:Receiver</env:Value></env:Code><env:Reason>
<env:Text xml:lang="de-AT">Der Parameter "UMFANG" fehlt oder ist ung\xc3\xbcltig</env:Text></env:Reason>
</env:Fault></env:Body></env:Envelope>"""
def test_register_numbers_are_normalised_without_leading_zeros():
assert firmenbuch_number("068616g") == firmenbuch_number("FN 68616 G") == "68616g"
assert firmenbuch_number("0a") is None
assert F.fn_display("306527a") == "306527 a"
def test_extract_reads_current_functions_but_no_addresses():
company = F.parse_extract(EXTRACT)
assert (company["fn"], company["name"], company["seat"], company["legal_form"], company["as_of"]) == (
"306527a", "25 PersonaldienstleistungsgesmbH", "Salzburg", "Gesellschaft mit beschränkter Haftung", "2026-11-18")
assert "Musterstraße" not in repr(company)
funcs = {f["pnr"]: f for f in company["functions"]}
assert set(funcs) == {"A", "C", "D"} # E's function has ended (AUFRECHT=false)
assert (funcs["C"]["given"], funcs["C"]["surname"], funcs["C"]["birth_date"], funcs["C"]["since"]) == (
"Tanja", "Graf", date(1975, 5, 7), date(2008, 2, 15))
assert funcs["C"]["label"] == "Geschäftsführer/in (handelsrechtlich)"
assert funcs["D"]["organization"] == "Muster Holding GmbH" and funcs["D"]["capital"] == 35000.0
def test_extract_records_match_people_only_by_birth_date():
ctx = RunContext(adapter="firmenbuch.extracts", spec=F.SPEC, state=StateStore(None, "firmenbuch.extracts"))
records = list(F.FirmenbuchExtracts().records(ctx, F.parse_extract(EXTRACT), "306527a"))
claims = [r for r in records if getattr(r, "claim_type", None) == "company_role"]
assert len(claims) == 2 and ctx.stats["officers_not_persons"] == 1
graf = next(c for c in claims if c.person.name == "Tanja Graf")
assert graf.person.hints == {"birth_date": date(1975, 5, 7), "no_name_match": True}
assert graf.summary_de == "Tanja Graf: Geschäftsführer/in (handelsrechtlich) bei 25 PersonaldienstleistungsgesmbH"
assert graf.summary_en == "Tanja Graf: managing director of 25 PersonaldienstleistungsgesmbH"
assert graf.key == ("firmenbuch", "306527a", "GF", "C") and graf.valid_from == date(2008, 2, 15)
assert graf.counterpart_org.ids == {"firmenbuch": "306527a"} and not graf.counterpart_org.create
def test_search_accepts_only_one_current_entry_with_the_same_name():
hits = F.parse_search(SEARCH)
assert hits[0] == {"fn": "68616g", "name": "Salzburger Parkgaragen Gesellschaft m.b.H.", "seat": "Salzburg",
"status": None, "legal_form": "Gesellschaft mit beschränkter Haftung"}
assert F.unique_match("Salzburger Parkgaragen Gesellschaft m.b.H", hits)["fn"] == "68616g" # deleted one ignored
assert F.unique_match("Salzburger Parkgaragen", hits)["fn"] == "68616g" # declarations often omit the legal form
twins = hits + [{"fn": "3c", "name": "Salzburger Parkgaragen GmbH", "seat": "Hallein", "status": None,
"legal_form": None}]
assert F.unique_match("Salzburger Parkgaragen GmbH", twins) is None # two current companies: never guess
assert F.search_term("Salzburger Parkgaragen Gesellschaft m.b.H.") == "Salzburger Parkgaragen"
assert F.search_term("„Wiener Städtische“ Versicherung AG Vienna Insurance Group") == "Wiener Städtische Versicherung"
assert F.search_term("AG") == ""
def test_faults_and_requests():
with pytest.raises(F.SoapFault, match="UMFANG"):
F.parse_extract(FAULT)
a = F.FirmenbuchExtracts.extract("306527a", date(2026, 11, 18))
b = F.FirmenbuchExtracts.extract("68616g", date(2026, 11, 18))
assert a.method == "POST" and b"<r:FNR>306527a</r:FNR>" in a.data and a.fingerprint != b.fingerprint
assert "X-API-KEY" not in repr(a.describe()) # the token is never archived
assert b"&amp;" in F.envelope("SucheFirmaRequest", "SUCHEFIRMAREQUEST", {"FIRMENWORTLAUT": "A & B"})
assert Request(url="x").fingerprint == Request(url="x", data=None).fingerprint