firmenbuch: a partnership (KG, OG, GmbH & Co KG) no longer matches the GmbH of the same name

The name search ignored the legal form, so "Huber GmbH & Co KG" (public contracts) was given the register number of
"Huber GmbH" in Ebenfurth and thereby linked to that company's managing director. Fixed on the server by moving the
number and the officer role to an organisation of their own. Commons register ids reuse firmenbuch_number().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
simonandClaude Opus 5.5 committed 2026-11-20 14:40:48 +01:00
1 parent b761517386
commit c61cb31e4a
3 files changed
+22 -6

No files matched your search

+12 -2
View File
@@ -203,10 +203,20 @@ def search_term(name: str) -> str:
return term if len(term) >= 3 else "" return term if len(term) >= 3 else ""
PARTNERSHIP = re.compile(r"\b(kg|og|kommanditgesellschaft|offene gesellschaft|co\.?\s*kg)\b", re.IGNORECASE)
def is_partnership(name: str) -> bool:
"""KG / OG / GmbH & Co KG: a different legal entity from the GmbH of the same name (often its general partner)."""
return bool(PARTNERSHIP.search(name))
def unique_match(name: str, hits: list[dict[str, Any]]) -> dict[str, Any] | None: def unique_match(name: str, hits: list[dict[str, Any]]) -> dict[str, Any] | None:
"""The one current register entry with the same name (legal form, case and punctuation ignored).""" """The one current register entry with the same name (legal form, case and punctuation ignored, but a
partnership never matches a corporation: 'Huber GmbH & Co KG' is not 'Huber GmbH')."""
target = normalize_org_name(name) target = normalize_org_name(name)
same = [h for h in hits if h["fn"] and normalize_org_name(h["name"]) == target] same = [h for h in hits if h["fn"] and normalize_org_name(h["name"]) == target
and is_partnership(h["name"]) == is_partnership(name)]
current = [h for h in same if not h["status"]] or same current = [h for h in same if not h["status"]] or same
return current[0] if len(current) == 1 else None return current[0] if len(current) == 1 else None
+2 -4
View File
@@ -25,7 +25,7 @@ from psycopg import Connection
from politrack.core import Adapter, Request, Response, RunContext, SourceSpec, register from politrack.core import Adapter, Request, Response, RunContext, SourceSpec, register
from politrack.core.records import Image, OrgRef, PersonRef from politrack.core.records import Image, OrgRef, PersonRef
from politrack.sources.wikidata import SPARQL, sparql from politrack.sources.wikidata import SPARQL, sparql
from politrack.text import html_to_text from politrack.text import firmenbuch_number, html_to_text
COMMONS_API = "https://commons.wikimedia.org/w/api.php" COMMONS_API = "https://commons.wikimedia.org/w/api.php"
THUMB_WIDTH = 330 # one of Wikimedia's standard thumbnail steps (cached at the edge) THUMB_WIDTH = 330 # one of Wikimedia's standard thumbnail steps (cached at the edge)
@@ -63,10 +63,8 @@ REGISTERS = {"firmenbuch": "P5285", "zvr": "P6279"}
def register_id(scheme: str, value: str) -> str | None: def register_id(scheme: str, value: str) -> str | None:
"""Wikidata's register number in our identifier format: Firmenbuch '520909 v' / 'FN 58358x' -> '520909v', """Wikidata's register number in our identifier format: Firmenbuch '520909 v' / 'FN 58358x' -> '520909v',
ZVR digits only.""" ZVR digits only."""
value = value.strip().lower()
if scheme == "firmenbuch": if scheme == "firmenbuch":
value = re.sub(r"^fn\s*", "", value).replace(" ", "") return firmenbuch_number(value)
return value.lstrip("0") if re.fullmatch(r"\d+[a-z]", value) else None
value = re.sub(r"\D", "", value) value = re.sub(r"\D", "", value)
return value.lstrip("0") or None return value.lstrip("0") or None
+8
View File
@@ -118,3 +118,11 @@ def test_faults_and_requests():
assert "X-API-KEY" not in repr(a.describe()) # the token is never archived 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 b"&amp;" in F.envelope("SucheFirmaRequest", "SUCHEFIRMAREQUEST", {"FIRMENWORTLAUT": "A & B"})
assert Request(url="x").fingerprint == Request(url="x", data=None).fingerprint assert Request(url="x").fingerprint == Request(url="x", data=None).fingerprint
def test_partnership_never_matches_the_corporation_of_the_same_name():
hits = [{"fn": "226399s", "name": "Huber GmbH", "seat": "Ebenfurth", "status": None, "legal_form": None}]
assert F.unique_match("Huber GmbH & Co KG", hits) is None
assert F.unique_match("Huber GmbH", hits)["fn"] == "226399s"
kg = [{"fn": "1k", "name": "Huber GmbH & Co KG", "seat": "Wels", "status": None, "legal_form": None}]
assert F.unique_match("Huber GmbH & Co. KG", kg)["fn"] == "1k"