From 0e51b035305562572e01b0c11a18bf1d90d75e3a Mon Sep 17 00:00:00 2001 From: Joshua Hawxwell Date: Wed, 25 Sep 2024 10:43:07 +0100 Subject: [PATCH] MLPAB-2231 Store independent witness and authorised signatory if given (#258) --- docs/schemas/2024-10/donor-details.json | 36 +++++++++++++++++++ internal/shared/lpa.go | 2 ++ internal/shared/person.go | 21 ++++++++--- lambda/create/main_test.go | 24 ++++++------- lambda/create/validate.go | 14 ++++++++ lambda/create/validate_test.go | 8 ++--- .../update/certificate_provider_sign_test.go | 4 +-- 7 files changed, 87 insertions(+), 22 deletions(-) diff --git a/docs/schemas/2024-10/donor-details.json b/docs/schemas/2024-10/donor-details.json index 2f94e241..6fc15dd3 100644 --- a/docs/schemas/2024-10/donor-details.json +++ b/docs/schemas/2024-10/donor-details.json @@ -104,6 +104,38 @@ "$ref": "#/$defs/PersonToNotify" } }, + "independentWitness": { + "allOf": [ + { + "$ref": "#/$defs/Person" + } + ], + "properties": { + "phone": { + "type": "string", + "x-faker": "phone.number" + } + }, + "required": ["phone"] + }, + "authorisedSignatory": { + "type": "object", + "required": ["uid", "firstNames", "lastName"], + "properties": { + "uid": { + "type": "string", + "format": "uuid" + }, + "firstNames": { + "type": "string", + "x-faker": "name.firstName" + }, + "lastName": { + "type": "string", + "x-faker": "name.lastName" + } + } + }, "howAttorneysMakeDecisions": { "type": "string", "enum": [ @@ -144,6 +176,10 @@ "signedAt": { "type": "string", "format": "date-time" + }, + "certificateProviderNotRelatedConfirmedAt": { + "type": "string", + "format": "date-time" } }, "if": { diff --git a/internal/shared/lpa.go b/internal/shared/lpa.go index 0fa3a6fa..1d075e59 100644 --- a/internal/shared/lpa.go +++ b/internal/shared/lpa.go @@ -12,6 +12,8 @@ type LpaInit struct { TrustCorporations []TrustCorporation `json:"trustCorporations,omitempty"` CertificateProvider CertificateProvider `json:"certificateProvider"` PeopleToNotify []PersonToNotify `json:"peopleToNotify,omitempty"` + IndependentWitness *IndependentWitness `json:"independentWitness,omitempty"` + AuthorisedSignatory *AuthorisedSignatory `json:"authorisedSignatory,omitempty"` HowAttorneysMakeDecisions HowMakeDecisions `json:"howAttorneysMakeDecisions,omitempty"` HowAttorneysMakeDecisionsDetails string `json:"howAttorneysMakeDecisionsDetails,omitempty"` HowReplacementAttorneysMakeDecisions HowMakeDecisions `json:"howReplacementAttorneysMakeDecisions,omitempty"` diff --git a/internal/shared/person.go b/internal/shared/person.go index 2463ddbe..c98f7eaf 100644 --- a/internal/shared/person.go +++ b/internal/shared/person.go @@ -16,14 +16,14 @@ func (a Address) IsZero() bool { } type Person struct { - UID string `json:"uid"` - FirstNames string `json:"firstNames"` - LastName string `json:"lastName"` - Address Address `json:"address"` + UID string `json:"uid"` + FirstNames string `json:"firstNames"` + LastName string `json:"lastName"` } type Donor struct { Person + Address Address `json:"address"` DateOfBirth Date `json:"dateOfBirth"` Email string `json:"email"` OtherNamesKnownBy string `json:"otherNamesKnownBy,omitempty"` @@ -33,6 +33,7 @@ type Donor struct { type CertificateProvider struct { Person + Address Address `json:"address"` Email string `json:"email"` Phone string `json:"phone"` Channel Channel `json:"channel"` @@ -66,6 +67,7 @@ func (a AttorneyStatus) IsValid() bool { type Attorney struct { Person + Address Address `json:"address"` DateOfBirth Date `json:"dateOfBirth"` Email string `json:"email,omitempty"` Status AttorneyStatus `json:"status"` @@ -101,6 +103,17 @@ func (s Signatory) IsZero() bool { type PersonToNotify struct { Person + Address Address `json:"address"` +} + +type IndependentWitness struct { + Person + Phone string `json:"phone"` + Address Address `json:"address"` +} + +type AuthorisedSignatory struct { + Person } type IdentityCheck struct { diff --git a/lambda/create/main_test.go b/lambda/create/main_test.go index 78c7a653..ba995041 100644 --- a/lambda/create/main_test.go +++ b/lambda/create/main_test.go @@ -28,10 +28,10 @@ var ( UID: "a06daa09-750d-4e02-9877-0ea782491014", FirstNames: "donor-firstname", LastName: "donor-lastname", - Address: shared.Address{ - Line1: "donor-line1", - Country: "GB", - }, + }, + Address: shared.Address{ + Line1: "donor-line1", + Country: "GB", }, DateOfBirth: makeDate("2020-01-02"), Email: "donor-email", @@ -42,10 +42,10 @@ var ( UID: "c442a9a2-9d14-48ca-9cfa-d30d591b0d68", FirstNames: "attorney-firstname", LastName: "attorney-lastname", - Address: shared.Address{ - Line1: "attorney-line1", - Country: "GB", - }, + }, + Address: shared.Address{ + Line1: "attorney-line1", + Country: "GB", }, DateOfBirth: makeDate("2020-02-03"), ContactLanguagePreference: shared.LangEn, @@ -57,10 +57,10 @@ var ( UID: "e9751c0a-0504-4ec6-942e-b85fddbbd178", FirstNames: "certificate-provider-firstname", LastName: "certificate-provider-lastname", - Address: shared.Address{ - Line1: "certificate-provider-line1", - Country: "GB", - }, + }, + Address: shared.Address{ + Line1: "certificate-provider-line1", + Country: "GB", }, Channel: shared.ChannelOnline, Email: "certificate-provider-email", diff --git a/lambda/create/validate.go b/lambda/create/validate.go index 74d785f0..f9bcda86 100644 --- a/lambda/create/validate.go +++ b/lambda/create/validate.go @@ -35,6 +35,20 @@ func Validate(lpa shared.LpaInit) []shared.FieldError { validate.Required("/certificateProvider/phone", lpa.CertificateProvider.Phone), validateAttorneys("/attorneys", lpa.Attorneys), validateTrustCorporations("/trustCorporations", lpa.TrustCorporations), + validate.IfFunc(lpa.AuthorisedSignatory != nil, func() []shared.FieldError { + return validate.All( + validate.Required("/authorisedSignatory/uid", lpa.AuthorisedSignatory.UID), + validate.Required("/authorisedSignatory/firstNames", lpa.AuthorisedSignatory.FirstNames), + validate.Required("/authorisedSignatory/lastName", lpa.AuthorisedSignatory.LastName)) + }), + validate.IfFunc(lpa.IndependentWitness != nil, func() []shared.FieldError { + return validate.All( + validate.Required("/independentWitness/uid", lpa.IndependentWitness.UID), + validate.Required("/independentWitness/firstNames", lpa.IndependentWitness.FirstNames), + validate.Required("/independentWitness/lastName", lpa.IndependentWitness.LastName), + validate.Required("/independentWitness/phone", lpa.IndependentWitness.Phone), + validate.Address("/independentWitness/address", lpa.IndependentWitness.Address)) + }), validate.IfElse(activeAttorneyCount > 1, validate.IsValid("/howAttorneysMakeDecisions", lpa.HowAttorneysMakeDecisions), validate.Unset("/howAttorneysMakeDecisions", lpa.HowAttorneysMakeDecisions)), diff --git a/lambda/create/validate_test.go b/lambda/create/validate_test.go index d65ed5ff..e1fbff28 100644 --- a/lambda/create/validate_test.go +++ b/lambda/create/validate_test.go @@ -25,8 +25,8 @@ func makeAttorney() shared.Attorney { UID: "b99af83d-5b6c-44f7-8c03-14004699bdb9", FirstNames: "Sharonda", LastName: "Graciani", - Address: validAddress, }, + Address: validAddress, Email: "some@example.com", Channel: shared.ChannelOnline, DateOfBirth: newDate("1977-10-30"), @@ -40,8 +40,8 @@ func makeReplacementAttorney() shared.Attorney { UID: "b99af83d-5b6c-44f7-8c03-14004699bdb9", FirstNames: "Sharonda", LastName: "Graciani", - Address: validAddress, }, + Address: validAddress, Email: "some@example.com", Channel: shared.ChannelOnline, DateOfBirth: newDate("1977-10-30"), @@ -55,8 +55,8 @@ func makeCertificateProvider() shared.CertificateProvider { UID: "b99af83d-5b6c-44f7-8c03-14004699bdb9", FirstNames: "Some", LastName: "Person", - Address: validAddress, }, + Address: validAddress, Email: "some@example.com", Channel: shared.ChannelOnline, Phone: "077777", @@ -84,8 +84,8 @@ func makeLpaWithDonorAndActors() shared.LpaInit { UID: "b99af83d-5b6c-44f7-8c03-14004699bdb9", FirstNames: "Otto", LastName: "Boudreau", - Address: validAddress, }, + Address: validAddress, ContactLanguagePreference: shared.LangEn, DateOfBirth: newDate("1956-08-08"), }, diff --git a/lambda/update/certificate_provider_sign_test.go b/lambda/update/certificate_provider_sign_test.go index d5914908..b2c9bc20 100644 --- a/lambda/update/certificate_provider_sign_test.go +++ b/lambda/update/certificate_provider_sign_test.go @@ -93,14 +93,14 @@ func TestValidateUpdateCertificateProviderSign(t *testing.T) { lpa: &shared.Lpa{ LpaInit: shared.LpaInit{ CertificateProvider: shared.CertificateProvider{ - Person: shared.Person{Address: shared.Address{ + Address: shared.Address{ Line1: "Line 1", Line2: "Line 2", Line3: "Line 3", Town: "Town", Postcode: "ABC 123", Country: "GB", - }}, + }, SignedAt: &yesterday, ContactLanguagePreference: shared.LangEn, Email: "a@example.com",