Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VEGA-2743 allow attorney details correction #283

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

MishNajam
Copy link
Contributor

@MishNajam MishNajam commented Dec 11, 2024

Purpose

Updates the correction event to allow for attorney details to also be corrected

Fixes (VEGA-2743)

Approach

Implementation just adds to the current correction method

@MishNajam MishNajam requested review from a team as code owners December 11, 2024 16:03
@MishNajam MishNajam force-pushed the VEGA-2743-change-attorney-details branch from 583fd16 to 0e2c8ee Compare December 11, 2024 17:50
@MishNajam MishNajam force-pushed the VEGA-2743-change-attorney-details branch from 0e2c8ee to a9d61fa Compare December 12, 2024 08:53
Comment on lines 135 to 144
Prefix("/address", func(p *parse.Parser) []shared.FieldError {
return p.
Field("/line1", &data.AttorneyAddress.Line1, parse.Optional()).
Field("/line2", &data.AttorneyAddress.Line2, parse.Optional()).
Field("/line3", &data.AttorneyAddress.Line3, parse.Optional()).
Field("/town", &data.AttorneyAddress.Town, parse.Optional()).
Field("/postcode", &data.AttorneyAddress.Postcode, parse.Optional()).
Field("/country", &data.AttorneyAddress.Country, parse.Validate(func() []shared.FieldError {
return validate.Country("", data.AttorneyAddress.Country)
}), parse.Optional()).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could extract the address bit like:

func validateAddress(address *shared.Address) func(p *parse.Parser) []shared.FieldError {
	return func(p *parse.Parser) []shared.FieldError {
		return p.
			Field("/line1", &address.Line1, parse.Optional()).
			Field("/line2", &address.Line2, parse.Optional()).
			Field("/line3", &address.Line3, parse.Optional()).
			Field("/town", &address.Town, parse.Optional()).
			Field("/postcode", &address.Postcode, parse.Optional()).
			Field("/country", &address.Country, parse.Validate(func() []shared.FieldError {
				return validate.Country("", address.Country)
			}), parse.Optional()).
			Consumed()
	}
}

// validateAddress(&data.DonorAddress)
// validateAddress(&data.AttorneyAddress)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could also use a similar technique to extract the /donor and /attorney handling if you wanted

Comment on lines 11 to 27
type Correction struct {
DonorFirstNames string
DonorLastName string
DonorOtherNames string
DonorDob shared.Date
DonorAddress shared.Address
DonorEmail string
LPASignedAt time.Time
DonorFirstNames string
DonorLastName string
DonorOtherNames string
DonorDob shared.Date
DonorAddress shared.Address
DonorEmail string
LPASignedAt time.Time
Index *int
AttorneyFirstNames string
AttorneyLastName string
AttorneyDob shared.Date
AttorneyAddress shared.Address
AttorneyEmail string
AttorneyMobile string
AttorneySignedAt time.Time
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe this would be neater, if it is going to grow, as

type Correction struct {
  Donor DonorCorrection
  LPASignedAt time.time
  Attorney AttorneyCorrection 
  // or if you can only have one of these pointers, then you can nil check to see which type it is?
}

type DonorCorrection struct { /* ... */ }
type AttorneyCorrection struct { /* ... */ }

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then you'd also have the option of adding (c DonorCorrection/AttorneyCorrection) Apply(lpa *shared.Lpa) []shared.FieldError methods to break that up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants