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 5 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
2 changes: 2 additions & 0 deletions migrations/app/migrations_manifest.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1072,3 +1072,5 @@
20250103130619_revert_data_change_for_gbloc_for_ak.up.sql
20250103180420_update_pricing_proc_to_use_local_price_variable.up.sql
20250110153428_add_shipment_address_updates_to_move_history.up.sql
20250110160244_update_ordering_service_items.up.sql
20250113152050_rename_ubp.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
CREATE OR REPLACE PROCEDURE create_approved_service_items_for_shipment(
IN shipment_id UUID
)
AS '
DECLARE
s_status mto_shipment_status;
s_type mto_shipment_type;
m_code market_code_enum;
move_id UUID;
pickup_address_id UUID;
destination_address_id UUID;
is_pickup_oconus BOOLEAN;
is_destination_oconus BOOLEAN;
service_item RECORD;
BEGIN
-- get shipment type, market code, move_id, and address IDs based on shipment_id
SELECT ms.shipment_type, ms.market_code, ms.move_id, ms.pickup_address_id, ms.destination_address_id, ms.status
INTO s_type, m_code, move_id, pickup_address_id, destination_address_id, s_status
FROM mto_shipments ms
WHERE ms.id = shipment_id;

IF s_type IS NULL OR m_code IS NULL THEN
RAISE EXCEPTION ''Shipment with ID % not found or missing required details.'', shipment_id;
END IF;

IF s_status IN (''APPROVED'') THEN
RAISE EXCEPTION ''Shipment with ID % is already in APPROVED status'', shipment_id;
END IF;

-- get the is_oconus values for both pickup and destination addresses - this determines POD/POE creation
is_pickup_oconus := get_is_oconus(pickup_address_id);
is_destination_oconus := get_is_oconus(destination_address_id);

-- determine which service item to create based on shipment direction
-- collect the service items into a temporary table for sorting
CREATE TEMPORARY TABLE temp_mto_service_items (
mto_shipment_id uuid,
move_id uuid,
re_service_id uuid,
service_location service_location_enum,
status service_item_status,
sort text
) ON COMMIT DROP;

-- first create the direction-specific service item (POEFSC or PODFSC)
IF is_pickup_oconus AND NOT is_destination_oconus THEN
-- Shipment is OCONUS to CONUS, create PODFSC item
FOR service_item IN
SELECT rsi.id,
rs.id AS re_service_id,
rs.service_location,
rsi.is_auto_approved,
rsi.sort
FROM re_service_items rsi
JOIN re_services rs ON rsi.service_id = rs.id
WHERE rsi.shipment_type = s_type
AND rsi.market_code = m_code
AND rs.code = ''PODFSC''
AND rsi.is_auto_approved = true
LOOP
BEGIN
IF NOT does_service_item_exist(service_item.re_service_id, shipment_id) THEN
INSERT INTO temp_mto_service_items (
mto_shipment_id,
move_id,
re_service_id,
service_location,
status,
sort
)
VALUES (
shipment_id,
move_id,
service_item.re_service_id,
service_item.service_location,
''APPROVED''::service_item_status,
service_item.sort
);
END IF;
EXCEPTION
WHEN OTHERS THEN
RAISE EXCEPTION ''Error creating PODFSC service item for shipment %: %'', shipment_id, SQLERRM;
END;
END LOOP;
ELSIF NOT is_pickup_oconus AND is_destination_oconus THEN
-- Shipment is CONUS to OCONUS, create POEFSC item
FOR service_item IN
SELECT rsi.id,
rs.id AS re_service_id,
rs.service_location,
rsi.is_auto_approved,
rsi.sort
FROM re_service_items rsi
JOIN re_services rs ON rsi.service_id = rs.id
WHERE rsi.shipment_type = s_type
AND rsi.market_code = m_code
AND rs.code = ''POEFSC''
AND rsi.is_auto_approved = true
LOOP
BEGIN
IF NOT does_service_item_exist(service_item.re_service_id, shipment_id) THEN
INSERT INTO temp_mto_service_items (
mto_shipment_id,
move_id,
re_service_id,
service_location,
status,
sort
)
VALUES (
shipment_id,
move_id,
service_item.re_service_id,
service_item.service_location,
''APPROVED''::service_item_status,
service_item.sort
);
END IF;
EXCEPTION
WHEN OTHERS THEN
RAISE EXCEPTION ''Error creating POEFSC service item for shipment %: %'', shipment_id, SQLERRM;
END;
END LOOP;
END IF;

-- create all other auto-approved service items, filtering out the POEFSC or PODFSC service items
FOR service_item IN
SELECT rsi.id,
rs.id AS re_service_id,
rs.service_location,
rsi.is_auto_approved,
rsi.sort
FROM re_service_items rsi
JOIN re_services rs ON rsi.service_id = rs.id
WHERE rsi.shipment_type = s_type
AND rsi.market_code = m_code
AND rsi.is_auto_approved = true
AND rs.code NOT IN (''POEFSC'', ''PODFSC'')
LOOP
BEGIN
IF NOT does_service_item_exist(service_item.re_service_id, shipment_id) THEN
INSERT INTO temp_mto_service_items (
mto_shipment_id,
move_id,
re_service_id,
service_location,
status,
sort
)
VALUES (
shipment_id,
move_id,
service_item.re_service_id,
service_item.service_location,
''APPROVED''::service_item_status,
service_item.sort
);
End IF;
EXCEPTION
WHEN OTHERS THEN
RAISE EXCEPTION ''Error creating other service item for shipment %: %'', shipment_id, SQLERRM;
END;
END LOOP;

-- Insert the mto_service_items in order
FOR service_item IN
SELECT tmsi.mto_shipment_id,
tmsi.move_id,
tmsi.re_service_id,
tmsi.service_location,
tmsi.status
FROM temp_mto_service_items tmsi
ORDER BY sort
LOOP
BEGIN
INSERT INTO mto_service_items (
mto_shipment_id,
move_id,
re_service_id,
service_location,
status,
created_at,
updated_at,
approved_at
)
VALUES (
service_item.mto_shipment_id,
service_item.move_id,
service_item.re_service_id,
service_item.service_location,
service_item.status,
NOW(),
NOW(),
NOW()
);
EXCEPTION
WHEN OTHERS THEN
RAISE EXCEPTION ''Error creating service items from temp table for shipment %: %'', shipment_id, SQLERRM;
END;
END LOOP;
END;
'
LANGUAGE plpgsql;
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';
2 changes: 1 addition & 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
39 changes: 28 additions & 11 deletions pkg/services/mto_shipment/shipment_approver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1059,17 +1059,23 @@ func (suite *MTOShipmentServiceSuite) TestApproveShipment() {
err2 := suite.AppContextForTest().DB().EagerPreload("ReService").Where("mto_shipment_id = ?", internationalShipment.ID).Order("created_at asc").All(&serviceItems)
suite.NoError(err2)

expectedReserviceCodes := []models.ReServiceCode{
expectedReServiceCodes := []models.ReServiceCode{
models.ReServiceCodeUBP,
models.ReServiceCodePOEFSC,
models.ReServiceCodeIUBPK,
models.ReServiceCodeIUBUPK,
models.ReServiceCodePOEFSC,
}
expectedReServiceNames := []string{
"International UB price",
"International POE Fuel Surcharge",
"International UB pack",
"International UB unpack",
}

suite.Equal(4, len(serviceItems))
for i := 0; i < len(serviceItems); i++ {
actualReServiceCode := serviceItems[i].ReService.Code
suite.True(slices.Contains(expectedReserviceCodes, actualReServiceCode), "Contains unexpected: "+actualReServiceCode.String())
suite.Equal(expectedReServiceCodes[i], serviceItems[i].ReService.Code)
suite.Equal(expectedReServiceNames[i], serviceItems[i].ReService.Name)
}
})

Expand Down Expand Up @@ -1119,17 +1125,23 @@ func (suite *MTOShipmentServiceSuite) TestApproveShipment() {
err2 := suite.AppContextForTest().DB().EagerPreload("ReService").Where("mto_shipment_id = ?", internationalShipment.ID).Order("created_at asc").All(&serviceItems)
suite.NoError(err2)

expectedReserviceCodes := []models.ReServiceCode{
expectedReServiceCodes := []models.ReServiceCode{
models.ReServiceCodeUBP,
models.ReServiceCodePODFSC,
models.ReServiceCodeIUBPK,
models.ReServiceCodeIUBUPK,
models.ReServiceCodePODFSC,
}
expectedReServiceNames := []string{
"International UB price",
"International POD Fuel Surcharge",
"International UB pack",
"International UB unpack",
}

suite.Equal(4, len(serviceItems))
for i := 0; i < len(serviceItems); i++ {
actualReServiceCode := serviceItems[i].ReService.Code
suite.True(slices.Contains(expectedReserviceCodes, actualReServiceCode), "Contains unexpected: "+actualReServiceCode.String())
suite.Equal(expectedReServiceCodes[i], serviceItems[i].ReService.Code)
suite.Equal(expectedReServiceNames[i], serviceItems[i].ReService.Name)
}
})

Expand Down Expand Up @@ -1179,16 +1191,21 @@ func (suite *MTOShipmentServiceSuite) TestApproveShipment() {
err2 := suite.AppContextForTest().DB().EagerPreload("ReService").Where("mto_shipment_id = ?", internationalShipment.ID).Order("created_at asc").All(&serviceItems)
suite.NoError(err2)

expectedReserviceCodes := []models.ReServiceCode{
expectedReServiceCodes := []models.ReServiceCode{
models.ReServiceCodeUBP,
models.ReServiceCodeIUBPK,
models.ReServiceCodeIUBUPK,
}
expectedReServiceNames := []string{
"International UB price",
"International UB pack",
"International UB unpack",
}

suite.Equal(3, len(serviceItems))
for i := 0; i < len(serviceItems); i++ {
actualReServiceCode := serviceItems[i].ReService.Code
suite.True(slices.Contains(expectedReserviceCodes, actualReServiceCode), "Contains unexpected: "+actualReServiceCode.String())
suite.Equal(expectedReServiceCodes[i], serviceItems[i].ReService.Code)
suite.Equal(expectedReServiceNames[i], serviceItems[i].ReService.Name)
}
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const reServiceItemResponse = [
isAutoApproved: true,
marketCode: 'i',
serviceCode: 'UBP',
serviceName: 'International UB',
serviceName: 'International UB price',
shipmentType: 'UNACCOMPANIED_BAGGAGE',
},
{
Expand Down Expand Up @@ -370,7 +370,7 @@ describe('Shipment Service Items Table', () => {

describe('renders the intl UB shipment type (CONUS -> OCONUS) with service items', () => {
it.each([
['International UB'],
['International UB price'],
['International POE Fuel Surcharge'],
['International UB pack'],
['International UB unpack'],
Expand All @@ -385,7 +385,7 @@ describe('Shipment Service Items Table', () => {

describe('renders the intl UB shipment type (OCONUS -> CONUS) with service items', () => {
it.each([
['International UB'],
['International UB price'],
['International POD Fuel Surcharge'],
['International UB pack'],
['International UB unpack'],
Expand All @@ -399,7 +399,7 @@ describe('Shipment Service Items Table', () => {
});

describe('renders the intl UB shipment type (OCONUS -> OCONUS) with service items', () => {
it.each([['International UB'], ['International UB pack'], ['International UB unpack']])(
it.each([['International UB price'], ['International UB pack'], ['International UB unpack']])(
'expects %s to be in the document',
async (serviceItem) => {
render(<ShipmentServiceItemsTable shipment={intlUbOconusToOconusShipment} />);
Expand Down
Loading