fix: keep organization identity types exclusive
All checks were successful
CI/CD Pipeline / Quality Gate (push) Successful in 35s
CI/CD Pipeline / Build and Push Images (push) Successful in 19s
CI/CD Pipeline / Internal Notify (push) Successful in 0s
CI/CD Pipeline / Deploy Dev in Dokploy (push) Successful in 1s

This commit is contained in:
2026-05-20 12:45:06 +02:00
parent 8dabfe9cdf
commit 76a99a4a1e
3 changed files with 59 additions and 7 deletions

View File

@@ -154,6 +154,52 @@ class OrganizationSourceIngestionServiceTest(TestCase):
record = OrganizationSourceRecord.objects.get(external_id="fstec-5067")
self.assertEqual(record.extension.organization, partial)
def test_save_records_ignores_ogrip_like_ogrn_for_legal_entity_inn(self):
result = OrganizationSourceIngestionService.save_records(
source=ParserLoadLog.Source.INDUSTRIAL,
load_batch=47,
records=[
SourceRecordInput(
external_id="cert-legal-entity-bad-ogrn",
title="cert-legal-entity-bad-ogrn",
organization_name='ООО "Металл-Завод"',
inn="7720525156",
ogrn="105774446645395",
)
],
)
self.assertEqual(result.created_records, 1)
organization = Organization.objects.get(inn="7720525156")
self.assertEqual(organization.ogrn, "")
self.assertEqual(organization.ogrip, "")
def test_save_records_does_not_add_ogrip_to_existing_legal_entity(self):
organization = Organization.objects.create(
name='ООО "Металл-Завод"',
inn="7720525156",
ogrn="1057746645395",
)
result = OrganizationSourceIngestionService.save_records(
source=ParserLoadLog.Source.INDUSTRIAL,
load_batch=48,
records=[
SourceRecordInput(
external_id="cert-legal-entity-existing-bad-ogrn",
title="cert-legal-entity-existing-bad-ogrn",
organization_name='ООО "Металл-Завод"',
inn="7720525156",
ogrn="105774446645395",
)
],
)
self.assertEqual(result.created_records, 1)
organization.refresh_from_db()
self.assertEqual(organization.ogrn, "1057746645395")
self.assertEqual(organization.ogrip, "")
def test_save_financial_report_writes_financial_lines_without_legacy_report(self):
result = OrganizationSourceIngestionService.save_records(
source=ParserLoadLog.Source.FNS_REPORTS,