Skip to content

Commit

Permalink
MLPAB-2231 Store independent witness and authorised signatory if given (
Browse files Browse the repository at this point in the history
  • Loading branch information
hawx authored Sep 25, 2024
1 parent fe3ebae commit 0e51b03
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 22 deletions.
36 changes: 36 additions & 0 deletions docs/schemas/2024-10/donor-details.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down Expand Up @@ -144,6 +176,10 @@
"signedAt": {
"type": "string",
"format": "date-time"
},
"certificateProviderNotRelatedConfirmedAt": {
"type": "string",
"format": "date-time"
}
},
"if": {
Expand Down
2 changes: 2 additions & 0 deletions internal/shared/lpa.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
21 changes: 17 additions & 4 deletions internal/shared/person.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand All @@ -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"`
Expand Down Expand Up @@ -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"`
Expand Down Expand Up @@ -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 {
Expand Down
24 changes: 12 additions & 12 deletions lambda/create/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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,
Expand All @@ -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",
Expand Down
14 changes: 14 additions & 0 deletions lambda/create/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand Down
8 changes: 4 additions & 4 deletions lambda/create/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ func makeAttorney() shared.Attorney {
UID: "b99af83d-5b6c-44f7-8c03-14004699bdb9",
FirstNames: "Sharonda",
LastName: "Graciani",
Address: validAddress,
},
Address: validAddress,
Email: "[email protected]",
Channel: shared.ChannelOnline,
DateOfBirth: newDate("1977-10-30"),
Expand All @@ -40,8 +40,8 @@ func makeReplacementAttorney() shared.Attorney {
UID: "b99af83d-5b6c-44f7-8c03-14004699bdb9",
FirstNames: "Sharonda",
LastName: "Graciani",
Address: validAddress,
},
Address: validAddress,
Email: "[email protected]",
Channel: shared.ChannelOnline,
DateOfBirth: newDate("1977-10-30"),
Expand All @@ -55,8 +55,8 @@ func makeCertificateProvider() shared.CertificateProvider {
UID: "b99af83d-5b6c-44f7-8c03-14004699bdb9",
FirstNames: "Some",
LastName: "Person",
Address: validAddress,
},
Address: validAddress,
Email: "[email protected]",
Channel: shared.ChannelOnline,
Phone: "077777",
Expand Down Expand Up @@ -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"),
},
Expand Down
4 changes: 2 additions & 2 deletions lambda/update/certificate_provider_sign_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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: "[email protected]",
Expand Down

0 comments on commit 0e51b03

Please sign in to comment.