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 21440 main #14858

Merged
merged 9 commits into from
Feb 21, 2025
Merged
42 changes: 42 additions & 0 deletions pkg/testdatagen/testharness/make_move.go
Original file line number Diff line number Diff line change
Expand Up @@ -9107,6 +9107,7 @@ func MakeBasicInternationalHHGMoveWithServiceItemsandPaymentRequestsForTIO(appCt
ihpkCost := unit.Cents(298800)
ihupkCost := unit.Cents(33280)
poefscCost := unit.Cents(25000)
idshutCost := unit.Cents(623)

// Create Customer
userInfo := newUserInfo("customer")
Expand Down Expand Up @@ -9441,6 +9442,47 @@ func MakeBasicInternationalHHGMoveWithServiceItemsandPaymentRequestsForTIO(appCt
},
}, nil)

// Shuttling service item
approvedAtTime := time.Now()
idshut := factory.BuildMTOServiceItem(appCtx.DB(), []factory.Customization{
{
Model: models.MTOServiceItem{
Status: models.MTOServiceItemStatusApproved,
ApprovedAt: &approvedAtTime,
EstimatedWeight: &estimatedWeight,
ActualWeight: &actualWeight,
},
},
{
Model: mto,
LinkOnly: true,
},
{
Model: mtoShipmentHHG,
LinkOnly: true,
},
{
Model: models.ReService{
ID: uuid.FromStringOrNil("22fc07ed-be15-4f50-b941-cbd38153b378"), // IDSHUT - International Destination Shuttle
},
},
}, nil)

factory.BuildPaymentServiceItemWithParams(appCtx.DB(), models.ReServiceCodeIDSHUT,
basicPaymentServiceItemParams, []factory.Customization{
{
Model: models.PaymentServiceItem{
PriceCents: &idshutCost,
},
}, {
Model: paymentRequestHHG,
LinkOnly: true,
}, {
Model: idshut,
LinkOnly: true,
},
}, nil)

basicPortFuelSurchargePaymentServiceItemParams := []factory.CreatePaymentServiceItemParams{
{
Key: models.ServiceItemParamNameContractCode,
Expand Down
15 changes: 13 additions & 2 deletions playwright/tests/office/txo/tioFlowsInternational.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,17 @@ test.describe('TIO user', () => {
await page.getByText('Next').click();
await tioFlowPage.slowDown();

await expect(page.getByText('International destination shuttle service')).toBeVisible();
await page.getByText('Show calculations').click();
await expect(page.locator('[data-testid="ServiceItemCalculations"]')).toContainText('Calculations');
await expect(page.locator('[data-testid="ServiceItemCalculations"]')).toContainText('Billable weight (cwt)');
await expect(page.locator('[data-testid="ServiceItemCalculations"]')).toContainText('Destination price');
await expect(page.locator('[data-testid="ServiceItemCalculations"]')).toContainText('Price escalation factor');
// approve
await tioFlowPage.approveServiceItem();
await page.getByText('Next').click();
await tioFlowPage.slowDown();

await expect(page.getByText('International POE Fuel Surcharge')).toBeVisible();
await page.getByText('Show calculations').click();
await expect(page.locator('[data-testid="ServiceItemCalculations"]')).toContainText('Calculations');
Expand All @@ -159,8 +170,8 @@ test.describe('TIO user', () => {
await expect(page.getByText('needs your review')).toHaveCount(0, { timeout: 10000 });
await page.getByText('Complete request').click();

await expect(page.locator('[data-testid="requested"]')).toContainText('$4,281.48');
await expect(page.locator('[data-testid="accepted"]')).toContainText('$4,281.48');
await expect(page.locator('[data-testid="requested"]')).toContainText('$4,287.71');
await expect(page.locator('[data-testid="accepted"]')).toContainText('$4,287.71');
await expect(page.locator('[data-testid="rejected"]')).toContainText('$0.00');

await page.getByText('Authorize payment').click();
Expand Down
46 changes: 46 additions & 0 deletions src/components/Office/ServiceItemCalculations/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,20 @@ const shuttleOriginPriceDomestic = (params) => {
);
};

const shuttleOriginPriceInternational = (params) => {
const value = getPriceRateOrFactor(params);
const label = SERVICE_ITEM_CALCULATION_LABELS.OriginPrice;

const pickupDate = `${SERVICE_ITEM_CALCULATION_LABELS.PickupDate}: ${formatDateWithUTC(
getParamValue(SERVICE_ITEM_PARAM_KEYS.ReferenceDate, params),
'DD MMM YYYY',
)}`;

const market = getParamValue(SERVICE_ITEM_PARAM_KEYS.MarketDest, params) === 'O' ? 'Oconus' : 'Conus';

return calculation(value, label, formatDetail(pickupDate), formatDetail(market));
};

// There is no param representing the destination price as available in the re_domestic_service_area_prices table
// A param to return the service schedule is also not being created
const destinationPrice = (params, shipmentType) => {
Expand Down Expand Up @@ -418,6 +432,20 @@ const shuttleDestinationPriceDomestic = (params) => {
);
};

const shuttleDestinationPriceInternational = (params) => {
const value = getPriceRateOrFactor(params);
const label = SERVICE_ITEM_CALCULATION_LABELS.DestinationPrice;

const deliveryDate = `${SERVICE_ITEM_CALCULATION_LABELS.DeliveryDate}: ${formatDateWithUTC(
getParamValue(SERVICE_ITEM_PARAM_KEYS.ReferenceDate, params),
'DD MMM YYYY',
)}`;

const market = getParamValue(SERVICE_ITEM_PARAM_KEYS.MarketDest, params) === 'O' ? 'OCONUS' : 'CONUS';

return calculation(value, label, formatDetail(deliveryDate), formatDetail(market));
};

const priceEscalationFactor = (params) => {
const value = getParamValue(SERVICE_ITEM_PARAM_KEYS.EscalationCompounded, params)
? getParamValue(SERVICE_ITEM_PARAM_KEYS.EscalationCompounded, params)
Expand Down Expand Up @@ -922,6 +950,15 @@ export default function makeCalculations(itemCode, totalAmount, params, mtoParam
totalAmountRequested(totalAmount),
];
break;
// International origin shuttle service
case SERVICE_ITEM_CODES.IOSHUT:
result = [
shuttleBillableWeight(params),
shuttleOriginPriceInternational(params),
priceEscalationFactorWithoutContractYear(params),
totalAmountRequested(totalAmount),
];
break;
// Domestic Destination Additional Days SIT
case SERVICE_ITEM_CODES.DDASIT:
result = [
Expand Down Expand Up @@ -950,6 +987,15 @@ export default function makeCalculations(itemCode, totalAmount, params, mtoParam
totalAmountRequested(totalAmount),
];
break;
// International destination shuttle service
case SERVICE_ITEM_CODES.IDSHUT:
result = [
shuttleBillableWeight(params),
shuttleDestinationPriceInternational(params),
priceEscalationFactorWithoutContractYear(params),
totalAmountRequested(totalAmount),
];
break;
// Domestic crating
case SERVICE_ITEM_CODES.DCRT:
result = [
Expand Down
2 changes: 2 additions & 0 deletions src/constants/serviceItems.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,12 +228,14 @@ const allowedServiceItemCalculations = [
SERVICE_ITEM_CODES.DOP,
SERVICE_ITEM_CODES.DOPSIT,
SERVICE_ITEM_CODES.DOSHUT,
SERVICE_ITEM_CODES.IOSHUT,
SERVICE_ITEM_CODES.DPK,
SERVICE_ITEM_CODES.DNPK,
SERVICE_ITEM_CODES.DSH,
SERVICE_ITEM_CODES.DUPK,
SERVICE_ITEM_CODES.FSC,
SERVICE_ITEM_CODES.DDSHUT,
SERVICE_ITEM_CODES.IDSHUT,
SERVICE_ITEM_CODES.DCRT,
SERVICE_ITEM_CODES.DUCRT,
SERVICE_ITEM_CODES.DOSFSC,
Expand Down
Loading