From 9d187f2f83d0bbdfb57063c58cec9f70607ebf11 Mon Sep 17 00:00:00 2001 From: Andrey Epifancev Date: Wed, 7 Oct 2026 18:17:13 +0400 Subject: [PATCH] =?UTF-8?q?fix(consolidations):=20MemberOut.entity=5Ftype?= =?UTF-8?q?=20nullable,=20=D0=BA=D0=B0=D0=BA=20legal=5Fentity.entity=5Ftyp?= =?UTF-8?q?e=20=D0=B2=20DBML=20(I-1,=20#42)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_012vJkmBGKKqMoEMzvsXG3y2 --- api/src/schemas/consolidations.py | 2 +- api/tests/test_api_consolidations.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/api/src/schemas/consolidations.py b/api/src/schemas/consolidations.py index 705f10b..35d37eb 100644 --- a/api/src/schemas/consolidations.py +++ b/api/src/schemas/consolidations.py @@ -117,7 +117,7 @@ class MemberOut(BaseModel): id: uuid.UUID name: str inn: str - entity_type: EntityType + entity_type: EntityType | None # DBML: `legal_entity.entity_type` nullable (I-1) is_head_entity: bool checklist: list[ChecklistCellOut] osv_accounts: list[str] diff --git a/api/tests/test_api_consolidations.py b/api/tests/test_api_consolidations.py index 68239d6..910ef67 100644 --- a/api/tests/test_api_consolidations.py +++ b/api/tests/test_api_consolidations.py @@ -656,3 +656,18 @@ async def test_card_member_osv_accounts_q1_version_ignores_later_quarters( member = next(member for member in card["members"] if member["id"] == str(company.id)) assert member["osv_accounts"] == ["60"] + + +@pytest.mark.integration +async def test_card_member_without_entity_type_is_served(auth_client: AuthClientFactory, seeded: AsyncSession) -> None: + """I-1: `legal_entity.entity_type` nullable в DBML — член периметра без типа не роняет карточку (тип `null`).""" + version, company, person = await _card_world(seeded) + person.entity_type = None + await seeded.flush() + client = await auth_client(KA_RF) + + response = await client.get(f"{VERSIONS}/{version.id}") + + assert response.status_code == HTTP_OK, response.text + types = {member["id"]: member["entity_type"] for member in response.json()["members"]} + assert types == {str(company.id): "ЮЛ", str(person.id): None}