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

MAIN-B-20941-ssw-duplicate-state-zip #13602

Merged
merged 15 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions pkg/factory/duty_location_factory.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package factory

import (
"fmt"

"github.com/gobuffalo/pop/v6"

"github.com/transcom/mymove/pkg/gen/internalmessages"
Expand Down Expand Up @@ -53,7 +55,8 @@ func buildDutyLocationWithBuildType(db *pop.Connection, customs []Customization,
affiliation := internalmessages.AffiliationAIRFORCE

location := models.DutyLocation{
Name: MakeRandomString(10),
// Make test duty location name consistent with how TRDM duty location is formatted
Name: fmt.Sprintf("%s, %s %s", MakeRandomString(10), dlAddress.State, dlAddress.PostalCode),
Affiliation: &affiliation,
AddressID: dlAddress.ID,
Address: dlAddress,
Expand Down Expand Up @@ -128,18 +131,18 @@ func FetchOrBuildCurrentDutyLocation(db *pop.Connection) models.DutyLocation {
return BuildDutyLocation(nil, []Customization{
{
Model: models.DutyLocation{
Name: "Yuma AFB",
Name: "Yuma AFB, IA 50309",
},
},
}, nil)
}
// Check if Yuma Duty Location exists, if not, create it.
defaultLocation, err := models.FetchDutyLocationByName(db, "Yuma AFB")
defaultLocation, err := models.FetchDutyLocationByName(db, "Yuma AFB, IA 50309")
if err != nil {
return BuildDutyLocation(db, []Customization{
{
Model: models.DutyLocation{
Name: "Yuma AFB",
Name: "Yuma AFB, IA 50309",
},
},
}, nil)
Expand Down
2 changes: 1 addition & 1 deletion pkg/factory/duty_location_factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func (suite *FactorySuite) TestBuildDutyLocation() {
})
suite.Run("test fetch stubbed current duty location", func() {
dutyLocation := FetchOrBuildCurrentDutyLocation(nil)
suite.Equal("Yuma AFB", dutyLocation.Name)
suite.Equal("Yuma AFB, IA 50309", dutyLocation.Name)
})
suite.Run("test fetch stubbed orders duty location", func() {
dutyLocation := FetchOrBuildOrdersDutyLocation(nil)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,9 @@ func FormatValuesShipmentSummaryWorksheetFormPage1(data services.ShipmentSummary
page1.OrdersIssueDate = FormatDate(data.Order.IssueDate)
page1.OrdersTypeAndOrdersNumber = FormatOrdersTypeAndOrdersNumber(data.Order)

page1.AuthorizedOrigin = FormatLocation(data.CurrentDutyLocation)
page1.AuthorizedOrigin = data.CurrentDutyLocation.Name
page1.AuthorizedDestination = data.NewDutyLocation.Name

page1.NewDutyAssignment = data.NewDutyLocation.Name

page1.WeightAllotment = FormatWeights(data.WeightAllotment.Entitlement)
Expand Down Expand Up @@ -447,11 +448,6 @@ func formatSSWDate(signedCertifications []*models.SignedCertification, ppmid uui
return "", errors.New("Payment Packet is not certified")
}

// FormatLocation formats AuthorizedOrigin and AuthorizedDestination for Shipment Summary Worksheet
func FormatLocation(dutyLocation models.DutyLocation) string {
return fmt.Sprintf("%s, %s %s", dutyLocation.Name, dutyLocation.Address.State, dutyLocation.Address.PostalCode)
}

// FormatAddress retrieves a PPMShipment W2Address and formats it for the SSW Document
func FormatAddress(w2Address *models.Address) string {
var addressString string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -554,14 +554,6 @@ func (suite *ShipmentSummaryWorksheetServiceSuite) TestFormatSSWGetEntitlementNo
suite.Equal(unit.Pound(500), sswEntitlement.SpouseProGear)
}

func (suite *ShipmentSummaryWorksheetServiceSuite) TestFormatLocation() {
fortEisenhower := models.DutyLocation{Name: "Fort Eisenhower, GA 30813", Address: models.Address{State: "GA", PostalCode: "30813"}}
yuma := models.DutyLocation{Name: "Yuma AFB", Address: models.Address{State: "IA", PostalCode: "50309"}}

suite.Equal("Fort Eisenhower, GA 30813", fortEisenhower.Name)
suite.Equal("Yuma AFB, IA 50309", FormatLocation(yuma))
}

func (suite *ShipmentSummaryWorksheetServiceSuite) TestFormatServiceMemberFullName() {
sm1 := models.ServiceMember{
Suffix: models.StringPointer("Jr."),
Expand Down