Skip to content

Commit

Permalink
fix: copy extended remarks from sdn_comments.csv
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdecaf committed Jan 8, 2024
1 parent 3fc5e3f commit f090478
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
14 changes: 13 additions & 1 deletion cmd/server/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ func ofacRecords(logger log.Logger, initialDir string) (*ofac.Results, error) {
}
if rr != nil {
res = rr
res.SDNs = mergeSpilloverRecords(res.SDNs, res.SDNComments)
}
} else {
rr, err := ofac.Read(files[i])
Expand All @@ -184,13 +185,24 @@ func ofacRecords(logger log.Logger, initialDir string) (*ofac.Results, error) {
res.Addresses = append(res.Addresses, rr.Addresses...)
res.AlternateIdentities = append(res.AlternateIdentities, rr.AlternateIdentities...)
res.SDNs = append(res.SDNs, rr.SDNs...)
res.SDNComments = append(res.SDNComments, rr.SDNComments...)
res.SDNs = mergeSpilloverRecords(res.SDNs, rr.SDNComments)
}
}
}
return res, err
}

func mergeSpilloverRecords(sdns []*ofac.SDN, comments []*ofac.SDNComments) []*ofac.SDN {
for i := range sdns {
for j := range comments {
if sdns[i].EntityID == comments[j].EntityID {
sdns[i].Remarks += comments[j].RemarksExtended
}
}
}
return sdns
}

func dplRecords(logger log.Logger, initialDir string) ([]*dpl.DPL, error) {
file, err := dpl.Download(logger, initialDir)
if err != nil {
Expand Down
22 changes: 22 additions & 0 deletions cmd/server/download_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (

"github.com/moov-io/base/log"
"github.com/moov-io/watchman/internal/database"
"github.com/moov-io/watchman/pkg/ofac"

"github.com/gorilla/mux"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -206,3 +207,24 @@ func TestDownload__lastRefresh(t *testing.T) {
}
}
}

func TestDownload__OFAC_Spillover(t *testing.T) {
logger := log.NewTestLogger()
initialDir := filepath.Join("..", "..", "test", "testdata")

res, err := ofacRecords(logger, initialDir)
require.NoError(t, err)

var sdn *ofac.SDN
for i := range res.SDNs {
if res.SDNs[i].EntityID == "12300" {
sdn = res.SDNs[i]
break
}
}
require.NotNil(t, sdn)

//nolint:misspell
expected := `DOB 13 May 1965; alt. DOB 13 Apr 1968; alt. DOB 07 Jul 1964; POB Medellin, Colombia; alt. POB Marinilla, Antioquia, Colombia; alt. POB Ciudad Victoria, Tamaulipas, Mexico; Cedula No. 7548733 (Colombia); alt. Cedula No. 70163752 (Colombia); alt. Cedula No. 172489729-1 (Ecuador); Passport AL720622 (Colombia); R.F.C. CIVJ650513LJA (Mexico); alt. R.F.C. OUSV-640707 (Mexico); C.U.R.P. CIVJ650513HNEFLR06 (Mexico); alt. C.U.R.P. OUVS640707HTSSLR07 (Mexico); Matricula Mercantil No 181301-1 Cali (Colombia); alt. Matricula Mercantil No 405885 Bogota (Colombia); Linked To: BIO FORESTAL S.A.S.; Linked To: CUBI CAFE CLICK CUBE MEXICO, S.A. DE C.V.; Linked To: DOLPHIN DIVE SCHOOL S.A.; Linked To: GANADERIA LA SORGUITA S.A.S.; Linked To: GESTORES DEL ECUADOR GESTORUM S.A.; Linked To: INVERPUNTO DEL VALLE S.A.; Linked To: INVERSIONES CIFUENTES Y CIA. S. EN C.; Linked To: LE CLAUDE, S.A. DE C.V.; Linked To: OPERADORA NUEVA GRANADA, S.A. DE C.V.; Linked To: PARQUES TEMATICOS S.A.S.; Linked To: PROMO RAIZ S.A.S.; Linked To: RED MUNDIAL INMOBILIARIA, S.A. DE C.V.; Linked To: FUNDACION PARA EL BIENESTAR Y EL PORVENIR; Linked To: C.I. METALURGIA EXTRACTIVA DE COLOMBIA S.A.S.; Linked To: GRUPO MUNDO MARINO, S.A.; Linked To: C.I. DISERCOM S.A.S.; Linked To: C.I. OKCOFFEE COLOMBIA S.A.S.; Linked To: C.I. OKCOFFEE INTERNATIONAL S.A.S.; Linked To: FUNDACION OKCOFFEE COLOMBIA; Linked To: CUBICAFE S.A.S.; Linked To: HOTELES Y BIENES S.A.; Linked To: FUNDACION SALVA LA SELVA; Linked To: LINEA AEREA PUEBLOS AMAZONICOS S.A.S.; Linked To: DESARROLLO MINERO RESPONSABLE C.I. S.A.S.; Linked To: R D I S.A.`
require.Equal(t, expected, sdn.Remarks)
}

0 comments on commit f090478

Please sign in to comment.