fix: auto-clear KRS people (zarząd/wspólnicy) when CEIDG data is fetched
Some checks failed
NordaBiz Tests / Unit & Integration Tests (push) Has been cancelled
NordaBiz Tests / E2E Tests (Playwright) (push) Has been cancelled
NordaBiz Tests / Smoke Tests (Production) (push) Has been cancelled
NordaBiz Tests / Send Failure Notification (push) Has been cancelled

JDG companies don't have board members or shareholders. When CEIDG
returns data for a company, automatically remove company_people
records sourced from ekrs.ms.gov.pl.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Maciej Pienczyn 2026-04-08 18:02:49 +02:00
parent 8c5d334b21
commit 9f82017d84

View File

@ -472,6 +472,16 @@ def api_enrich_company_registry(company_id):
company.legal_form = 'JEDNOOSOBOWA DZIAŁALNOŚĆ GOSPODARCZA'
updated_fields.append('forma prawna → JDG')
# --- Clear KRS-sourced people (zarząd, wspólnicy — not applicable to JDG) ---
krs_people = db.query(CompanyPerson).filter(
CompanyPerson.company_id == company.id,
CompanyPerson.source == 'ekrs.ms.gov.pl'
).all()
if krs_people:
for cp in krs_people:
db.delete(cp)
updated_fields.append(f'usunięto {len(krs_people)} osób z KRS (zarząd/wspólnicy)')
# --- Clear KRS data (CEIDG = JDG, not a spółka) ---
if company.krs:
company.krs = None