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

Revert "B 21583 int" #14508

Merged
merged 5 commits into from
Jan 3, 2025
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
1 change: 1 addition & 0 deletions migrations/app/migrations_manifest.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1067,3 +1067,4 @@
20241227202424_insert_transportation_offices_camp_pendelton.up.sql
20241230190638_remove_AK_zips_from_zip3.up.sql
20241230190647_add_missing_AK_zips_to_zip3_distances.up.sql
20250103130619_revert_data_change_for_gbloc_for_ak.up.sql

Large diffs are not rendered by default.

26 changes: 8 additions & 18 deletions pkg/handlers/ghcapi/orders.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,24 +225,14 @@ func (h CreateOrderHandler) Handle(params orderop.CreateOrderParams) middleware.
return orderop.NewCreateOrderUnprocessableEntity(), err
}

var originDutyLocationGBLOC *string
if *originDutyLocation.Address.IsOconus {
originDutyLocationGBLOCOconus, err := models.FetchOconusDutyLocationGbloc(appCtx.DB(), originDutyLocation, serviceMember)
if err != nil {
return nil, apperror.NewNotFoundError(originDutyLocation.ID, "while looking for Duty Location Oconus GBLOC")
}
originDutyLocationGBLOC = &originDutyLocationGBLOCOconus.Gbloc
} else {
originDutyLocationGBLOCConus, err := models.FetchGBLOCForPostalCode(appCtx.DB(), originDutyLocation.Address.PostalCode)
if err != nil {
switch err {
case sql.ErrNoRows:
return nil, apperror.NewNotFoundError(originDutyLocation.ID, "while looking for Duty Location PostalCodeToGBLOC")
default:
return nil, apperror.NewQueryError("PostalCodeToGBLOC", err, "")
}
originDutyLocationGBLOC, err := models.FetchGBLOCForPostalCode(appCtx.DB(), originDutyLocation.Address.PostalCode)
if err != nil {
switch err {
case sql.ErrNoRows:
return nil, apperror.NewNotFoundError(originDutyLocation.ID, "while looking for Duty Location PostalCodeToGBLOC")
default:
return nil, apperror.NewQueryError("PostalCodeToGBLOC", err, "")
}
originDutyLocationGBLOC = &originDutyLocationGBLOCConus.GBLOC
}

grade := (internalmessages.OrderPayGrade)(*payload.Grade)
Expand Down Expand Up @@ -321,7 +311,7 @@ func (h CreateOrderHandler) Handle(params orderop.CreateOrderParams) middleware.
&originDutyLocation,
&grade,
&entitlement,
originDutyLocationGBLOC,
&originDutyLocationGBLOC.GBLOC,
packingAndShippingInstructions,
&destinationGBLOC.GBLOC,
)
Expand Down
91 changes: 5 additions & 86 deletions pkg/handlers/ghcapi/orders_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,100 +106,20 @@ func (suite *HandlerSuite) TestCreateOrder() {
}

func (suite *HandlerSuite) TestCreateOrderWithOCONUSValues() {
customAffiliation := models.AffiliationARMY
sm := factory.BuildExtendedServiceMember(suite.DB(), []factory.Customization{
{
Model: models.ServiceMember{
Affiliation: &customAffiliation,
},
},
}, nil)
sm := factory.BuildExtendedServiceMember(suite.AppContextForTest().DB(), nil, nil)
officeUser := factory.BuildOfficeUserWithRoles(suite.AppContextForTest().DB(), nil, []roles.RoleType{roles.RoleTypeTOO})

usprc, err := models.FindByZipCode(suite.AppContextForTest().DB(), "99801")
suite.NotNil(usprc)
suite.FatalNoError(err)

address := factory.BuildAddress(suite.DB(), []factory.Customization{
{
Model: models.Address{
IsOconus: models.BoolPointer(true),
UsPostRegionCityID: &usprc.ID,
},
},
}, nil)

originDutyLocation := factory.BuildDutyLocation(suite.DB(), []factory.Customization{
originDutyLocation := factory.BuildDutyLocation(suite.AppContextForTest().DB(), []factory.Customization{
{
Model: models.DutyLocation{
Name: factory.MakeRandomString(8),
AddressID: address.ID,
Name: "Not Yuma AFB",
},
},
}, nil)

dutyLocation := factory.FetchOrBuildCurrentDutyLocation(suite.AppContextForTest().DB())

contract := models.ReContract{
Code: "Test_create_oconus_order_code",
Name: "Test_create_oconus_order",
}
verrs, err := suite.AppContextForTest().DB().ValidateAndSave(&contract)
if verrs.HasAny() {
suite.Fail(verrs.Error())
}
if err != nil {
suite.Fail(verrs.Error())
}

rateAreaCode := uuid.Must(uuid.NewV4()).String()[0:5]
rateArea := models.ReRateArea{
ID: uuid.Must(uuid.NewV4()),
ContractID: contract.ID,
IsOconus: true,
Code: rateAreaCode,
Name: fmt.Sprintf("Alaska-%s", rateAreaCode),
Contract: contract,
}
verrs, err = suite.DB().ValidateAndCreate(&rateArea)
if verrs.HasAny() {
suite.Fail(verrs.Error())
}
if err != nil {
suite.Fail(err.Error())
}

us_country, err := models.FetchCountryByCode(suite.DB(), "US")
suite.NotNil(us_country)
suite.Nil(err)

oconusRateArea := models.OconusRateArea{
ID: uuid.Must(uuid.NewV4()),
RateAreaId: rateArea.ID,
CountryId: us_country.ID,
UsPostRegionCityId: usprc.ID,
Active: true,
}
verrs, err = suite.DB().ValidateAndCreate(&oconusRateArea)
if verrs.HasAny() {
suite.Fail(verrs.Error())
}
if err != nil {
suite.Fail(err.Error())
}
jppsoRegion := models.JppsoRegions{
Name: "USCG Base Ketchikan",
Code: "MAPK",
}
suite.MustSave(&jppsoRegion)

gblocAors := models.GblocAors{
JppsoRegionID: jppsoRegion.ID,
OconusRateAreaID: oconusRateArea.ID,
}
suite.MustSave(&gblocAors)

factory.FetchOrBuildPostalCodeToGBLOC(suite.AppContextForTest().DB(), dutyLocation.Address.PostalCode, "KKFA")
factory.FetchOrBuildDefaultContractor(suite.AppContextForTest().DB(), nil, nil)

req := httptest.NewRequest("POST", "/orders", nil)
req = suite.AuthenticateOfficeRequest(req, officeUser)

Expand Down Expand Up @@ -251,7 +171,6 @@ func (suite *HandlerSuite) TestCreateOrderWithOCONUSValues() {
suite.Assertions.Equal(sm.ID.String(), okResponse.Payload.CustomerID.String())
suite.Assertions.Equal(ordersType, okResponse.Payload.OrderType)
suite.Assertions.Equal(handlers.FmtString("123456"), okResponse.Payload.OrderNumber)
suite.Assertions.Equal(ghcmessages.GBLOC("MAPK"), okResponse.Payload.OriginDutyLocationGBLOC)
suite.Assertions.Equal(handlers.FmtString("E19A"), okResponse.Payload.Tac)
suite.Assertions.Equal(handlers.FmtString("SacNumber"), okResponse.Payload.Sac)
suite.Assertions.Equal(&deptIndicator, okResponse.Payload.DepartmentIndicator)
Expand Down
26 changes: 8 additions & 18 deletions pkg/handlers/internalapi/orders.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,24 +183,14 @@ func (h CreateOrdersHandler) Handle(params ordersop.CreateOrdersParams) middlewa
dependentsUnderTwelve = models.IntPointer(int(*payload.DependentsUnderTwelve))
}

var originDutyLocationGBLOC *string
if *originDutyLocation.Address.IsOconus {
originDutyLocationGBLOCOconus, err := models.FetchOconusDutyLocationGbloc(appCtx.DB(), originDutyLocation, serviceMember)
if err != nil {
return nil, apperror.NewNotFoundError(originDutyLocation.ID, "while looking for Duty Location Oconus GBLOC")
}
originDutyLocationGBLOC = &originDutyLocationGBLOCOconus.Gbloc
} else {
originDutyLocationGBLOCConus, err := models.FetchGBLOCForPostalCode(appCtx.DB(), originDutyLocation.Address.PostalCode)
if err != nil {
switch err {
case sql.ErrNoRows:
return nil, apperror.NewNotFoundError(originDutyLocation.ID, "while looking for Duty Location PostalCodeToGBLOC")
default:
return nil, apperror.NewQueryError("PostalCodeToGBLOC", err, "")
}
originDutyLocationGBLOC, err := models.FetchGBLOCForPostalCode(appCtx.DB(), originDutyLocation.Address.PostalCode)
if err != nil {
switch err {
case sql.ErrNoRows:
return nil, apperror.NewNotFoundError(originDutyLocation.ID, "while looking for Duty Location PostalCodeToGBLOC")
default:
return nil, apperror.NewQueryError("PostalCodeToGBLOC", err, "")
}
originDutyLocationGBLOC = &originDutyLocationGBLOCConus.GBLOC
}

grade := payload.Grade
Expand Down Expand Up @@ -283,7 +273,7 @@ func (h CreateOrdersHandler) Handle(params ordersop.CreateOrdersParams) middlewa
&originDutyLocation,
grade,
&entitlement,
originDutyLocationGBLOC,
&originDutyLocationGBLOC.GBLOC,
packingAndShippingInstructions,
&newDutyLocationGBLOC.GBLOC,
)
Expand Down
Loading
Loading