diff --git a/internal/integrity/ofac_csl_us_test.go b/internal/integrity/ofac_csl_us_test.go index be83f37b..e2ae4998 100644 --- a/internal/integrity/ofac_csl_us_test.go +++ b/internal/integrity/ofac_csl_us_test.go @@ -28,7 +28,7 @@ func TestIntegrity_OFAC_US_CSL(t *testing.T) { require.ElementsMatch(t, ofacEntity.Business.AltNames, cslUSEntity.Business.AltNames) require.Equal(t, ofacEntity.Business.Created, cslUSEntity.Business.Created) require.Equal(t, ofacEntity.Business.Dissolved, cslUSEntity.Business.Dissolved) - require.ElementsMatch(t, ofacEntity.Business.Identifier, cslUSEntity.Business.Identifier) + require.ElementsMatch(t, ofacEntity.Business.Identifiers, cslUSEntity.Business.Identifiers) // Common Fields require.Equal(t, ofacEntity.Contact, cslUSEntity.Contact) diff --git a/pkg/csl_us/mapper.go b/pkg/csl_us/mapper.go index 14772e3e..edd85139 100644 --- a/pkg/csl_us/mapper.go +++ b/pkg/csl_us/mapper.go @@ -200,7 +200,7 @@ func mapBusiness(src ENHANCED_XML.EntitiesEntity) *search.Business { // Map business identifiers if src.IdentityDocuments != nil { - business.Identifier = mapIdentifiers(src.IdentityDocuments) + business.Identifiers = mapIdentifiers(src.IdentityDocuments) } return business @@ -230,7 +230,7 @@ func mapOrganization(src ENHANCED_XML.EntitiesEntity) *search.Organization { // Map organization identifiers if src.IdentityDocuments != nil { - org.Identifier = mapIdentifiers(src.IdentityDocuments) + org.Identifiers = mapIdentifiers(src.IdentityDocuments) } return org diff --git a/pkg/ofac/mapper.go b/pkg/ofac/mapper.go index 9682d4e2..725a6849 100644 --- a/pkg/ofac/mapper.go +++ b/pkg/ofac/mapper.go @@ -213,7 +213,7 @@ func ToEntity(sdn SDN, addresses []Address, comments []SDNComments, altIds []Alt out.Business.Created = findDateStamp(findMatchingRemarks(remarks, "Organization Established Date")) // out.Business.Dissolved = findDateStamp(findMatchingRemarks(remarks, "TODO(adam)")) - out.Business.Identifier = makeIdentifiers(remarks, []string{ + out.Business.Identifiers = makeIdentifiers(remarks, []string{ "Branch Unit Number", "Business Number", "Business Registration Document", diff --git a/pkg/ofac/mapper_business_test.go b/pkg/ofac/mapper_business_test.go index d2301475..2b3d6404 100644 --- a/pkg/ofac/mapper_business_test.go +++ b/pkg/ofac/mapper_business_test.go @@ -38,7 +38,7 @@ func TestMapperBusiness__FromSource(t *testing.T) { {Name: "Company Number", Country: "Czech Republic", Identifier: "07486049"}, {Name: "Legal Entity Number", Country: "Czech Republic", Identifier: "5299007NTWCC3U23WM81"}, } - require.ElementsMatch(t, expectedIdentifiers, business.Identifier) + require.ElementsMatch(t, expectedIdentifiers, business.Identifiers) expectedContact := search.ContactInfo{ Websites: []string{"suex.io"}, @@ -133,7 +133,7 @@ func TestMapperBusiness__FromSource(t *testing.T) { {Name: "Business Registration Number", Country: "Russia", Identifier: "1207700248030"}, {Name: "Tax ID No.", Country: "Russia", Identifier: "9709063550"}, } - require.ElementsMatch(t, expectedIdentifiers, business.Identifier) + require.ElementsMatch(t, expectedIdentifiers, business.Identifiers) expectedContact := search.ContactInfo{ Websites: []string{"www.dialog.info", "www.dialog-regions.ru"}, @@ -173,10 +173,10 @@ func TestMapper__CompleteBusiness(t *testing.T) { require.NotNil(t, e.Business) require.Equal(t, "ACME CORPORATION", e.Business.Name) - require.Len(t, e.Business.Identifier, 3) + require.Len(t, e.Business.Identifiers, 3) // Sort the identifiers to ensure consistent ordering for tests - identifiers := e.Business.Identifier + identifiers := e.Business.Identifiers sort.Slice(identifiers, func(i, j int) bool { return identifiers[i].Country < identifiers[j].Country }) diff --git a/pkg/search/models.go b/pkg/search/models.go index 73700296..aab73395 100644 --- a/pkg/search/models.go +++ b/pkg/search/models.go @@ -119,11 +119,11 @@ var ( ) type Business struct { - Name string `json:"name"` - AltNames []string `json:"altNames"` - Created *time.Time `json:"created"` - Dissolved *time.Time `json:"dissolved"` - Identifier []Identifier `json:"identifier"` + Name string `json:"name"` + AltNames []string `json:"altNames"` + Created *time.Time `json:"created"` + Dissolved *time.Time `json:"dissolved"` + Identifiers []Identifier `json:"identifiers"` } // Identifier @@ -140,11 +140,11 @@ type Identifier struct { // // TODO(adam): https://www.opensanctions.org/reference/#schema.Organization type Organization struct { - Name string `json:"name"` - AltNames []string `json:"altNames"` - Created *time.Time `json:"created"` - Dissolved *time.Time `json:"dissolved"` - Identifier []Identifier `json:"identifier"` + Name string `json:"name"` + AltNames []string `json:"altNames"` + Created *time.Time `json:"created"` + Dissolved *time.Time `json:"dissolved"` + Identifiers []Identifier `json:"identifier"` } type Aircraft struct { diff --git a/pkg/search/similarity.go b/pkg/search/similarity.go index 936ecc10..2cd760ec 100644 --- a/pkg/search/similarity.go +++ b/pkg/search/similarity.go @@ -372,7 +372,7 @@ func countBusinessFields(b *Business) int { if b.Created != nil { count++ } - if len(b.Identifier) > 0 { + if len(b.Identifiers) > 0 { count++ } @@ -394,7 +394,7 @@ func countOrganizationFields(o *Organization) int { if o.Created != nil { count++ } - if len(o.Identifier) > 0 { + if len(o.Identifiers) > 0 { count++ } diff --git a/pkg/search/similarity_exact.go b/pkg/search/similarity_exact.go index 00d664c3..6cb184a9 100644 --- a/pkg/search/similarity_exact.go +++ b/pkg/search/similarity_exact.go @@ -95,11 +95,11 @@ func compareBusinessExactIDs(w io.Writer, query *Business, index *Business, weig hasMatch := false // Business Registration/Tax IDs - if len(query.Identifier) > 0 && len(index.Identifier) > 0 { + if len(query.Identifiers) > 0 && len(index.Identifiers) > 0 { fieldsCompared++ totalWeight += 15.0 - for _, qID := range query.Identifier { - for _, iID := range index.Identifier { + for _, qID := range query.Identifiers { + for _, iID := range index.Identifiers { // Exact match on all identifier fields if strings.EqualFold(qID.Name, iID.Name) && strings.EqualFold(qID.Country, iID.Country) && @@ -141,11 +141,11 @@ func compareOrgExactIDs(w io.Writer, query *Organization, index *Organization, w hasMatch := false // Organization Registration/Tax IDs - if len(query.Identifier) > 0 && len(index.Identifier) > 0 { + if len(query.Identifiers) > 0 && len(index.Identifiers) > 0 { fieldsCompared++ totalWeight += 15.0 - for _, qID := range query.Identifier { - for _, iID := range index.Identifier { + for _, qID := range query.Identifiers { + for _, iID := range index.Identifiers { // Exact match on all identifier fields if strings.EqualFold(qID.Name, iID.Name) && strings.EqualFold(qID.Country, iID.Country) && @@ -461,8 +461,8 @@ func compareBusinessGovernmentIDs(query *Business, index *Business, weight float return scorePiece{score: 0, weight: weight, fieldsCompared: 0, pieceType: "gov-ids-exact"} } - qIDs := query.Identifier - iIDs := index.Identifier + qIDs := query.Identifiers + iIDs := index.Identifiers if len(qIDs) == 0 || len(iIDs) == 0 { return scorePiece{score: 0, weight: weight, fieldsCompared: 0, pieceType: "gov-ids-exact"} @@ -501,8 +501,8 @@ func compareOrgGovernmentIDs(query *Organization, index *Organization, weight fl return scorePiece{score: 0, weight: weight, fieldsCompared: 0, pieceType: "gov-ids-exact"} } - qIDs := query.Identifier - iIDs := index.Identifier + qIDs := query.Identifiers + iIDs := index.Identifiers if len(qIDs) == 0 || len(iIDs) == 0 { return scorePiece{score: 0, weight: weight, fieldsCompared: 0, pieceType: "gov-ids-exact"} diff --git a/pkg/search/similarity_ofac_test.go b/pkg/search/similarity_ofac_test.go index afc533e8..eb9c1452 100644 --- a/pkg/search/similarity_ofac_test.go +++ b/pkg/search/similarity_ofac_test.go @@ -142,7 +142,7 @@ func TestSimilarity_OFAC_SDN_Business(t *testing.T) { Business: &search.Business{ Name: "AUTONOMOUS NON-PROFIT ORGANIZATION DIALOG REGIONS", Created: &businessCreatedAt, - Identifier: []search.Identifier{ + Identifiers: []search.Identifier{ { Name: "Business Registration Number", Country: "Russia", @@ -160,7 +160,7 @@ func TestSimilarity_OFAC_SDN_Business(t *testing.T) { Type: search.EntityBusiness, Business: &search.Business{ Name: "AUTO NON-PROFIT ORGANIZATION", - Identifier: []search.Identifier{ + Identifiers: []search.Identifier{ { Name: "Tax ID No.", Country: "Russia", @@ -189,7 +189,7 @@ func TestSimilarity_OFAC_SDN_Business(t *testing.T) { Type: search.EntityBusiness, Business: &search.Business{ Name: "BETA Solutions", - Identifier: []search.Identifier{ + Identifiers: []search.Identifier{ {Name: "Registration", Country: "US", Identifier: "99999"}, }, },