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}