Skip to content

Commit

Permalink
Merge pull request #12013 from transcom/B-18058-new
Browse files Browse the repository at this point in the history
B 18058 aoa customer notification step
  • Loading branch information
r-mettler authored Feb 21, 2024
2 parents 96c9bb6 + 93de9eb commit f8a7ac3
Show file tree
Hide file tree
Showing 6 changed files with 230 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ func PPMShipment(storer storage.FileStorer, ppmShipment *models.PPMShipment) *in
AdvanceAmountRequested: handlers.FmtCost(ppmShipment.AdvanceAmountRequested),
HasReceivedAdvance: ppmShipment.HasReceivedAdvance,
AdvanceAmountReceived: handlers.FmtCost(ppmShipment.AdvanceAmountReceived),
AdvanceStatus: (*internalmessages.PPMAdvanceStatus)(ppmShipment.AdvanceStatus),
WeightTickets: WeightTickets(storer, ppmShipment.WeightTickets),
MovingExpenses: MovingExpenses(storer, ppmShipment.MovingExpenses),
ProGearWeightTickets: ProGearWeightTickets(storer, ppmShipment.ProgearWeightTickets),
Expand Down
7 changes: 6 additions & 1 deletion playwright/tests/my/milmove/ppms/customerPpmTestFixture.js
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,12 @@ export class CustomerPpmPage extends CustomerPage {

await expect(this.page.locator('.usa-alert--success')).toContainText('You submitted documentation for review.');

const stepContainer = this.page.locator('[data-testid="stepContainer5"]');
let stepContainer = this.page.locator('[data-testid="stepContainer6"]');

if (stepContainer == null) {
stepContainer = this.page.locator('[data-testid="stepContainer5"]');
}

await expect(stepContainer.getByRole('button', { name: 'Download Incentive Packet' })).toBeDisabled();
await expect(stepContainer.getByText(/PPM documentation submitted: \d{2} \w{3} \d{4}/)).toBeVisible();
}
Expand Down
17 changes: 11 additions & 6 deletions playwright/tests/my/milmove/ppms/entireShipmentOnboarding.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,16 @@ class CustomerPpmOnboardingPage extends CustomerPpmPage {

/**
*/
async verifyStep5ExistsAndBtnIsDisabled() {
const stepContainer5 = this.page.locator('[data-testid="stepContainer5"]');
await expect(stepContainer5.getByRole('button', { name: 'Upload PPM Documents' })).toBeDisabled();
async verifyManagePPMStepExistsAndBtnIsDisabled() {
const stepContainer = this.page.locator('[data-testid="stepContainer6"]');

if (stepContainer == null) {
this.page.locator('[data-testid="stepContainer5"]');
}

await expect(stepContainer.getByRole('button', { name: 'Upload PPM Documents' })).toBeDisabled();
await expect(
stepContainer5.locator('p').getByText('After a counselor approves your PPM, you will be able to:'),
stepContainer.locator('p').getByText('After a counselor approves your PPM, you will be able to:'),
).toBeVisible();
}

Expand Down Expand Up @@ -119,7 +124,7 @@ test.describe('Entire PPM onboarding flow', () => {
await customerPpmOnboardingPage.submitsAdvancePage({ addAdvance: true, isMobile });
await customerPpmOnboardingPage.navigateToAgreementAndSign();
await customerPpmOnboardingPage.submitMove();
await customerPpmOnboardingPage.verifyStep5ExistsAndBtnIsDisabled();
await customerPpmOnboardingPage.verifyManagePPMStepExistsAndBtnIsDisabled();
});

test('happy path with edits and backs', async () => {
Expand All @@ -138,7 +143,7 @@ test.describe('Entire PPM onboarding flow', () => {
await customerPpmOnboardingPage.navigateToAgreementAndSign();

await customerPpmOnboardingPage.submitMove();
await customerPpmOnboardingPage.verifyStep5ExistsAndBtnIsDisabled();
await customerPpmOnboardingPage.verifyManagePPMStepExistsAndBtnIsDisabled();
});
});
});
11 changes: 8 additions & 3 deletions playwright/tests/my/milmove/ppms/navigateToUploadDocs.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,14 @@ test.describe('PPM Request Payment - Begin providing documents flow', () => {

test('has upload documents button enabled', async ({ page }) => {
await expect(page.getByRole('heading', { name: 'Your move is in progress.' })).toBeVisible();
const stepContainer5 = page.getByTestId('stepContainer5');
await expect(stepContainer5.locator('p').getByText('15 Apr 2022')).toBeVisible();
await stepContainer5.getByRole('button', { name: 'Upload PPM Documents' }).click();
let stepContainer = page.getByTestId('stepContainer6');

if (stepContainer == null) {
stepContainer = page.getByTestId('stepContainer5');
}

await expect(stepContainer.locator('p').getByText('15 Apr 2022')).toBeVisible();
await stepContainer.getByRole('button', { name: 'Upload PPM Documents' }).click();
await expect(page).toHaveURL(/\/moves\/[^/]+\/shipments\/[^/]+\/about/);
});
});
Expand Down
108 changes: 107 additions & 1 deletion src/pages/MyMove/Home/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import { formatCustomerDate, formatWeight } from 'utils/formatters';
import { isPPMAboutInfoComplete, isPPMShipmentComplete, isWeightTicketComplete } from 'utils/shipments';
import withRouter from 'utils/routing';
import { RouterShape } from 'types/router';
import { ADVANCE_STATUSES } from 'constants/ppms';

const Description = ({ className, children, dataTestId }) => (
<p className={`${styles.description} ${className}`} data-testid={dataTestId}>
Expand Down Expand Up @@ -141,6 +142,30 @@ export class Home extends Component {
return mtoShipments?.filter((s) => s.shipmentType === SHIPMENT_OPTIONS.PPM)?.every((s) => isPPMShipmentComplete(s));
}

get hasAdvanceApproved() {
const { mtoShipments } = this.props;
// determine if at least one advance was APPROVED (advance_status in ppm_shipments table is not nil)
const appovedAdvances = mtoShipments.filter(
(shipment) => shipment?.ppmShipment?.advanceStatus === ADVANCE_STATUSES.APPROVED.apiValue,
);
return !!appovedAdvances.length;
}

get hasAllAdvancesRejected() {
// check to see if all advance_status are REJECTED
const { mtoShipments } = this.props;
const rejectedAdvances = mtoShipments.filter(
(shipment) => shipment?.ppmShipment?.advanceStatus === ADVANCE_STATUSES.REJECTED.apiValue,
);
return !this.hasAdvanceApproved && rejectedAdvances.length > 0;
}

get hasAdvanceRequested() {
const { mtoShipments } = this.props;
const requestedAdvances = mtoShipments.filter((shipment) => shipment?.ppmShipment?.hasRequestedAdvance);
return !!requestedAdvances.length;
}

get isMoveApproved() {
const { move } = this.props;
return move.status === MOVE_STATUSES.APPROVED;
Expand Down Expand Up @@ -384,6 +409,7 @@ export class Home extends Component {

// eslint-disable-next-line camelcase
const currentLocation = current_location;
const shipmentNumbersByType = {};

return (
<>
Expand Down Expand Up @@ -535,8 +561,88 @@ export class Home extends Component {
</Description>
)}
</Step>
{!!ppmShipments.length && this.hasSubmittedMove && this.hasAdvanceRequested && (
<Step
complete={this.hasAdvanceApproved || this.hasAllAdvancesRejected}
completedHeaderText={
this.hasAllAdvancesRejected ? 'Advance request denied' : 'Advance request reviewed'
}
headerText="Advance request submitted"
step="5"
>
<SectionWrapper className={styles['ppm-shipment']}>
{this.hasAdvanceApproved && (
<>
<Description>
Your Advance Operating Allowance (AOA) request has been reviewed. Download the paperwork
for approved requests and submit it to your Finance Office to receive your advance.
<br />
<br /> The amount you receive will be deducted from your PPM incentive payment. If your
incentive ends up being less than your advance, you will be required to pay back the
difference.
<br />
<br />
</Description>
{ppmShipments.map((shipment) => {
const { shipmentType } = shipment;
if (shipmentNumbersByType[shipmentType]) {
shipmentNumbersByType[shipmentType] += 1;
} else {
shipmentNumbersByType[shipmentType] = 1;
}
const shipmentNumber = shipmentNumbersByType[shipmentType];
return (
<>
<strong>
{shipmentTypes[shipment.shipmentType]}
{` ${shipmentNumber} `}
</strong>
{shipment?.ppmShipment?.advanceStatus === ADVANCE_STATUSES.APPROVED.apiValue && (
// TODO: B-18060 will add link to method that will create the AOA packet and return for download
<p className={styles.downloadLink}>
<a href="">
<span>Download AOA Paperwork (PDF)</span>
</a>
</p>
)}
{shipment?.ppmShipment?.advanceStatus === ADVANCE_STATUSES.REJECTED.apiValue && (
<Description>Advance request denied</Description>
)}
{shipment?.ppmShipment?.advanceStatus == null && (
<Description>Advance request pending</Description>
)}
</>
);
})}
</>
)}
{this.hasAllAdvancesRejected && (
<Description>
Your Advance Operating Allowance (AOA) request has been denied. You may be able to use your
Government Travel Charge Card (GTCC). Contact your local transportation office to verify
GTCC usage authorization or ask any questions.
</Description>
)}
{!this.hasAdvanceApproved && !this.hasAllAdvancesRejected && (
<Description>
Your service will review your request for an Advance Operating Allowance (AOA). If approved,
you will be able to download the paperwork for your request and submit it to your Finance
Office to receive your advance.
<br />
<br /> The amount you receive will be deducted from your PPM incentive payment. If your
incentive ends up being less than your advance, you will be required to pay back the
difference.
</Description>
)}
</SectionWrapper>
</Step>
)}
{!!ppmShipments.length && this.hasSubmittedMove && (
<Step headerText="Manage your PPM" completedHeaderText="Manage your PPM" step="5">
<Step
headerText="Manage your PPM"
completedHeaderText="Manage your PPM"
step={this.hasAdvanceRequested ? '6' : '5'}
>
<PPMSummaryList shipments={ppmShipments} onUploadClick={this.handlePPMUploadClick} />
</Step>
)}
Expand Down
101 changes: 97 additions & 4 deletions src/pages/MyMove/Home/index.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,40 @@ const ppmShipmentWithCompleteWeightTicket = {
},
};

const approvedAdvancePPMShipment = {
...incompletePPMShipment,
ppmShipment: {
...incompletePPMShipment.ppmShipment,
sitExpected: false,
estimatedWeight: 4000,
hasProGear: false,
estimatedIncentive: 10000000,
hasRequestedAdvance: true,
advanceAmountRequested: 30000,
advanceStatus: 'APPROVED',
status: ppmShipmentStatuses.SUBMITTED,
updatedAt: ppmShipmentUpdatedDate.toISOString(),
eTag: window.btoa(ppmShipmentUpdatedDate.toISOString()),
},
};

const rejectedAdvancePPMShipment = {
...incompletePPMShipment,
ppmShipment: {
...incompletePPMShipment.ppmShipment,
sitExpected: false,
estimatedWeight: 4000,
hasProGear: false,
estimatedIncentive: 10000000,
hasRequestedAdvance: true,
advanceAmountRequested: 30000,
advanceStatus: 'REJECTED',
status: ppmShipmentStatuses.SUBMITTED,
updatedAt: ppmShipmentUpdatedDate.toISOString(),
eTag: window.btoa(ppmShipmentUpdatedDate.toISOString()),
},
};

const mountHomeWithProviders = (props = {}) => {
return mount(
<MockProviders>
Expand Down Expand Up @@ -510,7 +544,7 @@ describe('Home component', () => {
expect(ordersStep.prop('editBtnLabel')).toEqual('Upload documents');
});

it('renders Step 5', () => {
it('renders Manage your PPM Step', () => {
render(<Home {...props} />);
expect(screen.getByText('Manage your PPM')).toBeInTheDocument();
});
Expand All @@ -521,6 +555,65 @@ describe('Home component', () => {
});
});

describe('for advance request approved PPM', () => {
it('renders advance request submitted for PPM', () => {
const mtoShipments = [submittedPPMShipment];
const props = { ...defaultProps, ...propUpdates, mtoShipments };
render(<Home {...props} />);
expect(screen.getByText('Advance request submitted')).toBeInTheDocument();
});

it('renders advance request submitted for PPM', () => {
const mtoShipments = [approvedAdvancePPMShipment];
const props = { ...defaultProps, ...propUpdates, mtoShipments };
render(<Home {...props} />);
expect(screen.getByText('Download AOA Paperwork (PDF)')).toBeInTheDocument();
});

it('renders advance request reviewed with 1 approved PPM', () => {
const mtoShipments = [approvedAdvancePPMShipment];
const wrapper = mountHomeWithProviders({ ...propUpdates, mtoShipments });
const advanceStep = wrapper.find('Step[step="5"]');
expect(advanceStep.prop('completedHeaderText')).toEqual('Advance request reviewed');

const props = { ...defaultProps, ...propUpdates, mtoShipments };
render(<Home {...props} />);
expect(screen.getByText('Download AOA Paperwork (PDF)')).toBeInTheDocument();
});

it('renders advance request reviewed for approved advance for PPM with HHG', () => {
const mtoShipments = [{ id: v4(), shipmentType: SHIPMENT_OPTIONS.HHG }, approvedAdvancePPMShipment];
const wrapper = mountHomeWithProviders({ ...propUpdates, mtoShipments });
const advanceStep = wrapper.find('Step[step="5"]');
expect(advanceStep.prop('completedHeaderText')).toEqual('Advance request reviewed');

const props = { ...defaultProps, ...propUpdates, mtoShipments };
render(<Home {...props} />);
expect(screen.getByText('Download AOA Paperwork (PDF)')).toBeInTheDocument();
});

it('renders advance request reviewed with 1 approved and 1 rejected advance', () => {
const mtoShipments = [approvedAdvancePPMShipment, rejectedAdvancePPMShipment];
const wrapper = mountHomeWithProviders({ ...propUpdates, mtoShipments });
const advanceStep = wrapper.find('Step[step="5"]');

expect(advanceStep.prop('completedHeaderText')).toEqual('Advance request reviewed');

const props = { ...defaultProps, ...propUpdates, mtoShipments };
render(<Home {...props} />);
expect(screen.getByText('Download AOA Paperwork (PDF)')).toBeInTheDocument();
expect(screen.getByText('Advance request denied')).toBeInTheDocument();
});

it('renders advance request denied for PPM', () => {
const mtoShipments = [rejectedAdvancePPMShipment];
const wrapper = mountHomeWithProviders({ ...propUpdates, mtoShipments });
const advanceStep = wrapper.find('Step[step="5"]');

expect(advanceStep.prop('completedHeaderText')).toEqual('Advance request denied');
});
});

describe('for HHG moves (no PPM)', () => {
const mtoShipments = [{ id: v4(), shipmentType: SHIPMENT_OPTIONS.HHG }];

Expand All @@ -542,7 +635,7 @@ describe('Home component', () => {
expect(ordersStep.prop('editBtnLabel')).toEqual('Upload documents');
});

it('does not render Step 5', () => {
it('does not render Manage your PPM Step', () => {
render(<Home {...props} />);
expect(screen.queryByText('Manage your PPM')).not.toBeInTheDocument();
});
Expand Down Expand Up @@ -574,7 +667,7 @@ describe('Home component', () => {
expect(ordersStep.prop('editBtnLabel')).toEqual('Upload documents');
});

it('does not render Step 5', () => {
it('does not render Manage your PPM Step', () => {
render(<Home {...props} />);
expect(screen.queryByText('Manage your PPM')).not.toBeInTheDocument();
});
Expand Down Expand Up @@ -618,7 +711,7 @@ describe('Home component', () => {
expect(ordersStep.prop('editBtnLabel')).toEqual('Upload documents');
});

it('renders Step 5', () => {
it('renders Manage your PPM Step', () => {
render(<Home {...props} />);
expect(screen.getByText('Manage your PPM')).toBeInTheDocument();
});
Expand Down

0 comments on commit f8a7ac3

Please sign in to comment.