Skip to content

Commit

Permalink
adding block for backup mailing address
Browse files Browse the repository at this point in the history
  • Loading branch information
danieljordan-caci committed Oct 14, 2024
1 parent 4c0a291 commit 8f9cb75
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions pkg/models/service_member.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,48 @@ func SaveServiceMember(appCtx appcontext.AppContext, serviceMember *ServiceMembe
return err
}
serviceMember.BackupMailingAddress.County = county
// until international moves are supported, we will default the country for created addresses to "US"
if serviceMember.BackupMailingAddress.Country != nil && serviceMember.BackupMailingAddress.Country.Country != "" {
country, err := FetchCountryByCode(appCtx.DB(), serviceMember.BackupMailingAddress.Country.Country)
if err != nil {
return err
}
serviceMember.BackupMailingAddress.Country = &country
serviceMember.BackupMailingAddress.CountryId = &country.ID
} else {
country, err := FetchCountryByCode(appCtx.DB(), "US")
if err != nil {
return err
}
serviceMember.BackupMailingAddress.Country = &country
serviceMember.BackupMailingAddress.CountryId = &country.ID
}

if serviceMember.BackupMailingAddress.Country != nil {
country := serviceMember.BackupMailingAddress.Country
if country.Country != "US" || country.Country == "US" && serviceMember.BackupMailingAddress.State == "AK" || country.Country == "US" && serviceMember.BackupMailingAddress.State == "HI" {
boolTrueVal := true
serviceMember.BackupMailingAddress.IsOconus = &boolTrueVal
} else {
boolFalseVal := false
serviceMember.BackupMailingAddress.IsOconus = &boolFalseVal
}
} else if serviceMember.BackupMailingAddress.CountryId != nil {
country, err := FetchCountryByID(appCtx.DB(), *serviceMember.BackupMailingAddress.CountryId)
if err != nil {
return err
}
if country.Country != "US" || country.Country == "US" && serviceMember.BackupMailingAddress.State == "AK" || country.Country == "US" && serviceMember.BackupMailingAddress.State == "HI" {
boolTrueVal := true
serviceMember.BackupMailingAddress.IsOconus = &boolTrueVal
} else {
boolFalseVal := false
serviceMember.BackupMailingAddress.IsOconus = &boolFalseVal
}
} else {
boolFalseVal := false
serviceMember.BackupMailingAddress.IsOconus = &boolFalseVal
}
if verrs, err := txnAppCtx.DB().ValidateAndSave(serviceMember.BackupMailingAddress); verrs.HasAny() || err != nil {
responseVErrors.Append(verrs)
responseError = err
Expand Down

0 comments on commit 8f9cb75

Please sign in to comment.