Skip to content

Commit

Permalink
Merge pull request #14208 from transcom/B-21455-MAIN
Browse files Browse the repository at this point in the history
B 21455 main
  • Loading branch information
r-mettler authored Dec 4, 2024
2 parents d391092 + fa3d203 commit 6fb6ae6
Show file tree
Hide file tree
Showing 11 changed files with 503 additions and 100 deletions.
2 changes: 1 addition & 1 deletion pkg/notifications/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const MyMoveLink = "https://my.move.mil/"
const WashingtonHQServicesLink = "https://www.esd.whs.mil"
const SmartVoucherLink = "https://smartvoucher.dfas.mil/"

const DTODFailureErrorMessage = "We are unable to calculate your distance. It may be that you have entered an invalid ZIP Code, or the system that calculates distance (DTOD) may be down. Please check your ZIP Code to ensure it was entered correctly and is not a PO Box."
const DTODFailureErrorMessage = "We are unable to calculate your distance. It may be that you have entered an invalid ZIP Code. Please check your ZIP Code to ensure it was entered correctly and is not a PO Box."
const DTODDownErrorMessage = "We are having an issue with the system we use to calculate mileage (DTOD) and cannot proceed."

var affiliationDisplayValue = map[models.ServiceMemberAffiliation]string{
Expand Down
12 changes: 8 additions & 4 deletions pkg/services/ppmshipment/ppm_estimator.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,14 @@ func (f *estimatePPM) PriceBreakdown(appCtx appcontext.AppContext, ppmShipment *
}

func shouldSkipEstimatingIncentive(newPPMShipment *models.PPMShipment, oldPPMShipment *models.PPMShipment) bool {
return oldPPMShipment.ExpectedDepartureDate.Equal(newPPMShipment.ExpectedDepartureDate) &&
newPPMShipment.PickupAddress.PostalCode == oldPPMShipment.PickupAddress.PostalCode &&
newPPMShipment.DestinationAddress.PostalCode == oldPPMShipment.DestinationAddress.PostalCode &&
((newPPMShipment.EstimatedWeight == nil && oldPPMShipment.EstimatedWeight == nil) || (oldPPMShipment.EstimatedWeight != nil && newPPMShipment.EstimatedWeight.Int() == oldPPMShipment.EstimatedWeight.Int()))
if oldPPMShipment.Status != models.PPMShipmentStatusDraft && oldPPMShipment.EstimatedIncentive != nil && *newPPMShipment.EstimatedIncentive == 0 {
return false
} else {
return oldPPMShipment.ExpectedDepartureDate.Equal(newPPMShipment.ExpectedDepartureDate) &&
newPPMShipment.PickupAddress.PostalCode == oldPPMShipment.PickupAddress.PostalCode &&
newPPMShipment.DestinationAddress.PostalCode == oldPPMShipment.DestinationAddress.PostalCode &&
((newPPMShipment.EstimatedWeight == nil && oldPPMShipment.EstimatedWeight == nil) || (oldPPMShipment.EstimatedWeight != nil && newPPMShipment.EstimatedWeight.Int() == oldPPMShipment.EstimatedWeight.Int()))
}
}

func shouldSkipCalculatingFinalIncentive(newPPMShipment *models.PPMShipment, oldPPMShipment *models.PPMShipment, originalTotalWeight unit.Pound, newTotalWeight unit.Pound) bool {
Expand Down
34 changes: 34 additions & 0 deletions pkg/services/ppmshipment/ppm_estimator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,40 @@ func (suite *PPMShipmentSuite) TestPPMEstimator() {
suite.Equal(unit.Cents(70064364), *ppmEstimate)
})

suite.Run("Estimated Incentive - Success when old Estimated Incentive is zero", func() {
oldPPMShipment := factory.BuildMinimalPPMShipment(suite.DB(), nil, nil)

zeroIncentive := unit.Cents(0)
oldPPMShipment.EstimatedIncentive = &zeroIncentive

setupPricerData()

// shipment has locations and date but is now updating the estimated weight for the first time
estimatedWeight := unit.Pound(5000)
newPPM := oldPPMShipment
newPPM.EstimatedWeight = &estimatedWeight

mockedPaymentRequestHelper.On(
"FetchServiceParamsForServiceItems",
mock.AnythingOfType("*appcontext.appContext"),
mock.AnythingOfType("[]models.MTOServiceItem")).Return(serviceParams, nil)

// DTOD distance is going to be less than the HHG Rand McNally distance of 2361 miles
mockedPlanner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"),
"50309", "30813").Return(2294, nil)

ppmEstimate, _, err := ppmEstimator.EstimateIncentiveWithDefaultChecks(suite.AppContextForTest(), oldPPMShipment, &newPPM)
suite.NilOrNoVerrs(err)

mockedPlanner.AssertCalled(suite.T(), "ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"),
"50309", "30813")
mockedPaymentRequestHelper.AssertCalled(suite.T(), "FetchServiceParamsForServiceItems", mock.AnythingOfType("*appcontext.appContext"), mock.AnythingOfType("[]models.MTOServiceItem"))

suite.Equal(oldPPMShipment.PickupAddress.PostalCode, newPPM.PickupAddress.PostalCode)
suite.Equal(unit.Pound(5000), *newPPM.EstimatedWeight)
suite.Equal(unit.Cents(70064364), *ppmEstimate)
})

suite.Run("Estimated Incentive - Success - clears advance and advance requested values", func() {
oldPPMShipment := factory.BuildPPMShipment(suite.DB(), []factory.Customization{
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import { act } from 'react-dom/test-utils';
import { render, screen, within } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { generatePath } from 'react-router-dom';
import { Provider } from 'react-redux';

Expand Down Expand Up @@ -54,17 +55,19 @@ const approveMTO = jest.fn().mockResolvedValue({ response: { status: 200 } });
const mockStore = configureStore({});

const submittedRequestedShipmentsComponent = (
<Provider store={mockStore.store}>
<SubmittedRequestedShipments
allowancesInfo={allowancesInfo}
moveCode="TE5TC0DE"
mtoShipments={shipments}
closeoutOffice={closeoutOffice}
customerInfo={customerInfo}
ordersInfo={ordersInfo}
approveMTO={approveMTO}
/>
</Provider>
<QueryClientProvider client={new QueryClient()}>
<Provider store={mockStore.store}>
<SubmittedRequestedShipments
allowancesInfo={allowancesInfo}
moveCode="TE5TC0DE"
mtoShipments={shipments}
closeoutOffice={closeoutOffice}
customerInfo={customerInfo}
ordersInfo={ordersInfo}
approveMTO={approveMTO}
/>
</Provider>
</QueryClientProvider>
);

const submittedRequestedShipmentsComponentWithPermission = (
Expand Down Expand Up @@ -111,18 +114,20 @@ const submittedRequestedShipmentsComponentAvailableToPrimeAt = (
);

const submittedRequestedShipmentsComponentServicesCounselingCompleted = (
<Provider store={mockStore.store}>
<SubmittedRequestedShipments
ordersInfo={ordersInfo}
allowancesInfo={allowancesInfo}
customerInfo={customerInfo}
mtoShipments={shipments}
closeoutOffice={closeoutOffice}
approveMTO={approveMTO}
moveTaskOrder={moveTaskOrderServicesCounselingCompleted}
moveCode="TE5TC0DE"
/>
</Provider>
<QueryClientProvider client={new QueryClient()}>
<Provider store={mockStore.store}>
<SubmittedRequestedShipments
ordersInfo={ordersInfo}
allowancesInfo={allowancesInfo}
customerInfo={customerInfo}
mtoShipments={shipments}
closeoutOffice={closeoutOffice}
approveMTO={approveMTO}
moveTaskOrder={moveTaskOrderServicesCounselingCompleted}
moveCode="TE5TC0DE"
/>
</Provider>
</QueryClientProvider>
);

const submittedRequestedShipmentsComponentMissingRequiredInfo = (
Expand Down Expand Up @@ -437,9 +442,11 @@ describe('RequestedShipments', () => {
const Component = statusComponents[status];

render(
<Provider store={mockStore.store}>
<Component {...statusTestProps[status]} />
</Provider>,
<QueryClientProvider client={new QueryClient()}>
<Provider store={mockStore.store}>
<Component {...statusTestProps[status]} />
</Provider>
</QueryClientProvider>,
);

const customerRemarks = screen.getAllByTestId('customerRemarks');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,103 @@ export const ppmOnlyShipments = [
},
];

export const zeroIncentivePPM = [
{
approvedDate: '0001-01-01',
createdAt: '2020-06-10T15:58:02.404029Z',
customerRemarks: 'please treat gently',
counselorRemarks: 'looks good',
destinationAddress: {
city: 'Fairfield',
country: 'US',
eTag: 'MjAyMC0wNi0xMFQxNTo1ODowMi4zODk0MTJa',
id: '672ff379-f6e3-48b4-a87d-796713f8f997',
postalCode: '94535',
state: 'CA',
streetAddress1: '987 Any Avenue',
streetAddress2: 'P.O. Box 9876',
streetAddress3: 'c/o Some Person',
},
eTag: 'MjAyMC0wNi0xMFQxNTo1ODowMi40MDQwMzFa',
id: 'ce01a5b8-9b44-4511-8a8d-edb60f2a4aea',
moveTaskOrderID: '9c7b255c-2981-4bf8-839f-61c7458e2b4d',
pickupAddress: {
city: 'Beverly Hills',
country: 'US',
eTag: 'MjAyMC0wNi0xMFQxNTo1ODowMi4zODQ3Njla',
id: '1686751b-ab36-43cf-b3c9-c0f467d13c19',
postalCode: '90210',
state: 'CA',
streetAddress1: '123 Any Street',
streetAddress2: 'P.O. Box 12345',
streetAddress3: 'c/o Some Person',
},
rejectionReason: 'shipment not good enough',
requestedPickupDate: '2018-03-15',
scheduledPickupDate: '2018-03-16',
secondaryDeliveryAddress: {
city: 'Beverly Hills',
country: 'US',
eTag: 'MjAyMC0wNi0xMFQxNTo1ODowMi4zOTkzMlo=',
id: '15e8f6cc-e1d7-44b2-b1e0-fcb3d6442831',
postalCode: '90210',
state: 'CA',
streetAddress1: '123 Any Street',
streetAddress2: 'P.O. Box 12345',
streetAddress3: 'c/o Some Person',
},
secondaryPickupAddress: {
city: 'Beverly Hills',
country: 'US',
eTag: 'MjAyMC0wNi0xMFQxNTo1ODowMi4zOTM4OTZa',
id: '9b79e0c3-8ed5-4fb8-aa36-95845707d8ee',
postalCode: '90210',
state: 'CA',
streetAddress1: '123 Any Street',
streetAddress2: 'P.O. Box 12345',
streetAddress3: 'c/o Some Person',
},
ppmShipment: {
pickupAddress: {
streetAddress1: '812 S 129th St',
streetAddress2: '#123',
city: 'San Antonio',
state: 'TX',
postalCode: '10001',
},
destinationAddress: {
streetAddress1: '813 S 129th St',
streetAddress2: '#124',
city: 'San Antonio',
state: 'TX',
postalCode: '10002',
},
secondaryPickupAddress: {
streetAddress1: '814 S 129th St',
streetAddress2: '#125',
city: 'San Antonio',
state: 'TX',
postalCode: '10001',
},
secondaryDestinationAddress: {
streetAddress1: '815 S 129th St',
streetAddress2: '#126',
city: 'San Antonio',
state: 'TX',
postalCode: '10002',
},
hasSecondaryDestinationAddress: true,
hasSecondaryPickupAddress: true,
expectedDepartureDate: '2022-07-04',
estimatedWeight: 500,
estimatedIncentive: 0,
},
shipmentType: SHIPMENT_OPTIONS.PPM,
status: 'SUBMITTED',
updatedAt: '2020-06-10T15:58:02.404031Z',
},
];

export const ordersInfo = {
newDutyLocation: {
address: {
Expand Down
Loading

0 comments on commit 6fb6ae6

Please sign in to comment.