From fb40d62b1d2780d0e4d2228460f415897c56e8dc Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Wed, 31 Jan 2024 00:47:17 +0000 Subject: [PATCH 01/14] advance request links for customer, download still needs updating --- .../internal/payloads/model_to_payload.go | 1 + src/hooks/queries.js | 54 +++++++++ src/pages/MyMove/Home/index.jsx | 112 +++++++++++++++++- 3 files changed, 165 insertions(+), 2 deletions(-) diff --git a/pkg/handlers/internalapi/internal/payloads/model_to_payload.go b/pkg/handlers/internalapi/internal/payloads/model_to_payload.go index 464d36267e9..f0b5fd06ed3 100644 --- a/pkg/handlers/internalapi/internal/payloads/model_to_payload.go +++ b/pkg/handlers/internalapi/internal/payloads/model_to_payload.go @@ -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), diff --git a/src/hooks/queries.js b/src/hooks/queries.js index 92aa2ad6dc0..c05e71f8985 100644 --- a/src/hooks/queries.js +++ b/src/hooks/queries.js @@ -428,6 +428,60 @@ export const useOrdersDocumentQueries = (moveCode) => { }; }; +export const useAOADocumentQueries = (moveCode) => { + // Get the ppm shipment info so we can get the aoa_packet_id (which is a document id) + + + + // const { data: move, ...moveQuery } = useQuery([MOVES, moveCode], ({ queryKey }) => getMove(...queryKey)); + + // const orderId = move?.ordersId; + + // // get orders + // const { data: { orders } = {}, ...orderQuery } = useQuery( + // [ORDERS, orderId], + // ({ queryKey }) => getOrder(...queryKey), + // { + // enabled: !!orderId, + // }, + // ); + + // const order = orders && orders[`${orderId}`]; + // // eslint-disable-next-line camelcase + // const documentId = order?.uploaded_order_id; + + // Get the AOA packet document + const staleTime = 15 * 60000; // 15 * 60000 milliseconds = 15 mins + const cacheTime = staleTime; + const { data: { documents, upload } = {}, ...aoaPacketDocumentQuery } = useQuery( + [ORDERS_DOCUMENTS, documentId], + ({ queryKey }) => getDocument(...queryKey), + { + enabled: !!documentId, + staleTime, + cacheTime, + refetchOnWindowFocus: false, + }, + ); + + // Check the status of all queries we have made + const { isLoading, isError, isSuccess } = getQueriesStatus([ + moveQuery, + orderQuery, + aoaPacketDocumentQuery, + ]); + + return { + move, + orders, + documents, + upload, + isLoading, + isError, + isSuccess, + }; +}; + export const useMovesQueueQueries = ({ sort, order, diff --git a/src/pages/MyMove/Home/index.jsx b/src/pages/MyMove/Home/index.jsx index 293c1ce9db6..c16bb28fd76 100644 --- a/src/pages/MyMove/Home/index.jsx +++ b/src/pages/MyMove/Home/index.jsx @@ -141,6 +141,26 @@ 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 === 'APPROVED'); + 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 === 'REJECTED'); + 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; @@ -348,6 +368,17 @@ export class Home extends Component { window.print(); }; + // return a link to use to download the AOA packet + // getAOAPacketFileUrl = (moveCode) => { + // // TODO: B-18061 will change this to download the actual AOA packet to include the SSW + // // For now we just provide a link to download the order documents as a placeholder + // const { upload, amendedUpload, isLoading, isError } = useOrdersDocumentQueries(moveCode); + // if (isLoading) return ; + // if (isError) return ; + // const orderDocuments = Object.values(upload || {}).concat(Object.values(amendedUpload || {})); + // const sortedFiles = orderDocuments.sort((a, b) => moment(b.createdAt) - moment(a.createdAt)); + // }; + render() { const { isProfileComplete, move, mtoShipments, serviceMember, signedCertification, uploadedOrderDocuments } = this.props; @@ -384,7 +415,7 @@ export class Home extends Component { // eslint-disable-next-line camelcase const currentLocation = current_location; - + const shipmentNumbersByType = {}; return ( <> )} + {!!ppmShipments.length && this.hasSubmittedMove && this.hasAdvanceRequested && ( + + + {this.hasAdvanceApproved && ( + <> + + 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. +
+
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. +
+
+
+ {allSortedShipments.map((shipment) => { + const { shipmentType } = shipment; + if (shipmentNumbersByType[shipmentType]) { + shipmentNumbersByType[shipmentType] += 1; + } else { + shipmentNumbersByType[shipmentType] = 1; + } + const shipmentNumber = shipmentNumbersByType[shipmentType]; + return ( + <> + + {shipmentTypes[shipment.shipmentType]} + {` ${shipmentNumber} `} + + {shipment?.ppmShipment?.advanceStatus === 'APPROVED' && ( + //

+ // + // Download AOA Paperwork (PDF) + // + //

+ Advance request approved + )} + {shipment?.ppmShipment?.advanceStatus === 'REJECTED' && ( + Advance request denied + )} + + ); + })} + + )} + {this.hasAllAdvancesRejected && ( + + 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. + + )} + {!this.hasAdvanceApproved && !this.hasAllAdvancesRejected && ( + + 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. +
+
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. +
+ )} +
+
+ )} {!!ppmShipments.length && this.hasSubmittedMove && ( - + )} From ccc5bd8365fb7da4ef433493d3a7c2fd6c9714da Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Wed, 31 Jan 2024 00:54:13 +0000 Subject: [PATCH 02/14] updates to retrieve aoa_packet_id from ppm_shipment --- .../internal/payloads/model_to_payload.go | 1 + src/hooks/queries.js | 41 ++++--------------- src/pages/MyMove/Home/index.jsx | 30 ++++++-------- swagger-def/definitions/PPMShipment.yaml | 4 ++ 4 files changed, 24 insertions(+), 52 deletions(-) diff --git a/pkg/handlers/internalapi/internal/payloads/model_to_payload.go b/pkg/handlers/internalapi/internal/payloads/model_to_payload.go index f0b5fd06ed3..a0e43b074d5 100644 --- a/pkg/handlers/internalapi/internal/payloads/model_to_payload.go +++ b/pkg/handlers/internalapi/internal/payloads/model_to_payload.go @@ -105,6 +105,7 @@ func PPMShipment(storer storage.FileStorer, ppmShipment *models.PPMShipment) *in HasReceivedAdvance: ppmShipment.HasReceivedAdvance, AdvanceAmountReceived: handlers.FmtCost(ppmShipment.AdvanceAmountReceived), AdvanceStatus: (*internalmessages.PPMAdvanceStatus)(ppmShipment.AdvanceStatus), + AoaPacketID: *handlers.FmtUUID(*ppmShipment.AOAPacketID), WeightTickets: WeightTickets(storer, ppmShipment.WeightTickets), MovingExpenses: MovingExpenses(storer, ppmShipment.MovingExpenses), ProGearWeightTickets: ProGearWeightTickets(storer, ppmShipment.ProgearWeightTickets), diff --git a/src/hooks/queries.js b/src/hooks/queries.js index c05e71f8985..80d7a05e984 100644 --- a/src/hooks/queries.js +++ b/src/hooks/queries.js @@ -428,36 +428,15 @@ export const useOrdersDocumentQueries = (moveCode) => { }; }; -export const useAOADocumentQueries = (moveCode) => { - // Get the ppm shipment info so we can get the aoa_packet_id (which is a document id) - - - - // const { data: move, ...moveQuery } = useQuery([MOVES, moveCode], ({ queryKey }) => getMove(...queryKey)); - - // const orderId = move?.ordersId; - - // // get orders - // const { data: { orders } = {}, ...orderQuery } = useQuery( - // [ORDERS, orderId], - // ({ queryKey }) => getOrder(...queryKey), - // { - // enabled: !!orderId, - // }, - // ); - - // const order = orders && orders[`${orderId}`]; - // // eslint-disable-next-line camelcase - // const documentId = order?.uploaded_order_id; - - // Get the AOA packet document +export const useAOAPacketDocumentQueries = (aoaPacketId) => { + // Get the packet using the aoa_packet_id (which is a document id) const staleTime = 15 * 60000; // 15 * 60000 milliseconds = 15 mins const cacheTime = staleTime; - const { data: { documents, upload } = {}, ...aoaPacketDocumentQuery } = useQuery( - [ORDERS_DOCUMENTS, documentId], + const { data: { documents, aoaPacket } = {}, ...aoaPacketDocumentQuery } = useQuery( + [ORDERS_DOCUMENTS, aoaPacketId], ({ queryKey }) => getDocument(...queryKey), { - enabled: !!documentId, + enabled: !!aoaPacketId, staleTime, cacheTime, refetchOnWindowFocus: false, @@ -465,17 +444,11 @@ export const useAOADocumentQueries = (moveCode) => { ); // Check the status of all queries we have made - const { isLoading, isError, isSuccess } = getQueriesStatus([ - moveQuery, - orderQuery, - aoaPacketDocumentQuery, - ]); + const { isLoading, isError, isSuccess } = getQueriesStatus([aoaPacketDocumentQuery]); return { - move, - orders, documents, - upload, + aoaPacket, isLoading, isError, isSuccess, diff --git a/src/pages/MyMove/Home/index.jsx b/src/pages/MyMove/Home/index.jsx index c16bb28fd76..8875654370b 100644 --- a/src/pages/MyMove/Home/index.jsx +++ b/src/pages/MyMove/Home/index.jsx @@ -38,6 +38,7 @@ import { selectSignedCertification, } from 'shared/Entities/modules/signed_certifications'; import LoadingPlaceholder from 'shared/LoadingPlaceholder'; +import SomethingWentWrong from 'shared/SomethingWentWrong'; import { updateMTOShipments } from 'store/entities/actions'; import { selectCurrentMove, @@ -52,6 +53,7 @@ import { MoveShape, OrdersShape, UploadShape } from 'types/customerShapes'; import { ShipmentShape } from 'types/shipment'; import { formatCustomerDate, formatWeight } from 'utils/formatters'; import { isPPMAboutInfoComplete, isPPMShipmentComplete, isWeightTicketComplete } from 'utils/shipments'; +import { useAOAPacketDocumentQueries } from 'hooks/queries'; import withRouter from 'utils/routing'; import { RouterShape } from 'types/router'; @@ -368,17 +370,6 @@ export class Home extends Component { window.print(); }; - // return a link to use to download the AOA packet - // getAOAPacketFileUrl = (moveCode) => { - // // TODO: B-18061 will change this to download the actual AOA packet to include the SSW - // // For now we just provide a link to download the order documents as a placeholder - // const { upload, amendedUpload, isLoading, isError } = useOrdersDocumentQueries(moveCode); - // if (isLoading) return ; - // if (isError) return ; - // const orderDocuments = Object.values(upload || {}).concat(Object.values(amendedUpload || {})); - // const sortedFiles = orderDocuments.sort((a, b) => moment(b.createdAt) - moment(a.createdAt)); - // }; - render() { const { isProfileComplete, move, mtoShipments, serviceMember, signedCertification, uploadedOrderDocuments } = this.props; @@ -416,6 +407,7 @@ export class Home extends Component { // eslint-disable-next-line camelcase const currentLocation = current_location; const shipmentNumbersByType = {}; + return ( <>
- {allSortedShipments.map((shipment) => { + {ppmShipments.map((shipment) => { const { shipmentType } = shipment; if (shipmentNumbersByType[shipmentType]) { shipmentNumbersByType[shipmentType] += 1; } else { shipmentNumbersByType[shipmentType] = 1; } + // if(shipment?.ppmShipment?.advanceStatus === 'APPROVED') { + // aoaPacketNumber += 1; + // } const shipmentNumber = shipmentNumbersByType[shipmentType]; return ( <> @@ -603,12 +598,11 @@ export class Home extends Component { {` ${shipmentNumber} `} {shipment?.ppmShipment?.advanceStatus === 'APPROVED' && ( - //

- // - // Download AOA Paperwork (PDF) - // - //

- Advance request approved +

+ + Download AOA Paperwork (PDF) NEED AOA PACKET URL HERE + +

)} {shipment?.ppmShipment?.advanceStatus === 'REJECTED' && ( Advance request denied diff --git a/swagger-def/definitions/PPMShipment.yaml b/swagger-def/definitions/PPMShipment.yaml index 93a18901a71..117a3d6ed53 100644 --- a/swagger-def/definitions/PPMShipment.yaml +++ b/swagger-def/definitions/PPMShipment.yaml @@ -225,6 +225,10 @@ properties: description: A hash unique to this shipment that should be used as the "If-Match" header for any updates. type: string readOnly: true + aoa_packet_id: + type: string + format: uuid + example: c56a4180-65aa-42ec-a945-5fd21dec0538 required: - id - shipmentId From 04b7f3c0d06ac3af8ffff3ce29b6aba24c4e0472 Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Wed, 31 Jan 2024 00:54:50 +0000 Subject: [PATCH 03/14] blank download link --- src/pages/MyMove/Home/index.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/MyMove/Home/index.jsx b/src/pages/MyMove/Home/index.jsx index 8875654370b..1c6203cdb90 100644 --- a/src/pages/MyMove/Home/index.jsx +++ b/src/pages/MyMove/Home/index.jsx @@ -599,8 +599,8 @@ export class Home extends Component { {shipment?.ppmShipment?.advanceStatus === 'APPROVED' && (

- - Download AOA Paperwork (PDF) NEED AOA PACKET URL HERE + + Download AOA Paperwork (PDF)

)} From 6f6168b93bc2223940cc9206bf4f13e60bc121f6 Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Wed, 31 Jan 2024 00:55:17 +0000 Subject: [PATCH 04/14] code cleanup --- src/hooks/queries.js | 27 --------------------------- src/pages/MyMove/Home/index.jsx | 5 ----- 2 files changed, 32 deletions(-) diff --git a/src/hooks/queries.js b/src/hooks/queries.js index 80d7a05e984..92aa2ad6dc0 100644 --- a/src/hooks/queries.js +++ b/src/hooks/queries.js @@ -428,33 +428,6 @@ export const useOrdersDocumentQueries = (moveCode) => { }; }; -export const useAOAPacketDocumentQueries = (aoaPacketId) => { - // Get the packet using the aoa_packet_id (which is a document id) - const staleTime = 15 * 60000; // 15 * 60000 milliseconds = 15 mins - const cacheTime = staleTime; - const { data: { documents, aoaPacket } = {}, ...aoaPacketDocumentQuery } = useQuery( - [ORDERS_DOCUMENTS, aoaPacketId], - ({ queryKey }) => getDocument(...queryKey), - { - enabled: !!aoaPacketId, - staleTime, - cacheTime, - refetchOnWindowFocus: false, - }, - ); - - // Check the status of all queries we have made - const { isLoading, isError, isSuccess } = getQueriesStatus([aoaPacketDocumentQuery]); - - return { - documents, - aoaPacket, - isLoading, - isError, - isSuccess, - }; -}; - export const useMovesQueueQueries = ({ sort, order, diff --git a/src/pages/MyMove/Home/index.jsx b/src/pages/MyMove/Home/index.jsx index 1c6203cdb90..60f54328d21 100644 --- a/src/pages/MyMove/Home/index.jsx +++ b/src/pages/MyMove/Home/index.jsx @@ -38,7 +38,6 @@ import { selectSignedCertification, } from 'shared/Entities/modules/signed_certifications'; import LoadingPlaceholder from 'shared/LoadingPlaceholder'; -import SomethingWentWrong from 'shared/SomethingWentWrong'; import { updateMTOShipments } from 'store/entities/actions'; import { selectCurrentMove, @@ -53,7 +52,6 @@ import { MoveShape, OrdersShape, UploadShape } from 'types/customerShapes'; import { ShipmentShape } from 'types/shipment'; import { formatCustomerDate, formatWeight } from 'utils/formatters'; import { isPPMAboutInfoComplete, isPPMShipmentComplete, isWeightTicketComplete } from 'utils/shipments'; -import { useAOAPacketDocumentQueries } from 'hooks/queries'; import withRouter from 'utils/routing'; import { RouterShape } from 'types/router'; @@ -587,9 +585,6 @@ export class Home extends Component { } else { shipmentNumbersByType[shipmentType] = 1; } - // if(shipment?.ppmShipment?.advanceStatus === 'APPROVED') { - // aoaPacketNumber += 1; - // } const shipmentNumber = shipmentNumbersByType[shipmentType]; return ( <> From 2249c7e63936da6d561a52d837ea767cf0ceea45 Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Wed, 31 Jan 2024 00:58:36 +0000 Subject: [PATCH 05/14] added tests for advance request --- .../internal/payloads/model_to_payload.go | 1 - src/pages/MyMove/Home/index.jsx | 3 +- src/pages/MyMove/Home/index.test.jsx | 103 +++++++++++++++++- swagger-def/definitions/PPMShipment.yaml | 4 - 4 files changed, 100 insertions(+), 11 deletions(-) diff --git a/pkg/handlers/internalapi/internal/payloads/model_to_payload.go b/pkg/handlers/internalapi/internal/payloads/model_to_payload.go index a0e43b074d5..f0b5fd06ed3 100644 --- a/pkg/handlers/internalapi/internal/payloads/model_to_payload.go +++ b/pkg/handlers/internalapi/internal/payloads/model_to_payload.go @@ -105,7 +105,6 @@ func PPMShipment(storer storage.FileStorer, ppmShipment *models.PPMShipment) *in HasReceivedAdvance: ppmShipment.HasReceivedAdvance, AdvanceAmountReceived: handlers.FmtCost(ppmShipment.AdvanceAmountReceived), AdvanceStatus: (*internalmessages.PPMAdvanceStatus)(ppmShipment.AdvanceStatus), - AoaPacketID: *handlers.FmtUUID(*ppmShipment.AOAPacketID), WeightTickets: WeightTickets(storer, ppmShipment.WeightTickets), MovingExpenses: MovingExpenses(storer, ppmShipment.MovingExpenses), ProGearWeightTickets: ProGearWeightTickets(storer, ppmShipment.ProgearWeightTickets), diff --git a/src/pages/MyMove/Home/index.jsx b/src/pages/MyMove/Home/index.jsx index 60f54328d21..09cfff0e623 100644 --- a/src/pages/MyMove/Home/index.jsx +++ b/src/pages/MyMove/Home/index.jsx @@ -593,8 +593,9 @@ export class Home extends Component { {` ${shipmentNumber} `} {shipment?.ppmShipment?.advanceStatus === 'APPROVED' && ( + // TODO: B-18060 will add link to method that will create the AOA packet and return for download

- + Download AOA Paperwork (PDF)

diff --git a/src/pages/MyMove/Home/index.test.jsx b/src/pages/MyMove/Home/index.test.jsx index 1201d8d6c3d..f46d7a221b6 100644 --- a/src/pages/MyMove/Home/index.test.jsx +++ b/src/pages/MyMove/Home/index.test.jsx @@ -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( @@ -493,7 +527,7 @@ describe('Home component', () => { const mtoShipments = [submittedPPMShipment]; const wrapper = mountHomeWithProviders({ ...propUpdates, mtoShipments }); - + const props = { ...defaultProps, ...propUpdates, mtoShipments }; it('renders the SubmittedMove helper', () => { @@ -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(); expect(screen.getByText('Manage your PPM')).toBeInTheDocument(); }); @@ -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(); + expect(screen.getByText('Advance request submitted')).toBeInTheDocument(); + }); + + it('renders advance request submitted for PPM', () => { + const mtoShipments = [approvedAdvancePPMShipment]; + const props = { ...defaultProps, ...propUpdates, mtoShipments }; + render(); + 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(); + 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(); + 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(); + 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 }]; @@ -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(); expect(screen.queryByText('Manage your PPM')).not.toBeInTheDocument(); }); @@ -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(); expect(screen.queryByText('Manage your PPM')).not.toBeInTheDocument(); }); @@ -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(); expect(screen.getByText('Manage your PPM')).toBeInTheDocument(); }); diff --git a/swagger-def/definitions/PPMShipment.yaml b/swagger-def/definitions/PPMShipment.yaml index 117a3d6ed53..93a18901a71 100644 --- a/swagger-def/definitions/PPMShipment.yaml +++ b/swagger-def/definitions/PPMShipment.yaml @@ -225,10 +225,6 @@ properties: description: A hash unique to this shipment that should be used as the "If-Match" header for any updates. type: string readOnly: true - aoa_packet_id: - type: string - format: uuid - example: c56a4180-65aa-42ec-a945-5fd21dec0538 required: - id - shipmentId From df4b6250fbdc6081d49e4a28766cacd1a5107621 Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Wed, 31 Jan 2024 00:59:12 +0000 Subject: [PATCH 06/14] lint cleanup --- src/pages/MyMove/Home/index.test.jsx | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/pages/MyMove/Home/index.test.jsx b/src/pages/MyMove/Home/index.test.jsx index f46d7a221b6..10faf81d6b1 100644 --- a/src/pages/MyMove/Home/index.test.jsx +++ b/src/pages/MyMove/Home/index.test.jsx @@ -527,7 +527,7 @@ describe('Home component', () => { const mtoShipments = [submittedPPMShipment]; const wrapper = mountHomeWithProviders({ ...propUpdates, mtoShipments }); - + const props = { ...defaultProps, ...propUpdates, mtoShipments }; it('renders the SubmittedMove helper', () => { @@ -565,29 +565,29 @@ describe('Home component', () => { it('renders advance request submitted for PPM', () => { const mtoShipments = [approvedAdvancePPMShipment]; - const props = { ...defaultProps, ...propUpdates, mtoShipments }; + const props = { ...defaultProps, ...propUpdates, mtoShipments }; render(); 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 wrapper = mountHomeWithProviders({ ...propUpdates, mtoShipments }); const advanceStep = wrapper.find('Step[step="5"]'); expect(advanceStep.prop('completedHeaderText')).toEqual('Advance request reviewed'); - - const props = { ...defaultProps, ...propUpdates, mtoShipments }; + + const props = { ...defaultProps, ...propUpdates, mtoShipments }; render(); 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 wrapper = mountHomeWithProviders({ ...propUpdates, mtoShipments }); const advanceStep = wrapper.find('Step[step="5"]'); expect(advanceStep.prop('completedHeaderText')).toEqual('Advance request reviewed'); - - const props = { ...defaultProps, ...propUpdates, mtoShipments }; + + const props = { ...defaultProps, ...propUpdates, mtoShipments }; render(); expect(screen.getByText('Download AOA Paperwork (PDF)')).toBeInTheDocument(); }); @@ -599,7 +599,7 @@ describe('Home component', () => { expect(advanceStep.prop('completedHeaderText')).toEqual('Advance request reviewed'); - const props = { ...defaultProps, ...propUpdates, mtoShipments }; + const props = { ...defaultProps, ...propUpdates, mtoShipments }; render(); expect(screen.getByText('Download AOA Paperwork (PDF)')).toBeInTheDocument(); expect(screen.getByText('Advance request denied')).toBeInTheDocument(); From 83401e9d526c6ed0e80df82a0b3770e85408d4b4 Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Wed, 31 Jan 2024 00:59:40 +0000 Subject: [PATCH 07/14] updated playwright test for 6 steps --- .../tests/my/milmove/ppms/customerPpmTestFixture.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/playwright/tests/my/milmove/ppms/customerPpmTestFixture.js b/playwright/tests/my/milmove/ppms/customerPpmTestFixture.js index 35f5d59400c..9763b57cf1f 100644 --- a/playwright/tests/my/milmove/ppms/customerPpmTestFixture.js +++ b/playwright/tests/my/milmove/ppms/customerPpmTestFixture.js @@ -5,6 +5,7 @@ */ // @ts-check +import { isNil } from 'lodash'; import { expect, test as customerTest, @@ -908,7 +909,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"]'); + const stepContainer = this.page.locator('[data-testid="stepContainer6"]'); + + if (stepContainer == null) { + 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(); } From ceace22bae9a1cd56a143814c1973af5d70bc593 Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Wed, 31 Jan 2024 01:00:01 +0000 Subject: [PATCH 08/14] added Pending label --- src/pages/MyMove/Home/index.jsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/MyMove/Home/index.jsx b/src/pages/MyMove/Home/index.jsx index 09cfff0e623..4c6bc90bce9 100644 --- a/src/pages/MyMove/Home/index.jsx +++ b/src/pages/MyMove/Home/index.jsx @@ -603,6 +603,7 @@ export class Home extends Component { {shipment?.ppmShipment?.advanceStatus === 'REJECTED' && ( Advance request denied )} + {shipment?.ppmShipment?.advanceStatus == null && Pending} ); })} From 597391f6542dce82757c749315d0c3fd0ad66101 Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Wed, 31 Jan 2024 01:00:22 +0000 Subject: [PATCH 09/14] unused import --- playwright/tests/my/milmove/ppms/customerPpmTestFixture.js | 1 - 1 file changed, 1 deletion(-) diff --git a/playwright/tests/my/milmove/ppms/customerPpmTestFixture.js b/playwright/tests/my/milmove/ppms/customerPpmTestFixture.js index 9763b57cf1f..80cdce0cf26 100644 --- a/playwright/tests/my/milmove/ppms/customerPpmTestFixture.js +++ b/playwright/tests/my/milmove/ppms/customerPpmTestFixture.js @@ -5,7 +5,6 @@ */ // @ts-check -import { isNil } from 'lodash'; import { expect, test as customerTest, From 122ca0278f591d904107671c5a42b9d11232590c Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Wed, 31 Jan 2024 17:32:23 +0000 Subject: [PATCH 10/14] changed Pending to Advance request pending --- src/pages/MyMove/Home/index.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/MyMove/Home/index.jsx b/src/pages/MyMove/Home/index.jsx index 4c6bc90bce9..c524ee1a930 100644 --- a/src/pages/MyMove/Home/index.jsx +++ b/src/pages/MyMove/Home/index.jsx @@ -603,7 +603,7 @@ export class Home extends Component { {shipment?.ppmShipment?.advanceStatus === 'REJECTED' && ( Advance request denied )} - {shipment?.ppmShipment?.advanceStatus == null && Pending} + {shipment?.ppmShipment?.advanceStatus == null && Advance request pending} ); })} From a0e9c4c35b940f9eb067fd043dea9645e129765c Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Wed, 31 Jan 2024 17:56:38 +0000 Subject: [PATCH 11/14] fixed formatting error --- src/pages/MyMove/Home/index.jsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pages/MyMove/Home/index.jsx b/src/pages/MyMove/Home/index.jsx index c524ee1a930..8ca71328708 100644 --- a/src/pages/MyMove/Home/index.jsx +++ b/src/pages/MyMove/Home/index.jsx @@ -603,7 +603,9 @@ export class Home extends Component { {shipment?.ppmShipment?.advanceStatus === 'REJECTED' && ( Advance request denied )} - {shipment?.ppmShipment?.advanceStatus == null && Advance request pending} + {shipment?.ppmShipment?.advanceStatus == null && ( + Advance request pending + )} ); })} From a6194988524571799a529c47c994c1991057954b Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Fri, 2 Feb 2024 17:43:41 +0000 Subject: [PATCH 12/14] use ADVANCE_STATUSES enum --- src/pages/MyMove/Home/index.jsx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/pages/MyMove/Home/index.jsx b/src/pages/MyMove/Home/index.jsx index 8ca71328708..f89ab76078a 100644 --- a/src/pages/MyMove/Home/index.jsx +++ b/src/pages/MyMove/Home/index.jsx @@ -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 }) => (

@@ -144,14 +145,18 @@ export class Home extends Component { 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 === 'APPROVED'); + 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 === 'REJECTED'); + const rejectedAdvances = mtoShipments.filter( + (shipment) => shipment?.ppmShipment?.advanceStatus === ADVANCE_STATUSES.REJECTED.apiValue, + ); return !this.hasAdvanceApproved && rejectedAdvances.length > 0; } @@ -592,7 +597,7 @@ export class Home extends Component { {shipmentTypes[shipment.shipmentType]} {` ${shipmentNumber} `} - {shipment?.ppmShipment?.advanceStatus === 'APPROVED' && ( + {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

@@ -600,7 +605,7 @@ export class Home extends Component {

)} - {shipment?.ppmShipment?.advanceStatus === 'REJECTED' && ( + {shipment?.ppmShipment?.advanceStatus === ADVANCE_STATUSES.REJECTED.apiValue && ( Advance request denied )} {shipment?.ppmShipment?.advanceStatus == null && ( From df30c652d10566e72575d68a32ac3d04ef175982 Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Tue, 13 Feb 2024 20:18:49 +0000 Subject: [PATCH 13/14] fixed playwright tests with upload PPM tests --- .../my/milmove/ppms/customerPpmTestFixture.js | 4 ++-- .../ppms/entireShipmentOnboarding.spec.js | 17 +++++++++++------ .../milmove/ppms/navigateToUploadDocs.spec.js | 11 ++++++++--- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/playwright/tests/my/milmove/ppms/customerPpmTestFixture.js b/playwright/tests/my/milmove/ppms/customerPpmTestFixture.js index 80cdce0cf26..1ab2ec588e3 100644 --- a/playwright/tests/my/milmove/ppms/customerPpmTestFixture.js +++ b/playwright/tests/my/milmove/ppms/customerPpmTestFixture.js @@ -908,10 +908,10 @@ 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="stepContainer6"]'); + var stepContainer = this.page.locator('[data-testid="stepContainer6"]'); if (stepContainer == null) { - this.page.locator('[data-testid="stepContainer5"]'); + stepContainer = this.page.locator('[data-testid="stepContainer5"]'); } await expect(stepContainer.getByRole('button', { name: 'Download Incentive Packet' })).toBeDisabled(); diff --git a/playwright/tests/my/milmove/ppms/entireShipmentOnboarding.spec.js b/playwright/tests/my/milmove/ppms/entireShipmentOnboarding.spec.js index d330106d3c7..ea57a703ae2 100644 --- a/playwright/tests/my/milmove/ppms/entireShipmentOnboarding.spec.js +++ b/playwright/tests/my/milmove/ppms/entireShipmentOnboarding.spec.js @@ -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(); } @@ -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 () => { @@ -138,7 +143,7 @@ test.describe('Entire PPM onboarding flow', () => { await customerPpmOnboardingPage.navigateToAgreementAndSign(); await customerPpmOnboardingPage.submitMove(); - await customerPpmOnboardingPage.verifyStep5ExistsAndBtnIsDisabled(); + await customerPpmOnboardingPage.verifyManagePPMStepExistsAndBtnIsDisabled(); }); }); }); diff --git a/playwright/tests/my/milmove/ppms/navigateToUploadDocs.spec.js b/playwright/tests/my/milmove/ppms/navigateToUploadDocs.spec.js index bc12f20a022..d46a68a0db9 100644 --- a/playwright/tests/my/milmove/ppms/navigateToUploadDocs.spec.js +++ b/playwright/tests/my/milmove/ppms/navigateToUploadDocs.spec.js @@ -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(); + var 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/); }); }); From b757cb3d7f7b95b1b41042c7351c45115081c859 Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Wed, 14 Feb 2024 22:23:31 +0000 Subject: [PATCH 14/14] change var to let --- playwright/tests/my/milmove/ppms/customerPpmTestFixture.js | 2 +- playwright/tests/my/milmove/ppms/navigateToUploadDocs.spec.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/playwright/tests/my/milmove/ppms/customerPpmTestFixture.js b/playwright/tests/my/milmove/ppms/customerPpmTestFixture.js index 1ab2ec588e3..392ea75d374 100644 --- a/playwright/tests/my/milmove/ppms/customerPpmTestFixture.js +++ b/playwright/tests/my/milmove/ppms/customerPpmTestFixture.js @@ -908,7 +908,7 @@ export class CustomerPpmPage extends CustomerPage { await expect(this.page.locator('.usa-alert--success')).toContainText('You submitted documentation for review.'); - var stepContainer = this.page.locator('[data-testid="stepContainer6"]'); + let stepContainer = this.page.locator('[data-testid="stepContainer6"]'); if (stepContainer == null) { stepContainer = this.page.locator('[data-testid="stepContainer5"]'); diff --git a/playwright/tests/my/milmove/ppms/navigateToUploadDocs.spec.js b/playwright/tests/my/milmove/ppms/navigateToUploadDocs.spec.js index d46a68a0db9..a40b8dfe36d 100644 --- a/playwright/tests/my/milmove/ppms/navigateToUploadDocs.spec.js +++ b/playwright/tests/my/milmove/ppms/navigateToUploadDocs.spec.js @@ -16,7 +16,7 @@ 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(); - var stepContainer = page.getByTestId('stepContainer6'); + let stepContainer = page.getByTestId('stepContainer6'); if (stepContainer == null) { stepContainer = page.getByTestId('stepContainer5');