Skip to content

Commit

Permalink
MLPAB-1804, MLPAB-1641: Fix reusing details and trust corp contents (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
acsauk authored May 16, 2024
1 parent 59871d4 commit 599d69e
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 30 deletions.
17 changes: 9 additions & 8 deletions internal/page/donor/choose_address.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@ func newChooseAddressData(appData page.AppData, actorLabel, fullName string, UID
}

type chooseAddressData struct {
App page.AppData
Errors validation.List
ActorLabel string
FullName string
UID actoruid.UID
Addresses []place.Address
Form *form.AddressForm
TitleKeys titleKeys
App page.AppData
Errors validation.List
ActorLabel string
FullName string
UID actoruid.UID
Addresses []place.Address
Form *form.AddressForm
TitleKeys titleKeys
MakingAnotherLPA bool
}

type titleKeys struct {
Expand Down
4 changes: 3 additions & 1 deletion internal/page/donor/your_address.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ func YourAddress(logger Logger, tmpl template.Template, addressClient AddressCli
data.Form.Address = &donor.Donor.Address
}

data.MakingAnotherLPA = r.URL.Query().Get("makingAnotherLPA") != ""

if r.Method == http.MethodPost {
data.Form = form.ReadAddressForm(r)
data.Errors = data.Form.Validate(true)
Expand All @@ -46,7 +48,7 @@ func YourAddress(logger Logger, tmpl template.Template, addressClient AddressCli
}
}

if r.URL.Query().Get("makingAnotherLPA") != "" {
if data.MakingAnotherLPA {
if !addressChangesMade {
return page.Paths.MakeANewLPA.Redirect(w, r, appData, donor)
}
Expand Down
50 changes: 36 additions & 14 deletions internal/page/donor/your_address_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,45 @@ import (
)

func TestGetYourAddress(t *testing.T) {
w := httptest.NewRecorder()
r, _ := http.NewRequest(http.MethodGet, "/", nil)
testcases := map[string]struct {
query string
expectedData *chooseAddressData
}{
"first time": {
expectedData: &chooseAddressData{
App: testAppData,
Form: form.NewAddressForm(),
TitleKeys: testTitleKeys,
},
},
"making another LPA": {
query: "?makingAnotherLPA=1",
expectedData: &chooseAddressData{
App: testAppData,
Form: form.NewAddressForm(),
TitleKeys: testTitleKeys,
MakingAnotherLPA: true,
},
},
}

template := newMockTemplate(t)
template.EXPECT().
Execute(w, &chooseAddressData{
App: testAppData,
Form: form.NewAddressForm(),
TitleKeys: testTitleKeys,
}).
Return(nil)
for name, tc := range testcases {
t.Run(name, func(t *testing.T) {
w := httptest.NewRecorder()
r, _ := http.NewRequest(http.MethodGet, "/"+tc.query, nil)

err := YourAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{})
resp := w.Result()
template := newMockTemplate(t)
template.EXPECT().
Execute(w, tc.expectedData).
Return(nil)

assert.Nil(t, err)
assert.Equal(t, http.StatusOK, resp.StatusCode)
err := YourAddress(nil, template.Execute, nil, nil)(testAppData, w, r, &actor.DonorProvidedDetails{})
resp := w.Result()

assert.Nil(t, err)
assert.Equal(t, http.StatusOK, resp.StatusCode)
})
}
}

func TestGetYourAddressFromStore(t *testing.T) {
Expand Down
4 changes: 3 additions & 1 deletion lang/cy.json
Original file line number Diff line number Diff line change
Expand Up @@ -1200,5 +1200,7 @@
"whenYouSelectConfirmWeWillContactDonor": "Welsh {{ .DonorFirstNames }} Welsh",
"thankYou": "Welsh",
"weHaveContactedDonorToLetThemKnowYourDecision": "Welsh {{ .DonorFullName }} Welsh",
"reportAConcernContent": "<h2 class=\"govuk-heading-m\">Welsh</h2> <p class=\"govuk-body\">Welsh:</p> <ul class=\"govuk-list govuk-list--bullet\"> <li>Welsh: 0115 934 2777</li> <li>Welsh: <a class=\"govuk-link\" href=\"mailto:[email protected]\">[email protected]</a> </li> </ul> <p class=\"govuk-body\">Welsh <a class=\"govuk-link\" href=\"#\">Welsh</a> Welsh</p>"
"reportAConcernContent": "<h2 class=\"govuk-heading-m\">Welsh</h2> <p class=\"govuk-body\">Welsh:</p> <ul class=\"govuk-list govuk-list--bullet\"> <li>Welsh: 0115 934 2777</li> <li>Welsh: <a class=\"govuk-link\" href=\"mailto:[email protected]\">[email protected]</a> </li> </ul> <p class=\"govuk-body\">Welsh <a class=\"govuk-link\" href=\"#\">Welsh</a> Welsh</p>",
"yourAddress": "Welsh",
"yourAddressWarning": "Welsh"
}
10 changes: 6 additions & 4 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@
"legalRightsAndResponsibilities": "Legal rights and responsibilities",
"attorneyRightsAndResponsibilitiesTitle": "Your legal rights and responsibilities",
"attorneyRightsAndResponsibilitiesContent": "<p class=\"govuk-body-l\">Before signing, you must read your legal rights and responsibilities as an attorney.</p> <h2 class=\"govuk-heading-m\">How attorneys should act</h2> <p class=\"govuk-body\">When the donor signs their LPA, they are appointing their attorneys to make decisions for them.</p> <p class=\"govuk-body\">As an attorney, you must follow the <a class=\"govuk-link\" href=\"https://www.gov.uk/government/publications/mental-capacity-act-code-of-practice\">Mental Capacity Act Code of Practice</a>:</p> <ul class=\"govuk-list govuk-list--bullet\"> <li>You must assume the donor can make their own decisions, unless it is established that they cannot do so.</li> <li>You must help the donor to make as many of their own decisions as they can.</li> <li>You must take all practical steps to help the donor make a decision. You must only treat the donor as unable to make a decision if you have not succeeded in helping the donor make a decision through those steps.</li> <li>You must not treat the donor as unable to make a decision because they have made an unwise decision.</li> <li>You must act and make decisions in the donor’s best interests when they are unable to make a decision.</li> <li>Before you make a decision or act for the donor, you must consider any option that is less restrictive of the donor’s rights and freedom which might achieve the same outcome.</li> </ul> <h2 class=\"govuk-heading-m\">How this LPA can be used</h2> <ul class=\"govuk-list govuk-list--bullet\"> <li>When the donor signs their LPA, along with all their attorneys, replacement attorneys and certificate provider, they are forming a legal agreement (a deed).</li> <li>This LPA can only be used if it’s registered with the Office of the Public Guardian (OPG).</li> <li>The donor can cancel their LPA at any time if they have mental capacity.</li> <li>You, or any other attorney named in this LPA, cannot use the LPA to make changes to the donor’s will.</li> <li>This LPA will expire when the donor dies.</li> </ul>",
"trustCorporationRightsAndResponsibilitiesContent": "<p class=\"govuk-body-l\">Before signing, you must read the trust corporation’s legal rights and responsibilities as an attorney.</p><h2 class=\"govuk-heading-m\">How attorneys should act</h2><p class=\"govuk-body\">As an attorney, the trust corporation must follow the <a href=\"https://www.gov.uk/government/publications/mental-capacity-act-code-of-practice\" class=\"govuk-link\">Mental Capacity Act Code of Practice</a>:</p><ul class=\"govuk-list govuk-list--bullet\"><li>It must assume the donor can make their own decisions, unless it is established that they cannot do so.</li><li>It must help the donor to make as many of their own decisions as they can.</li><li>It must take all practical steps to help the donor make a decision. It must only treat the donor as unable to make a decision if it has not succeeded in helping the donor make a decision through those steps.</li><li>It must not treat the donor as unable to make a decision because they have made an unwise decision.</li><li>It must act and make decisions in the donor’s best interests when they are unable to make a decision.</li><li>Before it makes a decision or acts for the donor, it must consider any option that is less restrictive of the donor’s rights and freedom which might achieve the same outcome.</li><li>It must not be going through winding-up proceedings.</li><li>It can spend spend money to make gifts but only to charities or customary occasions such as birthdays, and for reasonable amounts with regard to size of the donor’s estate.</li><li>It has a duty to keep accounts and financial records and produce them to the Office of the Public Guardian or to the Court of Protection on request.</li></ul><h2 class=\"govuk-heading-m\">How this LPA can be used</h2><ul class=\"govuk-list govuk-list--bullet\"><li>When the donor signs their LPA, along with all their attorneys, replacement attorneys and certificate provider, they are forming a legal agreement (a deed).</li><li>This LPA can only be used if it’s registered with the Office of the Public Guardian (OPG).</li><li>The donor can cancel their LPA at any time if they have mental capacity.</li><li>The trust corporation, or any other attorney named in this LPA, cannot use the LPA to make changes to the donor’s will.</li><li>This LPA will expire when the donor dies.</li></ul>",
"trustCorporationRightsAndResponsibilitiesContent": "<p class=\"govuk-body-l\">Before signing, you must read the trust corporation’s legal rights and responsibilities as an attorney.</p><h2 class=\"govuk-heading-m\">How attorneys should act</h2><p class=\"govuk-body\">As an attorney, the trust corporation must follow the <a href=\"https://www.gov.uk/government/publications/mental-capacity-act-code-of-practice\" class=\"govuk-link\">Mental Capacity Act Code of Practice</a>:</p><ul class=\"govuk-list govuk-list--bullet\"><li>It must assume the donor can make their own decisions, unless it is established that they cannot do so.</li><li>It must help the donor to make as many of their own decisions as they can.</li><li>It must take all practical steps to help the donor make a decision. It must only treat the donor as unable to make a decision if it has not succeeded in helping the donor make a decision through those steps.</li><li>It must not treat the donor as unable to make a decision because they have made an unwise decision.</li><li>It must act and make decisions in the donor’s best interests when they are unable to make a decision.</li><li>Before it makes a decision or acts for the donor, it must consider any option that is less restrictive of the donor’s rights and freedom which might achieve the same outcome.</li><li>It must not be going through winding-up proceedings.</li><li>It can spend money to make gifts but only to charities or customary occasions such as birthdays, and for reasonable amounts with regard to size of the donor’s estate.</li><li>It has a duty to keep accounts and financial records and produce them to the Office of the Public Guardian or to the Court of Protection on request.</li></ul><h2 class=\"govuk-heading-m\">How this LPA can be used</h2><ul class=\"govuk-list govuk-list--bullet\"><li>When the donor signs their LPA, along with all their attorneys, replacement attorneys and certificate provider, they are forming a legal agreement (a deed).</li><li>This LPA can only be used if it’s registered with the Office of the Public Guardian (OPG).</li><li>The donor can cancel their LPA at any time if they have mental capacity.</li><li>The trust corporation, or any other attorney named in this LPA, cannot use the LPA to make changes to the donor’s will.</li><li>This LPA will expire when the donor dies.</li></ul>",
"whatHappensWhenYouSignTheLpaTitle": "What happens when you sign the LPA",
"whatHappensWhenYouSignTheLpaContentAttorneyPw": "<p class=\"govuk-body\">Signing the LPA is an important and powerful legal step.</p> <p class=\"govuk-body\">When you sign, you’re officially saying that you want to be an attorney on {{ .DonorFullNamePossessive }} personal welfare LPA.</p> <p class=\"govuk-body\">This means that once the LPA has been registered, you (and any other attorneys named in this LPA) can make decisions about:</p>",
"whatHappensWhenYouSignTheLpaContentAttorneyPa": "<p class=\"govuk-body\">Signing the LPA is an important and powerful legal step.</p> <p class=\"govuk-body\">When you sign, you’re officially saying that you want to be an attorney on {{ .DonorFullNamePossessive }} property and affairs LPA.</p> <p class=\"govuk-body\">This means that once the LPA has been registered, you (and any other attorneys named in this LPA) have the power to:</p>",
Expand Down Expand Up @@ -951,8 +951,8 @@
"youShouldOnlyChangeYourDetailsIfTheyNeedToBeUpdated": "<p class=\"govuk-body\">You should only change your details if they need to be updated. You cannot make an LPA for someone else using your own account. <a href=\"#\" class=\"govuk-link\">Find out more about how to make an LPA for someone else</a>.</p>",
"yourName": "Your name",
"yourNameWarning": "You should only enter your details. You cannot make an LPA for someone else using your account.",
"yourDateOfBirth": "Your name",
"yourDateOfBirthWarning": "You should only enter your date of birth. You cannot make an LPA for someone else using your account.",
"yourDateOfBirth": "Your date of birth",
"yourDateOfBirthWarning": "You should only update your date of birth if it is incorrect. You cannot make an LPA for someone else using your account.",
"detailUpdated": "{{ .Detail }} updated",
"weHaveUpdatedYourDetail": "We have updated your {{ .Detail }}.",
"weHaveUpdatedYourDetails": "We have updated your details",
Expand Down Expand Up @@ -1132,5 +1132,7 @@
"whenYouSelectConfirmWeWillContactDonor": "When you select ‘Confirm’ we will contact {{ .DonorFirstNames }} to tell them what they should do next.",
"thankYou": "Thank you",
"weHaveContactedDonorToLetThemKnowYourDecision": "We have contacted {{ .DonorFullName }} to let them know of your decision to not be their certificate provider",
"reportAConcernContent": "<h2 class=\"govuk-heading-m\">Report a concern</h2> <p class=\"govuk-body\">If you have concerns about this LPA you can contact our safeguarding team:</p> <ul class=\"govuk-list govuk-list--bullet\"> <li>call: 0115 934 2777</li> <li>email: <a class=\"govuk-link\" href=\"mailto:[email protected]\">[email protected]</a> </li> </ul> <p class=\"govuk-body\">You can also <a class=\"govuk-link\" href=\"#\">report a concern</a> using our online form.</p>"
"reportAConcernContent": "<h2 class=\"govuk-heading-m\">Report a concern</h2> <p class=\"govuk-body\">If you have concerns about this LPA you can contact our safeguarding team:</p> <ul class=\"govuk-list govuk-list--bullet\"> <li>call: 0115 934 2777</li> <li>email: <a class=\"govuk-link\" href=\"mailto:[email protected]\">[email protected]</a> </li> </ul> <p class=\"govuk-body\">You can also <a class=\"govuk-link\" href=\"#\">report a concern</a> using our online form.</p>",
"yourAddress": "Your address",
"yourAddressWarning": "You should only enter your address. You cannot make an LPA for someone else using your account."
}
14 changes: 12 additions & 2 deletions web/template/donor/your_address.gohtml
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
{{ template "page" . }}

{{ define "pageTitle" }}{{ tr .App "whatIsYourAddress" }}{{ end }}
{{ define "pageTitle" }}
{{ if .MakingAnotherLPA }}
{{ tr .App "yourAddress" }}
{{ else }}
{{ tr .App "whatIsYourAddress" }}
{{ end }}
{{ end }}

{{ define "main" }}
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<form novalidate method="post">
<fieldset class="govuk-fieldset">
<legend class="govuk-fieldset__legend govuk-fieldset__legend--xl">
<h1 class="govuk-fieldset__heading">{{ tr .App "whatIsYourAddress" }}</h1>
<h1 class="govuk-fieldset__heading">{{ template "pageTitle" . }}</h1>
</legend>

{{ if .MakingAnotherLPA }}
{{ template "warning" (content .App "yourAddressWarning") }}
{{ end }}

{{ if eq .Form.Action "manual" }}
{{ template "input" (input . .Form.FieldNames.Line1 "addressLine1" .Form.Address.Line1 "autocomplete" "address-line1") }}
{{ template "input" (input . .Form.FieldNames.Line2 "addressLine2" .Form.Address.Line2 "autocomplete" "address-line2") }}
Expand Down

0 comments on commit 599d69e

Please sign in to comment.