robocop

Checks KYC attributes against sanction lists
Log | Files | Refs | Submodules | README | LICENSE

commit 97507ee6719787334dbaa195270d5d6900dc7b17
parent ba9a8c3e72318f8623414b7ed18fca325361220d
Author: Vint Leenaars <vl.software@leenaa.rs>
Date:   Tue, 13 May 2025 17:40:51 +0200

map YearMonthDay to CustomDay

Diffstat:
Msrc/KYCheck/GLS/Type.hs | 17++++++++++++++---
Mtest/Tests/Targets/Individuals/Sanctioned.hs | 51+++++++++++++++++++++++++--------------------------
Mtest/Tests/Targets/Individuals/Trusted.hs | 23+++++++++++------------
3 files changed, 50 insertions(+), 41 deletions(-)

diff --git a/src/KYCheck/GLS/Type.hs b/src/KYCheck/GLS/Type.hs @@ -5,13 +5,16 @@ -- | See https://git.taler.net/gana.git/tree/gnu-taler-form-attributes/registry.rec -{-# LANGUAGE DeriveGeneric #-} -{-# LANGUAGE RecordWildCards #-} +{-# LANGUAGE DeriveGeneric #-} +{-# LANGUAGE RecordWildCards #-} {-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE PatternSynonyms #-} +{-# LANGUAGE ViewPatterns #-} module KYCheck.GLS.Type ( Address(..) , CustomDay(..) + , pattern YMD , Entry(..) , LegalEntity(..) , NaturalPerson(..) @@ -22,7 +25,7 @@ import Control.Applicative ((<|>)) import Data.Aeson (FromJSON(..), ToJSON(..), withText, withObject, (.:), (.:?)) import Data.CountryCodes hiding (NP) import Data.Text -import Data.Time.Calendar (Day) +import Data.Time.Calendar import Data.Time.Format (defaultTimeLocale, parseTimeM) import GHC.Generics @@ -33,6 +36,14 @@ data Entry = NP NaturalPerson newtype CustomDay = CustomDay Day deriving (Show, Eq, Generic) +pattern YMD :: Year -> MonthOfYear -> DayOfMonth -> CustomDay +pattern YMD y m d <- + CustomDay (toGregorian -> (y,m,d)) + where + YMD y m d = CustomDay $ fromGregorian y m d + +{-# COMPLETE YMD #-} + data NaturalPerson = NaturalPerson { full_name :: Text , last_name :: Text diff --git a/test/Tests/Targets/Individuals/Sanctioned.hs b/test/Tests/Targets/Individuals/Sanctioned.hs @@ -34,7 +34,6 @@ module Tests.Targets.Individuals.Sanctioned ) where import Data.CountryCodes -import Data.Time.Calendar import KYCheck.GLS.Type as GLS @@ -61,7 +60,7 @@ target_5144 :: NaturalPerson target_5144 = NaturalPerson { full_name = "Dmitri Aliaksandravich Lukashenko" , last_name = "Lukashenko" - , birthdate = YearMonthDay 1980 03 23 + , birthdate = YMD 1980 03 23 , nationality = BY , national_id = "012345ABCDEF" , residential = GLS.Address { GLS.country = BY @@ -81,7 +80,7 @@ target_5266 :: NaturalPerson target_5266 = NaturalPerson { full_name = "Natallia Alexeeuna Chatviartkova" , last_name = "Chatviartkova" - , birthdate = YearMonthDay 1960 01 01 -- Made up birth date + , birthdate = YMD 1960 01 01 -- Made up birth date , nationality = RU , national_id = "012345ABCDEF" , residential = GLS.Address { GLS.country = RU @@ -101,7 +100,7 @@ target_49816_v1 :: NaturalPerson target_49816_v1 = NaturalPerson { full_name = "Vladimir Vladimirovich Putin" , last_name = "Putin" - , birthdate = YearMonthDay 1952 10 07 + , birthdate = YMD 1952 10 07 , nationality = RU , national_id = "012345ABCDEF" , residential = GLS.Address { GLS.country = RU @@ -121,7 +120,7 @@ target_49816_v2 :: NaturalPerson target_49816_v2 = NaturalPerson { full_name = "Vladimir Mouse" , last_name = "Mouse" - , birthdate = YearMonthDay 1952 10 07 + , birthdate = YMD 1952 10 07 , nationality = RU , national_id = "012345ABCDEF" , residential = GLS.Address { GLS.country = RU @@ -141,7 +140,7 @@ target_49816_v3 :: NaturalPerson target_49816_v3 = NaturalPerson { full_name = "Mickey Mouse" , last_name = "Mouse" - , birthdate = YearMonthDay 1951 04 12 + , birthdate = YMD 1951 04 12 , nationality = RU , national_id = "012345ABCDEF" , residential = GLS.Address { GLS.country = RU @@ -161,7 +160,7 @@ target_49816_v4 :: NaturalPerson target_49816_v4 = NaturalPerson { full_name = "Vladimir Vladimirovich Putin" , last_name = "Putin" - , birthdate = YearMonthDay 1952 10 07 + , birthdate = YMD 1952 10 07 , nationality = FR , national_id = "012345ABCDEF" , residential = GLS.Address { GLS.country = FR @@ -181,7 +180,7 @@ target_43462 :: NaturalPerson target_43462 = NaturalPerson { full_name = "Aleksandr Petrovich Barsukov" , last_name = "Barsukov" - , birthdate = YearMonthDay 1965 04 29 + , birthdate = YMD 1965 04 29 , nationality = BY , national_id = "012345ABCDEF" , residential = GLS.Address { GLS.country = BY @@ -201,7 +200,7 @@ target_43616 :: NaturalPerson target_43616 = NaturalPerson { full_name = "Oleg Anatolievich Chernyshev" , last_name = "Chernyshev" - , birthdate = YearMonthDay 1985 07 27 -- Made up birth date + , birthdate = YMD 1985 07 27 -- Made up birth date , nationality = RU , national_id = "012345ABCDEF" , residential = GLS.Address { GLS.country = RU @@ -221,7 +220,7 @@ target_43641 :: NaturalPerson target_43641 = NaturalPerson { full_name = "Vadzim Dzmitryevich Ipatau" , last_name = "Ipatau" - , birthdate = YearMonthDay 1964 10 30 + , birthdate = YMD 1964 10 30 , nationality = BY , national_id = "012345ABCDEF" , residential = GLS.Address { GLS.country = BY @@ -241,7 +240,7 @@ target_43718 :: NaturalPerson target_43718 = NaturalPerson { full_name = "Irina Aliaksandrauna Tselikavets" , last_name = "Tselikavets" - , birthdate = YearMonthDay 1976 11 02 + , birthdate = YMD 1976 11 02 , nationality = BY , national_id = "012345ABCDEF" , residential = GLS.Address { GLS.country = BY @@ -261,7 +260,7 @@ target_43662 :: NaturalPerson target_43662 = NaturalPerson { full_name = "Olga Leonidovna Doroshenko" , last_name = "Doroshenko" - , birthdate = YearMonthDay 1976 09 02 -- Made up birth month and day + , birthdate = YMD 1976 09 02 -- Made up birth month and day , nationality = BY , national_id = "012345ABCDEF" , residential = GLS.Address { GLS.country = BY @@ -281,7 +280,7 @@ target_43611 :: NaturalPerson target_43611 = NaturalPerson { full_name = "Vladimir Viktorovich Kalach" , last_name = "Kalach" - , birthdate = YearMonthDay 1960 12 22 -- Made up birth date + , birthdate = YMD 1960 12 22 -- Made up birth date , nationality = BY , national_id = "012345ABCDEF" , residential = GLS.Address { GLS.country = BY @@ -301,7 +300,7 @@ target_29723 :: NaturalPerson target_29723 = NaturalPerson { full_name = "Равиль Закариевич Халиков" , last_name = "Халиков" - , birthdate = YearMonthDay 1969 02 23 + , birthdate = YMD 1969 02 23 , nationality = RU , national_id = "012345ABCDEF" , residential = GLS.Address { GLS.country = RU @@ -321,7 +320,7 @@ target_38925_v1 :: NaturalPerson target_38925_v1 = NaturalPerson { full_name = "Solomon Grundy" , last_name = "Grundy" - , birthdate = YearMonthDay 1800 06 06 + , birthdate = YMD 1800 06 06 , nationality = BE , national_id = "012345ABCDEF" , residential = GLS.Address { GLS.country = HT @@ -341,7 +340,7 @@ target_38925_v2 :: NaturalPerson target_38925_v2 = NaturalPerson { full_name = "Natalia Ivanovna Bezruchenko" , last_name = "Bezruchenko" - , birthdate = YearMonthDay 1913 02 27 + , birthdate = YMD 1913 02 27 , nationality = BE , national_id = "012345ABCDEF" , residential = GLS.Address { GLS.country = BE @@ -361,7 +360,7 @@ target_38925_v3 :: NaturalPerson target_38925_v3 = NaturalPerson { full_name = "Mickey Bezruchenko" , last_name = "Bezruchenko" - , birthdate = YearMonthDay 1979 08 22 + , birthdate = YMD 1979 08 22 , nationality = BE , national_id = "012345ABCDEF" , residential = GLS.Address { GLS.country = HT @@ -381,7 +380,7 @@ target_38925_v4 :: NaturalPerson target_38925_v4 = NaturalPerson { full_name = "Mickey Bezruchenko" , last_name = "Bezruchenko" - , birthdate = YearMonthDay 1960 02 13 + , birthdate = YMD 1960 02 13 , nationality = BE , national_id = "012345ABCDEF" , residential = GLS.Address { GLS.country = HT @@ -401,7 +400,7 @@ target_38925_v5 :: NaturalPerson target_38925_v5 = NaturalPerson { full_name = "Natalia Ivanovna Bezruchenko" , last_name = "Bezruchenko" - , birthdate = YearMonthDay 1979 08 22 + , birthdate = YMD 1979 08 22 , nationality = RU , national_id = "012345ABCDEF" , residential = GLS.Address { GLS.country = RU @@ -421,7 +420,7 @@ target_68815 :: NaturalPerson target_68815 = NaturalPerson { full_name = "Innocent Vitelhomme" , last_name = "Vitelhomme" - , birthdate = YearMonthDay 1986 03 27 + , birthdate = YMD 1986 03 27 , nationality = HT , national_id = "012345ABCDEF" , residential = GLS.Address { GLS.country = HT @@ -441,7 +440,7 @@ target_57355_v1 :: NaturalPerson target_57355_v1 = NaturalPerson { full_name = "Jimmy Cherizier" , last_name = "Cherizier" - , birthdate = YearMonthDay 1977 03 30 + , birthdate = YMD 1977 03 30 , nationality = HT , national_id = "012345ABCDEF" , residential = GLS.Address { GLS.country = HT @@ -461,7 +460,7 @@ target_57355_v2 :: NaturalPerson target_57355_v2 = NaturalPerson { full_name = "Jimmy Barbeque" , last_name = "Barbeque" - , birthdate = YearMonthDay 1977 03 30 + , birthdate = YMD 1977 03 30 , nationality = HT , national_id = "012345ABCDEF" , residential = GLS.Address { GLS.country = HT @@ -481,7 +480,7 @@ target_57355_v3 :: NaturalPerson target_57355_v3 = NaturalPerson { full_name = "Jim Cherizier" , last_name = "Cherizier" - , birthdate = YearMonthDay 1953 02 19 + , birthdate = YMD 1953 02 19 , nationality = HT , national_id = "012345ABCDEF" , residential = GLS.Address { GLS.country = HT @@ -501,7 +500,7 @@ target_57355_v4 :: NaturalPerson target_57355_v4 = NaturalPerson { full_name = "Jimmy Cherisier" , last_name = "Cherisier" - , birthdate = YearMonthDay 1953 02 19 + , birthdate = YMD 1953 02 19 , nationality = HT , national_id = "012345ABCDEF" , residential = GLS.Address { GLS.country = HT @@ -521,7 +520,7 @@ target_57355_v5 :: NaturalPerson target_57355_v5 = NaturalPerson { full_name = "Jimmy Cherisier" , last_name = "Cherisier" - , birthdate = YearMonthDay 1977 03 30 + , birthdate = YMD 1977 03 30 , nationality = HT , national_id = "012345ABCDEF" , residential = GLS.Address { GLS.country = HT @@ -541,7 +540,7 @@ target_57355_v6 :: NaturalPerson target_57355_v6 = NaturalPerson { full_name = "Jim Cherizier" , last_name = "Cherizier" - , birthdate = YearMonthDay 1953 02 19 + , birthdate = YMD 1953 02 19 , nationality = HT , national_id = "012345ABCDEF" , residential = GLS.Address { GLS.country = HT diff --git a/test/Tests/Targets/Individuals/Trusted.hs b/test/Tests/Targets/Individuals/Trusted.hs @@ -20,7 +20,6 @@ module Tests.Targets.Individuals.Trusted ) where import Data.CountryCodes -import Data.Time.Calendar import KYCheck.GLS.Type as GLS @@ -47,7 +46,7 @@ public_figure_1 :: NaturalPerson public_figure_1 = NaturalPerson { full_name = "Georges Prosper Remi" , last_name = "Remi" - , birthdate = YearMonthDay 1907 05 22 + , birthdate = YMD 1907 05 22 , nationality = BE , national_id = "012345ABCDEF" , residential = GLS.Address { GLS.country = BE @@ -67,7 +66,7 @@ public_figure_2 :: NaturalPerson public_figure_2 = NaturalPerson { full_name = "Jeffrey Preston Bezos" , last_name = "Bezos" - , birthdate = YearMonthDay 1964 01 12 + , birthdate = YMD 1964 01 12 , nationality = US , national_id = "012345ABCDEF" , residential = GLS.Address { GLS.country = US @@ -87,7 +86,7 @@ public_figure_3 :: NaturalPerson public_figure_3 = NaturalPerson { full_name = "Abraham Lincoln" , last_name = "Lincoln" - , birthdate = YearMonthDay 1809 02 12 + , birthdate = YMD 1809 02 12 , nationality = US , national_id = "012345ABCDEF" , residential = GLS.Address { GLS.country = US @@ -107,7 +106,7 @@ public_figure_4 :: NaturalPerson public_figure_4 = NaturalPerson { full_name = "Willem-Alexander Claus George Ferdinand van Oranje-Nassau" , last_name = "van Oranje-Nassau" - , birthdate = YearMonthDay 1980 04 30 + , birthdate = YMD 1980 04 30 , nationality = NL , national_id = "012345ABCDEF" , residential = GLS.Address { GLS.country = NL @@ -127,7 +126,7 @@ public_figure_5 :: NaturalPerson public_figure_5 = NaturalPerson { full_name = "Leonardo di ser Piero da Vinci" , last_name = "da Vinci" - , birthdate = YearMonthDay 1452 04 15 + , birthdate = YMD 1452 04 15 , nationality = IT , national_id = "012345ABCDEF" , residential = GLS.Address { GLS.country = IT @@ -147,7 +146,7 @@ imaginary_figure_1 :: NaturalPerson imaginary_figure_1 = NaturalPerson { full_name = "Papa Smurf" , last_name = "Smurf" - , birthdate = YearMonthDay 1958 10 23 + , birthdate = YMD 1958 10 23 , nationality = FR , national_id = "012345ABCDEF" , residential = GLS.Address { GLS.country = FR @@ -167,7 +166,7 @@ imaginary_figure_2 :: NaturalPerson imaginary_figure_2 = NaturalPerson { full_name = "Donald Fauntleroy Duck" , last_name = "Duck" - , birthdate = YearMonthDay 1934 06 09 + , birthdate = YMD 1934 06 09 , nationality = US , national_id = "012345ABCDEF" , residential = GLS.Address { GLS.country = US @@ -187,7 +186,7 @@ imaginary_figure_3 :: NaturalPerson imaginary_figure_3 = NaturalPerson { full_name = "Willy Wonka" , last_name = "Wonka" - , birthdate = YearMonthDay 1964 01 17 + , birthdate = YMD 1964 01 17 , nationality = GB , national_id = "012345ABCDEF" , residential = GLS.Address { GLS.country = GB @@ -207,7 +206,7 @@ imaginary_figure_4 :: NaturalPerson imaginary_figure_4 = NaturalPerson { full_name = "Bilbo Baggins" , last_name = "Baggins" - , birthdate = YearMonthDay 1937 09 21 + , birthdate = YMD 1937 09 21 , nationality = GB , national_id = "012345ABCDEF" , residential = GLS.Address { GLS.country = GB @@ -227,7 +226,7 @@ imaginary_figure_5 :: NaturalPerson imaginary_figure_5 = NaturalPerson { full_name = "Bruce Wayne" , last_name = "Wayne" - , birthdate = YearMonthDay 1972 02 19 + , birthdate = YMD 1972 02 19 , nationality = US , national_id = "012345ABCDEF" , residential = GLS.Address { GLS.country = US @@ -247,7 +246,7 @@ target_6 :: NaturalPerson target_6 = NaturalPerson { full_name = "Bowser" , last_name = "Bowser" - , birthdate = YearMonthDay 1985 09 13 + , birthdate = YMD 1985 09 13 , nationality = JP , national_id = "012345ABCDEF" , residential = GLS.Address { GLS.country = JP