Skip to content

Commit

Permalink
Merge pull request #1511 from ministryofjustice/MLPAB-2231-send-peopl…
Browse files Browse the repository at this point in the history
…e-to-lpa-store

MLPAB-2231 Send independent witness and authorised signatory to lpa-store
  • Loading branch information
hawx authored Sep 26, 2024
2 parents 983392f + 1a6d6ca commit 10b5ed5
Show file tree
Hide file tree
Showing 8 changed files with 254 additions and 174 deletions.
283 changes: 154 additions & 129 deletions internal/lpastore/lpa.go

Large diffs are not rendered by default.

47 changes: 47 additions & 0 deletions internal/lpastore/lpa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ func TestClientSendLpa(t *testing.T) {
replacementAttorney2UID := actoruid.New()
certificateProviderUID := actoruid.New()
personToNotifyUID := actoruid.New()
authorisedSignatoryUID := actoruid.New()
independentWitnessUID := actoruid.New()

testcases := map[string]struct {
donor *donordata.Provided
Expand Down Expand Up @@ -242,6 +244,25 @@ func TestClientSendLpa(t *testing.T) {
Country: "GB",
},
}},
AuthorisedSignatory: donordata.AuthorisedSignatory{
UID: authorisedSignatoryUID,
FirstNames: "Author",
LastName: "Signor",
},
IndependentWitness: donordata.IndependentWitness{
UID: independentWitnessUID,
FirstNames: "Indiana",
LastName: "Witness",
Mobile: "0777777777",
Address: place.Address{
Line1: "i-line-1",
Line2: "i-line-2",
Line3: "i-line-3",
TownOrCity: "i-town",
Postcode: "I1 1WW",
Country: "GB",
},
},
IdentityUserData: identity.UserData{
Status: identity.StatusConfirmed,
FirstNames: "John Johnson",
Expand All @@ -268,6 +289,8 @@ func TestClientSendLpa(t *testing.T) {
],
"certificateProvider":{"uid":"` + certificateProviderUID.String() + `","firstNames":"Carol","lastName":"Cert","email":"[email protected]","phone":"0700009000","address":{"line1":"c-line-1","line2":"c-line-2","line3":"c-line-3","town":"c-town","postcode":"C1 1FF","country":"GB"},"channel":"online"},
"peopleToNotify":[{"uid":"` + personToNotifyUID.String() + `","firstNames":"Peter","lastName":"Notify","address":{"line1":"p-line-1","line2":"p-line-2","line3":"p-line-3","town":"p-town","postcode":"P1 1FF","country":"GB"}}],
"authorisedSignatory":{"uid":"` + authorisedSignatoryUID.String() + `","firstNames":"Author","lastName":"Signor"},
"independentWitness":{"uid":"` + independentWitnessUID.String() + `","firstNames":"Indiana","lastName":"Witness","phone":"0777777777","address":{"line1":"i-line-1","line2":"i-line-2","line3":"i-line-3","town":"i-town","postcode":"I1 1WW","country":"GB"}},
"howAttorneysMakeDecisions":"jointly",
"howReplacementAttorneysMakeDecisions":"jointly-for-some-severally-for-others",
"howReplacementAttorneysMakeDecisionsDetails":"umm",
Expand Down Expand Up @@ -393,6 +416,8 @@ func TestClientLpa(t *testing.T) {
replacementAttorney2UID := actoruid.New()
certificateProviderUID := actoruid.New()
personToNotifyUID := actoruid.New()
authorisedSignatoryUID := actoruid.New()
independentWitnessUID := actoruid.New()

testcases := map[string]struct {
donor *lpadata.Lpa
Expand Down Expand Up @@ -616,6 +641,25 @@ func TestClientLpa(t *testing.T) {
Country: "GB",
},
}},
AuthorisedSignatory: lpadata.AuthorisedSignatory{
UID: authorisedSignatoryUID,
FirstNames: "Author",
LastName: "Signor",
},
IndependentWitness: lpadata.IndependentWitness{
UID: independentWitnessUID,
FirstNames: "Indiana",
LastName: "Witness",
Mobile: "0777777777",
Address: place.Address{
Line1: "i-line-1",
Line2: "i-line-2",
Line3: "i-line-3",
TownOrCity: "i-town",
Postcode: "I1 1WW",
Country: "GB",
},
},
SignedAt: time.Date(2000, time.January, 2, 3, 4, 5, 6, time.UTC),
CertificateProviderNotRelatedConfirmedAt: time.Date(2001, time.February, 3, 4, 5, 6, 7, time.UTC),
},
Expand All @@ -636,6 +680,9 @@ func TestClientLpa(t *testing.T) {
],
"certificateProvider":{"uid":"` + certificateProviderUID.String() + `","firstNames":"Carol","lastName":"Cert","email":"[email protected]","phone":"0700009000","address":{"line1":"c-line-1","line2":"c-line-2","line3":"c-line-3","town":"c-town","postcode":"C1 1FF","country":"GB"},"channel":"online","identityCheck":{"checkedAt":"2002-01-01T13:14:15.000000016Z","type":"one-login"}},
"peopleToNotify":[{"uid":"` + personToNotifyUID.String() + `","firstNames":"Peter","lastName":"Notify","address":{"line1":"p-line-1","line2":"p-line-2","line3":"p-line-3","town":"p-town","postcode":"P1 1FF","country":"GB"}}],
"authorisedSignatory":{"uid":"` + authorisedSignatoryUID.String() + `","firstNames":"Author","lastName":"Signor"},
"independentWitness":{"uid":"` + independentWitnessUID.String() + `","firstNames":"Indiana","lastName":"Witness","phone":"0777777777",
"address":{"line1":"i-line-1","line2":"i-line-2","line3":"i-line-3","town":"i-town","postcode":"I1 1WW","country":"GB"}},
"howAttorneysMakeDecisions":"jointly",
"howReplacementAttorneysMakeDecisions":"jointly-for-some-severally-for-others",
"howReplacementAttorneysMakeDecisionsDetails":"umm",
Expand Down
13 changes: 13 additions & 0 deletions internal/lpastore/lpadata/authorised_signatory.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package lpadata

import "github.com/ministryofjustice/opg-modernising-lpa/internal/actor/actoruid"

type AuthorisedSignatory struct {
UID actoruid.UID
FirstNames string
LastName string
}

func (a AuthorisedSignatory) FullName() string {
return a.FirstNames + " " + a.LastName
}
11 changes: 11 additions & 0 deletions internal/lpastore/lpadata/authorised_signatory_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package lpadata

import (
"testing"

"github.com/stretchr/testify/assert"
)

func TestAuthorisedSignatoryFullName(t *testing.T) {
assert.Equal(t, "John Smith", AuthorisedSignatory{FirstNames: "John", LastName: "Smith"}.FullName())
}
9 changes: 7 additions & 2 deletions internal/lpastore/lpadata/lpa.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type Lpa struct {
Restrictions string
WhenCanTheLpaBeUsed CanBeUsedWhen
LifeSustainingTreatmentOption LifeSustainingTreatment
AuthorisedSignatory actor.Actor
AuthorisedSignatory AuthorisedSignatory
IndependentWitness IndependentWitness

// SignedAt is the date the Donor signed their LPA (and signifies it has been
Expand Down Expand Up @@ -161,7 +161,12 @@ func (l Lpa) Actors() iter.Seq[actor.Actor] {
}

if !l.AuthorisedSignatory.UID.IsZero() {
if !yield(l.AuthorisedSignatory) {
if !yield(actor.Actor{
Type: actor.TypeAuthorisedSignatory,
UID: l.AuthorisedSignatory.UID,
FirstNames: l.AuthorisedSignatory.FirstNames,
LastName: l.AuthorisedSignatory.LastName,
}) {
return
}
}
Expand Down
15 changes: 11 additions & 4 deletions internal/lpastore/lpadata/lpa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ func TestLpaCorrespondentEmailWhenCorrespondentProvided(t *testing.T) {
}

func TestLpaActors(t *testing.T) {
authorisedSignatory := actor.Actor{UID: actoruid.New()}

lpa := &Lpa{
Donor: Donor{
UID: actoruid.New(),
Expand Down Expand Up @@ -134,7 +132,11 @@ func TestLpaActors(t *testing.T) {
FirstNames: "Peter",
LastName: "Person",
}},
AuthorisedSignatory: authorisedSignatory,
AuthorisedSignatory: AuthorisedSignatory{
UID: actoruid.New(),
FirstNames: "Aut",
LastName: "Sig",
},
IndependentWitness: IndependentWitness{
UID: actoruid.New(),
FirstNames: "Ind",
Expand Down Expand Up @@ -181,7 +183,12 @@ func TestLpaActors(t *testing.T) {
UID: lpa.PeopleToNotify[0].UID,
FirstNames: "Peter",
LastName: "Person",
}, authorisedSignatory, {
}, {
Type: actor.TypeAuthorisedSignatory,
UID: lpa.AuthorisedSignatory.UID,
FirstNames: "Aut",
LastName: "Sig",
}, {
Type: actor.TypeIndependentWitness,
UID: lpa.IndependentWitness.UID,
FirstNames: "Ind",
Expand Down
22 changes: 0 additions & 22 deletions internal/lpastore/resolving_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"errors"

"github.com/ministryofjustice/opg-modernising-lpa/internal/actor"
"github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata"
"github.com/ministryofjustice/opg-modernising-lpa/internal/dynamo"
"github.com/ministryofjustice/opg-modernising-lpa/internal/lpastore/lpadata"
Expand Down Expand Up @@ -112,27 +111,6 @@ func (s *ResolvingService) merge(lpa *lpadata.Lpa, donor *donordata.Provided) *l
}
}

// TODO: remove this once authorised signatory is in lpa-store
if lpa.AuthorisedSignatory.FirstNames == "" && donor.AuthorisedSignatory.FirstNames != "" {
lpa.AuthorisedSignatory = actor.Actor{
Type: actor.TypeAuthorisedSignatory,
UID: donor.AuthorisedSignatory.UID,
FirstNames: donor.AuthorisedSignatory.FirstNames,
LastName: donor.AuthorisedSignatory.LastName,
}
}

// TODO: remove this once independent witness is in lpa-store
if lpa.IndependentWitness.FirstNames == "" && donor.IndependentWitness.FirstNames != "" {
lpa.IndependentWitness = lpadata.IndependentWitness{
UID: donor.IndependentWitness.UID,
FirstNames: donor.IndependentWitness.FirstNames,
LastName: donor.IndependentWitness.LastName,
Mobile: donor.IndependentWitness.Mobile,
Address: donor.IndependentWitness.Address,
}
}

// copy the relationship as it isn't stored in the lpastore.
lpa.CertificateProvider.Relationship = donor.CertificateProvider.Relationship

Expand Down
28 changes: 11 additions & 17 deletions internal/lpastore/resolving_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"testing"
"time"

"github.com/ministryofjustice/opg-modernising-lpa/internal/actor"
"github.com/ministryofjustice/opg-modernising-lpa/internal/actor/actoruid"
"github.com/ministryofjustice/opg-modernising-lpa/internal/donor/donordata"
"github.com/ministryofjustice/opg-modernising-lpa/internal/dynamo"
"github.com/ministryofjustice/opg-modernising-lpa/internal/identity"
Expand All @@ -16,6 +16,8 @@ import (
)

func TestResolvingServiceGet(t *testing.T) {
actorUID := actoruid.New()

testcases := map[string]struct {
donor *donordata.Provided
resolved *lpadata.Lpa
Expand All @@ -41,8 +43,8 @@ func TestResolvingServiceGet(t *testing.T) {
RetrievedAt: time.Now(),
},
Correspondent: donordata.Correspondent{Email: "x"},
AuthorisedSignatory: donordata.AuthorisedSignatory{FirstNames: "A", LastName: "S"},
IndependentWitness: donordata.IndependentWitness{FirstNames: "I", LastName: "W"},
AuthorisedSignatory: donordata.AuthorisedSignatory{UID: actorUID, FirstNames: "A", LastName: "S"},
IndependentWitness: donordata.IndependentWitness{UID: actorUID, FirstNames: "I", LastName: "W"},
Voucher: donordata.Voucher{Allowed: true, Email: "y"},
},
resolved: &lpadata.Lpa{
Expand All @@ -65,16 +67,7 @@ func TestResolvingServiceGet(t *testing.T) {
},
Donor: lpadata.Donor{Channel: lpadata.ChannelOnline},
Correspondent: lpadata.Correspondent{Email: "x"},
AuthorisedSignatory: actor.Actor{
Type: actor.TypeAuthorisedSignatory,
FirstNames: "A",
LastName: "S",
},
IndependentWitness: lpadata.IndependentWitness{
FirstNames: "I",
LastName: "W",
},
Voucher: lpadata.Voucher{Email: "y"},
Voucher: lpadata.Voucher{Email: "y"},
},
},
"online with no lpastore record": {
Expand All @@ -99,8 +92,8 @@ func TestResolvingServiceGet(t *testing.T) {
RetrievedAt: time.Date(2020, time.January, 2, 12, 13, 14, 5, time.UTC),
},
Correspondent: donordata.Correspondent{Email: "x"},
AuthorisedSignatory: donordata.AuthorisedSignatory{FirstNames: "A", LastName: "S"},
IndependentWitness: donordata.IndependentWitness{FirstNames: "I", LastName: "W"},
AuthorisedSignatory: donordata.AuthorisedSignatory{UID: actorUID, FirstNames: "A", LastName: "S"},
IndependentWitness: donordata.IndependentWitness{UID: actorUID, FirstNames: "I", LastName: "W"},
Voucher: donordata.Voucher{Allowed: true, Email: "y"},
},
error: ErrNotFound,
Expand All @@ -127,12 +120,13 @@ func TestResolvingServiceGet(t *testing.T) {
TrustCorporation: lpadata.TrustCorporation{Name: "d"},
},
Correspondent: lpadata.Correspondent{Email: "x"},
AuthorisedSignatory: actor.Actor{
Type: actor.TypeAuthorisedSignatory,
AuthorisedSignatory: lpadata.AuthorisedSignatory{
UID: actorUID,
FirstNames: "A",
LastName: "S",
},
IndependentWitness: lpadata.IndependentWitness{
UID: actorUID,
FirstNames: "I",
LastName: "W",
},
Expand Down

0 comments on commit 10b5ed5

Please sign in to comment.