Skip to content

Commit

Permalink
Correct use of inactive and replacement status for attorneys
Browse files Browse the repository at this point in the history
  • Loading branch information
hawx committed Dec 2, 2024
1 parent aad071a commit d5d0425
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 21 deletions.
2 changes: 1 addition & 1 deletion internal/lpastore/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
const (
issuer = "opg.poas.makeregister"
statusActive = "active"
statusReplacement = "replacement"
statusInactive = "inactive"
statusRemoved = "removed"
appointmentTypeOriginal = "original"
appointmentTypeReplacement = "replacement"
Expand Down
6 changes: 3 additions & 3 deletions internal/lpastore/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func TestClientServiceContract(t *testing.T) {
"country": matchers.String("GB"),
}),
"channel": matchers.Regex("online", "online|paper"),
"status": matchers.Regex("active", "active|inactive|removed|replacement"),
"status": matchers.Regex("active", "active|inactive|removed"),
"appointmentType": matchers.Regex("original", "original|replacement"),
}, 1),
"trustCorporations": matchers.EachLike(map[string]any{
Expand All @@ -138,7 +138,7 @@ func TestClientServiceContract(t *testing.T) {
"country": matchers.String("GB"),
}),
"channel": matchers.Regex("paper", "online|paper"),
"status": matchers.Regex("active", "active|replacement"),
"status": matchers.Regex("active", "active|inactive|removed"),
"appointmentType": matchers.Regex("original", "original|replacement"),
}, 1),
"certificateProvider": matchers.Like(map[string]any{
Expand Down Expand Up @@ -287,7 +287,7 @@ func TestClientServiceContract(t *testing.T) {
"postcode": matchers.String("A1 1FF"),
"country": matchers.String("GB"),
}),
"status": matchers.Regex("active", "active|replacement"),
"status": matchers.Regex("active", "active|inactive|removed"),
"appointmentType": matchers.Regex("original", "original|replacement"),
"channel": matchers.Regex("online", "online|post"),
}, 1),
Expand Down
12 changes: 2 additions & 10 deletions internal/lpastore/lpa.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ func (c *Client) SendLpa(ctx context.Context, donor *donordata.Provided) error {
DateOfBirth: attorney.DateOfBirth,
Email: attorney.Email,
Address: attorney.Address,
Status: statusReplacement,
Status: statusInactive,
AppointmentType: appointmentTypeReplacement,
Channel: attorney.Channel(),
})
Expand All @@ -230,7 +230,7 @@ func (c *Client) SendLpa(ctx context.Context, donor *donordata.Provided) error {
CompanyNumber: trustCorporation.CompanyNumber,
Email: trustCorporation.Email,
Address: trustCorporation.Address,
Status: statusReplacement,
Status: statusInactive,
AppointmentType: appointmentTypeReplacement,
Channel: trustCorporation.Channel(),
})
Expand Down Expand Up @@ -393,10 +393,6 @@ func lpaResponseToLpa(l lpaResponse) *lpadata.Lpa {
}

for _, a := range l.Attorneys {
if a.Status == "inactive" {
continue
}

at := lpadata.Attorney{
UID: a.UID,
FirstNames: a.FirstNames,
Expand All @@ -419,10 +415,6 @@ func lpaResponseToLpa(l lpaResponse) *lpadata.Lpa {
}

for _, t := range l.TrustCorporations {
if t.Status == "inactive" {
continue
}

tc := lpadata.TrustCorporation{
UID: t.UID,
Name: t.Name,
Expand Down
10 changes: 3 additions & 7 deletions internal/lpastore/lpa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,12 +284,12 @@ func TestClientSendLpa(t *testing.T) {
"attorneys":[
{"uid":"` + attorneyUID.String() + `","firstNames":"Adam","lastName":"Attorney","dateOfBirth":"1999-01-02","email":"[email protected]","address":{"line1":"a-line-1","line2":"a-line-2","line3":"a-line-3","town":"a-town","postcode":"A1 1FF","country":"GB"},"appointmentType":"original","status":"active","channel":"online"},
{"uid":"` + attorney2UID.String() + `","firstNames":"Alice","lastName":"Attorney","dateOfBirth":"1998-01-02","address":{"line1":"aa-line-1","line2":"aa-line-2","line3":"aa-line-3","town":"aa-town","postcode":"A1 1AF","country":"GB"},"appointmentType":"original","status":"active","channel":"paper"},
{"uid":"` + replacementAttorneyUID.String() + `","firstNames":"Richard","lastName":"Attorney","dateOfBirth":"1999-11-12","email":"[email protected]","address":{"line1":"r-line-1","line2":"r-line-2","line3":"r-line-3","town":"r-town","postcode":"R1 1FF","country":"GB"},"appointmentType":"replacement","status":"replacement","channel":"online"},
{"uid":"` + replacementAttorney2UID.String() + `","firstNames":"Rachel","lastName":"Attorney","dateOfBirth":"1998-11-12","email":"[email protected]","address":{"line1":"rr-line-1","line2":"rr-line-2","line3":"rr-line-3","town":"rr-town","postcode":"R1 1RF","country":"GB"},"appointmentType":"replacement","status":"replacement","channel":"online"}
{"uid":"` + replacementAttorneyUID.String() + `","firstNames":"Richard","lastName":"Attorney","dateOfBirth":"1999-11-12","email":"[email protected]","address":{"line1":"r-line-1","line2":"r-line-2","line3":"r-line-3","town":"r-town","postcode":"R1 1FF","country":"GB"},"appointmentType":"replacement","status":"inactive","channel":"online"},
{"uid":"` + replacementAttorney2UID.String() + `","firstNames":"Rachel","lastName":"Attorney","dateOfBirth":"1998-11-12","email":"[email protected]","address":{"line1":"rr-line-1","line2":"rr-line-2","line3":"rr-line-3","town":"rr-town","postcode":"R1 1RF","country":"GB"},"appointmentType":"replacement","status":"inactive","channel":"online"}
],
"trustCorporations":[
{"uid":"` + trustCorporationUID.String() + `","name":"Trusty","companyNumber":"55555","email":"[email protected]","address":{"line1":"a-line-1","line2":"a-line-2","line3":"a-line-3","town":"a-town","postcode":"A1 1FF","country":"GB"},"appointmentType":"original","status":"active","channel":"online"},
{"uid":"` + replacementTrustCorporationUID.String() + `","name":"UnTrusty","companyNumber":"65555","address":{"line1":"a-line-1","line2":"a-line-2","line3":"a-line-3","town":"a-town","postcode":"A1 1FF","country":"GB"},"appointmentType":"replacement","status":"replacement","channel":"paper"}
{"uid":"` + replacementTrustCorporationUID.String() + `","name":"UnTrusty","companyNumber":"65555","address":{"line1":"a-line-1","line2":"a-line-2","line3":"a-line-3","town":"a-town","postcode":"A1 1FF","country":"GB"},"appointmentType":"replacement","status":"inactive","channel":"paper"}
],
"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"}}],
Expand Down Expand Up @@ -875,10 +875,8 @@ func TestClientLpas(t *testing.T) {
donorUID, _ := actoruid.Parse("6178e739-76b0-426e-b9c4-e45be426fbdf")

trustCorporationUID := actoruid.New()
trustCorporation2UID := actoruid.New()
attorneyUID := actoruid.New()
attorney2UID := actoruid.New()
attorney3UID := actoruid.New()
replacementTrustCorporationUID := actoruid.New()
replacementAttorneyUID := actoruid.New()
replacementAttorney2UID := actoruid.New()
Expand Down Expand Up @@ -1116,13 +1114,11 @@ func TestClientLpas(t *testing.T) {
"attorneys":[
{"uid":"` + attorneyUID.String() + `","firstNames":"Adam","lastName":"Attorney","dateOfBirth":"1999-01-02","email":"[email protected]","address":{"line1":"a-line-1","line2":"a-line-2","line3":"a-line-3","town":"a-town","postcode":"A1 1FF","country":"GB"},"status":"active","appointmentType":"original"},
{"uid":"` + attorney2UID.String() + `","firstNames":"Alice","lastName":"Attorney","dateOfBirth":"1998-01-02","email":"[email protected]","address":{"line1":"aa-line-1","line2":"aa-line-2","line3":"aa-line-3","town":"aa-town","postcode":"A1 1AF","country":"GB"},"status":"removed","appointmentType":"original"},
{"uid":"` + attorney3UID.String() + `","firstNames":"Alice","lastName":"Attorney","dateOfBirth":"1998-01-02","email":"[email protected]","address":{"line1":"aa-line-1","line2":"aa-line-2","line3":"aa-line-3","town":"aa-town","postcode":"A1 1AF","country":"GB"},"status":"inactive","appointmentType":"original"},
{"uid":"` + replacementAttorneyUID.String() + `","firstNames":"Richard","lastName":"Attorney","dateOfBirth":"1999-11-12","email":"[email protected]","address":{"line1":"r-line-1","line2":"r-line-2","line3":"r-line-3","town":"r-town","postcode":"R1 1FF","country":"GB"},"status":"replacement","appointmentType":"replacement"},
{"uid":"` + replacementAttorney2UID.String() + `","firstNames":"Rachel","lastName":"Attorney","dateOfBirth":"1998-11-12","email":"[email protected]","address":{"line1":"rr-line-1","line2":"rr-line-2","line3":"rr-line-3","town":"rr-town","postcode":"R1 1RF","country":"GB"},"status":"replacement","appointmentType":"replacement"}
],
"trustCorporations":[
{"uid":"` + trustCorporationUID.String() + `","name":"Trusty","companyNumber":"55555","email":"[email protected]","address":{"line1":"a-line-1","line2":"a-line-2","line3":"a-line-3","town":"a-town","postcode":"A1 1FF","country":"GB"},"status":"active","appointmentType":"original"},
{"uid":"` + trustCorporation2UID.String() + `","name":"Trusty","companyNumber":"55555","email":"[email protected]","address":{"line1":"a-line-1","line2":"a-line-2","line3":"a-line-3","town":"a-town","postcode":"A1 1FF","country":"GB"},"status":"inactive","appointmentType":"original"},
{"uid":"` + replacementTrustCorporationUID.String() + `","name":"UnTrusty","companyNumber":"65555","email":"[email protected]","address":{"line1":"a-line-1","line2":"a-line-2","line3":"a-line-3","town":"a-town","postcode":"A1 1FF","country":"GB"},"status":"removed","appointmentType":"replacement"}
],
"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"},
Expand Down

0 comments on commit d5d0425

Please sign in to comment.