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

B-21569-INT 2 #14577

Merged
merged 31 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
e1c9254
B-21569 add the service items in their Sort order.
stevengleason-caci Jan 11, 2025
1c96244
B-21569 rename UBP to "International UB price",
stevengleason-caci Jan 13, 2025
0f72565
Merge branch 'B-21569' into B-21569-INT
stevengleason-caci Jan 13, 2025
7d4df07
Merge branch 'integrationTesting' into B-21569-INT
stevengleason-caci Jan 13, 2025
10cfb33
Merge branch 'integrationTesting' into B-21569-INT
stevengleason-caci Jan 13, 2025
ea981ca
B-21569 move the service item sorting from the insert proc to the UI.
stevengleason-caci Jan 16, 2025
acbbd5a
Merge remote-tracking branch 'origin/integrationTesting' into B-21569…
stevengleason-caci Jan 16, 2025
c6dcd96
Merge branch 'B-21569' into B-21569-INT
stevengleason-caci Jan 16, 2025
1837ce2
Merge remote-tracking branch 'origin/B-21569-INT' into B-21569-INT
stevengleason-caci Jan 16, 2025
fc421d6
Merge branch 'integrationTesting' into B-21569-INT
stevengleason-caci Jan 16, 2025
16930fb
Merge branch 'integrationTesting' into B-21569-INT
stevengleason-caci Jan 16, 2025
f3c0599
B-21569 fix null-safe issue with comparing the sort values,
stevengleason-caci Jan 16, 2025
b29387a
Merge branch 'B-21569' into B-21569-INT
stevengleason-caci Jan 16, 2025
327ed63
Merge remote-tracking branch 'origin/integrationTesting' into B-21569…
stevengleason-caci Jan 16, 2025
d06adec
Merge branch 'integrationTesting' into B-21569-INT
stevengleason-caci Jan 16, 2025
1b59d9d
B-21569 nullSafeStringCompare function in utils.js.
stevengleason-caci Jan 16, 2025
a946e9c
Merge branch 'B-21569' into B-21569-INT
stevengleason-caci Jan 16, 2025
d900dee
Merge remote-tracking branch 'origin/integrationTesting' into B-21569…
stevengleason-caci Jan 17, 2025
9b9e235
Merge branch 'integrationTesting' into B-21569-INT
stevengleason-caci Jan 17, 2025
ebf90eb
Merge branch 'integrationTesting' into B-21569-INT
stevengleason-caci Jan 17, 2025
cf97094
Merge branch 'integrationTesting' into B-21569-INT
stevengleason-caci Jan 17, 2025
f7d0ccd
B-21569 Fix the 1-N relationship for ReService and ReServiceItem.
stevengleason-caci Jan 22, 2025
1025de9
Merge remote-tracking branch 'origin/integrationTesting' into B-21569…
stevengleason-caci Jan 22, 2025
9b83c1c
Merge branch 'B-21569' into B-21569-INT
stevengleason-caci Jan 22, 2025
24d6ebb
B-21569 cleanup:
stevengleason-caci Jan 22, 2025
bc37b12
B-21569 move compare function from shared/utils. to new utils/string.js.
stevengleason-caci Jan 23, 2025
6c4f49d
Merge branch 'B-21569' into B-21569-INT
stevengleason-caci Jan 23, 2025
7c09b81
Merge remote-tracking branch 'origin/integrationTesting' into B-21569…
stevengleason-caci Jan 23, 2025
e999361
B-21569 per peer preference, no nill now needed
stevengleason-caci Jan 23, 2025
440dde0
Merge remote-tracking branch 'origin/integrationTesting' into B-21569…
stevengleason-caci Jan 23, 2025
afcc6a9
Merge branch 'B-21569' into B-21569-INT
stevengleason-caci Jan 23, 2025
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 @@ -1077,6 +1077,7 @@
20250110001339_update_nts_release_enum_name.up.sql
20250110153428_add_shipment_address_updates_to_move_history.up.sql
20250110214012_homesafeconnect_cert.up.sql
20250113152050_rename_ubp.up.sql
20250113201232_update_estimated_pricing_procs_add_is_peak_func.up.sql
20250116200912_disable_homesafe_stg_cert.up.sql
20250120144247_update_pricing_proc_to_use_110_percent_weight.up.sql
1 change: 1 addition & 0 deletions migrations/app/schema/20250113152050_rename_ubp.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
update re_services set name = 'International UB price' where code = 'UBP';
10 changes: 10 additions & 0 deletions pkg/gen/ghcapi/embedded_spec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions pkg/gen/ghcmessages/m_t_o_service_item.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions pkg/handlers/ghcapi/internal/payloads/model_to_payload.go
Original file line number Diff line number Diff line change
Expand Up @@ -1875,6 +1875,15 @@ func MTOServiceItemModel(s *models.MTOServiceItem, storer storage.FileStorer) *g
serviceRequestDocs[i] = payload
}
}
var sort *string = nil
if s.ReService.ReServiceItems != nil {
for _, reServiceItem := range *s.ReService.ReServiceItems {
if s.MTOShipment.MarketCode == reServiceItem.MarketCode && s.MTOShipment.ShipmentType == reServiceItem.ShipmentType {
sort = reServiceItem.Sort
break
}
}
}
payload := &ghcmessages.MTOServiceItem{
ID: handlers.FmtUUID(s.ID),
MoveTaskOrderID: handlers.FmtUUID(s.MoveTaskOrderID),
Expand All @@ -1890,6 +1899,7 @@ func MTOServiceItemModel(s *models.MTOServiceItem, storer storage.FileStorer) *g
SitDepartureDate: handlers.FmtDateTimePtr(s.SITDepartureDate),
SitCustomerContacted: handlers.FmtDatePtr(s.SITCustomerContacted),
SitRequestedDelivery: handlers.FmtDatePtr(s.SITRequestedDelivery),
Sort: sort,
Status: ghcmessages.MTOServiceItemStatus(s.Status),
Description: handlers.FmtStringPtr(s.Description),
Dimensions: MTOServiceItemDimensions(s.Dimensions),
Expand Down
45 changes: 45 additions & 0 deletions pkg/handlers/ghcapi/internal/payloads/model_to_payload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1218,6 +1218,51 @@ func (suite *PayloadsSuite) TestMTOServiceItemModel() {
suite.NotNil(result, "Expected result to not be nil for valid MTOServiceItem")
suite.Equal(handlers.FmtString(models.MarketOconus.FullString()), result.Market, "Expected Market to be OCONUS")
})

suite.Run("sets Sort from correct serviceItem", func() {
reServiceID := uuid.Must(uuid.NewV4())

reServiceItems := make(models.ReServiceItems, 3)
mockReService := models.ReService{
ID: reServiceID,
Code: models.ReServiceCodeUBP,
Name: "Test ReService",
ReServiceItems: &reServiceItems,
}

mockMTOShipment := models.MTOShipment{
ShipmentType: models.MTOShipmentTypeUnaccompaniedBaggage,
MarketCode: models.MarketCodeInternational,
}

reServiceItems[0] = models.ReServiceItem{
ReService: mockReService,
ShipmentType: models.MTOShipmentTypeHHG,
MarketCode: models.MarketCodeInternational,
Sort: models.StringPointer("0"),
}
reServiceItems[1] = models.ReServiceItem{
ReService: mockReService,
ShipmentType: models.MTOShipmentTypeUnaccompaniedBaggage,
MarketCode: models.MarketCodeInternational,
Sort: models.StringPointer("1"),
}
reServiceItems[2] = models.ReServiceItem{
ReService: mockReService,
ShipmentType: models.MTOShipmentTypeUnaccompaniedBaggage,
MarketCode: models.MarketCodeDomestic,
Sort: models.StringPointer("2"),
}

mockMtoServiceItem := models.MTOServiceItem{
ReService: mockReService,
MTOShipment: mockMTOShipment,
}

result := MTOServiceItemModel(&mockMtoServiceItem, suite.storer)
suite.NotNil(result, "Expected result to not be nil for valid MTOServiceItem")
suite.Equal("1", *result.Sort, "Expected to get the Sort value by matching the correct ReServiceItem using ShipmentType and MarketCode.")
})
}

func (suite *PayloadsSuite) TestPort() {
Expand Down
2 changes: 2 additions & 0 deletions pkg/handlers/ghcapi/mto_service_items.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,8 @@ func (h ListMTOServiceItemsHandler) Handle(params mtoserviceitemop.ListMTOServic
query.NewQueryAssociation("SITDestinationFinalAddress"),
query.NewQueryAssociation("SITOriginHHGOriginalAddress"),
query.NewQueryAssociation("SITOriginHHGActualAddress"),
query.NewQueryAssociation("ReService.ReServiceItems"),
query.NewQueryAssociation("MTOShipment"),
})

var serviceItems models.MTOServiceItems
Expand Down
131 changes: 112 additions & 19 deletions pkg/handlers/ghcapi/mto_service_items_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,33 +39,21 @@ import (
)

func (suite *HandlerSuite) TestListMTOServiceItemHandler() {
reServiceID, _ := uuid.NewV4()
serviceItemID, _ := uuid.NewV4()
mtoShipmentID, _ := uuid.NewV4()
var mtoID uuid.UUID

setupTestData := func() (models.User, models.MTOServiceItems) {
setupTestData := func() (models.User, models.MTOServiceItems, uuid.UUID) {
mto := factory.BuildMove(suite.DB(), nil, nil)
mtoID = mto.ID
reService := factory.FetchReService(suite.DB(), []factory.Customization{
{
Model: models.ReService{
ID: reServiceID,
Code: "TEST10000",
},
},
}, nil)
mtoShipment := factory.BuildMTOShipment(suite.DB(), []factory.Customization{
{
Model: models.MTOShipment{ID: mtoShipmentID},
},
}, nil)
mtoShipment := factory.BuildMTOShipment(suite.DB(), nil, nil)
requestUser := factory.BuildUser(nil, nil, nil)
serviceItem := factory.BuildMTOServiceItem(suite.DB(), []factory.Customization{
{
Model: models.MTOServiceItem{
ID: serviceItemID,
},
Model: models.MTOServiceItem{},
},
{
Model: mto,
Expand Down Expand Up @@ -132,11 +120,70 @@ func (suite *HandlerSuite) TestListMTOServiceItemHandler() {

serviceItems := models.MTOServiceItems{serviceItem, originSit, destinationSit}

return requestUser, serviceItems
return requestUser, serviceItems, mto.ID
}

setupIUBTestData := func() (models.User, models.MTOServiceItems, uuid.UUID) {
mto := factory.BuildMove(suite.DB(), nil, nil)
mtoShipment := factory.BuildMTOShipment(suite.DB(), []factory.Customization{
{
Model: models.MTOShipment{
ShipmentType: models.MTOShipmentTypeUnaccompaniedBaggage,
MarketCode: models.MarketCodeInternational,
},
},
}, nil)
requestUser := factory.BuildUser(nil, nil, nil)

poeFsc := factory.BuildMTOServiceItem(suite.DB(), []factory.Customization{
{
Model: models.MTOServiceItem{
Status: models.MTOServiceItemStatusApproved,
},
},
{
Model: mto,
LinkOnly: true,
},
{
Model: mtoShipment,
LinkOnly: true,
},
{
Model: models.ReService{
Code: models.ReServiceCodePOEFSC,
},
},
}, nil)

ubp := factory.BuildMTOServiceItem(suite.DB(), []factory.Customization{
{
Model: models.MTOServiceItem{
Status: models.MTOServiceItemStatusApproved,
},
},
{
Model: mto,
LinkOnly: true,
},
{
Model: mtoShipment,
LinkOnly: true,
},
{
Model: models.ReService{
Code: models.ReServiceCodeUBP,
},
},
}, nil)

serviceItems := models.MTOServiceItems{poeFsc, ubp}

return requestUser, serviceItems, mto.ID
}

suite.Run("Successful list fetch - Integration Test", func() {
requestUser, serviceItems := setupTestData()
requestUser, serviceItems, mtoID := setupTestData()
req := httptest.NewRequest("GET", fmt.Sprintf("/move_task_orders/%s/mto_service_items", mtoID.String()), nil)
req = suite.AuthenticateUserRequest(req, requestUser)

Expand Down Expand Up @@ -203,8 +250,54 @@ func (suite *HandlerSuite) TestListMTOServiceItemHandler() {
}
})

suite.Run("Successful sorted serviceItems for UB", func() {
requestUser, serviceItems, mtoID := setupIUBTestData()
req := httptest.NewRequest("GET", fmt.Sprintf("/move_task_orders/%s/mto_service_items", mtoID.String()), nil)
req = suite.AuthenticateUserRequest(req, requestUser)

params := mtoserviceitemop.ListMTOServiceItemsParams{
HTTPRequest: req,
MoveTaskOrderID: *handlers.FmtUUID(serviceItems[0].MoveTaskOrderID),
}

queryBuilder := query.NewQueryBuilder()
listFetcher := fetch.NewListFetcher(queryBuilder)
fetcher := fetch.NewFetcher(queryBuilder)
counselingPricer := ghcrateengine.NewCounselingServicesPricer()
moveManagementPricer := ghcrateengine.NewManagementServicesPricer()
handler := ListMTOServiceItemsHandler{
suite.createS3HandlerConfig(),
listFetcher,
fetcher,
counselingPricer,
moveManagementPricer,
}

// Validate incoming payload: no body to validate

response := handler.Handle(params)
suite.IsType(&mtoserviceitemop.ListMTOServiceItemsOK{}, response)
okResponse := response.(*mtoserviceitemop.ListMTOServiceItemsOK)

// Validate outgoing payload
suite.NoError(okResponse.Payload.Validate(strfmt.Default))
fmt.Println(okResponse.Payload)

suite.Len(okResponse.Payload, 2)
// Validate that sort field is populated for service items which have it.
// These test values can be updated to match any DB changes.
for _, payload := range okResponse.Payload {
if payload.ReServiceCode != nil && *payload.ReServiceCode == models.ReServiceCodePOEFSC.String() {
suite.Equal("2", *payload.Sort)
}
if payload.ReServiceCode != nil && *payload.ReServiceCode == models.ReServiceCodeUBP.String() {
suite.Equal("1", *payload.Sort)
}
}
})

suite.Run("Failure list fetch - Internal Server Error", func() {
requestUser, serviceItems := setupTestData()
requestUser, serviceItems, mtoID := setupTestData()
req := httptest.NewRequest("GET", fmt.Sprintf("/move_task_orders/%s/mto_service_items", mtoID.String()), nil)
req = suite.AuthenticateUserRequest(req, requestUser)

Expand Down Expand Up @@ -252,7 +345,7 @@ func (suite *HandlerSuite) TestListMTOServiceItemHandler() {
})

suite.Run("Failure list fetch - 404 Not Found - Move Task Order ID", func() {
requestUser, serviceItems := setupTestData()
requestUser, serviceItems, mtoID := setupTestData()
req := httptest.NewRequest("GET", fmt.Sprintf("/move_task_orders/%s/mto_service_items", mtoID.String()), nil)
req = suite.AuthenticateUserRequest(req, requestUser)

Expand Down
3 changes: 2 additions & 1 deletion pkg/models/re_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ const (
ReServiceCodeNSTH ReServiceCode = "NSTH"
// ReServiceCodeNSTUB Nonstandard UB
ReServiceCodeNSTUB ReServiceCode = "NSTUB"
// ReServiceCodeUBP International UB
// ReServiceCodeUBP International UB price
ReServiceCodeUBP ReServiceCode = "UBP"
// ReServiceCodeISLH Shipping & Linehaul
ReServiceCodeISLH ReServiceCode = "ISLH"
Expand Down Expand Up @@ -147,6 +147,7 @@ type ReService struct {
Priority int `db:"priority" rw:"r"`
Name string `json:"name" db:"name" rw:"r"`
ServiceLocation *ServiceLocationType `db:"service_location" rw:"r"`
ReServiceItems *ReServiceItems `has_many:"re_service_items" fk_id:"service_id"`
CreatedAt time.Time `json:"created_at" db:"created_at" rw:"r"`
UpdatedAt time.Time `json:"updated_at" db:"updated_at" rw:"r"`
}
Expand Down
Loading
Loading