From 986eb07fed69e5d65836eaee630c0af59611e26c Mon Sep 17 00:00:00 2001 From: Elizabeth Perkins Date: Mon, 28 Oct 2024 14:56:48 +0000 Subject: [PATCH 01/71] Begins adding ppm counsel routing --- pkg/handlers/internalapi/moves_test.go | 2 +- pkg/services/move/move_router.go | 4 +++ pkg/services/move/move_router_test.go | 16 ++++++------ .../RequestedShipments.test.jsx | 25 ++++++++----------- .../SubmittedRequestedShipments.jsx | 5 ++-- 5 files changed, 27 insertions(+), 25 deletions(-) diff --git a/pkg/handlers/internalapi/moves_test.go b/pkg/handlers/internalapi/moves_test.go index 9cbc2e8ef89..cafed375816 100644 --- a/pkg/handlers/internalapi/moves_test.go +++ b/pkg/handlers/internalapi/moves_test.go @@ -291,7 +291,7 @@ func (suite *HandlerSuite) TestSubmitMoveForApprovalHandler() { suite.NoError(err) // And: Returned query to have a submitted status - suite.Assertions.Equal(internalmessages.MoveStatusSUBMITTED, okResponse.Payload.Status) + suite.Assertions.Equal(internalmessages.MoveStatusNEEDSSERVICECOUNSELING, okResponse.Payload.Status) suite.Assertions.NotNil(okResponse.Payload.SubmittedAt) // And: SignedCertification was created diff --git a/pkg/services/move/move_router.go b/pkg/services/move/move_router.go index c510023e5a7..174e9dfc8f3 100644 --- a/pkg/services/move/move_router.go +++ b/pkg/services/move/move_router.go @@ -163,6 +163,10 @@ func (router moveRouter) needsServiceCounseling(appCtx appcontext.AppContext, mo return false, nil } + if move.IsPPMOnly() { + return true, nil + } + return originDutyLocation.ProvidesServicesCounseling, nil } diff --git a/pkg/services/move/move_router_test.go b/pkg/services/move/move_router_test.go index cd6b9f6623e..d2536cd8082 100644 --- a/pkg/services/move/move_router_test.go +++ b/pkg/services/move/move_router_test.go @@ -296,15 +296,15 @@ func (suite *MoveServiceSuite) TestMoveSubmission() { }, }, nil) - ppmShipment := factory.BuildPPMShipment(suite.DB(), []factory.Customization{ - { - Model: models.PPMShipment{ - Status: models.PPMShipmentStatusDraft, - }, - }, - }, nil) + // ppmShipment := factory.BuildPPMShipment(suite.DB(), []factory.Customization{ + // { + // Model: models.PPMShipment{ + // Status: models.PPMShipmentStatusDraft, + // }, + // }, + // }, nil) move.MTOShipments = models.MTOShipments{shipment} - move.MTOShipments[0].PPMShipment = &ppmShipment + // move.MTOShipments[0].PPMShipment = &ppmShipment newSignedCertification := factory.BuildSignedCertification(nil, []factory.Customization{ { diff --git a/src/components/Office/RequestedShipments/RequestedShipments.test.jsx b/src/components/Office/RequestedShipments/RequestedShipments.test.jsx index 2dd12b87ee9..7872ce01a59 100644 --- a/src/components/Office/RequestedShipments/RequestedShipments.test.jsx +++ b/src/components/Office/RequestedShipments/RequestedShipments.test.jsx @@ -488,6 +488,17 @@ describe('RequestedShipments', () => { expect(screen.getByText('Approve selected')).toBeInTheDocument(); }); + it('does not render the "Add service items to move" section when all shipments are PPM', () => { + const testProps = { + mtoShipments: ppmOnlyShipments, + ...conditionalFormTestProps, + }; + renderComponent(testProps); + + expect(screen.queryByText('Add service items to this move')).not.toBeInTheDocument(); + expect(screen.getByText('Approve selected')).toBeInTheDocument(); + }); + it('renders the "Add service items to move" section with only counseling when only move management is present in service items', () => { const testProps = { mtoServiceItems: serviceItemsMS, @@ -529,19 +540,5 @@ describe('RequestedShipments', () => { expect(screen.getByTestId('shipmentManagementFee')).toBeInTheDocument(); expect(screen.getByTestId('counselingFee')).toBeInTheDocument(); }); - - it('renders the "Add service items to move" section with only counseling when all shipments are PPM', () => { - const testProps = { - mtoServiceItems: serviceItemsEmpty, - mtoShipments: ppmOnlyShipments, - ...conditionalFormTestProps, - }; - renderComponent(testProps); - - expect(screen.getByText('Add service items to this move')).toBeInTheDocument(); - expect(screen.getByText('Approve selected')).toBeInTheDocument(); - expect(screen.queryByTestId('shipmentManagementFee')).not.toBeInTheDocument(); - expect(screen.getByTestId('counselingFee')).toBeInTheDocument(); - }); }); }); diff --git a/src/components/Office/RequestedShipments/SubmittedRequestedShipments.jsx b/src/components/Office/RequestedShipments/SubmittedRequestedShipments.jsx index bf847cb57cb..4b38c704787 100644 --- a/src/components/Office/RequestedShipments/SubmittedRequestedShipments.jsx +++ b/src/components/Office/RequestedShipments/SubmittedRequestedShipments.jsx @@ -163,8 +163,9 @@ const SubmittedRequestedShipments = ({ const dutyLocationPostal = { postalCode: ordersInfo.newDutyLocation?.address?.postalCode }; - // Hide counseling line item if prime counseling is already in the service items or if service counseling has been applied - const hideCounselingCheckbox = hasCounseling(mtoServiceItems) || moveTaskOrder?.serviceCounselingCompletedAt; + // Hide counseling line item if prime counseling is already in the service items, if service counseling has been applied, or if full PPM move + const hideCounselingCheckbox = + hasCounseling(mtoServiceItems) || moveTaskOrder?.serviceCounselingCompletedAt || isPPMOnly(mtoShipments); // Hide move management line item if it is already in the service items or for PPM only moves const hideMoveManagementCheckbox = hasMoveManagement(mtoServiceItems) || isPPMOnly(mtoShipments); From ddc6e3b3d480bebc07212204463f06689848d94b Mon Sep 17 00:00:00 2001 From: Elizabeth Perkins Date: Wed, 30 Oct 2024 18:56:56 +0000 Subject: [PATCH 02/71] Fixes shipment test --- pkg/services/move/move_router_test.go | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/pkg/services/move/move_router_test.go b/pkg/services/move/move_router_test.go index d2536cd8082..ec55d468eee 100644 --- a/pkg/services/move/move_router_test.go +++ b/pkg/services/move/move_router_test.go @@ -287,7 +287,7 @@ func (suite *MoveServiceSuite) TestMoveSubmission() { { Model: models.MTOShipment{ Status: models.MTOShipmentStatusDraft, - ShipmentType: models.MTOShipmentTypePPM, + ShipmentType: models.MTOShipmentTypeHHG, }, }, { @@ -296,15 +296,7 @@ func (suite *MoveServiceSuite) TestMoveSubmission() { }, }, nil) - // ppmShipment := factory.BuildPPMShipment(suite.DB(), []factory.Customization{ - // { - // Model: models.PPMShipment{ - // Status: models.PPMShipmentStatusDraft, - // }, - // }, - // }, nil) move.MTOShipments = models.MTOShipments{shipment} - // move.MTOShipments[0].PPMShipment = &ppmShipment newSignedCertification := factory.BuildSignedCertification(nil, []factory.Customization{ { @@ -393,7 +385,7 @@ func (suite *MoveServiceSuite) TestMoveSubmission() { err := moveRouter.Submit(suite.AppContextForTest(), &move, &newSignedCertification) suite.NoError(err) - suite.Equal(models.MoveStatusSUBMITTED, move.Status, "expected Submitted") + suite.Equal(models.MoveStatusNeedsServiceCounseling, move.Status, "expected Needs Service Counseling") suite.Equal(models.MTOShipmentStatusSubmitted, move.MTOShipments[0].Status, "expected Submitted") suite.Equal(models.PPMShipmentStatusSubmitted, move.MTOShipments[0].PPMShipment.Status, "expected Submitted") }) From 33dc7c1165f422307d0f2ac707ac363393c71e30 Mon Sep 17 00:00:00 2001 From: Elizabeth Perkins Date: Thu, 31 Oct 2024 14:20:12 +0000 Subject: [PATCH 03/71] Adds ppm test --- pkg/services/move/move_router_test.go | 70 +++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/pkg/services/move/move_router_test.go b/pkg/services/move/move_router_test.go index ec55d468eee..99cdf20590e 100644 --- a/pkg/services/move/move_router_test.go +++ b/pkg/services/move/move_router_test.go @@ -317,6 +317,76 @@ func (suite *MoveServiceSuite) TestMoveSubmission() { } }) + suite.Run("PPM moves are routed correctly and SignedCertification is created", func() { + // Under test: MoveRouter.Submit (Full PPM should always route to service counselor, never to office user) + // Set up: Create moves and SignedCertification + // Expected outcome: signed cert is created and move status is updated + tests := []struct { + desc string + ProvidesServicesCounseling bool + moveStatus models.MoveStatus + }{ + {"Routes to Service Counseling", true, models.MoveStatusNeedsServiceCounseling}, + {"Routes to Service Counseling", false, models.MoveStatusNeedsServiceCounseling}, + } + for _, tt := range tests { + suite.Run(tt.desc, func() { + move := factory.BuildMove(suite.DB(), []factory.Customization{ + { + Model: models.DutyLocation{ + ProvidesServicesCounseling: tt.ProvidesServicesCounseling, + }, + Type: &factory.DutyLocations.OriginDutyLocation, + }, + { + Model: models.Move{ + Status: models.MoveStatusDRAFT, + }, + }, + }, nil) + + shipment := factory.BuildMTOShipmentMinimal(suite.DB(), []factory.Customization{ + { + Model: models.MTOShipment{ + Status: models.MTOShipmentStatusDraft, + ShipmentType: models.MTOShipmentTypePPM, + }, + }, + { + Model: move, + LinkOnly: true, + }, + }, nil) + + ppmShipment := factory.BuildPPMShipment(suite.DB(), []factory.Customization{ + { + Model: models.PPMShipment{ + Status: models.PPMShipmentStatusDraft, + }, + }, + }, nil) + move.MTOShipments = models.MTOShipments{shipment} + move.MTOShipments[0].PPMShipment = &ppmShipment + + newSignedCertification := factory.BuildSignedCertification(nil, []factory.Customization{ + { + Model: move, + LinkOnly: true, + }, + }, nil) + err := moveRouter.Submit(suite.AppContextForTest(), &move, &newSignedCertification) + suite.NoError(err) + err = suite.DB().Where("move_id = $1", move.ID).First(&newSignedCertification) + suite.NoError(err) + suite.NotNil(newSignedCertification) + + err = suite.DB().Find(&move, move.ID) + suite.NoError(err) + suite.Equal(tt.moveStatus, move.Status) + }) + } + }) + suite.Run("Returns error if signedCertificate is missing", func() { // Under test: MoveRouter.Submit (both routing to services counselor and office user) // Set up: Create moves and SignedCertification From aceb0a8d1575f861e708b519f5d9c2f42336f28f Mon Sep 17 00:00:00 2001 From: Elizabeth Perkins Date: Fri, 1 Nov 2024 17:44:01 +0000 Subject: [PATCH 04/71] Adds better test description --- pkg/services/move/move_router_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/services/move/move_router_test.go b/pkg/services/move/move_router_test.go index 99cdf20590e..e36ec1330df 100644 --- a/pkg/services/move/move_router_test.go +++ b/pkg/services/move/move_router_test.go @@ -320,7 +320,8 @@ func (suite *MoveServiceSuite) TestMoveSubmission() { suite.Run("PPM moves are routed correctly and SignedCertification is created", func() { // Under test: MoveRouter.Submit (Full PPM should always route to service counselor, never to office user) // Set up: Create moves and SignedCertification - // Expected outcome: signed cert is created and move status is updated + // Expected outcome: signed cert is created + // Expected outcome: Move status is set to needs service counseling for both true and false on origin providing service counseling tests := []struct { desc string ProvidesServicesCounseling bool From 162da2f89224d8da7f897982aab00b3a291f383d Mon Sep 17 00:00:00 2001 From: Elizabeth Perkins Date: Fri, 1 Nov 2024 19:47:01 +0000 Subject: [PATCH 05/71] Fixes client tests for service items section not displaying --- .../Office/RequestedShipments/RequestedShipments.test.jsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/Office/RequestedShipments/RequestedShipments.test.jsx b/src/components/Office/RequestedShipments/RequestedShipments.test.jsx index 4b6230ec3d4..d3451918c1e 100644 --- a/src/components/Office/RequestedShipments/RequestedShipments.test.jsx +++ b/src/components/Office/RequestedShipments/RequestedShipments.test.jsx @@ -628,7 +628,7 @@ describe('RequestedShipments', () => { expect(screen.getByTestId('counselingFee')).toBeInTheDocument(); }); - it('renders the "Add service items to move" section with only counseling when all shipments are PPM', () => { + it('does not render the "Add service items to move" section or Counseling option when all shipments are PPM', () => { const testPropsServiceItemsEmpty = { mtoServiceItems: serviceItemsEmpty, mtoShipments: ppmOnlyShipments, @@ -636,10 +636,10 @@ describe('RequestedShipments', () => { }; renderComponent(testPropsServiceItemsEmpty); - expect(screen.getByText('Add service items to this move')).toBeInTheDocument(); + expect(screen.queryByText('Add service items to this move')).not.toBeInTheDocument(); expect(screen.getByText('Approve selected')).toBeInTheDocument(); expect(screen.queryByTestId('shipmentManagementFee')).not.toBeInTheDocument(); - expect(screen.getByTestId('counselingFee')).toBeInTheDocument(); + expect(screen.queryByTestId('counselingFee')).not.toBeInTheDocument(); }); }); }); From d1d9ecc44523309edf1c5a857d8a1fffa2dd47d4 Mon Sep 17 00:00:00 2001 From: Elizabeth Perkins Date: Fri, 8 Nov 2024 16:06:54 +0000 Subject: [PATCH 06/71] Adds test class --- .../SubmittedRequestedShipments.test.jsx | 190 ++++++++++++++++++ 1 file changed, 190 insertions(+) create mode 100644 src/components/Office/RequestedShipments/SubmittedRequestedShipments.test.jsx diff --git a/src/components/Office/RequestedShipments/SubmittedRequestedShipments.test.jsx b/src/components/Office/RequestedShipments/SubmittedRequestedShipments.test.jsx new file mode 100644 index 00000000000..60907948176 --- /dev/null +++ b/src/components/Office/RequestedShipments/SubmittedRequestedShipments.test.jsx @@ -0,0 +1,190 @@ +import React from 'react'; +import { render, screen, within } from '@testing-library/react'; + +import { + shipments, + ordersInfo, + allowancesInfo, + customerInfo, + serviceItemsEmpty, + ppmOnlyShipments, + closeoutOffice, +} from './RequestedShipmentsTestData'; +import SubmittedRequestedShipments from './SubmittedRequestedShipments'; + +import { MockProviders } from 'testUtils'; +import { permissionTypes } from 'constants/permissions'; + +const mockNavigate = jest.fn(); +jest.mock('react-router-dom', () => ({ + ...jest.requireActual('react-router-dom'), + useNavigate: () => mockNavigate, +})); + +const moveTaskOrderAvailableToPrimeAt = { + eTag: 'MjAyMC0wNi0yNlQyMDoyMjo0MS43Mjc4NTNa', + id: '6e8c5ca4-774c-4170-934a-59d22259e480', + availableToPrimeAt: '2020-06-10T15:58:02.431995Z', +}; + +const moveTaskOrderServicesCounselingCompleted = { + eTag: 'MjAyMC0wNi0yNlQyMDoyMjo0MS43Mjc4NTNa', + id: '6e8c5ca4-774c-4170-934a-59d22259e480', + serviceCounselingCompletedAt: '2020-10-02T19:20:08.481139Z', +}; + +const approveMTO = jest.fn().mockResolvedValue({ response: { status: 200 } }); + +const submittedRequestedShipmentsComponent = ( + +); + +const submittedRequestedShipmentsComponentWithPermission = ( + + + +); + +const submittedRequestedShipmentsComponentAvailableToPrimeAt = ( + + + +); + +const submittedRequestedShipmentsComponentServicesCounselingCompleted = ( + +); + +const submittedRequestedShipmentsCanCreateNewShipment = ( + + + +); + +describe('RequestedShipments', () => { + describe('Prime-handled shipments', () => { + it('renders the container successfully without services counseling completed', () => { + render(submittedRequestedShipmentsComponent); + expect(screen.getByTestId('requested-shipments')).toBeInTheDocument(); + expect(screen.queryByTestId('services-counseling-completed-text')).not.toBeInTheDocument(); + }); + + it('renders the container successfully with services counseling completed', () => { + render(submittedRequestedShipmentsComponentServicesCounselingCompleted); + expect(screen.getByTestId('requested-shipments')).toBeInTheDocument(); + expect(screen.queryByTestId('services-counseling-completed-text')).not.toBeInTheDocument(); + }); + + it('renders a shipment passed to it', () => { + render(submittedRequestedShipmentsComponent); + const withinContainer = within(screen.getByTestId('requested-shipments')); + expect(withinContainer.getAllByText('HHG').length).toEqual(2); + expect(withinContainer.getAllByText('NTS').length).toEqual(1); + }); + + it('renders the button', () => { + render(submittedRequestedShipmentsComponentWithPermission); + expect( + screen.getByRole('button', { + name: 'Approve selected', + }), + ).toBeInTheDocument(); + expect( + screen.getByRole('button', { + name: 'Approve selected', + }), + ).toBeDisabled(); + }); + + it('renders the button when it is available to the prime', () => { + render(submittedRequestedShipmentsComponentAvailableToPrimeAt); + expect(screen.getByTestId('shipmentApproveButton')).toBeInTheDocument(); + expect(screen.getByTestId('shipmentApproveButton')).toBeDisabled(); + }); + + it('renders the checkboxes', () => { + render(submittedRequestedShipmentsComponentWithPermission); + expect(screen.getAllByTestId('checkbox').length).toEqual(5); + }); + + it('renders Add a new shipment Button', async () => { + render(submittedRequestedShipmentsCanCreateNewShipment); + + expect(await screen.getByRole('combobox', { name: 'Add a new shipment' })).toBeInTheDocument(); + }); + }); + + describe('Conditional form display', () => { + const renderComponent = (props) => { + render( + + + , + ); + }; + const conditionalFormTestProps = { + ordersInfo, + allowancesInfo, + customerInfo, + approveMTO, + moveCode: 'TE5TC0DE', + }; + + it('does not render the "Add service items to move" section or Counseling option when all shipments are PPM', () => { + const testPropsServiceItemsEmpty = { + mtoServiceItems: serviceItemsEmpty, + mtoShipments: ppmOnlyShipments, + ...conditionalFormTestProps, + }; + renderComponent(testPropsServiceItemsEmpty); + + expect(screen.queryByText('Add service items to this move')).not.toBeInTheDocument(); + expect(screen.getByText('Approve selected')).toBeInTheDocument(); + expect(screen.queryByTestId('shipmentManagementFee')).not.toBeInTheDocument(); + expect(screen.queryByTestId('counselingFee')).not.toBeInTheDocument(); + }); + }); +}); From ff73a08f6ecba2166afbfc1f3f886374a8002be4 Mon Sep 17 00:00:00 2001 From: Elizabeth Perkins Date: Tue, 12 Nov 2024 15:38:33 +0000 Subject: [PATCH 07/71] Fixes test --- .../SubmittedRequestedShipments.test.jsx | 44 ++++++++++--------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/src/components/Office/RequestedShipments/SubmittedRequestedShipments.test.jsx b/src/components/Office/RequestedShipments/SubmittedRequestedShipments.test.jsx index 60907948176..1388bdf84e4 100644 --- a/src/components/Office/RequestedShipments/SubmittedRequestedShipments.test.jsx +++ b/src/components/Office/RequestedShipments/SubmittedRequestedShipments.test.jsx @@ -36,15 +36,17 @@ const moveTaskOrderServicesCounselingCompleted = { const approveMTO = jest.fn().mockResolvedValue({ response: { status: 200 } }); const submittedRequestedShipmentsComponent = ( - + + + ); const submittedRequestedShipmentsComponentWithPermission = ( @@ -77,16 +79,18 @@ const submittedRequestedShipmentsComponentAvailableToPrimeAt = ( ); const submittedRequestedShipmentsComponentServicesCounselingCompleted = ( - + + + ); const submittedRequestedShipmentsCanCreateNewShipment = ( @@ -115,7 +119,7 @@ describe('RequestedShipments', () => { it('renders the container successfully with services counseling completed', () => { render(submittedRequestedShipmentsComponentServicesCounselingCompleted); expect(screen.getByTestId('requested-shipments')).toBeInTheDocument(); - expect(screen.queryByTestId('services-counseling-completed-text')).not.toBeInTheDocument(); + expect(screen.queryByTestId('services-counseling-completed-text')).toBeInTheDocument(); }); it('renders a shipment passed to it', () => { From 7e9693ae4d85bad5d465256c34b7e452d3379045 Mon Sep 17 00:00:00 2001 From: Elizabeth Perkins Date: Mon, 16 Dec 2024 15:04:03 +0000 Subject: [PATCH 08/71] Disables counseling checkbox --- pkg/services/move/move_router.go | 10 ++++++++++ .../RequestedShipments/SubmittedRequestedShipments.jsx | 10 ++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/pkg/services/move/move_router.go b/pkg/services/move/move_router.go index c44f3756de0..d06994bed41 100644 --- a/pkg/services/move/move_router.go +++ b/pkg/services/move/move_router.go @@ -188,6 +188,16 @@ func (router moveRouter) sendToServiceCounselor(appCtx appcontext.AppContext, mo } } + // if move.IsPPMOnly() && !orders.OriginDutyLocation.ProvidesServicesCounseling { + // originLocationID := uuid.FromStringOrNil(orders.OriginDutyLocationID.String()) + + // officeList, err := ShowCounselingOfficesHandler.TransportationOfficesFetcher.GetCounselingOffices(appCtx, originLocationID) + // if err != nil { + + // } + + // } + if move.Status == models.MoveStatusNeedsServiceCounseling { return nil } diff --git a/src/components/Office/RequestedShipments/SubmittedRequestedShipments.jsx b/src/components/Office/RequestedShipments/SubmittedRequestedShipments.jsx index 7359b232780..5b50fe94a87 100644 --- a/src/components/Office/RequestedShipments/SubmittedRequestedShipments.jsx +++ b/src/components/Office/RequestedShipments/SubmittedRequestedShipments.jsx @@ -255,9 +255,11 @@ const SubmittedRequestedShipments = ({ const dutyLocationPostal = { postalCode: ordersInfo.newDutyLocation?.address?.postalCode }; - // Hide counseling line item if prime counseling is already in the service items, if service counseling has been applied, or if full PPM move - const hideCounselingCheckbox = - hasCounseling(mtoServiceItems) || moveTaskOrder?.serviceCounselingCompletedAt || isPPMOnly(mtoShipments); + // Hide counseling line item if prime counseling is already in the service items or if service counseling has been applied + const hideCounselingCheckbox = hasCounseling(mtoServiceItems) || moveTaskOrder?.serviceCounselingCompletedAt; + + // Disable counseling checkbox if full PPM shipment + const disableCounselingCheckbox = isPPMOnly(mtoShipments); // Hide move management line item if it is already in the service items or for PPM only moves const hideMoveManagementCheckbox = hasMoveManagement(mtoServiceItems) || isPPMOnly(mtoShipments); @@ -373,7 +375,7 @@ const SubmittedRequestedShipments = ({ name="counselingFee" onChange={formik.handleChange} data-testid="counselingFee" - disabled={isMoveLocked} + disabled={isMoveLocked || disableCounselingCheckbox} /> )} From 945cf219f57fd944733878ab03822b4d86fa3411 Mon Sep 17 00:00:00 2001 From: Elizabeth Perkins Date: Tue, 24 Dec 2024 16:46:03 +0000 Subject: [PATCH 09/71] Changes moveRouter struct to add transportationOfficesFetcher --- pkg/handlers/adminapi/api.go | 2 +- pkg/handlers/adminapi/moves_test.go | 3 +- pkg/handlers/ghcapi/api.go | 2 +- pkg/handlers/ghcapi/move_task_order_test.go | 9 +-- pkg/handlers/ghcapi/mto_service_items_test.go | 9 +-- pkg/handlers/ghcapi/mto_shipment_test.go | 51 ++++++++-------- pkg/handlers/ghcapi/orders_test.go | 19 +++--- pkg/handlers/internalapi/api.go | 2 +- pkg/handlers/internalapi/moves_test.go | 8 +-- pkg/handlers/internalapi/mto_shipment_test.go | 3 +- pkg/handlers/internalapi/office_test.go | 13 ++-- pkg/handlers/internalapi/orders_test.go | 3 +- .../internalapi/service_members_test.go | 3 +- pkg/handlers/primeapi/api.go | 3 +- pkg/handlers/primeapi/move_task_order_test.go | 5 +- .../primeapi/mto_service_item_test.go | 39 ++++++------ pkg/handlers/primeapi/mto_shipment_test.go | 5 +- pkg/handlers/primeapi/sit_extension_test.go | 3 +- pkg/handlers/primeapiv2/api.go | 3 +- .../primeapiv2/mto_service_item_test.go | 35 +++++------ pkg/handlers/primeapiv2/mto_shipment_test.go | 3 +- pkg/handlers/primeapiv3/api.go | 3 +- .../primeapiv3/mto_service_item_test.go | 35 +++++------ pkg/handlers/primeapiv3/mto_shipment_test.go | 3 +- pkg/handlers/supportapi/api.go | 3 +- .../supportapi/move_task_order_test.go | 5 +- .../supportapi/mto_service_item_test.go | 7 ++- pkg/handlers/supportapi/mto_shipment_test.go | 3 +- .../mocks/TransportationOfficesFetcher.go | 6 ++ pkg/services/move/move_router.go | 26 ++++---- pkg/services/move/move_router_test.go | 13 ++-- .../move_history/move_history_fetcher_test.go | 7 ++- .../move_task_order_updater_test.go | 29 ++++----- .../mto_service_item_creator_test.go | 23 +++---- .../mto_service_item_updater_test.go | 5 +- .../mto_shipment/mto_shipment_creator_test.go | 5 +- .../mto_shipment/mto_shipment_updater_test.go | 15 ++--- .../mto_shipment/shipment_approver_test.go | 3 +- .../shipment_cancellation_requester_test.go | 7 ++- .../mto_shipment/shipment_deleter_test.go | 15 ++--- .../shipment_diversion_approver_test.go | 3 +- .../order/excess_weight_risk_manager_test.go | 43 ++++++------- pkg/services/order/order_updater_test.go | 61 ++++++++++--------- .../shipment_address_update_requester_test.go | 7 ++- .../sit_extension_approver_test.go | 3 +- .../sit_extension_creator_test.go | 3 +- .../sit_extension_denier_test.go | 3 +- pkg/services/transportation_office.go | 1 + .../transportation_office_fetcher.go | 12 ++++ pkg/testdatagen/scenario/devseed.go | 3 +- pkg/testdatagen/scenario/e2ebasic.go | 3 +- pkg/testdatagen/testharness/make_move.go | 11 ++-- 52 files changed, 327 insertions(+), 262 deletions(-) diff --git a/pkg/handlers/adminapi/api.go b/pkg/handlers/adminapi/api.go index 34d6729a0f2..39132e12843 100644 --- a/pkg/handlers/adminapi/api.go +++ b/pkg/handlers/adminapi/api.go @@ -209,7 +209,7 @@ func NewAdminAPI(handlerConfig handlers.HandlerConfig) *adminops.MymoveAPI { pagination.NewPagination, } - moveRouter := move.NewMoveRouter() + moveRouter := move.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) signedCertificationCreator := signedcertification.NewSignedCertificationCreator() signedCertificationUpdater := signedcertification.NewSignedCertificationUpdater() adminAPI.MovesUpdateMoveHandler = UpdateMoveHandler{ diff --git a/pkg/handlers/adminapi/moves_test.go b/pkg/handlers/adminapi/moves_test.go index 81e166a35e8..222c396d434 100644 --- a/pkg/handlers/adminapi/moves_test.go +++ b/pkg/handlers/adminapi/moves_test.go @@ -22,6 +22,7 @@ import ( mtoserviceitem "github.com/transcom/mymove/pkg/services/mto_service_item" "github.com/transcom/mymove/pkg/services/pagination" "github.com/transcom/mymove/pkg/services/query" + transportationoffice "github.com/transcom/mymove/pkg/services/transportation_office" ) func (suite *HandlerSuite) TestIndexMovesHandler() { @@ -111,7 +112,7 @@ func (suite *HandlerSuite) TestUpdateMoveHandler() { ppmEstimator := &mocks.PPMEstimator{} setupHandler := func() UpdateMoveHandler { builder := query.NewQueryBuilder() - moveRouter := move.NewMoveRouter() + moveRouter := move.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), diff --git a/pkg/handlers/ghcapi/api.go b/pkg/handlers/ghcapi/api.go index 5edc3f7e3ee..d8d4edc1d01 100644 --- a/pkg/handlers/ghcapi/api.go +++ b/pkg/handlers/ghcapi/api.go @@ -64,7 +64,7 @@ func NewGhcAPIHandler(handlerConfig handlers.HandlerConfig) *ghcops.MymoveAPI { } ghcAPI := ghcops.NewMymoveAPI(ghcSpec) queryBuilder := query.NewQueryBuilder() - moveRouter := move.NewMoveRouter() + moveRouter := move.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) moveLocker := movelocker.NewMoveLocker() addressCreator := address.NewAddressCreator() shipmentFetcher := mtoshipment.NewMTOShipmentFetcher() diff --git a/pkg/handlers/ghcapi/move_task_order_test.go b/pkg/handlers/ghcapi/move_task_order_test.go index 10e9630fc44..0ecbb0e9741 100644 --- a/pkg/handlers/ghcapi/move_task_order_test.go +++ b/pkg/handlers/ghcapi/move_task_order_test.go @@ -36,6 +36,7 @@ import ( movetaskorder "github.com/transcom/mymove/pkg/services/move_task_order" mtoserviceitem "github.com/transcom/mymove/pkg/services/mto_service_item" "github.com/transcom/mymove/pkg/services/query" + transportationoffice "github.com/transcom/mymove/pkg/services/transportation_office" "github.com/transcom/mymove/pkg/testdatagen" "github.com/transcom/mymove/pkg/trace" ) @@ -183,7 +184,7 @@ func (suite *HandlerSuite) TestUpdateMoveTaskOrderHandlerIntegrationSuccess() { handlerConfig := suite.HandlerConfig() handlerConfig.SetNotificationSender(notifications.NewStubNotificationSender("milmovelocal")) queryBuilder := query.NewQueryBuilder() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -306,7 +307,7 @@ func (suite *HandlerSuite) TestUpdateMoveTaskOrderHandlerIntegrationWithIncomple } handlerConfig := suite.HandlerConfig() queryBuilder := query.NewQueryBuilder() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) ppmEstimator := &mocks.PPMEstimator{} planner := &routemocks.Planner{} planner.On("ZipTransitDistance", @@ -395,7 +396,7 @@ func (suite *HandlerSuite) TestUpdateMTOStatusServiceCounselingCompletedHandler( setupTestData := func() UpdateMTOStatusServiceCounselingCompletedHandlerFunc { handlerConfig := suite.HandlerConfig() queryBuilder := query.NewQueryBuilder() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -614,7 +615,7 @@ func (suite *HandlerSuite) TestUpdateMoveTIORemarksHandler() { requestUser := factory.BuildUser(nil, nil, nil) handlerConfig := suite.HandlerConfig() queryBuilder := query.NewQueryBuilder() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), diff --git a/pkg/handlers/ghcapi/mto_service_items_test.go b/pkg/handlers/ghcapi/mto_service_items_test.go index 16bd37da126..21d6ad52d17 100644 --- a/pkg/handlers/ghcapi/mto_service_items_test.go +++ b/pkg/handlers/ghcapi/mto_service_items_test.go @@ -32,6 +32,7 @@ import ( ppmshipment "github.com/transcom/mymove/pkg/services/ppmshipment" "github.com/transcom/mymove/pkg/services/query" sitstatus "github.com/transcom/mymove/pkg/services/sit_status" + transportationoffice "github.com/transcom/mymove/pkg/services/transportation_office" "github.com/transcom/mymove/pkg/testdatagen" "github.com/transcom/mymove/pkg/trace" ) @@ -322,7 +323,7 @@ func (suite *HandlerSuite) TestUpdateMTOServiceItemStatusHandler() { mockSender := suite.TestNotificationSender() addressUpdater := address.NewAddressUpdater() addressCreator := address.NewAddressCreator() - moveRouter := moveservices.NewMoveRouter() + moveRouter := moveservices.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) noCheckUpdater := mtoshipment.NewMTOShipmentUpdater(builder, fetcher, planner, moveRouter, moveWeights, mockSender, paymentRequestShipmentRecalculator, addressUpdater, addressCreator) ppmEstimator := mocks.PPMEstimator{} @@ -554,7 +555,7 @@ func (suite *HandlerSuite) TestUpdateMTOServiceItemStatusHandler() { } fetcher := fetch.NewFetcher(queryBuilder) - moveRouter := moveservices.NewMoveRouter() + moveRouter := moveservices.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) shipmentFetcher := mtoshipment.NewMTOShipmentFetcher() addressCreator := address.NewAddressCreator() planner := &routemocks.Planner{} @@ -593,7 +594,7 @@ func (suite *HandlerSuite) TestUpdateMTOServiceItemStatusHandler() { // by the handler is working as expected. suite.Run("Successful status update of MTO service item and event trigger", func() { queryBuilder := query.NewQueryBuilder() - moveRouter := moveservices.NewMoveRouter() + moveRouter := moveservices.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) shipmentFetcher := mtoshipment.NewMTOShipmentFetcher() mtoServiceItem, availableMove := suite.createServiceItem() requestUser := factory.BuildUser(nil, nil, nil) @@ -767,7 +768,7 @@ func (suite *HandlerSuite) TestUpdateServiceItemSitEntryDateHandler() { mockSender := suite.TestNotificationSender() addressUpdater := address.NewAddressUpdater() addressCreator := address.NewAddressCreator() - moveRouter := moveservices.NewMoveRouter() + moveRouter := moveservices.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) noCheckUpdater := mtoshipment.NewMTOShipmentUpdater(builder, fetcher, planner, moveRouter, moveWeights, mockSender, paymentRequestShipmentRecalculator, addressUpdater, addressCreator) ppmEstimator := mocks.PPMEstimator{} diff --git a/pkg/handlers/ghcapi/mto_shipment_test.go b/pkg/handlers/ghcapi/mto_shipment_test.go index 1fb84918cc7..381c2ca8623 100644 --- a/pkg/handlers/ghcapi/mto_shipment_test.go +++ b/pkg/handlers/ghcapi/mto_shipment_test.go @@ -38,6 +38,7 @@ import ( "github.com/transcom/mymove/pkg/services/query" sitextension "github.com/transcom/mymove/pkg/services/sit_extension" sitstatus "github.com/transcom/mymove/pkg/services/sit_status" + transportationoffice "github.com/transcom/mymove/pkg/services/transportation_office" "github.com/transcom/mymove/pkg/swagger/nullable" "github.com/transcom/mymove/pkg/trace" "github.com/transcom/mymove/pkg/unit" @@ -595,7 +596,7 @@ func (suite *HandlerSuite) TestApproveShipmentHandler() { eTag := etag.GenerateEtag(shipment.UpdatedAt) officeUser := factory.BuildOfficeUserWithRoles(nil, nil, []roles.RoleType{roles.RoleTypeTOO}) builder := query.NewQueryBuilder() - moveRouter := moveservices.NewMoveRouter() + moveRouter := moveservices.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} moveWeights := moveservices.NewMoveWeights(mtoshipment.NewShipmentReweighRequester()) planner.On("ZipTransitDistance", @@ -1195,7 +1196,7 @@ func (suite *HandlerSuite) TestApproveShipmentDiversionHandler() { officeUser := factory.BuildOfficeUserWithRoles(nil, nil, []roles.RoleType{roles.RoleTypeTOO}) approver := mtoshipment.NewShipmentDiversionApprover( mtoshipment.NewShipmentRouter(), - moveservices.NewMoveRouter(), + moveservices.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()), ) req := httptest.NewRequest("POST", fmt.Sprintf("/shipments/%s/approve-diversion", shipment.ID.String()), nil) @@ -1821,7 +1822,7 @@ func (suite *HandlerSuite) TestRequestShipmentCancellationHandler() { officeUser := factory.BuildOfficeUserWithRoles(nil, nil, []roles.RoleType{roles.RoleTypeTOO}) canceler := mtoshipment.NewShipmentCancellationRequester( mtoshipment.NewShipmentRouter(), - moveservices.NewMoveRouter(), + moveservices.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()), ) req := httptest.NewRequest("POST", fmt.Sprintf("/shipments/%s/request-cancellation", shipment.ID.String()), nil) @@ -2123,7 +2124,7 @@ func (suite *HandlerSuite) TestRequestShipmentReweighHandler() { mock.Anything, mock.Anything, ).Return(400, nil) - moveRouter := moveservices.NewMoveRouter() + moveRouter := moveservices.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) moveWeights := moveservices.NewMoveWeights(mtoshipment.NewShipmentReweighRequester()) // Get shipment payment request recalculator service @@ -2181,7 +2182,7 @@ func (suite *HandlerSuite) TestRequestShipmentReweighHandler() { mock.Anything, mock.Anything, ).Return(400, nil) - moveRouter := moveservices.NewMoveRouter() + moveRouter := moveservices.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) moveWeights := moveservices.NewMoveWeights(mtoshipment.NewShipmentReweighRequester()) // Get shipment payment request recalculator service @@ -2236,7 +2237,7 @@ func (suite *HandlerSuite) TestRequestShipmentReweighHandler() { mock.Anything, mock.Anything, ).Return(400, nil) - moveRouter := moveservices.NewMoveRouter() + moveRouter := moveservices.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) moveWeights := moveservices.NewMoveWeights(mtoshipment.NewShipmentReweighRequester()) // Get shipment payment request recalculator service @@ -2292,7 +2293,7 @@ func (suite *HandlerSuite) TestRequestShipmentReweighHandler() { mock.Anything, mock.Anything, ).Return(400, nil) - moveRouter := moveservices.NewMoveRouter() + moveRouter := moveservices.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) moveWeights := moveservices.NewMoveWeights(mtoshipment.NewShipmentReweighRequester()) // Get shipment payment request recalculator service @@ -2349,7 +2350,7 @@ func (suite *HandlerSuite) TestRequestShipmentReweighHandler() { mock.Anything, mock.Anything, ).Return(400, nil) - moveRouter := moveservices.NewMoveRouter() + moveRouter := moveservices.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) moveWeights := moveservices.NewMoveWeights(mtoshipment.NewShipmentReweighRequester()) // Get shipment payment request recalculator service @@ -2405,7 +2406,7 @@ func (suite *HandlerSuite) TestRequestShipmentReweighHandler() { mock.Anything, mock.Anything, ).Return(400, nil) - moveRouter := moveservices.NewMoveRouter() + moveRouter := moveservices.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) moveWeights := moveservices.NewMoveWeights(mtoshipment.NewShipmentReweighRequester()) // Get shipment payment request recalculator service @@ -2729,7 +2730,7 @@ func (suite *HandlerSuite) TestApproveSITExtensionHandler() { }, nil) eTag := etag.GenerateEtag(mtoShipment.UpdatedAt) officeUser := factory.BuildOfficeUserWithRoles(nil, nil, []roles.RoleType{roles.RoleTypeTOO}) - moveRouter := moveservices.NewMoveRouter() + moveRouter := moveservices.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) sitExtensionApprover := sitextension.NewSITExtensionApprover(moveRouter) req := httptest.NewRequest("PATCH", fmt.Sprintf("/shipments/%s/sit-extension/%s/approve", mtoShipment.ID.String(), sitExtension.ID.String()), nil) req = suite.AuthenticateOfficeRequest(req, officeUser) @@ -2826,7 +2827,7 @@ func (suite *HandlerSuite) TestDenySITExtensionHandler() { }, nil) eTag := etag.GenerateEtag(mtoShipment.UpdatedAt) officeUser := factory.BuildOfficeUserWithRoles(nil, nil, []roles.RoleType{roles.RoleTypeTOO}) - moveRouter := moveservices.NewMoveRouter() + moveRouter := moveservices.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) sitExtensionDenier := sitextension.NewSITExtensionDenier(moveRouter) req := httptest.NewRequest("PATCH", fmt.Sprintf("/shipments/%s/sit-extension/%s/deny", mtoShipment.ID.String(), sitExtension.ID.String()), nil) req = suite.AuthenticateOfficeRequest(req, officeUser) @@ -2893,7 +2894,7 @@ func (suite *HandlerSuite) CreateApprovedSITDurationUpdate() { mockSender := suite.TestNotificationSender() addressUpdater := address.NewAddressUpdater() addressCreator := address.NewAddressCreator() - moveRouter := moveservices.NewMoveRouter() + moveRouter := moveservices.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) noCheckUpdater := mtoshipment.NewMTOShipmentUpdater(builder, fetcher, planner, moveRouter, moveWeights, mockSender, paymentRequestShipmentRecalculator, addressUpdater, addressCreator) ppmEstimator := mocks.PPMEstimator{} @@ -2976,7 +2977,7 @@ func (suite *HandlerSuite) CreateApprovedSITDurationUpdate() { mockSender := suite.TestNotificationSender() addressUpdater := address.NewAddressUpdater() addressCreator := address.NewAddressCreator() - moveRouter := moveservices.NewMoveRouter() + moveRouter := moveservices.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) noCheckUpdater := mtoshipment.NewMTOShipmentUpdater(builder, fetcher, planner, moveRouter, moveWeights, mockSender, paymentRequestShipmentRecalculator, addressUpdater, addressCreator) ppmEstimator := mocks.PPMEstimator{} @@ -3091,7 +3092,7 @@ func (suite *HandlerSuite) makeCreateMTOShipmentSubtestData() (subtestData *crea } func (suite *HandlerSuite) TestCreateMTOShipmentHandler() { - moveRouter := moveservices.NewMoveRouter() + moveRouter := moveservices.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) addressCreator := address.NewAddressCreator() setUpSignedCertificationCreatorMock := func(returnValue ...interface{}) services.SignedCertificationCreator { @@ -3450,7 +3451,7 @@ func (suite *HandlerSuite) TestCreateMTOShipmentHandlerUsingPPM() { handlerConfig := suite.HandlerConfig() builder := query.NewQueryBuilder() fetcher := fetch.NewFetcher(builder) - creator := mtoshipment.NewMTOShipmentCreatorV1(builder, fetcher, moveservices.NewMoveRouter(), addressCreator) + creator := mtoshipment.NewMTOShipmentCreatorV1(builder, fetcher, moveservices.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()), addressCreator) ppmEstimator := mocks.PPMEstimator{} ppmCreator := ppmshipment.NewPPMShipmentCreator(&ppmEstimator, addressCreator) boatCreator := boatshipment.NewBoatShipmentCreator() @@ -3465,8 +3466,8 @@ func (suite *HandlerSuite) TestCreateMTOShipmentHandlerUsingPPM() { moveTaskOrderUpdater := movetaskorder.NewMoveTaskOrderUpdater( builder, - mtoserviceitem.NewMTOServiceItemCreator(planner, builder, moveservices.NewMoveRouter(), ghcrateengine.NewDomesticUnpackPricer(), ghcrateengine.NewDomesticPackPricer(), ghcrateengine.NewDomesticLinehaulPricer(), ghcrateengine.NewDomesticShorthaulPricer(), ghcrateengine.NewDomesticOriginPricer(), ghcrateengine.NewDomesticDestinationPricer(), ghcrateengine.NewFuelSurchargePricer()), - moveservices.NewMoveRouter(), setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), &ppmEstimator, + mtoserviceitem.NewMTOServiceItemCreator(planner, builder, moveservices.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()), ghcrateengine.NewDomesticUnpackPricer(), ghcrateengine.NewDomesticPackPricer(), ghcrateengine.NewDomesticLinehaulPricer(), ghcrateengine.NewDomesticShorthaulPricer(), ghcrateengine.NewDomesticOriginPricer(), ghcrateengine.NewDomesticDestinationPricer(), ghcrateengine.NewFuelSurchargePricer()), + moveservices.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()), setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), &ppmEstimator, ) shipmentCreator := shipmentorchestrator.NewShipmentCreator(creator, ppmCreator, boatCreator, mobileHomeCreator, shipmentRouter, moveTaskOrderUpdater) sitStatus := sitstatus.NewShipmentSITStatus() @@ -3662,7 +3663,7 @@ func (suite *HandlerSuite) TestCreateMTOShipmentHandlerUsingPPM() { handlerConfig := suite.HandlerConfig() builder := query.NewQueryBuilder() fetcher := fetch.NewFetcher(builder) - creator := mtoshipment.NewMTOShipmentCreatorV1(builder, fetcher, moveservices.NewMoveRouter(), addressCreator) + creator := mtoshipment.NewMTOShipmentCreatorV1(builder, fetcher, moveservices.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()), addressCreator) ppmEstimator := mocks.PPMEstimator{} boatCreator := boatshipment.NewBoatShipmentCreator() mobileHomeCreator := mobilehomeshipment.NewMobileHomeShipmentCreator() @@ -3675,8 +3676,8 @@ func (suite *HandlerSuite) TestCreateMTOShipmentHandlerUsingPPM() { ).Return(400, nil) moveTaskOrderUpdater := movetaskorder.NewMoveTaskOrderUpdater( builder, - mtoserviceitem.NewMTOServiceItemCreator(planner, builder, moveservices.NewMoveRouter(), ghcrateengine.NewDomesticUnpackPricer(), ghcrateengine.NewDomesticPackPricer(), ghcrateengine.NewDomesticLinehaulPricer(), ghcrateengine.NewDomesticShorthaulPricer(), ghcrateengine.NewDomesticOriginPricer(), ghcrateengine.NewDomesticDestinationPricer(), ghcrateengine.NewFuelSurchargePricer()), - moveservices.NewMoveRouter(), setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), &ppmEstimator, + mtoserviceitem.NewMTOServiceItemCreator(planner, builder, moveservices.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()), ghcrateengine.NewDomesticUnpackPricer(), ghcrateengine.NewDomesticPackPricer(), ghcrateengine.NewDomesticLinehaulPricer(), ghcrateengine.NewDomesticShorthaulPricer(), ghcrateengine.NewDomesticOriginPricer(), ghcrateengine.NewDomesticDestinationPricer(), ghcrateengine.NewFuelSurchargePricer()), + moveservices.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()), setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), &ppmEstimator, ) shipmentCreator := shipmentorchestrator.NewShipmentCreator(creator, ppmshipment.NewPPMShipmentCreator(&ppmEstimator, addressCreator), boatCreator, mobileHomeCreator, shipmentRouter, moveTaskOrderUpdater) handler := CreateMTOShipmentHandler{ @@ -3812,7 +3813,7 @@ func (suite *HandlerSuite) TestCreateMTOShipmentHandlerUsingPPM() { handlerConfig := suite.HandlerConfig() builder := query.NewQueryBuilder() fetcher := fetch.NewFetcher(builder) - creator := mtoshipment.NewMTOShipmentCreatorV1(builder, fetcher, moveservices.NewMoveRouter(), addressCreator) + creator := mtoshipment.NewMTOShipmentCreatorV1(builder, fetcher, moveservices.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()), addressCreator) ppmEstimator := mocks.PPMEstimator{} boatCreator := boatshipment.NewBoatShipmentCreator() mobileHomeCreator := mobilehomeshipment.NewMobileHomeShipmentCreator() @@ -3825,8 +3826,8 @@ func (suite *HandlerSuite) TestCreateMTOShipmentHandlerUsingPPM() { ).Return(400, nil) moveTaskOrderUpdater := movetaskorder.NewMoveTaskOrderUpdater( builder, - mtoserviceitem.NewMTOServiceItemCreator(planner, builder, moveservices.NewMoveRouter(), ghcrateengine.NewDomesticUnpackPricer(), ghcrateengine.NewDomesticPackPricer(), ghcrateengine.NewDomesticLinehaulPricer(), ghcrateengine.NewDomesticShorthaulPricer(), ghcrateengine.NewDomesticOriginPricer(), ghcrateengine.NewDomesticDestinationPricer(), ghcrateengine.NewFuelSurchargePricer()), - moveservices.NewMoveRouter(), setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), &ppmEstimator, + mtoserviceitem.NewMTOServiceItemCreator(planner, builder, moveservices.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()), ghcrateengine.NewDomesticUnpackPricer(), ghcrateengine.NewDomesticPackPricer(), ghcrateengine.NewDomesticLinehaulPricer(), ghcrateengine.NewDomesticShorthaulPricer(), ghcrateengine.NewDomesticOriginPricer(), ghcrateengine.NewDomesticDestinationPricer(), ghcrateengine.NewFuelSurchargePricer()), + moveservices.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()), setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), &ppmEstimator, ) shipmentCreator := shipmentorchestrator.NewShipmentCreator(creator, ppmshipment.NewPPMShipmentCreator(&ppmEstimator, addressCreator), boatCreator, mobileHomeCreator, shipmentRouter, moveTaskOrderUpdater) handler := CreateMTOShipmentHandler{ @@ -4028,7 +4029,7 @@ func (suite *HandlerSuite) TestUpdateShipmentHandler() { mock.Anything, mock.Anything, ).Return(400, nil) - moveRouter := moveservices.NewMoveRouter() + moveRouter := moveservices.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) moveWeights := moveservices.NewMoveWeights(mtoshipment.NewShipmentReweighRequester()) // Get shipment payment request recalculator service @@ -4650,7 +4651,7 @@ func (suite *HandlerSuite) TestUpdateShipmentHandler() { }) } func (suite *HandlerSuite) TestUpdateSITServiceItemCustomerExpenseHandler() { - moveRouter := moveservices.NewMoveRouter() + moveRouter := moveservices.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) builder := query.NewQueryBuilder() shipmentFetcher := mtoshipment.NewMTOShipmentFetcher() addressCreator := address.NewAddressCreator() diff --git a/pkg/handlers/ghcapi/orders_test.go b/pkg/handlers/ghcapi/orders_test.go index 93fdc901600..e40efd4ea7f 100644 --- a/pkg/handlers/ghcapi/orders_test.go +++ b/pkg/handlers/ghcapi/orders_test.go @@ -29,6 +29,7 @@ import ( mtoserviceitem "github.com/transcom/mymove/pkg/services/mto_service_item" orderservice "github.com/transcom/mymove/pkg/services/order" "github.com/transcom/mymove/pkg/services/query" + transportationoffice "github.com/transcom/mymove/pkg/services/transportation_office" storageTest "github.com/transcom/mymove/pkg/storage/test" "github.com/transcom/mymove/pkg/swagger/nullable" "github.com/transcom/mymove/pkg/trace" @@ -392,7 +393,7 @@ func (suite *HandlerSuite) makeUpdateOrderHandlerAmendedUploadSubtestData() (sub func (suite *HandlerSuite) TestUpdateOrderHandlerWithAmendedUploads() { queryBuilder := query.NewQueryBuilder() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -725,7 +726,7 @@ func (suite *HandlerSuite) TestUpdateOrderHandler() { } moveTaskOrderUpdater := mocks.MoveTaskOrderUpdater{} - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) handler := UpdateOrderHandler{ handlerConfig, orderservice.NewOrderUpdater(moveRouter), @@ -1017,7 +1018,7 @@ func (suite *HandlerSuite) TestCounselingUpdateOrderHandler() { Body: body, } - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) handler := CounselingUpdateOrderHandler{ handlerConfig, orderservice.NewOrderUpdater(moveRouter), @@ -1265,7 +1266,7 @@ func (suite *HandlerSuite) TestUpdateAllowanceHandler() { Body: body, } - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) handler := UpdateAllowanceHandler{ handlerConfig, orderservice.NewOrderUpdater(moveRouter), @@ -1493,7 +1494,7 @@ func (suite *HandlerSuite) TestCounselingUpdateAllowanceHandler() { Body: body, } - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) handler := CounselingUpdateAllowanceHandler{ handlerConfig, orderservice.NewOrderUpdater(moveRouter), @@ -1651,7 +1652,7 @@ func (suite *HandlerSuite) TestUpdateMaxBillableWeightAsTIOHandler() { Body: body, } - router := moverouter.NewMoveRouter() + router := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) handler := UpdateMaxBillableWeightAsTIOHandler{ handlerConfig, orderservice.NewExcessWeightRiskManager(router), @@ -1814,7 +1815,7 @@ func (suite *HandlerSuite) TestUpdateBillableWeightHandler() { Body: body, } - router := moverouter.NewMoveRouter() + router := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) handler := UpdateBillableWeightHandler{ handlerConfig, orderservice.NewExcessWeightRiskManager(router), @@ -2030,7 +2031,7 @@ func (suite *HandlerSuite) TestAcknowledgeExcessWeightRiskHandler() { IfMatch: etag.GenerateEtag(move.UpdatedAt), } - router := moverouter.NewMoveRouter() + router := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) handler := AcknowledgeExcessWeightRiskHandler{ handlerConfig, orderservice.NewExcessWeightRiskManager(router), @@ -2440,7 +2441,7 @@ func (suite *HandlerSuite) TestUploadAmendedOrdersHandlerUnit() { } func (suite *HandlerSuite) TestUploadAmendedOrdersHandlerIntegration() { - orderUpdater := orderservice.NewOrderUpdater(moverouter.NewMoveRouter()) + orderUpdater := orderservice.NewOrderUpdater(moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher())) setUpRequestAndParams := func(orders models.Order) *orderop.UploadAmendedOrdersParams { endpoint := fmt.Sprintf("/orders/%v/upload_amended_orders", orders.ID.String()) diff --git a/pkg/handlers/internalapi/api.go b/pkg/handlers/internalapi/api.go index eb5386c4356..f843b5a9179 100644 --- a/pkg/handlers/internalapi/api.go +++ b/pkg/handlers/internalapi/api.go @@ -56,7 +56,7 @@ func NewInternalAPI(handlerConfig handlers.HandlerConfig) *internalops.MymoveAPI internalAPI.ServeError = handlers.ServeCustomError builder := query.NewQueryBuilder() fetcher := fetch.NewFetcher(builder) - moveRouter := move.NewMoveRouter() + moveRouter := move.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) uploadCreator := upload.NewUploadCreator(handlerConfig.FileStorer()) ppmEstimator := ppmshipment.NewEstimatePPM(handlerConfig.DTODPlanner(), &paymentrequesthelper.RequestPaymentHelper{}) ppmCloseoutFetcher := ppmcloseout.NewPPMCloseoutFetcher(handlerConfig.DTODPlanner(), &paymentrequesthelper.RequestPaymentHelper{}, ppmEstimator) diff --git a/pkg/handlers/internalapi/moves_test.go b/pkg/handlers/internalapi/moves_test.go index 40e2e9283f5..abd154aa95c 100644 --- a/pkg/handlers/internalapi/moves_test.go +++ b/pkg/handlers/internalapi/moves_test.go @@ -281,7 +281,7 @@ func (suite *HandlerSuite) TestSubmitMoveForApprovalHandler() { // When: a move is submitted handlerConfig := suite.HandlerConfig() handlerConfig.SetNotificationSender(notifications.NewStubNotificationSender("milmovelocal")) - handler := SubmitMoveHandler{handlerConfig, moverouter.NewMoveRouter()} + handler := SubmitMoveHandler{handlerConfig, moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher())} response := handler.Handle(params) // Then: expect a 200 status code @@ -332,7 +332,7 @@ func (suite *HandlerSuite) TestSubmitMoveForApprovalHandler() { // And: a move is submitted handlerConfig := suite.HandlerConfig() handlerConfig.SetNotificationSender(notifications.NewStubNotificationSender("milmovelocal")) - handler := SubmitMoveHandler{handlerConfig, moverouter.NewMoveRouter()} + handler := SubmitMoveHandler{handlerConfig, moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher())} response := handler.Handle(params) // Then: expect a 200 status code @@ -385,7 +385,7 @@ func (suite *HandlerSuite) TestSubmitMoveForServiceCounselingHandler() { // When: a move is submitted handlerConfig := suite.HandlerConfig() handlerConfig.SetNotificationSender(notifications.NewStubNotificationSender("milmovelocal")) - handler := SubmitMoveHandler{handlerConfig, moverouter.NewMoveRouter()} + handler := SubmitMoveHandler{handlerConfig, moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher())} response := handler.Handle(params) // Then: expect a 200 status code @@ -435,7 +435,7 @@ func (suite *HandlerSuite) TestSubmitAmendedOrdersHandler() { // And: a move is submitted handlerConfig := suite.HandlerConfig() - handler := SubmitAmendedOrdersHandler{handlerConfig, moverouter.NewMoveRouter()} + handler := SubmitAmendedOrdersHandler{handlerConfig, moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher())} response := handler.Handle(params) // Then: expect a 200 status code diff --git a/pkg/handlers/internalapi/mto_shipment_test.go b/pkg/handlers/internalapi/mto_shipment_test.go index 4d2b557286f..f034d5cd72f 100644 --- a/pkg/handlers/internalapi/mto_shipment_test.go +++ b/pkg/handlers/internalapi/mto_shipment_test.go @@ -34,6 +34,7 @@ import ( paymentrequest "github.com/transcom/mymove/pkg/services/payment_request" "github.com/transcom/mymove/pkg/services/ppmshipment" "github.com/transcom/mymove/pkg/services/query" + transportationoffice "github.com/transcom/mymove/pkg/services/transportation_office" "github.com/transcom/mymove/pkg/testdatagen" "github.com/transcom/mymove/pkg/unit" ) @@ -47,7 +48,7 @@ type mtoShipmentObjects struct { func (suite *HandlerSuite) setUpMTOShipmentObjects() *mtoShipmentObjects { builder := query.NewQueryBuilder() fetcher := fetch.NewFetcher(builder) - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) return &mtoShipmentObjects{ builder: builder, diff --git a/pkg/handlers/internalapi/office_test.go b/pkg/handlers/internalapi/office_test.go index 9370fb0c76f..f7e7101f388 100644 --- a/pkg/handlers/internalapi/office_test.go +++ b/pkg/handlers/internalapi/office_test.go @@ -12,6 +12,7 @@ import ( "github.com/transcom/mymove/pkg/models" "github.com/transcom/mymove/pkg/models/roles" moverouter "github.com/transcom/mymove/pkg/services/move" + transportationoffice "github.com/transcom/mymove/pkg/services/transportation_office" "github.com/transcom/mymove/pkg/testdatagen" ) @@ -31,7 +32,7 @@ func (suite *HandlerSuite) TestApproveMoveHandler() { }, nil) // Given: an office User officeUser := factory.BuildOfficeUserWithRoles(suite.DB(), nil, []roles.RoleType{roles.RoleTypeTOO}) - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) // Move is submitted and saved newSignedCertification := factory.BuildSignedCertification(nil, []factory.Customization{ @@ -73,7 +74,7 @@ func (suite *HandlerSuite) TestApproveMoveHandlerIncompleteOrders() { move := factory.BuildMove(suite.DB(), nil, nil) // Given: an office User officeUser := factory.BuildOfficeUserWithRoles(suite.DB(), nil, []roles.RoleType{roles.RoleTypeTOO}) - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) // Move is submitted and saved newSignedCertification := factory.BuildSignedCertification(nil, []factory.Customization{ @@ -116,7 +117,7 @@ func (suite *HandlerSuite) TestApproveMoveHandlerForbidden() { move := factory.BuildMove(suite.DB(), nil, nil) // Given: an non-office User user := factory.BuildServiceMember(suite.DB(), nil, nil) - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) // And: the context contains the auth values req := httptest.NewRequest("POST", "/moves/some_id/approve", nil) @@ -141,7 +142,7 @@ func (suite *HandlerSuite) TestCancelMoveHandler() { suite.Run("Successfully cancels move", func() { // Given: a set of orders, a move, and office user // Orders has service member with transportation office and phone nums - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) // Given: a set of orders, a move, user and servicemember move := factory.BuildMove(suite.DB(), nil, nil) @@ -171,7 +172,7 @@ func (suite *HandlerSuite) TestCancelMoveHandler() { suite.Run("Fails to cancel someone elses move", func() { // Given: a set of orders, a move, and office user // Orders has service member with transportation office and phone nums - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) // Given: a set of orders, a move, user and servicemember move := factory.BuildMove(suite.DB(), nil, nil) @@ -198,7 +199,7 @@ func (suite *HandlerSuite) TestCancelMoveHandler() { suite.Run("Fails to cancel submitted move", func() { // Given: a set of orders, a move, and office user // Orders has service member with transportation office and phone nums - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) // Given: a set of orders, a move, user and servicemember move := factory.BuildMove(suite.DB(), []factory.Customization{ diff --git a/pkg/handlers/internalapi/orders_test.go b/pkg/handlers/internalapi/orders_test.go index a4a74bb81e0..477ff06ff09 100644 --- a/pkg/handlers/internalapi/orders_test.go +++ b/pkg/handlers/internalapi/orders_test.go @@ -20,6 +20,7 @@ import ( "github.com/transcom/mymove/pkg/services/mocks" "github.com/transcom/mymove/pkg/services/move" orderservice "github.com/transcom/mymove/pkg/services/order" + transportationoffice "github.com/transcom/mymove/pkg/services/transportation_office" storageTest "github.com/transcom/mymove/pkg/storage/test" "github.com/transcom/mymove/pkg/uploader" ) @@ -487,7 +488,7 @@ func (suite *HandlerSuite) TestUploadAmendedOrdersHandlerUnit() { } func (suite *HandlerSuite) TestUploadAmendedOrdersHandlerIntegration() { - orderUpdater := orderservice.NewOrderUpdater(move.NewMoveRouter()) + orderUpdater := orderservice.NewOrderUpdater(move.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher())) setUpRequestAndParams := func(orders models.Order) *ordersop.UploadAmendedOrdersParams { endpoint := fmt.Sprintf("/orders/%v/upload_amended_orders", orders.ID.String()) diff --git a/pkg/handlers/internalapi/service_members_test.go b/pkg/handlers/internalapi/service_members_test.go index 9764091a4e6..4041faeb9f3 100644 --- a/pkg/handlers/internalapi/service_members_test.go +++ b/pkg/handlers/internalapi/service_members_test.go @@ -23,6 +23,7 @@ import ( "github.com/transcom/mymove/pkg/handlers" "github.com/transcom/mymove/pkg/models" moverouter "github.com/transcom/mymove/pkg/services/move" + transportationoffice "github.com/transcom/mymove/pkg/services/transportation_office" storageTest "github.com/transcom/mymove/pkg/storage/test" ) @@ -392,7 +393,7 @@ func (suite *HandlerSuite) TestPatchServiceMemberHandlerSubmittedMove() { move.Orders.OrdersTypeDetail = nil suite.MustSave(&move.Orders) - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) newSignedCertification := factory.BuildSignedCertification(nil, []factory.Customization{ { Model: move, diff --git a/pkg/handlers/primeapi/api.go b/pkg/handlers/primeapi/api.go index 40da37ee4dc..5d9b6a9331a 100644 --- a/pkg/handlers/primeapi/api.go +++ b/pkg/handlers/primeapi/api.go @@ -27,6 +27,7 @@ import ( shipmentaddressupdate "github.com/transcom/mymove/pkg/services/shipment_address_update" signedcertification "github.com/transcom/mymove/pkg/services/signed_certification" sitextension "github.com/transcom/mymove/pkg/services/sit_extension" + transportationoffice "github.com/transcom/mymove/pkg/services/transportation_office" "github.com/transcom/mymove/pkg/services/upload" "github.com/transcom/mymove/pkg/uploader" ) @@ -42,7 +43,7 @@ func NewPrimeAPI(handlerConfig handlers.HandlerConfig) *primeoperations.MymoveAP } primeAPI := primeoperations.NewMymoveAPI(primeSpec) queryBuilder := query.NewQueryBuilder() - moveRouter := move.NewMoveRouter() + moveRouter := move.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) addressCreator := address.NewAddressCreator() shipmentFetcher := mtoshipment.NewMTOShipmentFetcher() moveWeights := move.NewMoveWeights(mtoshipment.NewShipmentReweighRequester()) diff --git a/pkg/handlers/primeapi/move_task_order_test.go b/pkg/handlers/primeapi/move_task_order_test.go index 2bfa5abfbcc..870c4acf10c 100644 --- a/pkg/handlers/primeapi/move_task_order_test.go +++ b/pkg/handlers/primeapi/move_task_order_test.go @@ -28,6 +28,7 @@ import ( movetaskorder "github.com/transcom/mymove/pkg/services/move_task_order" mtoserviceitem "github.com/transcom/mymove/pkg/services/mto_service_item" "github.com/transcom/mymove/pkg/services/query" + transportationoffice "github.com/transcom/mymove/pkg/services/transportation_office" "github.com/transcom/mymove/pkg/services/upload" storageTest "github.com/transcom/mymove/pkg/storage/test" "github.com/transcom/mymove/pkg/testdatagen" @@ -1704,7 +1705,7 @@ func (suite *HandlerSuite) TestUpdateMTOPostCounselingInfo() { queryBuilder := query.NewQueryBuilder() fetcher := fetch.NewFetcher(queryBuilder) - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -1787,7 +1788,7 @@ func (suite *HandlerSuite) TestUpdateMTOPostCounselingInfo() { mtoChecker := movetaskorder.NewMoveTaskOrderChecker() queryBuilder := query.NewQueryBuilder() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) fetcher := fetch.NewFetcher(queryBuilder) planner := &routemocks.Planner{} planner.On("ZipTransitDistance", diff --git a/pkg/handlers/primeapi/mto_service_item_test.go b/pkg/handlers/primeapi/mto_service_item_test.go index c3e8b9daef6..44d6f84ef47 100644 --- a/pkg/handlers/primeapi/mto_service_item_test.go +++ b/pkg/handlers/primeapi/mto_service_item_test.go @@ -29,6 +29,7 @@ import ( mtoshipment "github.com/transcom/mymove/pkg/services/mto_shipment" "github.com/transcom/mymove/pkg/services/query" sitstatus "github.com/transcom/mymove/pkg/services/sit_status" + transportationoffice "github.com/transcom/mymove/pkg/services/transportation_office" "github.com/transcom/mymove/pkg/unit" ) @@ -87,7 +88,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemHandler() { suite.Run("Successful POST - Integration Test", func() { subtestData := makeSubtestData() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -145,7 +146,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemHandler() { Body: payloads.MTOServiceItem(&mtoServiceItem), } - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -283,7 +284,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemHandler() { suite.Run("POST failure - 404 - MTO is not available to Prime", func() { subtestData := makeSubtestData() mtoNotAvailable := factory.BuildMove(suite.DB(), nil, nil) - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -327,7 +328,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemHandler() { LinkOnly: true, }, }, nil) - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -478,7 +479,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemDomesticCratingHandler() { suite.Run("Successful POST - Integration Test - Domestic Crating", func() { subtestData := makeSubtestData() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -515,7 +516,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemDomesticCratingHandler() { suite.Run("Successful POST - Integration Test - Domestic Uncrating", func() { subtestData := makeSubtestData() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -638,7 +639,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemOriginSITHandler() { requestApprovalRequestedStatus := false subtestData.mtoServiceItem.RequestedApprovalsRequestedStatus = &requestApprovalRequestedStatus subtestData.mtoServiceItem.ReService.Code = models.ReServiceCodeDOPSIT - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -684,7 +685,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemOriginSITHandler() { requestApprovalRequestedStatus := false subtestData.mtoServiceItem.RequestedApprovalsRequestedStatus = &requestApprovalRequestedStatus - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -753,7 +754,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemOriginSITHandler() { }, nil) subtestData.mtoServiceItem.ReService.Code = models.ReServiceCodeDOASIT - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -837,7 +838,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemOriginSITHandlerWithDOFSITNoA requstedApprovalsRequestedStatus := false subtestData.mtoServiceItem.RequestedApprovalsRequestedStatus = &requstedApprovalsRequestedStatus subtestData.mtoServiceItem.ReService.Code = models.ReServiceCodeDOFSIT - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -947,7 +948,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemOriginSITHandlerWithDOFSITWit requestedApprovalsRequestedStatus := false subtestData.mtoServiceItem.RequestedApprovalsRequestedStatus = &requestedApprovalsRequestedStatus subtestData.mtoServiceItem.ReService.Code = models.ReServiceCodeDOFSIT - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -1120,7 +1121,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemDestSITHandler() { suite.Run("Successful POST - Integration Test", func() { subtestData := makeSubtestData() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -1194,7 +1195,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemDestSITHandler() { SITEntryDate: &sitEntryDate, Reason: models.StringPointer("lorem ipsum"), } - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -1227,7 +1228,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemDestSITHandler() { suite.Run("Failure POST - Integration Test - Missing reason", func() { subtestData := makeSubtestData() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -1283,7 +1284,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemDestSITHandler() { HTTPRequest: subtestData.params.HTTPRequest, Body: payloads.MTOServiceItem(&subtestData.mtoServiceItem), } - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -1337,7 +1338,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemDestSITHandler() { HTTPRequest: subtestData.params.HTTPRequest, Body: payloads.MTOServiceItem(&subtestData.mtoServiceItem), } - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -1373,7 +1374,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemDestSITHandler() { // SETUP // Create the payload subtestData.mtoServiceItem.ReService.Code = models.ReServiceCodeDDDSIT - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} creator := mtoserviceitem.NewMTOServiceItemCreator(planner, builder, moveRouter, ghcrateengine.NewDomesticUnpackPricer(), ghcrateengine.NewDomesticPackPricer(), ghcrateengine.NewDomesticLinehaulPricer(), ghcrateengine.NewDomesticShorthaulPricer(), ghcrateengine.NewDomesticOriginPricer(), ghcrateengine.NewDomesticDestinationPricer(), ghcrateengine.NewFuelSurchargePricer()) handler := CreateMTOServiceItemHandler{ @@ -1532,7 +1533,7 @@ func (suite *HandlerSuite) TestUpdateMTOServiceItemDDDSIT() { // Create the handler queryBuilder := query.NewQueryBuilder() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) shipmentFetcher := mtoshipment.NewMTOShipmentFetcher() addressCreator := address.NewAddressCreator() planner := &routemocks.Planner{} @@ -1712,7 +1713,7 @@ func (suite *HandlerSuite) TestUpdateMTOServiceItemDOPSIT() { // Create the service item in the db for dofsit and DOPSIT // Create the handler queryBuilder := query.NewQueryBuilder() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) shipmentFetcher := mtoshipment.NewMTOShipmentFetcher() addressCreator := address.NewAddressCreator() sitStatusService := sitstatus.NewShipmentSITStatus() diff --git a/pkg/handlers/primeapi/mto_shipment_test.go b/pkg/handlers/primeapi/mto_shipment_test.go index 5b602de7873..3fa3bfa8824 100644 --- a/pkg/handlers/primeapi/mto_shipment_test.go +++ b/pkg/handlers/primeapi/mto_shipment_test.go @@ -31,6 +31,7 @@ import ( mtoshipment "github.com/transcom/mymove/pkg/services/mto_shipment" paymentrequest "github.com/transcom/mymove/pkg/services/payment_request" "github.com/transcom/mymove/pkg/services/query" + transportationoffice "github.com/transcom/mymove/pkg/services/transportation_office" ) func (suite *HandlerSuite) TestUpdateShipmentDestinationAddressHandler() { @@ -204,7 +205,7 @@ func (suite *HandlerSuite) TestUpdateMTOShipmentStatusHandler() { mock.Anything, mock.Anything, ).Return(400, nil) - moveRouter := moveservices.NewMoveRouter() + moveRouter := moveservices.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) addressUpdater := address.NewAddressUpdater() addressCreator := address.NewAddressCreator() moveWeights := moveservices.NewMoveWeights(mtoshipment.NewShipmentReweighRequester()) @@ -408,7 +409,7 @@ func (suite *HandlerSuite) TestUpdateMTOShipmentStatusHandler() { func (suite *HandlerSuite) TestDeleteMTOShipmentHandler() { setupTestData := func() DeleteMTOShipmentHandler { builder := query.NewQueryBuilder() - moveRouter := moveservices.NewMoveRouter() + moveRouter := moveservices.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), diff --git a/pkg/handlers/primeapi/sit_extension_test.go b/pkg/handlers/primeapi/sit_extension_test.go index 2e30b6f4576..dfd6052d67a 100644 --- a/pkg/handlers/primeapi/sit_extension_test.go +++ b/pkg/handlers/primeapi/sit_extension_test.go @@ -14,6 +14,7 @@ import ( "github.com/transcom/mymove/pkg/models" moverouter "github.com/transcom/mymove/pkg/services/move" sitextensionservice "github.com/transcom/mymove/pkg/services/sit_extension" + transportationoffice "github.com/transcom/mymove/pkg/services/transportation_office" ) func (suite *HandlerSuite) CreateSITExtensionHandler() { @@ -30,7 +31,7 @@ func (suite *HandlerSuite) CreateSITExtensionHandler() { } // Create move router for SitExtension Createor - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) setupTestData := func() (CreateSITExtensionHandler, models.MTOShipment) { // Make an available move diff --git a/pkg/handlers/primeapiv2/api.go b/pkg/handlers/primeapiv2/api.go index dedf3e218ac..b0a6b4dfda2 100644 --- a/pkg/handlers/primeapiv2/api.go +++ b/pkg/handlers/primeapiv2/api.go @@ -23,6 +23,7 @@ import ( "github.com/transcom/mymove/pkg/services/ppmshipment" "github.com/transcom/mymove/pkg/services/query" signedcertification "github.com/transcom/mymove/pkg/services/signed_certification" + transportationoffice "github.com/transcom/mymove/pkg/services/transportation_office" ) // NewPrimeAPI returns the Prime API @@ -30,7 +31,7 @@ func NewPrimeAPI(handlerConfig handlers.HandlerConfig) *primev2operations.Mymove builder := query.NewQueryBuilder() fetcher := fetch.NewFetcher(builder) queryBuilder := query.NewQueryBuilder() - moveRouter := move.NewMoveRouter() + moveRouter := move.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) primeSpec, err := loads.Analyzed(primev2api.SwaggerJSON, "") if err != nil { diff --git a/pkg/handlers/primeapiv2/mto_service_item_test.go b/pkg/handlers/primeapiv2/mto_service_item_test.go index ffe960ba4f4..f18475b09b1 100644 --- a/pkg/handlers/primeapiv2/mto_service_item_test.go +++ b/pkg/handlers/primeapiv2/mto_service_item_test.go @@ -25,6 +25,7 @@ import ( movetaskorder "github.com/transcom/mymove/pkg/services/move_task_order" mtoserviceitem "github.com/transcom/mymove/pkg/services/mto_service_item" "github.com/transcom/mymove/pkg/services/query" + transportationoffice "github.com/transcom/mymove/pkg/services/transportation_office" ) func (suite *HandlerSuite) TestCreateMTOServiceItemHandler() { @@ -82,7 +83,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemHandler() { suite.Run("Successful POST - Integration Test", func() { subtestData := makeSubtestData() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -140,7 +141,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemHandler() { Body: payloads.MTOServiceItem(&mtoServiceItem), } - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -278,7 +279,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemHandler() { suite.Run("POST failure - 404 - MTO is not available to Prime", func() { subtestData := makeSubtestData() mtoNotAvailable := factory.BuildMove(suite.DB(), nil, nil) - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -322,7 +323,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemHandler() { LinkOnly: true, }, }, nil) - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -473,7 +474,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemDomesticCratingHandler() { suite.Run("Successful POST - Integration Test - Domestic Crating", func() { subtestData := makeSubtestData() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -510,7 +511,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemDomesticCratingHandler() { suite.Run("Successful POST - Integration Test - Domestic Uncrating", func() { subtestData := makeSubtestData() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -633,7 +634,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemOriginSITHandler() { requestApprovalRequestedStatus := false subtestData.mtoServiceItem.RequestedApprovalsRequestedStatus = &requestApprovalRequestedStatus subtestData.mtoServiceItem.ReService.Code = models.ReServiceCodeDOPSIT - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -679,7 +680,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemOriginSITHandler() { requestApprovalRequestedStatus := false subtestData.mtoServiceItem.RequestedApprovalsRequestedStatus = &requestApprovalRequestedStatus - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -748,7 +749,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemOriginSITHandler() { }, nil) subtestData.mtoServiceItem.ReService.Code = models.ReServiceCodeDOASIT - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -832,7 +833,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemOriginSITHandlerWithDOFSITNoA requstedApprovalsRequestedStatus := false subtestData.mtoServiceItem.RequestedApprovalsRequestedStatus = &requstedApprovalsRequestedStatus subtestData.mtoServiceItem.ReService.Code = models.ReServiceCodeDOFSIT - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -940,7 +941,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemOriginSITHandlerWithDOFSITWit requestedApprovalsRequestedStatus := false subtestData.mtoServiceItem.RequestedApprovalsRequestedStatus = &requestedApprovalsRequestedStatus subtestData.mtoServiceItem.ReService.Code = models.ReServiceCodeDOFSIT - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -1107,7 +1108,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemDestSITHandler() { suite.Run("Successful POST - Integration Test", func() { subtestData := makeSubtestData() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -1181,7 +1182,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemDestSITHandler() { SITEntryDate: &sitEntryDate, Reason: models.StringPointer("lorem ipsum"), } - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -1214,7 +1215,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemDestSITHandler() { suite.Run("Failure POST - Integration Test - Missing reason", func() { subtestData := makeSubtestData() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -1270,7 +1271,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemDestSITHandler() { HTTPRequest: subtestData.params.HTTPRequest, Body: payloads.MTOServiceItem(&subtestData.mtoServiceItem), } - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -1334,7 +1335,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemDestSITHandler() { HTTPRequest: subtestData.params.HTTPRequest, Body: payloads.MTOServiceItem(&subtestData.mtoServiceItem), } - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -1370,7 +1371,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemDestSITHandler() { // SETUP // Create the payload subtestData.mtoServiceItem.ReService.Code = models.ReServiceCodeDDDSIT - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} creator := mtoserviceitem.NewMTOServiceItemCreator(planner, builder, moveRouter, ghcrateengine.NewDomesticUnpackPricer(), ghcrateengine.NewDomesticPackPricer(), ghcrateengine.NewDomesticLinehaulPricer(), ghcrateengine.NewDomesticShorthaulPricer(), ghcrateengine.NewDomesticOriginPricer(), ghcrateengine.NewDomesticDestinationPricer(), ghcrateengine.NewFuelSurchargePricer()) handler := CreateMTOServiceItemHandler{ diff --git a/pkg/handlers/primeapiv2/mto_shipment_test.go b/pkg/handlers/primeapiv2/mto_shipment_test.go index 314dc9c3a5f..e6aa5916a17 100644 --- a/pkg/handlers/primeapiv2/mto_shipment_test.go +++ b/pkg/handlers/primeapiv2/mto_shipment_test.go @@ -31,6 +31,7 @@ import ( shipmentorchestrator "github.com/transcom/mymove/pkg/services/orchestrators/shipment" "github.com/transcom/mymove/pkg/services/ppmshipment" "github.com/transcom/mymove/pkg/services/query" + transportationoffice "github.com/transcom/mymove/pkg/services/transportation_office" "github.com/transcom/mymove/pkg/unit" ) @@ -38,7 +39,7 @@ func (suite *HandlerSuite) TestCreateMTOShipmentHandler() { builder := query.NewQueryBuilder() mtoChecker := movetaskorder.NewMoveTaskOrderChecker() - moveRouter := moveservices.NewMoveRouter() + moveRouter := moveservices.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) fetcher := fetch.NewFetcher(builder) addressCreator := address.NewAddressCreator() mtoShipmentCreator := mtoshipment.NewMTOShipmentCreatorV2(builder, fetcher, moveRouter, addressCreator) diff --git a/pkg/handlers/primeapiv3/api.go b/pkg/handlers/primeapiv3/api.go index e9c522f8d42..a61ecb63b21 100644 --- a/pkg/handlers/primeapiv3/api.go +++ b/pkg/handlers/primeapiv3/api.go @@ -23,6 +23,7 @@ import ( "github.com/transcom/mymove/pkg/services/ppmshipment" "github.com/transcom/mymove/pkg/services/query" signedcertification "github.com/transcom/mymove/pkg/services/signed_certification" + transportationoffice "github.com/transcom/mymove/pkg/services/transportation_office" ) // NewPrimeAPI returns the Prime API @@ -30,7 +31,7 @@ func NewPrimeAPI(handlerConfig handlers.HandlerConfig) *primev3operations.Mymove builder := query.NewQueryBuilder() fetcher := fetch.NewFetcher(builder) queryBuilder := query.NewQueryBuilder() - moveRouter := move.NewMoveRouter() + moveRouter := move.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) primeSpec, err := loads.Analyzed(primev3api.SwaggerJSON, "") if err != nil { diff --git a/pkg/handlers/primeapiv3/mto_service_item_test.go b/pkg/handlers/primeapiv3/mto_service_item_test.go index 1bc9362127c..f2253acd24b 100644 --- a/pkg/handlers/primeapiv3/mto_service_item_test.go +++ b/pkg/handlers/primeapiv3/mto_service_item_test.go @@ -25,6 +25,7 @@ import ( movetaskorder "github.com/transcom/mymove/pkg/services/move_task_order" mtoserviceitem "github.com/transcom/mymove/pkg/services/mto_service_item" "github.com/transcom/mymove/pkg/services/query" + transportationoffice "github.com/transcom/mymove/pkg/services/transportation_office" ) func (suite *HandlerSuite) TestCreateMTOServiceItemHandler() { @@ -89,7 +90,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemHandler() { mock.Anything, ).Return(400, nil) subtestData := makeSubtestData() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) creator := mtoserviceitem.NewMTOServiceItemCreator(planner, builder, moveRouter, ghcrateengine.NewDomesticUnpackPricer(), ghcrateengine.NewDomesticPackPricer(), ghcrateengine.NewDomesticLinehaulPricer(), ghcrateengine.NewDomesticShorthaulPricer(), ghcrateengine.NewDomesticOriginPricer(), ghcrateengine.NewDomesticDestinationPricer(), ghcrateengine.NewFuelSurchargePricer()) handler := CreateMTOServiceItemHandler{ suite.HandlerConfig(), @@ -141,7 +142,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemHandler() { Body: payloads.MTOServiceItem(&mtoServiceItem), } - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -279,7 +280,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemHandler() { suite.Run("POST failure - 404 - MTO is not available to Prime", func() { subtestData := makeSubtestData() mtoNotAvailable := factory.BuildMove(suite.DB(), nil, nil) - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -323,7 +324,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemHandler() { LinkOnly: true, }, }, nil) - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -474,7 +475,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemDomesticCratingHandler() { suite.Run("Successful POST - Integration Test - Domestic Crating", func() { subtestData := makeSubtestData() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -511,7 +512,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemDomesticCratingHandler() { suite.Run("Successful POST - Integration Test - Domestic Uncrating", func() { subtestData := makeSubtestData() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -634,7 +635,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemOriginSITHandler() { requestApprovalRequestedStatus := false subtestData.mtoServiceItem.RequestedApprovalsRequestedStatus = &requestApprovalRequestedStatus subtestData.mtoServiceItem.ReService.Code = models.ReServiceCodeDOPSIT - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -680,7 +681,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemOriginSITHandler() { requestApprovalRequestedStatus := false subtestData.mtoServiceItem.RequestedApprovalsRequestedStatus = &requestApprovalRequestedStatus - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -749,7 +750,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemOriginSITHandler() { }, nil) subtestData.mtoServiceItem.ReService.Code = models.ReServiceCodeDOASIT - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -833,7 +834,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemOriginSITHandlerWithDOFSITNoA requstedApprovalsRequestedStatus := false subtestData.mtoServiceItem.RequestedApprovalsRequestedStatus = &requstedApprovalsRequestedStatus subtestData.mtoServiceItem.ReService.Code = models.ReServiceCodeDOFSIT - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -941,7 +942,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemOriginSITHandlerWithDOFSITWit requestedApprovalsRequestedStatus := false subtestData.mtoServiceItem.RequestedApprovalsRequestedStatus = &requestedApprovalsRequestedStatus subtestData.mtoServiceItem.ReService.Code = models.ReServiceCodeDOFSIT - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -1108,7 +1109,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemDestSITHandler() { suite.Run("Successful POST - Integration Test", func() { subtestData := makeSubtestData() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -1182,7 +1183,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemDestSITHandler() { SITEntryDate: &sitEntryDate, Reason: models.StringPointer("lorem ipsum"), } - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -1215,7 +1216,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemDestSITHandler() { suite.Run("Failure POST - Integration Test - Missing reason", func() { subtestData := makeSubtestData() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -1271,7 +1272,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemDestSITHandler() { HTTPRequest: subtestData.params.HTTPRequest, Body: payloads.MTOServiceItem(&subtestData.mtoServiceItem), } - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -1335,7 +1336,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemDestSITHandler() { HTTPRequest: subtestData.params.HTTPRequest, Body: payloads.MTOServiceItem(&subtestData.mtoServiceItem), } - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -1371,7 +1372,7 @@ func (suite *HandlerSuite) TestCreateMTOServiceItemDestSITHandler() { // SETUP // Create the payload subtestData.mtoServiceItem.ReService.Code = models.ReServiceCodeDDDSIT - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), diff --git a/pkg/handlers/primeapiv3/mto_shipment_test.go b/pkg/handlers/primeapiv3/mto_shipment_test.go index c0443c77eb2..a46c0f0a90c 100644 --- a/pkg/handlers/primeapiv3/mto_shipment_test.go +++ b/pkg/handlers/primeapiv3/mto_shipment_test.go @@ -36,6 +36,7 @@ import ( paymentrequest "github.com/transcom/mymove/pkg/services/payment_request" "github.com/transcom/mymove/pkg/services/ppmshipment" "github.com/transcom/mymove/pkg/services/query" + transportationoffice "github.com/transcom/mymove/pkg/services/transportation_office" "github.com/transcom/mymove/pkg/unit" ) @@ -43,7 +44,7 @@ func (suite *HandlerSuite) TestCreateMTOShipmentHandler() { builder := query.NewQueryBuilder() mtoChecker := movetaskorder.NewMoveTaskOrderChecker() - moveRouter := moveservices.NewMoveRouter() + moveRouter := moveservices.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) fetcher := fetch.NewFetcher(builder) addressCreator := address.NewAddressCreator() addressUpdater := address.NewAddressUpdater() diff --git a/pkg/handlers/supportapi/api.go b/pkg/handlers/supportapi/api.go index ea5aaf3ae8b..fa858b2140c 100644 --- a/pkg/handlers/supportapi/api.go +++ b/pkg/handlers/supportapi/api.go @@ -26,12 +26,13 @@ import ( signedcertification "github.com/transcom/mymove/pkg/services/signed_certification" internalmovetaskorder "github.com/transcom/mymove/pkg/services/support/move_task_order" transportationaccountingcode "github.com/transcom/mymove/pkg/services/transportation_accounting_code" + transportationoffice "github.com/transcom/mymove/pkg/services/transportation_office" ) // NewSupportAPIHandler returns a handler for the Prime API func NewSupportAPIHandler(handlerConfig handlers.HandlerConfig) http.Handler { queryBuilder := query.NewQueryBuilder() - moveRouter := move.NewMoveRouter() + moveRouter := move.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) shipmentFetcher := mtoshipment.NewMTOShipmentFetcher() addressCreator := address.NewAddressCreator() supportSpec, err := loads.Analyzed(supportapi.SwaggerJSON, "") diff --git a/pkg/handlers/supportapi/move_task_order_test.go b/pkg/handlers/supportapi/move_task_order_test.go index f10fde1438e..ebbfa9ea193 100644 --- a/pkg/handlers/supportapi/move_task_order_test.go +++ b/pkg/handlers/supportapi/move_task_order_test.go @@ -26,6 +26,7 @@ import ( "github.com/transcom/mymove/pkg/services/query" supportMocks "github.com/transcom/mymove/pkg/services/support/mocks" internalmovetaskorder "github.com/transcom/mymove/pkg/services/support/move_task_order" + transportationoffice "github.com/transcom/mymove/pkg/services/transportation_office" ) func (suite *HandlerSuite) TestListMTOsHandler() { @@ -167,7 +168,7 @@ func (suite *HandlerSuite) TestMakeMoveAvailableHandlerIntegrationSuccess() { } handlerConfig := suite.HandlerConfig() queryBuilder := query.NewQueryBuilder() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -382,7 +383,7 @@ func (suite *HandlerSuite) TestCreateMoveTaskOrderRequestHandler() { IfMatch: createdMTO.ETag, } queryBuilder := query.NewQueryBuilder() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), diff --git a/pkg/handlers/supportapi/mto_service_item_test.go b/pkg/handlers/supportapi/mto_service_item_test.go index 44a56716688..ad6177e8ea0 100644 --- a/pkg/handlers/supportapi/mto_service_item_test.go +++ b/pkg/handlers/supportapi/mto_service_item_test.go @@ -26,6 +26,7 @@ import ( mtoserviceitem "github.com/transcom/mymove/pkg/services/mto_service_item" mtoshipment "github.com/transcom/mymove/pkg/services/mto_shipment" "github.com/transcom/mymove/pkg/services/query" + transportationoffice "github.com/transcom/mymove/pkg/services/transportation_office" ) // Create a service item on a Move with Approvals Requested status @@ -75,7 +76,7 @@ func (suite *HandlerSuite) TestUpdateMTOServiceItemStatusHandlerApproveSuccess() handlerConfig := suite.HandlerConfig() queryBuilder := query.NewQueryBuilder() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) shipmentFetcher := mtoshipment.NewMTOShipmentFetcher() addressCreator := address.NewAddressCreator() planner := &routemocks.Planner{} @@ -131,7 +132,7 @@ func (suite *HandlerSuite) TestUpdateMTOServiceItemStatusHandlerRejectSuccess() handlerConfig := suite.HandlerConfig() queryBuilder := query.NewQueryBuilder() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) shipmentFetcher := mtoshipment.NewMTOShipmentFetcher() addressCreator := address.NewAddressCreator() planner := &routemocks.Planner{} @@ -187,7 +188,7 @@ func (suite *HandlerSuite) TestUpdateMTOServiceItemStatusHandlerRejectionFailedN handlerConfig := suite.HandlerConfig() queryBuilder := query.NewQueryBuilder() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) shipmentFetcher := mtoshipment.NewMTOShipmentFetcher() addressCreator := address.NewAddressCreator() planner := &routemocks.Planner{} diff --git a/pkg/handlers/supportapi/mto_shipment_test.go b/pkg/handlers/supportapi/mto_shipment_test.go index c1a9bb7018b..c111449d875 100644 --- a/pkg/handlers/supportapi/mto_shipment_test.go +++ b/pkg/handlers/supportapi/mto_shipment_test.go @@ -23,6 +23,7 @@ import ( mtoserviceitem "github.com/transcom/mymove/pkg/services/mto_service_item" mtoshipment "github.com/transcom/mymove/pkg/services/mto_shipment" "github.com/transcom/mymove/pkg/services/query" + transportationoffice "github.com/transcom/mymove/pkg/services/transportation_office" ) func (suite *HandlerSuite) TestUpdateMTOShipmentStatusHandler() { @@ -91,7 +92,7 @@ func (suite *HandlerSuite) TestUpdateMTOShipmentStatusHandler() { // Used for all tests except 500 error: queryBuilder := query.NewQueryBuilder() fetcher := fetch.NewFetcher(queryBuilder) - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), diff --git a/pkg/services/mocks/TransportationOfficesFetcher.go b/pkg/services/mocks/TransportationOfficesFetcher.go index eed32753594..754823af361 100644 --- a/pkg/services/mocks/TransportationOfficesFetcher.go +++ b/pkg/services/mocks/TransportationOfficesFetcher.go @@ -136,6 +136,12 @@ func (_m *TransportationOfficesFetcher) GetTransportationOffices(appCtx appconte return r0, r1 } +func (_m *TransportationOfficesFetcher) FindClosestCounselingOffice(appCtx appcontext.AppContext, dutyLocationID uuid.UUID) (models.TransportationOffice, error) { + _m.GetCounselingOffices(appCtx, dutyLocationID) + //TODO: Fix + return models.TransportationOffice{}, nil +} + // NewTransportationOfficesFetcher creates a new instance of TransportationOfficesFetcher. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. // The first argument is typically a *testing.T value. func NewTransportationOfficesFetcher(t interface { diff --git a/pkg/services/move/move_router.go b/pkg/services/move/move_router.go index d06994bed41..9e3f35a7483 100644 --- a/pkg/services/move/move_router.go +++ b/pkg/services/move/move_router.go @@ -17,11 +17,14 @@ import ( ) type moveRouter struct { + transportationOfficesFetcher services.TransportationOfficesFetcher } // NewMoveRouter creates a new moveRouter service -func NewMoveRouter() services.MoveRouter { - return &moveRouter{} +func NewMoveRouter(transportationOfficeFetcher services.TransportationOfficesFetcher) services.MoveRouter { + return &moveRouter{ + transportationOfficesFetcher: transportationOfficeFetcher, + } } // Submit is called when the customer submits amended orders or submits their move. It determines whether @@ -188,16 +191,6 @@ func (router moveRouter) sendToServiceCounselor(appCtx appcontext.AppContext, mo } } - // if move.IsPPMOnly() && !orders.OriginDutyLocation.ProvidesServicesCounseling { - // originLocationID := uuid.FromStringOrNil(orders.OriginDutyLocationID.String()) - - // officeList, err := ShowCounselingOfficesHandler.TransportationOfficesFetcher.GetCounselingOffices(appCtx, originLocationID) - // if err != nil { - - // } - - // } - if move.Status == models.MoveStatusNeedsServiceCounseling { return nil } @@ -228,6 +221,15 @@ func (router moveRouter) sendToServiceCounselor(appCtx appcontext.AppContext, mo move.MTOShipments[i].PPMShipment.Status = models.PPMShipmentStatusSubmitted // actual expense reimbursement is always true for civilian moves move.MTOShipments[i].PPMShipment.IsActualExpenseReimbursement = models.BoolPointer(isCivilian) + if move.IsPPMOnly() && !orders.OriginDutyLocation.ProvidesServicesCounseling { + closestCounselingOffice, err := router.transportationOfficesFetcher.FindClosestCounselingOffice(appCtx, *move.Orders.OriginDutyLocationID) + if err != nil { + msg := "Failure setting PPM counseling office to closest service counseling office" + appCtx.Logger().Error(msg, zap.Error(err)) + return apperror.NewQueryError("Closest Counseling Office", err, "Failed to find counseling office that provides counseling") + } + move.CounselingOffice = &closestCounselingOffice + } if verrs, err := appCtx.DB().ValidateAndUpdate(&move.MTOShipments[i]); verrs.HasAny() || err != nil { msg := "failure saving shipment when routing move submission" diff --git a/pkg/services/move/move_router_test.go b/pkg/services/move/move_router_test.go index 7b1e21f0d2f..89d6d6f351d 100644 --- a/pkg/services/move/move_router_test.go +++ b/pkg/services/move/move_router_test.go @@ -9,13 +9,14 @@ import ( "github.com/transcom/mymove/pkg/apperror" "github.com/transcom/mymove/pkg/factory" "github.com/transcom/mymove/pkg/models" + transportationoffice "github.com/transcom/mymove/pkg/services/transportation_office" storageTest "github.com/transcom/mymove/pkg/storage/test" "github.com/transcom/mymove/pkg/testdatagen" "github.com/transcom/mymove/pkg/uploader" ) func (suite *MoveServiceSuite) TestMoveApproval() { - moveRouter := NewMoveRouter() + moveRouter := NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) suite.Run("from valid statuses", func() { move := factory.BuildMove(nil, nil, nil) @@ -61,7 +62,7 @@ func (suite *MoveServiceSuite) TestMoveApproval() { } func (suite *MoveServiceSuite) TestMoveSubmission() { - moveRouter := NewMoveRouter() + moveRouter := NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) suite.Run("returns error when needsServicesCounseling cannot find move", func() { // Under test: MoveRouter.Submit @@ -992,7 +993,7 @@ func (suite *MoveServiceSuite) TestMoveSubmission() { } func (suite *MoveServiceSuite) TestMoveCancellation() { - moveRouter := NewMoveRouter() + moveRouter := NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) suite.Run("Cancel move with no shipments", func() { move := factory.BuildMove(suite.DB(), nil, nil) @@ -1056,7 +1057,7 @@ func (suite *MoveServiceSuite) TestMoveCancellation() { } func (suite *MoveServiceSuite) TestSendToOfficeUser() { - moveRouter := NewMoveRouter() + moveRouter := NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) suite.Run("from valid statuses", func() { move := factory.BuildMove(suite.DB(), nil, nil) @@ -1114,7 +1115,7 @@ func (suite *MoveServiceSuite) TestSendToOfficeUser() { } func (suite *MoveServiceSuite) TestApproveOrRequestApproval() { - moveRouter := NewMoveRouter() + moveRouter := NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) suite.Run("approves the move if TOO no longer has actions to perform", func() { move := factory.BuildApprovalsRequestedMove(suite.DB(), nil, nil) @@ -1273,7 +1274,7 @@ func (suite *MoveServiceSuite) TestApproveOrRequestApproval() { } func (suite *MoveServiceSuite) TestCompleteServiceCounseling() { - moveRouter := NewMoveRouter() + moveRouter := NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) suite.Run("status changed to service counseling completed", func() { move := factory.BuildStubbedMoveWithStatus(models.MoveStatusNeedsServiceCounseling) diff --git a/pkg/services/move_history/move_history_fetcher_test.go b/pkg/services/move_history/move_history_fetcher_test.go index f84af138e33..11e26fdd421 100644 --- a/pkg/services/move_history/move_history_fetcher_test.go +++ b/pkg/services/move_history/move_history_fetcher_test.go @@ -24,6 +24,7 @@ import ( mtoshipment "github.com/transcom/mymove/pkg/services/mto_shipment" "github.com/transcom/mymove/pkg/services/query" "github.com/transcom/mymove/pkg/services/reweigh" + transportationoffice "github.com/transcom/mymove/pkg/services/transportation_office" "github.com/transcom/mymove/pkg/testdatagen" "github.com/transcom/mymove/pkg/unit" ) @@ -365,7 +366,7 @@ func (suite *MoveHistoryServiceSuite) TestMoveHistoryFetcherScenarios() { suite.Run("has audit history records for service item", func() { builder := query.NewQueryBuilder() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) shipmentFetcher := mtoshipment.NewMTOShipmentFetcher() addressCreator := address.NewAddressCreator() planner := &routemocks.Planner{} @@ -542,7 +543,7 @@ func (suite *MoveHistoryServiceSuite) TestMoveHistoryFetcherScenarios() { }, }, nil) builder := query.NewQueryBuilder() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -615,7 +616,7 @@ func (suite *MoveHistoryServiceSuite) TestMoveHistoryFetcherScenarios() { }, }, nil) builder := query.NewQueryBuilder() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), diff --git a/pkg/services/move_task_order/move_task_order_updater_test.go b/pkg/services/move_task_order/move_task_order_updater_test.go index bd1e001e494..9c82b65fc51 100644 --- a/pkg/services/move_task_order/move_task_order_updater_test.go +++ b/pkg/services/move_task_order/move_task_order_updater_test.go @@ -21,11 +21,12 @@ import ( mtoserviceitem "github.com/transcom/mymove/pkg/services/mto_service_item" "github.com/transcom/mymove/pkg/services/query" signedcertification "github.com/transcom/mymove/pkg/services/signed_certification" + transportationoffice "github.com/transcom/mymove/pkg/services/transportation_office" "github.com/transcom/mymove/pkg/testdatagen" ) func (suite *MoveTaskOrderServiceSuite) TestMoveTaskOrderUpdater_UpdateStatusServiceCounselingCompleted() { - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) queryBuilder := query.NewQueryBuilder() planner := &routemocks.Planner{} ppmEstimator := &mocks.PPMEstimator{} @@ -339,7 +340,7 @@ func (suite *MoveTaskOrderServiceSuite) TestMoveTaskOrderUpdater_UpdateStatusSer func (suite *MoveTaskOrderServiceSuite) TestMoveTaskOrderUpdater_UpdatePostCounselingInfo() { queryBuilder := query.NewQueryBuilder() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} ppmEstimator := &mocks.PPMEstimator{} planner.On("ZipTransitDistance", @@ -506,7 +507,7 @@ func (suite *MoveTaskOrderServiceSuite) TestMoveTaskOrderUpdater_ShowHide() { // Set up the necessary updater objects: queryBuilder := query.NewQueryBuilder() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} ppmEstimator := &mocks.PPMEstimator{} planner.On("ZipTransitDistance", @@ -713,7 +714,7 @@ func (suite *MoveTaskOrderServiceSuite) TestMoveTaskOrderUpdater_MakeAvailableTo suite.Run("Service item creator is not called if move fails to get approved", func() { mockserviceItemCreator := &mocks.MTOServiceItemCreator{} queryBuilder := query.NewQueryBuilder() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) mtoUpdater := mt.NewMoveTaskOrderUpdater(queryBuilder, mockserviceItemCreator, moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), ppmEstimator) // Create move in DRAFT status, which should fail to get approved move := factory.BuildMove(suite.DB(), nil, nil) @@ -733,7 +734,7 @@ func (suite *MoveTaskOrderServiceSuite) TestMoveTaskOrderUpdater_MakeAvailableTo suite.Run("When ETag is stale", func() { mockserviceItemCreator := &mocks.MTOServiceItemCreator{} queryBuilder := query.NewQueryBuilder() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) mtoUpdater := mt.NewMoveTaskOrderUpdater(queryBuilder, mockserviceItemCreator, moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), ppmEstimator) move := factory.BuildSubmittedMove(suite.DB(), nil, nil) @@ -748,7 +749,7 @@ func (suite *MoveTaskOrderServiceSuite) TestMoveTaskOrderUpdater_MakeAvailableTo suite.Run("Makes move available to Prime and creates Move management and Service counseling service items when both are specified", func() { queryBuilder := query.NewQueryBuilder() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -786,7 +787,7 @@ func (suite *MoveTaskOrderServiceSuite) TestMoveTaskOrderUpdater_MakeAvailableTo suite.Run("Makes move available to Prime and only creates Move management when it's the only one specified", func() { queryBuilder := query.NewQueryBuilder() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -820,7 +821,7 @@ func (suite *MoveTaskOrderServiceSuite) TestMoveTaskOrderUpdater_MakeAvailableTo suite.Run("Makes move available to Prime and only creates CS service item when it's the only one specified", func() { queryBuilder := query.NewQueryBuilder() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} serviceItemCreator := mtoserviceitem.NewMTOServiceItemCreator(planner, queryBuilder, moveRouter, ghcrateengine.NewDomesticUnpackPricer(), ghcrateengine.NewDomesticPackPricer(), ghcrateengine.NewDomesticLinehaulPricer(), ghcrateengine.NewDomesticShorthaulPricer(), ghcrateengine.NewDomesticOriginPricer(), ghcrateengine.NewDomesticDestinationPricer(), ghcrateengine.NewFuelSurchargePricer()) mtoUpdater := mt.NewMoveTaskOrderUpdater(queryBuilder, serviceItemCreator, moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), ppmEstimator) @@ -849,7 +850,7 @@ func (suite *MoveTaskOrderServiceSuite) TestMoveTaskOrderUpdater_MakeAvailableTo suite.Run("Does not create service items if neither CS nor MS are requested", func() { queryBuilder := query.NewQueryBuilder() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) mockserviceItemCreator := &mocks.MTOServiceItemCreator{} mtoUpdater := mt.NewMoveTaskOrderUpdater(queryBuilder, mockserviceItemCreator, moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), ppmEstimator) @@ -873,7 +874,7 @@ func (suite *MoveTaskOrderServiceSuite) TestMoveTaskOrderUpdater_MakeAvailableTo suite.Run("Does not make move available to prime if Order is missing required fields", func() { mockserviceItemCreator := &mocks.MTOServiceItemCreator{} queryBuilder := query.NewQueryBuilder() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) mtoUpdater := mt.NewMoveTaskOrderUpdater(queryBuilder, mockserviceItemCreator, moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), ppmEstimator) orderWithoutDefaults := factory.BuildOrderWithoutDefaults(suite.DB(), nil, nil) @@ -928,7 +929,7 @@ func (suite *MoveTaskOrderServiceSuite) TestMoveTaskOrderUpdater_BillableWeights suite.Run("Service item creator is not called if move fails to get approved", func() { mockserviceItemCreator := &mocks.MTOServiceItemCreator{} queryBuilder := query.NewQueryBuilder() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) mtoUpdater := mt.NewMoveTaskOrderUpdater(queryBuilder, mockserviceItemCreator, moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), ppmEstimator) move := factory.BuildMove(suite.DB(), nil, nil) eTag := etag.GenerateEtag(move.UpdatedAt) @@ -942,7 +943,7 @@ func (suite *MoveTaskOrderServiceSuite) TestMoveTaskOrderUpdater_BillableWeights suite.Run("When ETag is stale", func() { mockserviceItemCreator := &mocks.MTOServiceItemCreator{} queryBuilder := query.NewQueryBuilder() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) mtoUpdater := mt.NewMoveTaskOrderUpdater(queryBuilder, mockserviceItemCreator, moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), ppmEstimator) move := factory.BuildSubmittedMove(suite.DB(), nil, nil) @@ -959,7 +960,7 @@ func (suite *MoveTaskOrderServiceSuite) TestMoveTaskOrderUpdater_TIORemarks() { mockserviceItemCreator := &mocks.MTOServiceItemCreator{} ppmEstimator := &mocks.PPMEstimator{} queryBuilder := query.NewQueryBuilder() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) setUpSignedCertificationCreatorMock := func(returnValue ...interface{}) services.SignedCertificationCreator { mockCreator := &mocks.SignedCertificationCreator{} @@ -1034,7 +1035,7 @@ func (suite *MoveTaskOrderServiceSuite) TestMoveTaskOrderUpdater_UpdatePPMType() // Set up the necessary updater objects: queryBuilder := query.NewQueryBuilder() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} ppmEstimator := &mocks.PPMEstimator{} planner.On("ZipTransitDistance", diff --git a/pkg/services/mto_service_item/mto_service_item_creator_test.go b/pkg/services/mto_service_item/mto_service_item_creator_test.go index e9799db0278..8f160a508bf 100644 --- a/pkg/services/mto_service_item/mto_service_item_creator_test.go +++ b/pkg/services/mto_service_item/mto_service_item_creator_test.go @@ -27,6 +27,7 @@ import ( "github.com/transcom/mymove/pkg/services/ghcrateengine" moverouter "github.com/transcom/mymove/pkg/services/move" "github.com/transcom/mymove/pkg/services/query" + transportationoffice "github.com/transcom/mymove/pkg/services/transportation_office" "github.com/transcom/mymove/pkg/testdatagen" "github.com/transcom/mymove/pkg/unit" ) @@ -187,7 +188,7 @@ func (suite *MTOServiceItemServiceSuite) TestCreateMTOServiceItemWithInvalidMove // Error because we cannot create service items before move is approved. builder := query.NewQueryBuilder() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &mocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -215,7 +216,7 @@ func (suite *MTOServiceItemServiceSuite) TestCreateMTOServiceItemWithInvalidMove func (suite *MTOServiceItemServiceSuite) TestCreateMTOServiceItem() { builder := query.NewQueryBuilder() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &mocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -1025,7 +1026,7 @@ func (suite *MTOServiceItemServiceSuite) TestCreateOriginSITServiceItem() { } builder := query.NewQueryBuilder() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &mocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -1074,7 +1075,7 @@ func (suite *MTOServiceItemServiceSuite) TestCreateOriginSITServiceItem() { } builder := query.NewQueryBuilder() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &mocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -1148,7 +1149,7 @@ func (suite *MTOServiceItemServiceSuite) TestCreateOriginSITServiceItem() { } builder := query.NewQueryBuilder() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &mocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -1274,7 +1275,7 @@ func (suite *MTOServiceItemServiceSuite) TestCreateOriginSITServiceItem() { } builder := query.NewQueryBuilder() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &mocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -1308,7 +1309,7 @@ func (suite *MTOServiceItemServiceSuite) TestCreateOriginSITServiceItem() { } builder := query.NewQueryBuilder() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &mocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -1341,7 +1342,7 @@ func (suite *MTOServiceItemServiceSuite) TestCreateOriginSITServiceItem() { } builder := query.NewQueryBuilder() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &mocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -1416,7 +1417,7 @@ func (suite *MTOServiceItemServiceSuite) TestCreateOriginSITServiceItemFailToCre Reason: &reason, } builder := query.NewQueryBuilder() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &mocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -1450,7 +1451,7 @@ func (suite *MTOServiceItemServiceSuite) TestCreateDestSITServiceItem() { }, }, nil) builder := query.NewQueryBuilder() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &mocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -1749,7 +1750,7 @@ func (suite *MTOServiceItemServiceSuite) TestCreateDestSITServiceItem() { } builder := query.NewQueryBuilder() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &mocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), diff --git a/pkg/services/mto_service_item/mto_service_item_updater_test.go b/pkg/services/mto_service_item/mto_service_item_updater_test.go index f2c6889ca98..094f7c32870 100644 --- a/pkg/services/mto_service_item/mto_service_item_updater_test.go +++ b/pkg/services/mto_service_item/mto_service_item_updater_test.go @@ -28,6 +28,7 @@ import ( mtoshipment "github.com/transcom/mymove/pkg/services/mto_shipment" "github.com/transcom/mymove/pkg/services/query" sitstatus "github.com/transcom/mymove/pkg/services/sit_status" + transportationoffice "github.com/transcom/mymove/pkg/services/transportation_office" storageTest "github.com/transcom/mymove/pkg/storage/test" "github.com/transcom/mymove/pkg/testdatagen" "github.com/transcom/mymove/pkg/unit" @@ -37,7 +38,7 @@ import ( func (suite *MTOServiceItemServiceSuite) TestMTOServiceItemUpdater() { builder := query.NewQueryBuilder() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) shipmentFetcher := mtoshipment.NewMTOShipmentFetcher() addressCreator := address.NewAddressCreator() sitStatusService := sitstatus.NewShipmentSITStatus() @@ -1748,7 +1749,7 @@ func (suite *MTOServiceItemServiceSuite) createServiceItemForMoveWithUnacknowled func (suite *MTOServiceItemServiceSuite) TestUpdateMTOServiceItemStatus() { builder := query.NewQueryBuilder() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) shipmentFetcher := mtoshipment.NewMTOShipmentFetcher() addressCreator := address.NewAddressCreator() planner := &mocks.Planner{} diff --git a/pkg/services/mto_shipment/mto_shipment_creator_test.go b/pkg/services/mto_shipment/mto_shipment_creator_test.go index 82e057c61f6..91a1074e37c 100644 --- a/pkg/services/mto_shipment/mto_shipment_creator_test.go +++ b/pkg/services/mto_shipment/mto_shipment_creator_test.go @@ -14,6 +14,7 @@ import ( "github.com/transcom/mymove/pkg/services/fetch" moverouter "github.com/transcom/mymove/pkg/services/move" "github.com/transcom/mymove/pkg/services/query" + transportationoffice "github.com/transcom/mymove/pkg/services/transportation_office" "github.com/transcom/mymove/pkg/testdatagen" "github.com/transcom/mymove/pkg/unit" ) @@ -29,7 +30,7 @@ func (suite *MTOShipmentServiceSuite) createSubtestData(customs []factory.Custom subtestData.move = factory.BuildMove(suite.DB(), customs, nil) builder := query.NewQueryBuilder() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) fetcher := fetch.NewFetcher(builder) addressCreator := address.NewAddressCreator() @@ -45,7 +46,7 @@ func (suite *MTOShipmentServiceSuite) createSubtestDataV2(customs []factory.Cust subtestData.move = factory.BuildMove(suite.DB(), customs, nil) builder := query.NewQueryBuilder() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) fetcher := fetch.NewFetcher(builder) addressCreator := address.NewAddressCreator() diff --git a/pkg/services/mto_shipment/mto_shipment_updater_test.go b/pkg/services/mto_shipment/mto_shipment_updater_test.go index dfabece3112..67aa1beab14 100644 --- a/pkg/services/mto_shipment/mto_shipment_updater_test.go +++ b/pkg/services/mto_shipment/mto_shipment_updater_test.go @@ -25,6 +25,7 @@ import ( moveservices "github.com/transcom/mymove/pkg/services/move" mtoserviceitem "github.com/transcom/mymove/pkg/services/mto_service_item" "github.com/transcom/mymove/pkg/services/query" + transportationoffice "github.com/transcom/mymove/pkg/services/transportation_office" "github.com/transcom/mymove/pkg/testdatagen" "github.com/transcom/mymove/pkg/unit" ) @@ -51,7 +52,7 @@ func (suite *MTOShipmentServiceSuite) TestMTOShipmentUpdater() { mock.Anything, mock.Anything, ).Return(1000, nil) - moveRouter := moveservices.NewMoveRouter() + moveRouter := moveservices.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) moveWeights := moveservices.NewMoveWeights(NewShipmentReweighRequester()) mockShipmentRecalculator := mockservices.PaymentRequestShipmentRecalculator{} mockShipmentRecalculator.On("ShipmentRecalculatePaymentRequest", @@ -1787,7 +1788,7 @@ func (suite *MTOShipmentServiceSuite) TestUpdateMTOShipmentStatus() { } builder := query.NewQueryBuilder() - moveRouter := moveservices.NewMoveRouter() + moveRouter := moveservices.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &mocks.Planner{} var TransitDistancePickupArg string var TransitDistanceDestinationArg string @@ -2401,7 +2402,7 @@ func (suite *MTOShipmentServiceSuite) TestMTOShipmentsMTOAvailableToPrime() { builder := query.NewQueryBuilder() fetcher := fetch.NewFetcher(builder) planner := &mocks.Planner{} - moveRouter := moveservices.NewMoveRouter() + moveRouter := moveservices.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) moveWeights := moveservices.NewMoveWeights(NewShipmentReweighRequester()) mockShipmentRecalculator := mockservices.PaymentRequestShipmentRecalculator{} mockShipmentRecalculator.On("ShipmentRecalculatePaymentRequest", @@ -2470,7 +2471,7 @@ func (suite *MTOShipmentServiceSuite) TestUpdateShipmentEstimatedWeightMoveExces builder := query.NewQueryBuilder() fetcher := fetch.NewFetcher(builder) planner := &mocks.Planner{} - moveRouter := moveservices.NewMoveRouter() + moveRouter := moveservices.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) moveWeights := moveservices.NewMoveWeights(NewShipmentReweighRequester()) mockShipmentRecalculator := mockservices.PaymentRequestShipmentRecalculator{} mockShipmentRecalculator.On("ShipmentRecalculatePaymentRequest", @@ -2653,7 +2654,7 @@ func (suite *MTOShipmentServiceSuite) TestUpdateShipmentActualWeightAutoReweigh( builder := query.NewQueryBuilder() fetcher := fetch.NewFetcher(builder) planner := &mocks.Planner{} - moveRouter := moveservices.NewMoveRouter() + moveRouter := moveservices.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) moveWeights := moveservices.NewMoveWeights(NewShipmentReweighRequester()) mockShipmentRecalculator := mockservices.PaymentRequestShipmentRecalculator{} mockShipmentRecalculator.On("ShipmentRecalculatePaymentRequest", @@ -2792,7 +2793,7 @@ func (suite *MTOShipmentServiceSuite) TestUpdateShipmentNullableFields() { builder := query.NewQueryBuilder() fetcher := fetch.NewFetcher(builder) planner := &mocks.Planner{} - moveRouter := moveservices.NewMoveRouter() + moveRouter := moveservices.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) mockShipmentRecalculator := mockservices.PaymentRequestShipmentRecalculator{} mockShipmentRecalculator.On("ShipmentRecalculatePaymentRequest", mock.AnythingOfType("*appcontext.appContext"), @@ -2943,7 +2944,7 @@ func (suite *MTOShipmentServiceSuite) TestUpdateStatusServiceItems() { } builder := query.NewQueryBuilder() - moveRouter := moveservices.NewMoveRouter() + moveRouter := moveservices.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &mocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), diff --git a/pkg/services/mto_shipment/shipment_approver_test.go b/pkg/services/mto_shipment/shipment_approver_test.go index 943cd4edb72..f8cca9b5477 100644 --- a/pkg/services/mto_shipment/shipment_approver_test.go +++ b/pkg/services/mto_shipment/shipment_approver_test.go @@ -22,6 +22,7 @@ import ( moverouter "github.com/transcom/mymove/pkg/services/move" mtoserviceitem "github.com/transcom/mymove/pkg/services/mto_service_item" "github.com/transcom/mymove/pkg/services/query" + transportationoffice "github.com/transcom/mymove/pkg/services/transportation_office" "github.com/transcom/mymove/pkg/testdatagen" "github.com/transcom/mymove/pkg/unit" ) @@ -85,7 +86,7 @@ func (suite *MTOShipmentServiceSuite) createApproveShipmentSubtestData() (subtes router := NewShipmentRouter() builder := query.NewQueryBuilder() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &mocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), diff --git a/pkg/services/mto_shipment/shipment_cancellation_requester_test.go b/pkg/services/mto_shipment/shipment_cancellation_requester_test.go index 0d2b4c33310..8c9a9ea1994 100644 --- a/pkg/services/mto_shipment/shipment_cancellation_requester_test.go +++ b/pkg/services/mto_shipment/shipment_cancellation_requester_test.go @@ -11,11 +11,12 @@ import ( "github.com/transcom/mymove/pkg/factory" "github.com/transcom/mymove/pkg/models" moveservices "github.com/transcom/mymove/pkg/services/move" + transportationoffice "github.com/transcom/mymove/pkg/services/transportation_office" ) func (suite *MTOShipmentServiceSuite) TestRequestShipmentCancellation() { router := NewShipmentRouter() - moveRouter := moveservices.NewMoveRouter() + moveRouter := moveservices.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) requester := NewShipmentCancellationRequester(router, moveRouter) suite.Run("If the shipment diversion is requested successfully, it should update the shipment status in the DB", func() { @@ -108,7 +109,7 @@ func (suite *MTOShipmentServiceSuite) TestRequestShipmentCancellation() { suite.Run("It calls RequestCancellation on the ShipmentRouter", func() { shipmentRouter := NewShipmentRouter() - moveRouter := moveservices.NewMoveRouter() + moveRouter := moveservices.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) requester := NewShipmentCancellationRequester(shipmentRouter, moveRouter) // valid pickupdate is anytime after the request to cancel date actualPickupDate := time.Now().AddDate(0, 0, 1) @@ -143,7 +144,7 @@ func (suite *MTOShipmentServiceSuite) TestRequestShipmentCancellation() { suite.Run("It calls RequestCancellation on shipment with invalid actualPickupDate", func() { shipmentRouter := NewShipmentRouter() - moveRouter := moveservices.NewMoveRouter() + moveRouter := moveservices.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) requester := NewShipmentCancellationRequester(shipmentRouter, moveRouter) actualPickupDate := time.Now() shipment := factory.BuildMTOShipmentMinimal(suite.DB(), []factory.Customization{ diff --git a/pkg/services/mto_shipment/shipment_deleter_test.go b/pkg/services/mto_shipment/shipment_deleter_test.go index 1e0ca2796f6..204ff1d157c 100644 --- a/pkg/services/mto_shipment/shipment_deleter_test.go +++ b/pkg/services/mto_shipment/shipment_deleter_test.go @@ -19,11 +19,12 @@ import ( movetaskorder "github.com/transcom/mymove/pkg/services/move_task_order" mtoserviceitem "github.com/transcom/mymove/pkg/services/mto_service_item" "github.com/transcom/mymove/pkg/services/query" + transportationoffice "github.com/transcom/mymove/pkg/services/transportation_office" ) func (suite *MTOShipmentServiceSuite) TestShipmentDeleter() { builder := query.NewQueryBuilder() - moveRouter := moveservices.NewMoveRouter() + moveRouter := moveservices.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -77,7 +78,7 @@ func (suite *MTOShipmentServiceSuite) TestShipmentDeleter() { }) suite.Run("Returns an error when the Move is neither in Draft nor in NeedsServiceCounseling status", func() { - moveRouter := moveservices.NewMoveRouter() + moveRouter := moveservices.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) shipmentDeleter := NewShipmentDeleter(moveTaskOrderUpdater, moveRouter) shipment := factory.BuildMTOShipmentMinimal(suite.DB(), nil, nil) move := shipment.MoveTaskOrder @@ -96,7 +97,7 @@ func (suite *MTOShipmentServiceSuite) TestShipmentDeleter() { }) suite.Run("Soft deletes the shipment when it is found", func() { - moveRouter := moveservices.NewMoveRouter() + moveRouter := moveservices.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) shipmentDeleter := NewShipmentDeleter(moveTaskOrderUpdater, moveRouter) shipment := factory.BuildMTOShipmentMinimal(suite.DB(), nil, nil) @@ -138,7 +139,7 @@ func (suite *MTOShipmentServiceSuite) TestShipmentDeleter() { }) suite.Run("Soft deletes the shipment when it is found and check if shipment_seq_num changed", func() { - moveRouter := moveservices.NewMoveRouter() + moveRouter := moveservices.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) move := factory.BuildMove(suite.DB(), nil, nil) shipmentDeleter := NewShipmentDeleter(moveTaskOrderUpdater, moveRouter) shipment := factory.BuildMTOShipmentMinimal(suite.DB(), []factory.Customization{ @@ -201,7 +202,7 @@ func (suite *MTOShipmentServiceSuite) TestShipmentDeleter() { }) suite.Run("Returns not found error when the shipment is already deleted", func() { - moveRouter := moveservices.NewMoveRouter() + moveRouter := moveservices.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) shipmentDeleter := NewShipmentDeleter(moveTaskOrderUpdater, moveRouter) shipment := factory.BuildMTOShipmentMinimal(suite.DB(), nil, nil) session := suite.AppContextWithSessionForTest(&auth.Session{ @@ -218,7 +219,7 @@ func (suite *MTOShipmentServiceSuite) TestShipmentDeleter() { }) suite.Run("Soft deletes the associated PPM shipment", func() { - moveRouter := moveservices.NewMoveRouter() + moveRouter := moveservices.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) shipmentDeleter := NewShipmentDeleter(moveTaskOrderUpdater, moveRouter) ppmShipment := factory.BuildPPMShipment(suite.DB(), []factory.Customization{ { @@ -253,7 +254,7 @@ func (suite *MTOShipmentServiceSuite) TestShipmentDeleter() { func (suite *MTOShipmentServiceSuite) TestPrimeShipmentDeleter() { builder := query.NewQueryBuilder() - moveRouter := moveservices.NewMoveRouter() + moveRouter := moveservices.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &routemocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), diff --git a/pkg/services/mto_shipment/shipment_diversion_approver_test.go b/pkg/services/mto_shipment/shipment_diversion_approver_test.go index 73195c53c4e..e43319b2fba 100644 --- a/pkg/services/mto_shipment/shipment_diversion_approver_test.go +++ b/pkg/services/mto_shipment/shipment_diversion_approver_test.go @@ -11,11 +11,12 @@ import ( "github.com/transcom/mymove/pkg/factory" "github.com/transcom/mymove/pkg/models" moverouter "github.com/transcom/mymove/pkg/services/move" + transportationoffice "github.com/transcom/mymove/pkg/services/transportation_office" ) func (suite *MTOShipmentServiceSuite) TestApproveShipmentDiversion() { router := NewShipmentRouter() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) approver := NewShipmentDiversionApprover(router, moveRouter) suite.Run("If the shipment diversion is approved successfully, it should update the shipment status in the DB", func() { diff --git a/pkg/services/order/excess_weight_risk_manager_test.go b/pkg/services/order/excess_weight_risk_manager_test.go index ad67a0d80b5..282eefd6a8b 100644 --- a/pkg/services/order/excess_weight_risk_manager_test.go +++ b/pkg/services/order/excess_weight_risk_manager_test.go @@ -10,13 +10,14 @@ import ( "github.com/transcom/mymove/pkg/factory" "github.com/transcom/mymove/pkg/models" moverouter "github.com/transcom/mymove/pkg/services/move" + transportationoffice "github.com/transcom/mymove/pkg/services/transportation_office" storageTest "github.com/transcom/mymove/pkg/storage/test" "github.com/transcom/mymove/pkg/uploader" ) func (suite *OrderServiceSuite) TestUpdateBillableWeightAsTOO() { suite.Run("Returns an error when order is not found", func() { - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) excessWeightRiskManager := NewExcessWeightRiskManager(moveRouter) nonexistentUUID := uuid.Must(uuid.NewV4()) newAuthorizedWeight := int(10000) @@ -29,7 +30,7 @@ func (suite *OrderServiceSuite) TestUpdateBillableWeightAsTOO() { }) suite.Run("Returns an error when the etag does not match", func() { - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) excessWeightRiskManager := NewExcessWeightRiskManager(moveRouter) order := factory.BuildMove(suite.DB(), nil, nil).Orders newAuthorizedWeight := int(10000) @@ -43,7 +44,7 @@ func (suite *OrderServiceSuite) TestUpdateBillableWeightAsTOO() { }) suite.Run("Updates the BillableWeight and approves the move when all fields are valid", func() { - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) excessWeightRiskManager := NewExcessWeightRiskManager(moveRouter) now := time.Now() move := factory.BuildApprovalsRequestedMove(suite.DB(), []factory.Customization{ @@ -76,7 +77,7 @@ func (suite *OrderServiceSuite) TestUpdateBillableWeightAsTOO() { }) suite.Run("Updates the BillableWeight but does not approve the move if unacknowledged amended orders exist", func() { - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) excessWeightRiskManager := NewExcessWeightRiskManager(moveRouter) storer := storageTest.NewFakeS3Storage(true) userUploader, err := uploader.NewUserUploader(storer, 100*uploader.MB) @@ -137,7 +138,7 @@ func (suite *OrderServiceSuite) TestUpdateBillableWeightAsTOO() { }) suite.Run("Updates the BillableWeight but does not approve the move if unreviewed service items exist", func() { - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) excessWeightRiskManager := NewExcessWeightRiskManager(moveRouter) _, _, move := suite.createServiceItem() @@ -164,7 +165,7 @@ func (suite *OrderServiceSuite) TestUpdateBillableWeightAsTOO() { }) suite.Run("Updates the BillableWeight but does not acknowledge the risk if there is no excess weight risk", func() { - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) excessWeightRiskManager := NewExcessWeightRiskManager(moveRouter) move := factory.BuildApprovalsRequestedMove(suite.DB(), nil, nil) order := move.Orders @@ -189,7 +190,7 @@ func (suite *OrderServiceSuite) TestUpdateBillableWeightAsTOO() { }) suite.Run("Updates the BillableWeight but does not acknowledge the risk if the risk was already acknowledged", func() { - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) excessWeightRiskManager := NewExcessWeightRiskManager(moveRouter) now := time.Now() move := factory.BuildApprovalsRequestedMove(suite.DB(), []factory.Customization{ @@ -223,7 +224,7 @@ func (suite *OrderServiceSuite) TestUpdateBillableWeightAsTOO() { func (suite *OrderServiceSuite) TestUpdateBillableWeightAsTIO() { suite.Run("Returns an error when order is not found", func() { - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) excessWeightRiskManager := NewExcessWeightRiskManager(moveRouter) nonexistentUUID := uuid.Must(uuid.NewV4()) newAuthorizedWeight := int(10000) @@ -237,7 +238,7 @@ func (suite *OrderServiceSuite) TestUpdateBillableWeightAsTIO() { }) suite.Run("Returns an error when the etag does not match", func() { - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) excessWeightRiskManager := NewExcessWeightRiskManager(moveRouter) order := factory.BuildMove(suite.DB(), nil, nil).Orders newAuthorizedWeight := int(10000) @@ -252,7 +253,7 @@ func (suite *OrderServiceSuite) TestUpdateBillableWeightAsTIO() { }) suite.Run("Updates the MaxBillableWeight and TIO remarks and approves the move when all fields are valid", func() { - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) excessWeightRiskManager := NewExcessWeightRiskManager(moveRouter) now := time.Now() move := factory.BuildApprovalsRequestedMove(suite.DB(), []factory.Customization{ @@ -287,7 +288,7 @@ func (suite *OrderServiceSuite) TestUpdateBillableWeightAsTIO() { }) suite.Run("Updates the MaxBillableWeight and TIO remarks but does not approve the move if unacknowledged amended orders exist", func() { - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) excessWeightRiskManager := NewExcessWeightRiskManager(moveRouter) storer := storageTest.NewFakeS3Storage(true) userUploader, err := uploader.NewUserUploader(storer, 100*uploader.MB) @@ -350,7 +351,7 @@ func (suite *OrderServiceSuite) TestUpdateBillableWeightAsTIO() { }) suite.Run("Updates the MaxBillableWeight and TIO remarks but does not approve the move if unreviewed service items exist", func() { - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) excessWeightRiskManager := NewExcessWeightRiskManager(moveRouter) _, _, move := suite.createServiceItem() @@ -379,7 +380,7 @@ func (suite *OrderServiceSuite) TestUpdateBillableWeightAsTIO() { }) suite.Run("Updates the MaxBillableWeight and TIO remarks but does not acknowledge the risk if there is no excess weight risk", func() { - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) excessWeightRiskManager := NewExcessWeightRiskManager(moveRouter) move := factory.BuildApprovalsRequestedMove(suite.DB(), nil, nil) order := move.Orders @@ -406,7 +407,7 @@ func (suite *OrderServiceSuite) TestUpdateBillableWeightAsTIO() { }) suite.Run("Updates the MaxBillableWeight and TIO remarks but does not acknowledge the risk if the risk was already acknowledged", func() { - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) excessWeightRiskManager := NewExcessWeightRiskManager(moveRouter) now := time.Now() move := factory.BuildApprovalsRequestedMove(suite.DB(), []factory.Customization{ @@ -442,7 +443,7 @@ func (suite *OrderServiceSuite) TestUpdateBillableWeightAsTIO() { func (suite *OrderServiceSuite) TestAcknowledgeExcessWeightRisk() { suite.Run("Returns an error when move is not found", func() { - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) excessWeightRiskManager := NewExcessWeightRiskManager(moveRouter) nonexistentUUID := uuid.Must(uuid.NewV4()) eTag := "" @@ -454,7 +455,7 @@ func (suite *OrderServiceSuite) TestAcknowledgeExcessWeightRisk() { }) suite.Run("Returns an error when the etag does not match", func() { - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) excessWeightRiskManager := NewExcessWeightRiskManager(moveRouter) move := factory.BuildMove(suite.DB(), nil, nil) order := move.Orders @@ -468,7 +469,7 @@ func (suite *OrderServiceSuite) TestAcknowledgeExcessWeightRisk() { }) suite.Run("Updates the ExcessWeightAcknowledgedAt field and approves the move when all fields are valid", func() { - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) excessWeightRiskManager := NewExcessWeightRiskManager(moveRouter) now := time.Now() move := factory.BuildApprovalsRequestedMove(suite.DB(), []factory.Customization{ @@ -496,7 +497,7 @@ func (suite *OrderServiceSuite) TestAcknowledgeExcessWeightRisk() { }) suite.Run("Updates the ExcessWeightAcknowledgedAt field but does not approve the move if unacknowledged amended orders exist", func() { - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) excessWeightRiskManager := NewExcessWeightRiskManager(moveRouter) storer := storageTest.NewFakeS3Storage(true) userUploader, err := uploader.NewUserUploader(storer, 100*uploader.MB) @@ -550,7 +551,7 @@ func (suite *OrderServiceSuite) TestAcknowledgeExcessWeightRisk() { }) suite.Run("Updates the ExcessWeightAcknowledgedAt field but does not approve the move if unreviewed service items exist", func() { - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) excessWeightRiskManager := NewExcessWeightRiskManager(moveRouter) _, _, move := suite.createServiceItem() @@ -570,7 +571,7 @@ func (suite *OrderServiceSuite) TestAcknowledgeExcessWeightRisk() { }) suite.Run("Does not update the ExcessWeightAcknowledgedAt field if there is no risk of excess weight", func() { - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) excessWeightRiskManager := NewExcessWeightRiskManager(moveRouter) move := factory.BuildApprovalsRequestedMove(suite.DB(), nil, nil) @@ -591,7 +592,7 @@ func (suite *OrderServiceSuite) TestAcknowledgeExcessWeightRisk() { }) suite.Run("Does not update the ExcessWeightAcknowledgedAt field if the risk was already acknowledged", func() { - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) excessWeightRiskManager := NewExcessWeightRiskManager(moveRouter) date := time.Now().Add(30 * time.Minute) diff --git a/pkg/services/order/order_updater_test.go b/pkg/services/order/order_updater_test.go index 1bf72866552..8994233f250 100644 --- a/pkg/services/order/order_updater_test.go +++ b/pkg/services/order/order_updater_test.go @@ -17,6 +17,7 @@ import ( "github.com/transcom/mymove/pkg/handlers" "github.com/transcom/mymove/pkg/models" "github.com/transcom/mymove/pkg/services/move" + transportationoffice "github.com/transcom/mymove/pkg/services/transportation_office" storageTest "github.com/transcom/mymove/pkg/storage/test" "github.com/transcom/mymove/pkg/swagger/nullable" "github.com/transcom/mymove/pkg/testdatagen" @@ -24,7 +25,7 @@ import ( func (suite *OrderServiceSuite) TestUpdateOrderAsTOO() { suite.Run("Returns an error when order is not found", func() { - moveRouter := move.NewMoveRouter() + moveRouter := move.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) orderUpdater := NewOrderUpdater(moveRouter) nonexistentUUID := uuid.Must(uuid.NewV4()) @@ -38,7 +39,7 @@ func (suite *OrderServiceSuite) TestUpdateOrderAsTOO() { }) suite.Run("Returns an error when origin duty location is not found", func() { - moveRouter := move.NewMoveRouter() + moveRouter := move.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) orderUpdater := NewOrderUpdater(moveRouter) order := factory.BuildMove(suite.DB(), nil, nil).Orders newDutyLocation := factory.BuildDutyLocation(suite.DB(), nil, nil) @@ -57,7 +58,7 @@ func (suite *OrderServiceSuite) TestUpdateOrderAsTOO() { }) suite.Run("Returns an error when new duty location is not found", func() { - moveRouter := move.NewMoveRouter() + moveRouter := move.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) orderUpdater := NewOrderUpdater(moveRouter) order := factory.BuildMove(suite.DB(), nil, nil).Orders originDutyLocation := factory.BuildDutyLocation(suite.DB(), nil, nil) @@ -76,7 +77,7 @@ func (suite *OrderServiceSuite) TestUpdateOrderAsTOO() { }) suite.Run("Returns an error when the etag does not match", func() { - moveRouter := move.NewMoveRouter() + moveRouter := move.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) orderUpdater := NewOrderUpdater(moveRouter) order := factory.BuildMove(suite.DB(), nil, nil).Orders @@ -90,7 +91,7 @@ func (suite *OrderServiceSuite) TestUpdateOrderAsTOO() { }) suite.Run("Updates the order when all fields are valid", func() { - moveRouter := move.NewMoveRouter() + moveRouter := move.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) orderUpdater := NewOrderUpdater(moveRouter) move := factory.BuildServiceCounselingCompletedMove(suite.DB(), nil, nil) order := move.Orders @@ -154,7 +155,7 @@ func (suite *OrderServiceSuite) TestUpdateOrderAsTOO() { }) suite.Run("Rolls back transaction if Order is invalid", func() { - moveRouter := move.NewMoveRouter() + moveRouter := move.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) orderUpdater := NewOrderUpdater(moveRouter) order := factory.BuildServiceCounselingCompletedMove(suite.DB(), nil, nil).Orders @@ -188,7 +189,7 @@ func (suite *OrderServiceSuite) TestUpdateOrderAsTOO() { }) suite.Run("Allow Order update to have a missing HHG SAC", func() { - moveRouter := move.NewMoveRouter() + moveRouter := move.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) orderUpdater := NewOrderUpdater(moveRouter) order := factory.BuildServiceCounselingCompletedMove(suite.DB(), nil, nil).Orders @@ -232,7 +233,7 @@ func (suite *OrderServiceSuite) TestUpdateOrderAsTOO() { }) suite.Run("Allow Order update to have a missing NTS SAC", func() { - moveRouter := move.NewMoveRouter() + moveRouter := move.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) orderUpdater := NewOrderUpdater(moveRouter) order := factory.BuildServiceCounselingCompletedMove(suite.DB(), nil, nil).Orders @@ -276,7 +277,7 @@ func (suite *OrderServiceSuite) TestUpdateOrderAsTOO() { }) suite.Run("Allow Order update to have a missing NTS TAC", func() { - moveRouter := move.NewMoveRouter() + moveRouter := move.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) orderUpdater := NewOrderUpdater(moveRouter) order := factory.BuildServiceCounselingCompletedMove(suite.DB(), nil, nil).Orders @@ -320,7 +321,7 @@ func (suite *OrderServiceSuite) TestUpdateOrderAsTOO() { }) suite.Run("Rolls back transaction if Order is invalid", func() { - moveRouter := move.NewMoveRouter() + moveRouter := move.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) orderUpdater := NewOrderUpdater(moveRouter) order := factory.BuildServiceCounselingCompletedMove(suite.DB(), nil, nil).Orders @@ -355,7 +356,7 @@ func (suite *OrderServiceSuite) TestUpdateOrderAsTOO() { }) suite.Run("Rolls back transaction if Order is missing required fields", func() { - moveRouter := move.NewMoveRouter() + moveRouter := move.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) orderUpdater := NewOrderUpdater(moveRouter) orderWithoutDefaults := factory.BuildOrderWithoutDefaults(suite.DB(), nil, nil) @@ -398,7 +399,7 @@ func (suite *OrderServiceSuite) TestUpdateOrderAsTOO() { func (suite *OrderServiceSuite) TestUpdateOrderAsCounselor() { suite.Run("Returns an error when order is not found", func() { - moveRouter := move.NewMoveRouter() + moveRouter := move.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) orderUpdater := NewOrderUpdater(moveRouter) nonexistentUUID := uuid.Must(uuid.NewV4()) @@ -412,7 +413,7 @@ func (suite *OrderServiceSuite) TestUpdateOrderAsCounselor() { }) suite.Run("Returns an error when the etag does not match", func() { - moveRouter := move.NewMoveRouter() + moveRouter := move.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) orderUpdater := NewOrderUpdater(moveRouter) order := factory.BuildMove(suite.DB(), nil, nil).Orders @@ -426,7 +427,7 @@ func (suite *OrderServiceSuite) TestUpdateOrderAsCounselor() { }) suite.Run("Updates the order when it is found", func() { - moveRouter := move.NewMoveRouter() + moveRouter := move.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) orderUpdater := NewOrderUpdater(moveRouter) order := factory.BuildNeedsServiceCounselingMove(suite.DB(), nil, nil).Orders @@ -477,7 +478,7 @@ func (suite *OrderServiceSuite) TestUpdateOrderAsCounselor() { }) suite.Run("Updates the PPM actual expense reimbursement when pay grade is civilian", func() { - moveRouter := move.NewMoveRouter() + moveRouter := move.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) orderUpdater := NewOrderUpdater(moveRouter) ppmShipment := factory.BuildPPMShipmentThatNeedsCloseout(suite.DB(), nil, nil) @@ -505,7 +506,7 @@ func (suite *OrderServiceSuite) TestUpdateOrderAsCounselor() { }) suite.Run("Rolls back transaction if Order is invalid", func() { - moveRouter := move.NewMoveRouter() + moveRouter := move.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) orderUpdater := NewOrderUpdater(moveRouter) order := factory.BuildOrderWithoutDefaults(suite.DB(), nil, nil) @@ -540,7 +541,7 @@ func (suite *OrderServiceSuite) TestUpdateOrderAsCounselor() { func (suite *OrderServiceSuite) TestUpdateAllowanceAsTOO() { suite.Run("Returns an error when order is not found", func() { - moveRouter := move.NewMoveRouter() + moveRouter := move.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) orderUpdater := NewOrderUpdater(moveRouter) nonexistentUUID := uuid.Must(uuid.NewV4()) @@ -554,7 +555,7 @@ func (suite *OrderServiceSuite) TestUpdateAllowanceAsTOO() { }) suite.Run("Returns an error when the etag does not match", func() { - moveRouter := move.NewMoveRouter() + moveRouter := move.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) orderUpdater := NewOrderUpdater(moveRouter) order := factory.BuildMove(suite.DB(), nil, nil).Orders @@ -568,7 +569,7 @@ func (suite *OrderServiceSuite) TestUpdateAllowanceAsTOO() { }) suite.Run("Updates the allowance when all fields are valid and no dependents", func() { - moveRouter := move.NewMoveRouter() + moveRouter := move.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) orderUpdater := NewOrderUpdater(moveRouter) order := factory.BuildServiceCounselingCompletedMove(suite.DB(), nil, nil).Orders @@ -607,7 +608,7 @@ func (suite *OrderServiceSuite) TestUpdateAllowanceAsTOO() { }) suite.Run("Updates the allowance when all OCONUS fields are valid with dependents", func() { - moveRouter := move.NewMoveRouter() + moveRouter := move.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) orderUpdater := NewOrderUpdater(moveRouter) order := factory.BuildServiceCounselingCompletedMove(suite.DB(), nil, nil).Orders @@ -652,7 +653,7 @@ func (suite *OrderServiceSuite) TestUpdateAllowanceAsTOO() { }) suite.Run("Updates the allowance when all fields are valid with dependents", func() { - moveRouter := move.NewMoveRouter() + moveRouter := move.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) orderUpdater := NewOrderUpdater(moveRouter) // Build with dependents trait order := factory.BuildServiceCounselingCompletedMove(suite.DB(), nil, []factory.Trait{ @@ -696,7 +697,7 @@ func (suite *OrderServiceSuite) TestUpdateAllowanceAsTOO() { func (suite *OrderServiceSuite) TestUpdateAllowanceAsCounselor() { suite.Run("Returns an error when order is not found", func() { - moveRouter := move.NewMoveRouter() + moveRouter := move.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) orderUpdater := NewOrderUpdater(moveRouter) nonexistentUUID := uuid.Must(uuid.NewV4()) @@ -710,7 +711,7 @@ func (suite *OrderServiceSuite) TestUpdateAllowanceAsCounselor() { }) suite.Run("Returns an error when the etag does not match", func() { - moveRouter := move.NewMoveRouter() + moveRouter := move.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) orderUpdater := NewOrderUpdater(moveRouter) order := factory.BuildMove(suite.DB(), nil, nil).Orders @@ -724,7 +725,7 @@ func (suite *OrderServiceSuite) TestUpdateAllowanceAsCounselor() { }) suite.Run("Updates the entitlement of OCONUS fields", func() { - moveRouter := move.NewMoveRouter() + moveRouter := move.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) orderUpdater := NewOrderUpdater(moveRouter) order := factory.BuildNeedsServiceCounselingMove(suite.DB(), nil, nil).Orders @@ -764,7 +765,7 @@ func (suite *OrderServiceSuite) TestUpdateAllowanceAsCounselor() { }) suite.Run("Updates the allowance when all fields are valid with dependents authorized but not present", func() { - moveRouter := move.NewMoveRouter() + moveRouter := move.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) orderUpdater := NewOrderUpdater(moveRouter) order := factory.BuildNeedsServiceCounselingMove(suite.DB(), nil, nil).Orders @@ -807,7 +808,7 @@ func (suite *OrderServiceSuite) TestUpdateAllowanceAsCounselor() { }) suite.Run("Updates the allowance when all fields are valid with dependents present and authorized", func() { - moveRouter := move.NewMoveRouter() + moveRouter := move.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) orderUpdater := NewOrderUpdater(moveRouter) order := factory.BuildNeedsServiceCounselingMove(suite.DB(), nil, []factory.Trait{ factory.GetTraitHasDependents, @@ -852,7 +853,7 @@ func (suite *OrderServiceSuite) TestUpdateAllowanceAsCounselor() { }) suite.Run("Updates the allowance when move needs service counseling and order fields are missing", func() { - moveRouter := move.NewMoveRouter() + moveRouter := move.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) orderUpdater := NewOrderUpdater(moveRouter) orderWithoutDefaults := factory.BuildOrderWithoutDefaults(suite.DB(), nil, nil) move := factory.BuildNeedsServiceCounselingMove(suite.DB(), []factory.Customization{ @@ -909,7 +910,7 @@ func (suite *OrderServiceSuite) TestUpdateAllowanceAsCounselor() { }) suite.Run("Entire update is aborted when ProGearWeight is over max amount", func() { - moveRouter := move.NewMoveRouter() + moveRouter := move.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) orderUpdater := NewOrderUpdater(moveRouter) order := factory.BuildNeedsServiceCounselingMove(suite.DB(), nil, nil).Orders @@ -945,7 +946,7 @@ func (suite *OrderServiceSuite) TestUpdateAllowanceAsCounselor() { }) suite.Run("Entire update is aborted when ProGearWeightSpouse is over max amount", func() { - moveRouter := move.NewMoveRouter() + moveRouter := move.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) orderUpdater := NewOrderUpdater(moveRouter) order := factory.BuildNeedsServiceCounselingMove(suite.DB(), nil, nil).Orders @@ -982,7 +983,7 @@ func (suite *OrderServiceSuite) TestUpdateAllowanceAsCounselor() { } func (suite *OrderServiceSuite) TestUploadAmendedOrdersForCustomer() { - moveRouter := move.NewMoveRouter() + moveRouter := move.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) orderUpdater := NewOrderUpdater(moveRouter) setUpOrders := func(setUpPreExistingAmendedOrders bool) *models.Order { diff --git a/pkg/services/shipment_address_update/shipment_address_update_requester_test.go b/pkg/services/shipment_address_update/shipment_address_update_requester_test.go index 863e1851d21..d9a3dad5a54 100644 --- a/pkg/services/shipment_address_update/shipment_address_update_requester_test.go +++ b/pkg/services/shipment_address_update/shipment_address_update_requester_test.go @@ -13,6 +13,7 @@ import ( routemocks "github.com/transcom/mymove/pkg/route/mocks" "github.com/transcom/mymove/pkg/services/address" moveservices "github.com/transcom/mymove/pkg/services/move" + transportationoffice "github.com/transcom/mymove/pkg/services/transportation_office" "github.com/transcom/mymove/pkg/testdatagen" ) @@ -62,7 +63,7 @@ func (suite *ShipmentAddressUpdateServiceSuite) TestCreateApprovedShipmentAddres } addressCreator := address.NewAddressCreator() mockPlanner := &routemocks.Planner{} - moveRouter := moveservices.NewMoveRouter() + moveRouter := moveservices.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) addressUpdateRequester := NewShipmentAddressUpdateRequester(mockPlanner, addressCreator, moveRouter) suite.Run("Successfully create ShipmentAddressUpdate", func() { @@ -577,7 +578,7 @@ func (suite *ShipmentAddressUpdateServiceSuite) TestCreateApprovedShipmentAddres func (suite *ShipmentAddressUpdateServiceSuite) TestTOOApprovedShipmentAddressUpdateRequest() { addressCreator := address.NewAddressCreator() mockPlanner := &routemocks.Planner{} - moveRouter := moveservices.NewMoveRouter() + moveRouter := moveservices.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) mockPlanner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), mock.Anything, @@ -834,7 +835,7 @@ func (suite *ShipmentAddressUpdateServiceSuite) TestTOOApprovedShipmentAddressUp } addressCreator := address.NewAddressCreator() mockPlanner := &routemocks.Planner{} - moveRouter := moveservices.NewMoveRouter() + moveRouter := moveservices.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) addressUpdateRequester := NewShipmentAddressUpdateRequester(mockPlanner, addressCreator, moveRouter) suite.Run("Service items are rejected and regenerated when pricing type changes post TOO approval", func() { diff --git a/pkg/services/sit_extension/sit_extension_approver_test.go b/pkg/services/sit_extension/sit_extension_approver_test.go index 286d31cfcc8..56e787d7de2 100644 --- a/pkg/services/sit_extension/sit_extension_approver_test.go +++ b/pkg/services/sit_extension/sit_extension_approver_test.go @@ -9,10 +9,11 @@ import ( "github.com/transcom/mymove/pkg/factory" "github.com/transcom/mymove/pkg/models" moverouter "github.com/transcom/mymove/pkg/services/move" + transportationoffice "github.com/transcom/mymove/pkg/services/transportation_office" ) func (suite *SitExtensionServiceSuite) TestApproveSITExtension() { - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) sitExtensionApprover := NewSITExtensionApprover(moveRouter) suite.Run("Returns an error when shipment is not found", func() { diff --git a/pkg/services/sit_extension/sit_extension_creator_test.go b/pkg/services/sit_extension/sit_extension_creator_test.go index 9a3a15afc98..a0531ee0c0c 100644 --- a/pkg/services/sit_extension/sit_extension_creator_test.go +++ b/pkg/services/sit_extension/sit_extension_creator_test.go @@ -9,12 +9,13 @@ import ( "github.com/transcom/mymove/pkg/services" moverouter "github.com/transcom/mymove/pkg/services/move" movefetcher "github.com/transcom/mymove/pkg/services/move_task_order" + transportationoffice "github.com/transcom/mymove/pkg/services/transportation_office" ) func (suite *SitExtensionServiceSuite) TestSITExtensionCreator() { // Create move router for SitExtension Createor - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) sitExtensionCreator := NewSitExtensionCreator(moveRouter) movefetcher := movefetcher.NewMoveTaskOrderFetcher() diff --git a/pkg/services/sit_extension/sit_extension_denier_test.go b/pkg/services/sit_extension/sit_extension_denier_test.go index 3ea81e61d42..1649346eb76 100644 --- a/pkg/services/sit_extension/sit_extension_denier_test.go +++ b/pkg/services/sit_extension/sit_extension_denier_test.go @@ -11,11 +11,12 @@ import ( "github.com/transcom/mymove/pkg/factory" "github.com/transcom/mymove/pkg/models" moverouter "github.com/transcom/mymove/pkg/services/move" + transportationoffice "github.com/transcom/mymove/pkg/services/transportation_office" "github.com/transcom/mymove/pkg/testdatagen" ) func (suite *SitExtensionServiceSuite) TestDenySITExtension() { - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) sitExtensionDenier := NewSITExtensionDenier(moveRouter) suite.Run("Returns an error when shipment is not found", func() { diff --git a/pkg/services/transportation_office.go b/pkg/services/transportation_office.go index 307f0d0fef5..a0d5cd95b8c 100644 --- a/pkg/services/transportation_office.go +++ b/pkg/services/transportation_office.go @@ -13,4 +13,5 @@ type TransportationOfficesFetcher interface { GetTransportationOffice(appCtx appcontext.AppContext, transportationOfficeID uuid.UUID, includeOnlyPPMCloseoutOffices bool) (*models.TransportationOffice, error) GetAllGBLOCs(appCtx appcontext.AppContext) (*models.GBLOCs, error) GetCounselingOffices(appCtx appcontext.AppContext, dutyLocationID uuid.UUID) (*models.TransportationOffices, error) + FindClosestCounselingOffice(appCtx appcontext.AppContext, dutyLocationID uuid.UUID) (models.TransportationOffice, error) } diff --git a/pkg/services/transportation_office/transportation_office_fetcher.go b/pkg/services/transportation_office/transportation_office_fetcher.go index be942890c75..0f8b77ff181 100644 --- a/pkg/services/transportation_office/transportation_office_fetcher.go +++ b/pkg/services/transportation_office/transportation_office_fetcher.go @@ -142,6 +142,18 @@ func (o transportationOfficesFetcher) GetCounselingOffices(appCtx appcontext.App return &officeList, nil } +func (o transportationOfficesFetcher) FindClosestCounselingOffice(appCtx appcontext.AppContext, dutyLocationID uuid.UUID) (models.TransportationOffice, error) { + officeList, err := findCounselingOffice(appCtx, dutyLocationID) + var closestOffice models.TransportationOffice + + if err != nil { + return closestOffice, err + } + + closestOffice = officeList[0] + return closestOffice, nil +} + // return all the transportation offices in the GBLOC of the given duty location where provides_services_counseling = true func findCounselingOffice(appCtx appcontext.AppContext, dutyLocationID uuid.UUID) (models.TransportationOffices, error) { var officeList []models.TransportationOffice diff --git a/pkg/testdatagen/scenario/devseed.go b/pkg/testdatagen/scenario/devseed.go index fe698271e8d..93555dd2ce3 100644 --- a/pkg/testdatagen/scenario/devseed.go +++ b/pkg/testdatagen/scenario/devseed.go @@ -14,6 +14,7 @@ import ( "github.com/transcom/mymove/pkg/models" moverouter "github.com/transcom/mymove/pkg/services/move" mtoshipment "github.com/transcom/mymove/pkg/services/mto_shipment" + transportationoffice "github.com/transcom/mymove/pkg/services/transportation_office" "github.com/transcom/mymove/pkg/uploader" ) @@ -28,7 +29,7 @@ var DevSeedScenario = devSeedScenario{ // Setup initializes the run setup for the devseed scenario func (e *devSeedScenario) Setup(appCtx appcontext.AppContext, userUploader *uploader.UserUploader, primeUploader *uploader.PrimeUploader) { db := appCtx.DB() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) shipmentFetcher := mtoshipment.NewMTOShipmentFetcher() // Testdatagen factories will create new random duty locations so let's get the standard ones in the migrations diff --git a/pkg/testdatagen/scenario/e2ebasic.go b/pkg/testdatagen/scenario/e2ebasic.go index 3f778ea4894..2ddf692fe32 100644 --- a/pkg/testdatagen/scenario/e2ebasic.go +++ b/pkg/testdatagen/scenario/e2ebasic.go @@ -15,6 +15,7 @@ import ( "github.com/transcom/mymove/pkg/models" "github.com/transcom/mymove/pkg/models/roles" moverouter "github.com/transcom/mymove/pkg/services/move" + transportationoffice "github.com/transcom/mymove/pkg/services/transportation_office" "github.com/transcom/mymove/pkg/testdatagen" "github.com/transcom/mymove/pkg/unit" "github.com/transcom/mymove/pkg/uploader" @@ -4299,7 +4300,7 @@ func createNTSMoveWithServiceItemsandPaymentRequests(appCtx appcontext.AppContex // Run does that data load thing func (e e2eBasicScenario) Run(appCtx appcontext.AppContext, userUploader *uploader.UserUploader, primeUploader *uploader.PrimeUploader) { - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) // Testdatagen factories will create new random duty locations so let's get the standard ones in the migrations var allDutyLocations []models.DutyLocation err := appCtx.DB().All(&allDutyLocations) diff --git a/pkg/testdatagen/testharness/make_move.go b/pkg/testdatagen/testharness/make_move.go index fd337bb029f..937b9fae06e 100644 --- a/pkg/testdatagen/testharness/make_move.go +++ b/pkg/testdatagen/testharness/make_move.go @@ -24,6 +24,7 @@ import ( mtoserviceitem "github.com/transcom/mymove/pkg/services/mto_service_item" mtoshipment "github.com/transcom/mymove/pkg/services/mto_shipment" "github.com/transcom/mymove/pkg/services/query" + transportationoffice "github.com/transcom/mymove/pkg/services/transportation_office" "github.com/transcom/mymove/pkg/storage" "github.com/transcom/mymove/pkg/testdatagen" "github.com/transcom/mymove/pkg/testdatagen/scenario" @@ -3792,7 +3793,7 @@ func MakeHHGMoveWithApprovedNTSShipmentsForTOO(appCtx appcontext.AppContext) mod locator := models.GenerateLocator() move := scenario.CreateMoveWithHHGAndNTSShipments(appCtx, locator, false) - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) err := moveRouter.Approve(appCtx, &move) if err != nil { log.Panic("Failed to approve move: %w", err) @@ -3896,7 +3897,7 @@ func MakeHHGMoveWithApprovedNTSRShipmentsForTOO(appCtx appcontext.AppContext) mo locator := models.GenerateLocator() move := scenario.CreateMoveWithHHGAndNTSRShipments(appCtx, locator, false) - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) err := moveRouter.Approve(appCtx, &move) if err != nil { log.Panic("Failed to approve move: %w", err) @@ -4028,7 +4029,7 @@ func MakeBoatHaulAwayMoveNeedsSC(appCtx appcontext.AppContext) models.Move { MoveLocator: models.GenerateLocator(), } - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) move := scenario.CreateBoatHaulAwayMoveForSC(appCtx, userUploader, moveRouter, moveInfo) @@ -4057,7 +4058,7 @@ func MakeBoatHaulAwayMoveNeedsTOOApproval(appCtx appcontext.AppContext) models.M MoveLocator: models.GenerateLocator(), } - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) move := scenario.CreateBoatHaulAwayMoveForTOO(appCtx, userUploader, moveRouter, moveInfo) @@ -4567,7 +4568,7 @@ func MakeSubmittedMoveWithPPMShipmentForSC(appCtx appcontext.AppContext) models. MoveLocator: models.GenerateLocator(), } - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) move := scenario.CreateSubmittedMoveWithPPMShipmentForSC(appCtx, userUploader, moveRouter, moveInfo) From e5a6ef0ac5e2c1043fe2c59c3a42198f2232573c Mon Sep 17 00:00:00 2001 From: Samay Sofo Date: Mon, 6 Jan 2025 14:10:12 +0000 Subject: [PATCH 10/71] fixed origindutylocation providesServicesCounseling nil issue --- pkg/services/move/move_router.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pkg/services/move/move_router.go b/pkg/services/move/move_router.go index 9e3f35a7483..9df5ccbe531 100644 --- a/pkg/services/move/move_router.go +++ b/pkg/services/move/move_router.go @@ -176,6 +176,7 @@ func (router moveRouter) needsServiceCounseling(appCtx appcontext.AppContext, mo // sendToServiceCounselor makes the move available for a Service Counselor to review func (router moveRouter) sendToServiceCounselor(appCtx appcontext.AppContext, move *models.Move) error { var orders models.Order + var originDutyLocation models.DutyLocation err := appCtx.DB().Q(). Where("orders.id = ?", move.OrdersID). First(&orders) @@ -213,7 +214,20 @@ func (router moveRouter) sendToServiceCounselor(appCtx appcontext.AppContext, mo move.Status = models.MoveStatusNeedsServiceCounseling now := time.Now() move.SubmittedAt = &now + if orders.OriginDutyLocationID == nil || *orders.OriginDutyLocationID == uuid.Nil { + return apperror.NewInvalidInputError(orders.ID, err, nil, "orders missing OriginDutyLocation") + } + originDutyLocation, err = models.FetchDutyLocation(appCtx.DB(), *orders.OriginDutyLocationID) + if err != nil { + appCtx.Logger().Error("failure finding the origin duty location", zap.Error(err)) + return apperror.NewInvalidInputError(*orders.OriginDutyLocationID, err, nil, "unable to find origin duty location") + } + orders.OriginDutyLocation = &originDutyLocation + if err != nil { + appCtx.Logger().Error("failure finding the origin duty location", zap.Error(err)) + return apperror.NewInvalidInputError(*orders.OriginDutyLocationID, err, nil, "unable to find origin duty location") + } for i := range move.MTOShipments { // if it's a PPMShipment update both the mto and ppm shipment level statuses if move.MTOShipments[i].ShipmentType == models.MTOShipmentTypePPM { From fe1793e36e37e1561caff80a84a27232240e38c8 Mon Sep 17 00:00:00 2001 From: Samay Sofo Date: Mon, 6 Jan 2025 14:26:45 +0000 Subject: [PATCH 11/71] code clean up --- pkg/services/move/move_router.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/pkg/services/move/move_router.go b/pkg/services/move/move_router.go index 9df5ccbe531..9b47f5b5d48 100644 --- a/pkg/services/move/move_router.go +++ b/pkg/services/move/move_router.go @@ -224,10 +224,6 @@ func (router moveRouter) sendToServiceCounselor(appCtx appcontext.AppContext, mo return apperror.NewInvalidInputError(*orders.OriginDutyLocationID, err, nil, "unable to find origin duty location") } orders.OriginDutyLocation = &originDutyLocation - if err != nil { - appCtx.Logger().Error("failure finding the origin duty location", zap.Error(err)) - return apperror.NewInvalidInputError(*orders.OriginDutyLocationID, err, nil, "unable to find origin duty location") - } for i := range move.MTOShipments { // if it's a PPMShipment update both the mto and ppm shipment level statuses if move.MTOShipments[i].ShipmentType == models.MTOShipmentTypePPM { From 78581e2b452afcbe3553358ae72d243c5a5db78a Mon Sep 17 00:00:00 2001 From: Samay Sofo Date: Thu, 9 Jan 2025 15:18:39 +0000 Subject: [PATCH 12/71] Added function for finding the closeset counseling office with its assciated tests --- .../transportation_office_fetcher.go | 105 ++++++++++++++++-- .../transportation_office_fetcher_test.go | 78 +++++++++++++ 2 files changed, 171 insertions(+), 12 deletions(-) diff --git a/pkg/services/transportation_office/transportation_office_fetcher.go b/pkg/services/transportation_office/transportation_office_fetcher.go index 0f8b77ff181..f1b565f4a3a 100644 --- a/pkg/services/transportation_office/transportation_office_fetcher.go +++ b/pkg/services/transportation_office/transportation_office_fetcher.go @@ -6,6 +6,7 @@ import ( "github.com/gofrs/uuid" "github.com/pkg/errors" + "go.uber.org/zap" "github.com/transcom/mymove/pkg/appcontext" "github.com/transcom/mymove/pkg/apperror" @@ -142,18 +143,6 @@ func (o transportationOfficesFetcher) GetCounselingOffices(appCtx appcontext.App return &officeList, nil } -func (o transportationOfficesFetcher) FindClosestCounselingOffice(appCtx appcontext.AppContext, dutyLocationID uuid.UUID) (models.TransportationOffice, error) { - officeList, err := findCounselingOffice(appCtx, dutyLocationID) - var closestOffice models.TransportationOffice - - if err != nil { - return closestOffice, err - } - - closestOffice = officeList[0] - return closestOffice, nil -} - // return all the transportation offices in the GBLOC of the given duty location where provides_services_counseling = true func findCounselingOffice(appCtx appcontext.AppContext, dutyLocationID uuid.UUID) (models.TransportationOffices, error) { var officeList []models.TransportationOffice @@ -317,3 +306,95 @@ func findOconusGblocDepartmentIndicator(appCtx appcontext.AppContext, dutyLocati return nil, apperror.NewImplementationError(fmt.Sprintf("Error: Cannot determine GBLOC -- serviceMember.Affiliation: %s, DutyLocaton: %s, departmentIndicator: %s, dutyLocation.Address.ID: %s", serviceMember.Affiliation, dutyLocation.Name, *departmentIndicator, dutyLocation.Address.ID)) } + +// Return the closeset transportation office in the GBLOC of the given duty location for oconus/cunus duty locations +func (o transportationOfficesFetcher) FindClosestCounselingOffice(appCtx appcontext.AppContext, dutyLocationID uuid.UUID) (models.TransportationOffice, error) { + var closestOffice models.TransportationOffice + duty_location, err := models.FetchDutyLocation(appCtx.DB(), dutyLocationID) + if err != nil { + appCtx.Logger().Error("Failed to fetch duty location", zap.Error(err)) + return closestOffice, err + } + var sqlQuery string + + // Find for oconus duty location + if *duty_location.Address.IsOconus { + gblocDepartmentIndicator, err := findOconusGblocDepartmentIndicator(appCtx, duty_location) + if err != nil { + appCtx.Logger().Error("Failed to find OCONUS GBLOC department indicator", zap.Error(err)) + return closestOffice, err + } + + sqlQuery = ` + WITH counseling_offices AS ( + SELECT transportation_offices.id, transportation_offices.name, transportation_offices.address_id AS counseling_address, + SUBSTRING(a.postal_code, 1, 3) AS origin_zip, SUBSTRING(a2.postal_code, 1, 3) AS dest_zip + FROM duty_locations + JOIN addresses a ON duty_locations.address_id = a.id + JOIN v_locations v ON (a.us_post_region_cities_id = v.uprc_id OR v.uprc_id IS NULL) + JOIN re_oconus_rate_areas r ON r.us_post_region_cities_id = v.uprc_id + JOIN gbloc_aors ON gbloc_aors.oconus_rate_area_id = r.id + JOIN jppso_regions j ON gbloc_aors.jppso_regions_id = j.id + JOIN transportation_offices ON j.code = transportation_offices.gbloc + JOIN addresses a2 ON a2.id = transportation_offices.address_id + WHERE duty_locations.id = $1 AND j.code = $2 + AND transportation_offices.provides_ppm_closeout = true + ) + SELECT counseling_offices.id, counseling_offices.name + FROM counseling_offices + JOIN addresses cnsl_address ON counseling_offices.counseling_address = cnsl_address.id + LEFT JOIN zip3_distances ON ( + (SUBSTRING(cnsl_address.postal_code, 1, 3) = zip3_distances.to_zip3 + AND counseling_offices.origin_zip = zip3_distances.from_zip3) + OR + (SUBSTRING(cnsl_address.postal_code, 1, 3) = zip3_distances.from_zip3 + AND counseling_offices.origin_zip = zip3_distances.to_zip3) + ) + GROUP BY counseling_offices.id, counseling_offices.name, zip3_distances.distance_miles + ORDER BY COALESCE(zip3_distances.distance_miles, 0) ASC + FETCH FIRST 1 ROW ONLY` + + if err := appCtx.DB().Q().RawQuery(sqlQuery, dutyLocationID, gblocDepartmentIndicator.Gbloc).First(&closestOffice); err != nil { + appCtx.Logger().Error("Failed to execute OCONUS SQL query", zap.Error(err)) + if errors.Cause(err).Error() != models.RecordNotFoundErrorString { + return closestOffice, err + } + } + return closestOffice, nil + } else { + + // Find for conus duty location + sqlQuery = ` + WITH counseling_offices AS ( + SELECT transportation_offices.id, transportation_offices.name, transportation_offices.address_id AS counseling_address, SUBSTRING(addresses.postal_code, 1, 3) AS pickup_zip + FROM postal_code_to_gblocs + JOIN addresses ON postal_code_to_gblocs.postal_code = addresses.postal_code + JOIN duty_locations ON addresses.id = duty_locations.address_id + JOIN transportation_offices ON postal_code_to_gblocs.gbloc = transportation_offices.gbloc + WHERE duty_locations.id = $1 + ) + SELECT counseling_offices.id, counseling_offices.name + FROM counseling_offices + JOIN duty_locations duty_locations2 ON counseling_offices.id = duty_locations2.transportation_office_id + JOIN addresses ON counseling_offices.counseling_address = addresses.id + JOIN re_us_post_regions ON addresses.postal_code = re_us_post_regions.uspr_zip_id + LEFT JOIN zip3_distances ON ( + (re_us_post_regions.zip3 = zip3_distances.to_zip3 AND counseling_offices.pickup_zip = zip3_distances.from_zip3) + OR + (re_us_post_regions.zip3 = zip3_distances.from_zip3 AND counseling_offices.pickup_zip = zip3_distances.to_zip3) + ) + WHERE duty_locations2.provides_services_counseling = true + GROUP BY counseling_offices.id, counseling_offices.name, zip3_distances.distance_miles + ORDER BY COALESCE(zip3_distances.distance_miles, 0), counseling_offices.name ASC + FETCH FIRST 1 ROW ONLY` + + if err := appCtx.DB().Q().RawQuery(sqlQuery, dutyLocationID).First(&closestOffice); err != nil { + appCtx.Logger().Error("Failed to execute CONUS SQL query", zap.Error(err)) + if errors.Cause(err).Error() != models.RecordNotFoundErrorString { + return closestOffice, err + } + } + } + + return closestOffice, nil +} diff --git a/pkg/services/transportation_office/transportation_office_fetcher_test.go b/pkg/services/transportation_office/transportation_office_fetcher_test.go index ab07d8c5e39..415fa3422ba 100644 --- a/pkg/services/transportation_office/transportation_office_fetcher_test.go +++ b/pkg/services/transportation_office/transportation_office_fetcher_test.go @@ -677,3 +677,81 @@ func (suite *TransportationOfficeServiceSuite) Test_GetTransportationOffice() { suite.Equal("OFFICE ONE", office1f.Name) suite.Equal("OFFICE TWO", office2f.Name) } + +func (suite *TransportationOfficeServiceSuite) Test_FindClosestCounselingOffices() { + // Test for CONUS + suite.Run("success - find closest counseling office for CONUS", func() { + customAddressCONUS := models.Address{ + ID: uuid.Must(uuid.NewV4()), + StreetAddress1: "123 Mayport St", + City: "NS Mayport", + State: "FL", + PostalCode: "32228", + County: "Duval", + IsOconus: models.BoolPointer(false), + } + suite.MustSave(&customAddressCONUS) + airForce := models.AffiliationAIRFORCE + + origDutyLocationCONUS := factory.BuildDutyLocation(suite.DB(), []factory.Customization{ + {Model: customAddressCONUS, Type: &factory.Addresses.DutyLocationAddress}, + { + Model: models.DutyLocation{ + ProvidesServicesCounseling: false, + }, + }, + {Model: models.TransportationOffice{ + Name: "NS Mayport", + Gbloc: "CNNQ", + ProvidesCloseout: false, + }}, + {Model: models.ServiceMember{Affiliation: &airForce}}, + }, nil) + + suite.NotNil(origDutyLocationCONUS) + suite.NotNil(suite.toFetcher) + + officeCONUS, err := suite.toFetcher.FindClosestCounselingOffice(suite.AppContextForTest(), origDutyLocationCONUS.ID) + + suite.NoError(err) + suite.NotNil(officeCONUS) + suite.Equal("PPPO Jacksonville - USN", officeCONUS.Name) // Check for CONUS condition + }) + + // Test for OCONUS + suite.Run("success - find closest counseling office for OCONUS", func() { + customAddressOCONUS := models.Address{ + ID: uuid.Must(uuid.NewV4()), + StreetAddress1: "456 Yokota St", + City: "Yokota AB", + State: "Tokyo", + PostalCode: "197-0001", + County: "Japan", + IsOconus: models.BoolPointer(true), + } + suite.MustSave(&customAddressOCONUS) + army := models.AffiliationARMY + + origDutyLocationOCONUS := factory.BuildDutyLocation(suite.DB(), []factory.Customization{ + {Model: customAddressOCONUS, Type: &factory.Addresses.DutyLocationAddress}, + { + Model: models.DutyLocation{ + ProvidesServicesCounseling: false, + }, + }, + {Model: models.TransportationOffice{ + Name: "Yokota AB", + Gbloc: "JPN1", + ProvidesCloseout: true, + }}, + {Model: models.ServiceMember{Affiliation: &army}}, + }, nil) + + suite.NotNil(origDutyLocationOCONUS) + suite.NotNil(suite.toFetcher) + officeOCONUS, err := suite.toFetcher.FindClosestCounselingOffice(suite.AppContextForTest(), origDutyLocationOCONUS.ID) + suite.NoError(err) + suite.NotNil(officeOCONUS) + suite.Equal("Yokota AB - USN", officeOCONUS.Name) // Check for OCONUS condition + }) +} From faa41a8fd7133e118f89ef86c36ab6c37162ff92 Mon Sep 17 00:00:00 2001 From: Samay Sofo Date: Fri, 10 Jan 2025 12:43:10 +0000 Subject: [PATCH 13/71] Added test for CONUS/OCONUS for finding the closest counseling offices. --- .../mocks/TransportationOfficesFetcher.go | 34 +- .../transportation_office_fetcher.go | 2 +- .../transportation_office_fetcher_test.go | 532 ++++++++++++++++-- 3 files changed, 501 insertions(+), 67 deletions(-) diff --git a/pkg/services/mocks/TransportationOfficesFetcher.go b/pkg/services/mocks/TransportationOfficesFetcher.go index 754823af361..ca9277f5f9f 100644 --- a/pkg/services/mocks/TransportationOfficesFetcher.go +++ b/pkg/services/mocks/TransportationOfficesFetcher.go @@ -16,6 +16,34 @@ type TransportationOfficesFetcher struct { mock.Mock } +// FindClosestCounselingOffice provides a mock function with given fields: appCtx, dutyLocationID +func (_m *TransportationOfficesFetcher) FindClosestCounselingOffice(appCtx appcontext.AppContext, dutyLocationID uuid.UUID) (models.TransportationOffice, error) { + ret := _m.Called(appCtx, dutyLocationID) + + if len(ret) == 0 { + panic("no return value specified for FindClosestCounselingOffice") + } + + var r0 models.TransportationOffice + var r1 error + if rf, ok := ret.Get(0).(func(appcontext.AppContext, uuid.UUID) (models.TransportationOffice, error)); ok { + return rf(appCtx, dutyLocationID) + } + if rf, ok := ret.Get(0).(func(appcontext.AppContext, uuid.UUID) models.TransportationOffice); ok { + r0 = rf(appCtx, dutyLocationID) + } else { + r0 = ret.Get(0).(models.TransportationOffice) + } + + if rf, ok := ret.Get(1).(func(appcontext.AppContext, uuid.UUID) error); ok { + r1 = rf(appCtx, dutyLocationID) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + // GetAllGBLOCs provides a mock function with given fields: appCtx func (_m *TransportationOfficesFetcher) GetAllGBLOCs(appCtx appcontext.AppContext) (*models.GBLOCs, error) { ret := _m.Called(appCtx) @@ -136,12 +164,6 @@ func (_m *TransportationOfficesFetcher) GetTransportationOffices(appCtx appconte return r0, r1 } -func (_m *TransportationOfficesFetcher) FindClosestCounselingOffice(appCtx appcontext.AppContext, dutyLocationID uuid.UUID) (models.TransportationOffice, error) { - _m.GetCounselingOffices(appCtx, dutyLocationID) - //TODO: Fix - return models.TransportationOffice{}, nil -} - // NewTransportationOfficesFetcher creates a new instance of TransportationOfficesFetcher. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. // The first argument is typically a *testing.T value. func NewTransportationOfficesFetcher(t interface { diff --git a/pkg/services/transportation_office/transportation_office_fetcher.go b/pkg/services/transportation_office/transportation_office_fetcher.go index f1b565f4a3a..6ebb89837e4 100644 --- a/pkg/services/transportation_office/transportation_office_fetcher.go +++ b/pkg/services/transportation_office/transportation_office_fetcher.go @@ -307,7 +307,7 @@ func findOconusGblocDepartmentIndicator(appCtx appcontext.AppContext, dutyLocati serviceMember.Affiliation, dutyLocation.Name, *departmentIndicator, dutyLocation.Address.ID)) } -// Return the closeset transportation office in the GBLOC of the given duty location for oconus/cunus duty locations +// Return the closeset transportation office in the GBLOC of the given duty location for oconus/conus duty locations func (o transportationOfficesFetcher) FindClosestCounselingOffice(appCtx appcontext.AppContext, dutyLocationID uuid.UUID) (models.TransportationOffice, error) { var closestOffice models.TransportationOffice duty_location, err := models.FetchDutyLocation(appCtx.DB(), dutyLocationID) diff --git a/pkg/services/transportation_office/transportation_office_fetcher_test.go b/pkg/services/transportation_office/transportation_office_fetcher_test.go index 415fa3422ba..a18b64eb335 100644 --- a/pkg/services/transportation_office/transportation_office_fetcher_test.go +++ b/pkg/services/transportation_office/transportation_office_fetcher_test.go @@ -678,80 +678,492 @@ func (suite *TransportationOfficeServiceSuite) Test_GetTransportationOffice() { suite.Equal("OFFICE TWO", office2f.Name) } -func (suite *TransportationOfficeServiceSuite) Test_FindClosestCounselingOffices() { - // Test for CONUS - suite.Run("success - find closest counseling office for CONUS", func() { - customAddressCONUS := models.Address{ - ID: uuid.Must(uuid.NewV4()), - StreetAddress1: "123 Mayport St", - City: "NS Mayport", - State: "FL", - PostalCode: "32228", - County: "Duval", - IsOconus: models.BoolPointer(false), - } - suite.MustSave(&customAddressCONUS) - airForce := models.AffiliationAIRFORCE - - origDutyLocationCONUS := factory.BuildDutyLocation(suite.DB(), []factory.Customization{ - {Model: customAddressCONUS, Type: &factory.Addresses.DutyLocationAddress}, +func (suite *TransportationOfficeServiceSuite) Test_FindClosestCounselingOfficeCONUS() { + suite.toFetcher = NewTransportationOfficesFetcher() + customAddress1 := models.Address{ + ID: uuid.Must(uuid.NewV4()), + StreetAddress1: "123 Mayport St", + City: "Mayport", + State: "FL", + PostalCode: "32228", + County: "Duval", + IsOconus: models.BoolPointer(false), + } + factory.BuildDutyLocation(suite.DB(), []factory.Customization{ + {Model: customAddress1, Type: &factory.Addresses.DutyLocationAddress}, + { + Model: models.DutyLocation{ + ProvidesServicesCounseling: false, + }, + }, + { + Model: models.TransportationOffice{ + Name: "PPPO Holloman AFB - USAF", + }, + }, + }, nil) + + customAddress2 := models.Address{ + ID: uuid.Must(uuid.NewV4()), + StreetAddress1: "123 Mayport St", + City: "Jacksonville", + State: "FL", + PostalCode: "32228", + County: "Duval", + IsOconus: models.BoolPointer(false), + } + factory.BuildDutyLocation(suite.DB(), []factory.Customization{ + {Model: customAddress2, Type: &factory.Addresses.DutyLocationAddress}, + { + Model: models.DutyLocation{ + ProvidesServicesCounseling: true, + }, + }, + { + Model: models.TransportationOffice{ + Name: "PPPO Jacksonville - USN", + }, + }, + }, nil) + + customAddress3 := models.Address{ + ID: uuid.Must(uuid.NewV4()), + StreetAddress1: "123 Mayport St", + City: "Palm Valley", + State: "FL", + PostalCode: "32228", + County: "Duval", + IsOconus: models.BoolPointer(false), + } + origDutyLocation := factory.BuildDutyLocation(suite.DB(), []factory.Customization{ + {Model: customAddress3, Type: &factory.Addresses.DutyLocationAddress}, + { + Model: models.DutyLocation{ + ProvidesServicesCounseling: true, + }, + }, + { + Model: models.TransportationOffice{ + Name: "PPPO Fort Moore - USA", + Gbloc: "CNNQ", + ProvidesCloseout: true, + }, + }, + }, nil) + + customAddress4 := models.Address{ + ID: uuid.Must(uuid.NewV4()), + StreetAddress1: "123 Mayport St", + City: "Fernandina", + State: "FL", + PostalCode: "32228", + County: "Duval", + IsOconus: models.BoolPointer(false), + } + factory.BuildDutyLocation(suite.DB(), []factory.Customization{ + {Model: customAddress4, Type: &factory.Addresses.DutyLocationAddress}, + { + Model: models.DutyLocation{ + ProvidesServicesCounseling: true, + }, + }, + { + Model: models.TransportationOffice{ + Name: "PPPO Fort Meade - USA", + Gbloc: "CNNQ", + ProvidesCloseout: true, + }, + }, + }, nil) + + offices, err := suite.toFetcher.FindClosestCounselingOffice(suite.AppContextForTest(), origDutyLocation.ID) + suite.NoError(err) + suite.Equal(offices.Name, "PPPO Jacksonville - USN") +} + +func (suite *TransportationOfficeServiceSuite) Test_FindClosestCounselingOfficeOCONUS() { + testContractName := "Test_findOconusGblocDepartmentIndicator" + testContractCode := "Test_findOconusGblocDepartmentIndicator_Code" + testPostalCode := "32228" + testPostalCode2 := "99701" + testGbloc := "CNNQ" + testGbloc2 := "KKFA" + testTransportationName := "JPPSO - North West (JEAT) - USA" + testTransportationName2 := "PPPO Fort Belvoir - USA" + + serviceAffiliations := []models.ServiceMemberAffiliation{models.AffiliationARMY, + models.AffiliationNAVY, models.AffiliationMARINES, models.AffiliationAIRFORCE, models.AffiliationCOASTGUARD, + models.AffiliationSPACEFORCE} + + setupServiceMember := func(serviceMemberAffiliation models.ServiceMemberAffiliation) models.ServiceMember { + customServiceMember := models.ServiceMember{ + FirstName: models.StringPointer("John"), + LastName: models.StringPointer("Doe"), + Telephone: models.StringPointer("999-999-9999"), + SecondaryTelephone: models.StringPointer("123-555-9999"), + PersonalEmail: models.StringPointer("peyton@example.com"), + Edipi: models.StringPointer("1000011111"), + Affiliation: &serviceMemberAffiliation, + Suffix: models.StringPointer("Random suffix string"), + PhoneIsPreferred: models.BoolPointer(false), + EmailIsPreferred: models.BoolPointer(false), + } + + customAddress := models.Address{ + StreetAddress1: "987 Another Street", + } + + customUser := models.User{ + OktaEmail: "test_email@email.com", + } + + serviceMember := factory.BuildServiceMember(suite.DB(), []factory.Customization{ + {Model: customServiceMember}, + {Model: customAddress}, + {Model: customUser}, + }, nil) + + return serviceMember + } + + createContract := func(appCtx appcontext.AppContext, contractCode string, contractName string) (*models.ReContract, error) { + // See if contract code already exists. + exists, err := appCtx.DB().Where("code = ?", contractCode).Exists(&models.ReContract{}) + if err != nil { + return nil, fmt.Errorf("could not determine if contract code [%s] existed: %w", contractCode, err) + } + if exists { + return nil, fmt.Errorf("the provided contract code [%s] already exists", contractCode) + } + + // Contract code is new; insert it. + contract := models.ReContract{ + Code: contractCode, + Name: contractName, + } + verrs, err := appCtx.DB().ValidateAndSave(&contract) + if verrs.HasAny() { + return nil, fmt.Errorf("validation errors when saving contract [%+v]: %w", contract, verrs) + } + if err != nil { + return nil, fmt.Errorf("could not save contract [%+v]: %w", contract, err) + } + return &contract, nil + } + + setupDataForOconusSearchCounselingOffice := func(contract models.ReContract, postalCode string, gbloc string, transportationName string) (models.ReRateArea, models.OconusRateArea, models.UsPostRegionCity, models.DutyLocation) { + rateAreaCode := uuid.Must(uuid.NewV4()).String()[0:5] + rateArea := models.ReRateArea{ + ID: uuid.Must(uuid.NewV4()), + ContractID: contract.ID, + IsOconus: true, + Code: rateAreaCode, + Name: fmt.Sprintf("Alaska-%s", rateAreaCode), + Contract: contract, + } + verrs, err := suite.DB().ValidateAndCreate(&rateArea) + if verrs.HasAny() { + suite.Fail(verrs.Error()) + } + if err != nil { + suite.Fail(err.Error()) + } + + us_country, err := models.FetchCountryByCode(suite.DB(), "US") + suite.NotNil(us_country) + suite.Nil(err) + + usprc, err := models.FindByZipCode(suite.AppContextForTest().DB(), postalCode) + suite.NotNil(usprc) + suite.FatalNoError(err) + + oconusRateArea := models.OconusRateArea{ + ID: uuid.Must(uuid.NewV4()), + RateAreaId: rateArea.ID, + CountryId: us_country.ID, + UsPostRegionCityId: usprc.ID, + Active: true, + } + verrs, err = suite.DB().ValidateAndCreate(&oconusRateArea) + if verrs.HasAny() { + suite.Fail(verrs.Error()) + } + if err != nil { + suite.Fail(err.Error()) + } + + address := models.Address{ + StreetAddress1: "123 Ocunus St.", + City: "Fairbanks", + State: "AK", + PostalCode: postalCode, + County: "Fairbanks North Star Borough", + IsOconus: models.BoolPointer(true), + UsPostRegionCityId: &usprc.ID, + CountryId: models.UUIDPointer(us_country.ID), + } + suite.MustSave(&address) + + origDutyLocation := factory.BuildDutyLocation(suite.DB(), []factory.Customization{ { Model: models.DutyLocation{ - ProvidesServicesCounseling: false, + AddressID: address.ID, + ProvidesServicesCounseling: true, + }, + }, + { + Model: models.TransportationOffice{ + Name: transportationName, + Gbloc: gbloc, + ProvidesCloseout: true, }, }, - {Model: models.TransportationOffice{ - Name: "NS Mayport", - Gbloc: "CNNQ", - ProvidesCloseout: false, - }}, - {Model: models.ServiceMember{Affiliation: &airForce}}, }, nil) + suite.MustSave(&origDutyLocation) + found_duty_location, _ := models.FetchDutyLocation(suite.DB(), origDutyLocation.ID) + return rateArea, oconusRateArea, *usprc, found_duty_location + } + + suite.Run("success - findOconusGblocDepartmentIndicator - returns default GLOC for departmentAffiliation if no specific departmentAffilation mapping is defined", func() { + contract, err := createContract(suite.AppContextForTest(), testContractCode, testContractName) + suite.NotNil(contract) + suite.FatalNoError(err) + + const fairbanksAlaskaPostalCode = "99790" + _, oconusRateArea, _, dutylocation := setupDataForOconusSearchCounselingOffice(*contract, fairbanksAlaskaPostalCode, testGbloc, testTransportationName) + + // setup department affiliation to GBLOC mappings + expected_gbloc := "TEST-GBLOC" + jppsoRegion := models.JppsoRegions{ + Code: expected_gbloc, + Name: "TEST PPM", + } + suite.MustSave(&jppsoRegion) - suite.NotNil(origDutyLocationCONUS) - suite.NotNil(suite.toFetcher) + gblocAors := models.GblocAors{ + JppsoRegionID: jppsoRegion.ID, + OconusRateAreaID: oconusRateArea.ID, + // DepartmentIndicator is nil, + } + suite.MustSave(&gblocAors) - officeCONUS, err := suite.toFetcher.FindClosestCounselingOffice(suite.AppContextForTest(), origDutyLocationCONUS.ID) + serviceAffiliations := []models.ServiceMemberAffiliation{models.AffiliationARMY, + models.AffiliationNAVY, models.AffiliationMARINES, models.AffiliationAIRFORCE, models.AffiliationCOASTGUARD, + models.AffiliationSPACEFORCE} - suite.NoError(err) - suite.NotNil(officeCONUS) - suite.Equal("PPPO Jacksonville - USN", officeCONUS.Name) // Check for CONUS condition + // loop through and make sure all branches are using expected default GBLOC + for _, affiliation := range serviceAffiliations { + serviceMember := setupServiceMember(affiliation) + appCtx := suite.AppContextWithSessionForTest(&auth.Session{ + ServiceMemberID: serviceMember.ID, + }) + suite.Nil(err) + departmentIndictor, err := findOconusGblocDepartmentIndicator(appCtx, dutylocation) + suite.NotNil(departmentIndictor) + suite.Nil(err) + suite.Nil(departmentIndictor.DepartmentIndicator) + suite.Equal(expected_gbloc, departmentIndictor.Gbloc) + } }) - // Test for OCONUS - suite.Run("success - find closest counseling office for OCONUS", func() { - customAddressOCONUS := models.Address{ - ID: uuid.Must(uuid.NewV4()), - StreetAddress1: "456 Yokota St", - City: "Yokota AB", - State: "Tokyo", - PostalCode: "197-0001", - County: "Japan", - IsOconus: models.BoolPointer(true), - } - suite.MustSave(&customAddressOCONUS) - army := models.AffiliationARMY - - origDutyLocationOCONUS := factory.BuildDutyLocation(suite.DB(), []factory.Customization{ - {Model: customAddressOCONUS, Type: &factory.Addresses.DutyLocationAddress}, + suite.Run("Success - findOconusGblocDepartmentIndicator - Should return specific GLOC for departmentAffiliation when a specific departmentAffilation mapping is defined", func() { + contract, err := createContract(suite.AppContextForTest(), testContractCode, testContractName) + suite.NotNil(contract) + suite.FatalNoError(err) + + _, oconusRateArea, _, dutylocation := setupDataForOconusSearchCounselingOffice(*contract, testPostalCode, testGbloc, testTransportationName) + + departmentIndicators := []models.DepartmentIndicator{models.DepartmentIndicatorARMY, + models.DepartmentIndicatorARMYCORPSOFENGINEERS, models.DepartmentIndicatorCOASTGUARD, + models.DepartmentIndicatorNAVYANDMARINES, models.DepartmentIndicatorAIRANDSPACEFORCE} + + expectedAffiliationToDepartmentIndicatorMap := make(map[string]string, 0) + expectedAffiliationToDepartmentIndicatorMap[models.AffiliationARMY.String()] = models.DepartmentIndicatorARMY.String() + expectedAffiliationToDepartmentIndicatorMap[models.AffiliationNAVY.String()] = models.DepartmentIndicatorNAVYANDMARINES.String() + expectedAffiliationToDepartmentIndicatorMap[models.AffiliationMARINES.String()] = models.DepartmentIndicatorNAVYANDMARINES.String() + expectedAffiliationToDepartmentIndicatorMap[models.AffiliationAIRFORCE.String()] = models.DepartmentIndicatorAIRANDSPACEFORCE.String() + expectedAffiliationToDepartmentIndicatorMap[models.AffiliationCOASTGUARD.String()] = models.DepartmentIndicatorCOASTGUARD.String() + expectedAffiliationToDepartmentIndicatorMap[models.AffiliationSPACEFORCE.String()] = models.DepartmentIndicatorAIRANDSPACEFORCE.String() + + // setup department affiliation to GBLOC mappings + expected_gbloc := "TEST-GBLOC" + jppsoRegion := models.JppsoRegions{ + Code: expected_gbloc, + Name: "TEST PPM", + } + suite.MustSave(&jppsoRegion) + + defaultGblocAors := models.GblocAors{ + JppsoRegionID: jppsoRegion.ID, + OconusRateAreaID: oconusRateArea.ID, + //DepartmentIndicator is nil, + } + suite.MustSave(&defaultGblocAors) + + // setup specific departmentAffiliation mapping for each branch + for _, departmentIndicator := range departmentIndicators { + gblocAors := models.GblocAors{ + JppsoRegionID: jppsoRegion.ID, + OconusRateAreaID: oconusRateArea.ID, + DepartmentIndicator: models.StringPointer(departmentIndicator.String()), + } + suite.MustSave(&gblocAors) + } + + // loop through and make sure all branches are using it's own dedicated GBLOC and not default + for _, affiliation := range serviceAffiliations { + serviceMember := setupServiceMember(affiliation) + appCtx := suite.AppContextWithSessionForTest(&auth.Session{ + ServiceMemberID: serviceMember.ID, + }) + suite.Nil(err) + departmentIndictor, err := findOconusGblocDepartmentIndicator(appCtx, dutylocation) + suite.NotNil(departmentIndictor) + suite.Nil(err) + suite.NotNil(departmentIndictor.DepartmentIndicator) + if match, ok := expectedAffiliationToDepartmentIndicatorMap[affiliation.String()]; ok { + // verify service member's affiliation matches on specific departmentIndicator mapping record + suite.Equal(match, *departmentIndictor.DepartmentIndicator) + } else { + suite.Fail(fmt.Sprintf("key does not exist for %s", affiliation.String())) + } + suite.Equal(expected_gbloc, departmentIndictor.Gbloc) + } + }) + + suite.Run("success - offices using default departmentIndicator mapping", func() { + contract, err := createContract(suite.AppContextForTest(), testContractCode, testContractName) + suite.NotNil(contract) + suite.FatalNoError(err) + + _, oconusRateArea, _, dutylocation := setupDataForOconusSearchCounselingOffice(*contract, testPostalCode, testGbloc, testTransportationName) + + // setup department affiliation to GBLOC mappings + jppsoRegion := models.JppsoRegions{ + Code: testGbloc, + Name: "TEST PPM", + } + suite.MustSave(&jppsoRegion) + + gblocAors := models.GblocAors{ + JppsoRegionID: jppsoRegion.ID, + OconusRateAreaID: oconusRateArea.ID, + } + suite.MustSave(&gblocAors) + + postalCodeToGBLOC := models.PostalCodeToGBLOC{ + PostalCode: testPostalCode, + GBLOC: testGbloc, + CreatedAt: time.Now(), + UpdatedAt: time.Now(), + } + suite.MustSave(&postalCodeToGBLOC) + + serviceMember := setupServiceMember(models.AffiliationAIRFORCE) + appCtx := suite.AppContextWithSessionForTest(&auth.Session{ + ServiceMemberID: serviceMember.ID, + }) + + suite.Nil(err) + offices, err := findCounselingOffice(appCtx, dutylocation.ID) + suite.NotNil(offices) + suite.Nil(err) + suite.Equal(1, len(offices)) + suite.Equal(testTransportationName, offices[0].Name) + + factory.BuildTransportationOffice(suite.DB(), []factory.Customization{ { - Model: models.DutyLocation{ - ProvidesServicesCounseling: false, + Model: models.TransportationOffice{ + Name: testTransportationName2, + ProvidesCloseout: true, + Gbloc: testGbloc, + }, + }, + }, nil) + offices, err = findCounselingOffice(appCtx, dutylocation.ID) + suite.NotNil(offices) + suite.Nil(err) + suite.Equal(2, len(offices)) + }) + + suite.Run("Should return correct office based on service affiliation", func() { + contract, err := createContract(suite.AppContextForTest(), testContractCode, testContractName) + suite.NotNil(contract) + suite.FatalNoError(err) + + _, oconusRateArea, _, dutylocation := setupDataForOconusSearchCounselingOffice(*contract, testPostalCode, testGbloc, testTransportationName) + + jppsoRegion_AFSF := models.JppsoRegions{ + Code: testGbloc, + Name: "TEST PPO", + } + suite.MustSave(&jppsoRegion_AFSF) + + gblocAors_AFSF := models.GblocAors{ + JppsoRegionID: jppsoRegion_AFSF.ID, + OconusRateAreaID: oconusRateArea.ID, + DepartmentIndicator: models.StringPointer(models.DepartmentIndicatorAIRANDSPACEFORCE.String()), + } + suite.MustSave(&gblocAors_AFSF) + + postalCodeToGBLOC_AFSF := models.PostalCodeToGBLOC{ + PostalCode: testPostalCode, + GBLOC: testGbloc, + CreatedAt: time.Now(), + UpdatedAt: time.Now(), + } + suite.MustSave(&postalCodeToGBLOC_AFSF) + + jppsoRegion_not_AFSF := models.JppsoRegions{ + Code: testGbloc2, + Name: "TEST PPO 2", + } + suite.MustSave(&jppsoRegion_not_AFSF) + + gblocAors_not_AFSF := models.GblocAors{ + JppsoRegionID: jppsoRegion_not_AFSF.ID, + OconusRateAreaID: oconusRateArea.ID, + } + suite.MustSave(&gblocAors_not_AFSF) + + postalCodeToGBLOC_not_AFSF := models.PostalCodeToGBLOC{ + PostalCode: testPostalCode2, + GBLOC: testGbloc2, + CreatedAt: time.Now(), + UpdatedAt: time.Now(), + } + suite.MustSave(&postalCodeToGBLOC_not_AFSF) + + // add transportation office for other branches not AF/SF + factory.BuildTransportationOffice(suite.DB(), []factory.Customization{ + { + Model: models.TransportationOffice{ + Name: testTransportationName2, + ProvidesCloseout: true, + Gbloc: testGbloc2, }, }, - {Model: models.TransportationOffice{ - Name: "Yokota AB", - Gbloc: "JPN1", - ProvidesCloseout: true, - }}, - {Model: models.ServiceMember{Affiliation: &army}}, }, nil) - suite.NotNil(origDutyLocationOCONUS) - suite.NotNil(suite.toFetcher) - officeOCONUS, err := suite.toFetcher.FindClosestCounselingOffice(suite.AppContextForTest(), origDutyLocationOCONUS.ID) - suite.NoError(err) - suite.NotNil(officeOCONUS) - suite.Equal("Yokota AB - USN", officeOCONUS.Name) // Check for OCONUS condition + for _, affiliation := range serviceAffiliations { + serviceMember := setupServiceMember(affiliation) + if affiliation == models.AffiliationAIRFORCE || affiliation == models.AffiliationSPACEFORCE { + appCtx := suite.AppContextWithSessionForTest(&auth.Session{ + ServiceMemberID: serviceMember.ID, + }) + offices, err := suite.toFetcher.FindClosestCounselingOffice(appCtx, dutylocation.ID) + suite.NotNil(offices) + suite.Nil(err) + suite.Equal(testTransportationName, offices.Name) + } else { + appCtx := suite.AppContextWithSessionForTest(&auth.Session{ + ServiceMemberID: serviceMember.ID, + }) + offices, err := suite.toFetcher.FindClosestCounselingOffice(appCtx, dutylocation.ID) + suite.NotNil(offices) + suite.Nil(err) + suite.Equal(testTransportationName2, offices.Name) + } + } }) } From c70c798d8b05e810becfed343c076b9299d59748 Mon Sep 17 00:00:00 2001 From: Samay Sofo Date: Fri, 10 Jan 2025 14:41:35 +0000 Subject: [PATCH 14/71] merged main and refactored refactored failing tests --- .../mto_service_item/mto_service_item_creator_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/services/mto_service_item/mto_service_item_creator_test.go b/pkg/services/mto_service_item/mto_service_item_creator_test.go index bb797d0451a..cd18573a069 100644 --- a/pkg/services/mto_service_item/mto_service_item_creator_test.go +++ b/pkg/services/mto_service_item/mto_service_item_creator_test.go @@ -2109,7 +2109,7 @@ func (suite *MTOServiceItemServiceSuite) TestPriceEstimator() { } builder := query.NewQueryBuilder() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &mocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -2409,7 +2409,7 @@ func (suite *MTOServiceItemServiceSuite) TestPriceEstimator() { } builder := query.NewQueryBuilder() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &mocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), From ec9946b34e5988de48c0dec917589abbac5ad9d3 Mon Sep 17 00:00:00 2001 From: Samay Sofo Date: Mon, 13 Jan 2025 17:10:21 +0000 Subject: [PATCH 15/71] fixed failing tests for disabling the counseling checkbox --- .../Office/RequestedShipments/RequestedShipments.test.jsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/components/Office/RequestedShipments/RequestedShipments.test.jsx b/src/components/Office/RequestedShipments/RequestedShipments.test.jsx index 8fdd77d5f51..3ba0372039f 100644 --- a/src/components/Office/RequestedShipments/RequestedShipments.test.jsx +++ b/src/components/Office/RequestedShipments/RequestedShipments.test.jsx @@ -667,7 +667,7 @@ describe('RequestedShipments', () => { expect(screen.getByTestId('counselingFee')).toBeInTheDocument(); }); - it('does not render the "Add service items to move" section or Counseling option when all shipments are PPM', () => { + it('should disable the counseling checkbox when full ppm shipment', () => { const testPropsServiceItemsEmpty = { mtoServiceItems: serviceItemsEmpty, mtoShipments: ppmOnlyShipments, @@ -675,10 +675,9 @@ describe('RequestedShipments', () => { }; renderComponent(testPropsServiceItemsEmpty); - expect(screen.queryByText('Add service items to this move')).not.toBeInTheDocument(); + expect(screen.queryByText('Add service items to this move')).toBeInTheDocument(); expect(screen.getByText('Approve selected')).toBeInTheDocument(); - expect(screen.queryByTestId('shipmentManagementFee')).not.toBeInTheDocument(); - expect(screen.queryByTestId('counselingFee')).not.toBeInTheDocument(); + expect(screen.queryByTestId('counselingFee')).toBeDisabled(); }); }); }); From 63555bb8861e707485a2bd2bd53e832a98b177a0 Mon Sep 17 00:00:00 2001 From: Samay Sofo Date: Mon, 13 Jan 2025 18:22:44 +0000 Subject: [PATCH 16/71] updated failing tests --- .../SubmittedRequestedShipments.test.jsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/components/Office/RequestedShipments/SubmittedRequestedShipments.test.jsx b/src/components/Office/RequestedShipments/SubmittedRequestedShipments.test.jsx index 1388bdf84e4..30ec9358f6f 100644 --- a/src/components/Office/RequestedShipments/SubmittedRequestedShipments.test.jsx +++ b/src/components/Office/RequestedShipments/SubmittedRequestedShipments.test.jsx @@ -177,7 +177,7 @@ describe('RequestedShipments', () => { moveCode: 'TE5TC0DE', }; - it('does not render the "Add service items to move" section or Counseling option when all shipments are PPM', () => { + it('should disable the counseling checkbox when full ppm shipment', () => { const testPropsServiceItemsEmpty = { mtoServiceItems: serviceItemsEmpty, mtoShipments: ppmOnlyShipments, @@ -185,10 +185,9 @@ describe('RequestedShipments', () => { }; renderComponent(testPropsServiceItemsEmpty); - expect(screen.queryByText('Add service items to this move')).not.toBeInTheDocument(); + expect(screen.queryByText('Add service items to this move')).toBeInTheDocument(); expect(screen.getByText('Approve selected')).toBeInTheDocument(); - expect(screen.queryByTestId('shipmentManagementFee')).not.toBeInTheDocument(); - expect(screen.queryByTestId('counselingFee')).not.toBeInTheDocument(); + expect(screen.queryByTestId('counselingFee')).toBeDisabled(); }); }); }); From f946703b210248e8429b13d3fd3a1b33ae9c305b Mon Sep 17 00:00:00 2001 From: Samay Sofo Date: Wed, 22 Jan 2025 10:42:30 +0000 Subject: [PATCH 17/71] fixed suggested comments from pr. --- .../mocks/TransportationOfficesFetcher.go | 12 +-- pkg/services/move/move_router.go | 2 +- pkg/services/transportation_office.go | 2 +- .../transportation_office_fetcher.go | 16 ++-- .../transportation_office_fetcher_test.go | 89 +++++-------------- .../RequestedShipments.test.jsx | 2 +- .../SubmittedRequestedShipments.test.jsx | 2 +- 7 files changed, 40 insertions(+), 85 deletions(-) diff --git a/pkg/services/mocks/TransportationOfficesFetcher.go b/pkg/services/mocks/TransportationOfficesFetcher.go index ca9277f5f9f..47f5a5f9477 100644 --- a/pkg/services/mocks/TransportationOfficesFetcher.go +++ b/pkg/services/mocks/TransportationOfficesFetcher.go @@ -17,22 +17,24 @@ type TransportationOfficesFetcher struct { } // FindClosestCounselingOffice provides a mock function with given fields: appCtx, dutyLocationID -func (_m *TransportationOfficesFetcher) FindClosestCounselingOffice(appCtx appcontext.AppContext, dutyLocationID uuid.UUID) (models.TransportationOffice, error) { +func (_m *TransportationOfficesFetcher) FindClosestCounselingOffice(appCtx appcontext.AppContext, dutyLocationID uuid.UUID) (*models.TransportationOffice, error) { ret := _m.Called(appCtx, dutyLocationID) if len(ret) == 0 { panic("no return value specified for FindClosestCounselingOffice") } - var r0 models.TransportationOffice + var r0 *models.TransportationOffice var r1 error - if rf, ok := ret.Get(0).(func(appcontext.AppContext, uuid.UUID) (models.TransportationOffice, error)); ok { + if rf, ok := ret.Get(0).(func(appcontext.AppContext, uuid.UUID) (*models.TransportationOffice, error)); ok { return rf(appCtx, dutyLocationID) } - if rf, ok := ret.Get(0).(func(appcontext.AppContext, uuid.UUID) models.TransportationOffice); ok { + if rf, ok := ret.Get(0).(func(appcontext.AppContext, uuid.UUID) *models.TransportationOffice); ok { r0 = rf(appCtx, dutyLocationID) } else { - r0 = ret.Get(0).(models.TransportationOffice) + if ret.Get(0) != nil { + r0 = ret.Get(0).(*models.TransportationOffice) + } } if rf, ok := ret.Get(1).(func(appcontext.AppContext, uuid.UUID) error); ok { diff --git a/pkg/services/move/move_router.go b/pkg/services/move/move_router.go index 9b47f5b5d48..ce706240b69 100644 --- a/pkg/services/move/move_router.go +++ b/pkg/services/move/move_router.go @@ -238,7 +238,7 @@ func (router moveRouter) sendToServiceCounselor(appCtx appcontext.AppContext, mo appCtx.Logger().Error(msg, zap.Error(err)) return apperror.NewQueryError("Closest Counseling Office", err, "Failed to find counseling office that provides counseling") } - move.CounselingOffice = &closestCounselingOffice + move.CounselingOffice = closestCounselingOffice } if verrs, err := appCtx.DB().ValidateAndUpdate(&move.MTOShipments[i]); verrs.HasAny() || err != nil { diff --git a/pkg/services/transportation_office.go b/pkg/services/transportation_office.go index a0d5cd95b8c..f8cc2cf3afa 100644 --- a/pkg/services/transportation_office.go +++ b/pkg/services/transportation_office.go @@ -13,5 +13,5 @@ type TransportationOfficesFetcher interface { GetTransportationOffice(appCtx appcontext.AppContext, transportationOfficeID uuid.UUID, includeOnlyPPMCloseoutOffices bool) (*models.TransportationOffice, error) GetAllGBLOCs(appCtx appcontext.AppContext) (*models.GBLOCs, error) GetCounselingOffices(appCtx appcontext.AppContext, dutyLocationID uuid.UUID) (*models.TransportationOffices, error) - FindClosestCounselingOffice(appCtx appcontext.AppContext, dutyLocationID uuid.UUID) (models.TransportationOffice, error) + FindClosestCounselingOffice(appCtx appcontext.AppContext, dutyLocationID uuid.UUID) (*models.TransportationOffice, error) } diff --git a/pkg/services/transportation_office/transportation_office_fetcher.go b/pkg/services/transportation_office/transportation_office_fetcher.go index 6ebb89837e4..0e9948752c7 100644 --- a/pkg/services/transportation_office/transportation_office_fetcher.go +++ b/pkg/services/transportation_office/transportation_office_fetcher.go @@ -307,13 +307,13 @@ func findOconusGblocDepartmentIndicator(appCtx appcontext.AppContext, dutyLocati serviceMember.Affiliation, dutyLocation.Name, *departmentIndicator, dutyLocation.Address.ID)) } -// Return the closeset transportation office in the GBLOC of the given duty location for oconus/conus duty locations -func (o transportationOfficesFetcher) FindClosestCounselingOffice(appCtx appcontext.AppContext, dutyLocationID uuid.UUID) (models.TransportationOffice, error) { +// Return the closest transportation office in the GBLOC of the given duty location for oconus/conus duty locations +func (o transportationOfficesFetcher) FindClosestCounselingOffice(appCtx appcontext.AppContext, dutyLocationID uuid.UUID) (*models.TransportationOffice, error) { var closestOffice models.TransportationOffice duty_location, err := models.FetchDutyLocation(appCtx.DB(), dutyLocationID) if err != nil { appCtx.Logger().Error("Failed to fetch duty location", zap.Error(err)) - return closestOffice, err + return &closestOffice, err } var sqlQuery string @@ -322,7 +322,7 @@ func (o transportationOfficesFetcher) FindClosestCounselingOffice(appCtx appcont gblocDepartmentIndicator, err := findOconusGblocDepartmentIndicator(appCtx, duty_location) if err != nil { appCtx.Logger().Error("Failed to find OCONUS GBLOC department indicator", zap.Error(err)) - return closestOffice, err + return &closestOffice, err } sqlQuery = ` @@ -357,10 +357,10 @@ func (o transportationOfficesFetcher) FindClosestCounselingOffice(appCtx appcont if err := appCtx.DB().Q().RawQuery(sqlQuery, dutyLocationID, gblocDepartmentIndicator.Gbloc).First(&closestOffice); err != nil { appCtx.Logger().Error("Failed to execute OCONUS SQL query", zap.Error(err)) if errors.Cause(err).Error() != models.RecordNotFoundErrorString { - return closestOffice, err + return &closestOffice, err } } - return closestOffice, nil + return &closestOffice, nil } else { // Find for conus duty location @@ -391,10 +391,10 @@ func (o transportationOfficesFetcher) FindClosestCounselingOffice(appCtx appcont if err := appCtx.DB().Q().RawQuery(sqlQuery, dutyLocationID).First(&closestOffice); err != nil { appCtx.Logger().Error("Failed to execute CONUS SQL query", zap.Error(err)) if errors.Cause(err).Error() != models.RecordNotFoundErrorString { - return closestOffice, err + return &closestOffice, err } } } - return closestOffice, nil + return &closestOffice, nil } diff --git a/pkg/services/transportation_office/transportation_office_fetcher_test.go b/pkg/services/transportation_office/transportation_office_fetcher_test.go index cca4d4c6fd5..a1f47237cd9 100644 --- a/pkg/services/transportation_office/transportation_office_fetcher_test.go +++ b/pkg/services/transportation_office/transportation_office_fetcher_test.go @@ -680,17 +680,12 @@ func (suite *TransportationOfficeServiceSuite) Test_GetTransportationOffice() { func (suite *TransportationOfficeServiceSuite) Test_FindClosestCounselingOfficeCONUS() { suite.toFetcher = NewTransportationOfficesFetcher() - customAddress1 := models.Address{ - ID: uuid.Must(uuid.NewV4()), - StreetAddress1: "123 Mayport St", - City: "Mayport", - State: "FL", - PostalCode: "32228", - County: models.StringPointer("Duval"), - IsOconus: models.BoolPointer(false), - } factory.BuildDutyLocation(suite.DB(), []factory.Customization{ - {Model: customAddress1, Type: &factory.Addresses.DutyLocationAddress}, + {Model: models.Address{ + ID: uuid.Must(uuid.NewV4()), + PostalCode: "32228", + IsOconus: models.BoolPointer(false), + }, Type: &factory.Addresses.DutyLocationAddress}, { Model: models.DutyLocation{ ProvidesServicesCounseling: false, @@ -702,18 +697,11 @@ func (suite *TransportationOfficeServiceSuite) Test_FindClosestCounselingOfficeC }, }, }, nil) - - customAddress2 := models.Address{ - ID: uuid.Must(uuid.NewV4()), - StreetAddress1: "123 Mayport St", - City: "Jacksonville", - State: "FL", - PostalCode: "32228", - County: models.StringPointer("Duval"), - IsOconus: models.BoolPointer(false), - } factory.BuildDutyLocation(suite.DB(), []factory.Customization{ - {Model: customAddress2, Type: &factory.Addresses.DutyLocationAddress}, + {Model: models.Address{ + PostalCode: "32228", + IsOconus: models.BoolPointer(false), + }, Type: &factory.Addresses.DutyLocationAddress}, { Model: models.DutyLocation{ ProvidesServicesCounseling: true, @@ -725,18 +713,12 @@ func (suite *TransportationOfficeServiceSuite) Test_FindClosestCounselingOfficeC }, }, }, nil) - - customAddress3 := models.Address{ - ID: uuid.Must(uuid.NewV4()), - StreetAddress1: "123 Mayport St", - City: "Palm Valley", - State: "FL", - PostalCode: "32228", - County: models.StringPointer("Duval"), - IsOconus: models.BoolPointer(false), - } origDutyLocation := factory.BuildDutyLocation(suite.DB(), []factory.Customization{ - {Model: customAddress3, Type: &factory.Addresses.DutyLocationAddress}, + {Model: models.Address{ + ID: uuid.Must(uuid.NewV4()), + PostalCode: "32228", + IsOconus: models.BoolPointer(false), + }, Type: &factory.Addresses.DutyLocationAddress}, { Model: models.DutyLocation{ ProvidesServicesCounseling: true, @@ -750,18 +732,11 @@ func (suite *TransportationOfficeServiceSuite) Test_FindClosestCounselingOfficeC }, }, }, nil) - - customAddress4 := models.Address{ - ID: uuid.Must(uuid.NewV4()), - StreetAddress1: "123 Mayport St", - City: "Fernandina", - State: "FL", - PostalCode: "32228", - County: models.StringPointer("Duval"), - IsOconus: models.BoolPointer(false), - } factory.BuildDutyLocation(suite.DB(), []factory.Customization{ - {Model: customAddress4, Type: &factory.Addresses.DutyLocationAddress}, + {Model: models.Address{ + PostalCode: "32228", + IsOconus: models.BoolPointer(false), + }, Type: &factory.Addresses.DutyLocationAddress}, { Model: models.DutyLocation{ ProvidesServicesCounseling: true, @@ -796,31 +771,10 @@ func (suite *TransportationOfficeServiceSuite) Test_FindClosestCounselingOfficeO models.AffiliationSPACEFORCE} setupServiceMember := func(serviceMemberAffiliation models.ServiceMemberAffiliation) models.ServiceMember { - customServiceMember := models.ServiceMember{ - FirstName: models.StringPointer("John"), - LastName: models.StringPointer("Doe"), - Telephone: models.StringPointer("999-999-9999"), - SecondaryTelephone: models.StringPointer("123-555-9999"), - PersonalEmail: models.StringPointer("peyton@example.com"), - Edipi: models.StringPointer("1000011111"), - Affiliation: &serviceMemberAffiliation, - Suffix: models.StringPointer("Random suffix string"), - PhoneIsPreferred: models.BoolPointer(false), - EmailIsPreferred: models.BoolPointer(false), - } - - customAddress := models.Address{ - StreetAddress1: "987 Another Street", - } - - customUser := models.User{ - OktaEmail: "test_email@email.com", - } - serviceMember := factory.BuildServiceMember(suite.DB(), []factory.Customization{ - {Model: customServiceMember}, - {Model: customAddress}, - {Model: customUser}, + {Model: models.ServiceMember{ + Affiliation: &serviceMemberAffiliation, + }}, }, nil) return serviceMember @@ -919,7 +873,6 @@ func (suite *TransportationOfficeServiceSuite) Test_FindClosestCounselingOfficeO }, }, }, nil) - suite.MustSave(&origDutyLocation) found_duty_location, _ := models.FetchDutyLocation(suite.DB(), origDutyLocation.ID) return rateArea, oconusRateArea, *usprc, found_duty_location } diff --git a/src/components/Office/RequestedShipments/RequestedShipments.test.jsx b/src/components/Office/RequestedShipments/RequestedShipments.test.jsx index 3ba0372039f..99b9c4be671 100644 --- a/src/components/Office/RequestedShipments/RequestedShipments.test.jsx +++ b/src/components/Office/RequestedShipments/RequestedShipments.test.jsx @@ -667,7 +667,7 @@ describe('RequestedShipments', () => { expect(screen.getByTestId('counselingFee')).toBeInTheDocument(); }); - it('should disable the counseling checkbox when full ppm shipment', () => { + it('should disable the counseling checkbox when all shipments are PPM', () => { const testPropsServiceItemsEmpty = { mtoServiceItems: serviceItemsEmpty, mtoShipments: ppmOnlyShipments, diff --git a/src/components/Office/RequestedShipments/SubmittedRequestedShipments.test.jsx b/src/components/Office/RequestedShipments/SubmittedRequestedShipments.test.jsx index 30ec9358f6f..68e7e6e6964 100644 --- a/src/components/Office/RequestedShipments/SubmittedRequestedShipments.test.jsx +++ b/src/components/Office/RequestedShipments/SubmittedRequestedShipments.test.jsx @@ -177,7 +177,7 @@ describe('RequestedShipments', () => { moveCode: 'TE5TC0DE', }; - it('should disable the counseling checkbox when full ppm shipment', () => { + it('should disable the counseling checkbox when all shipments are PPM', () => { const testPropsServiceItemsEmpty = { mtoServiceItems: serviceItemsEmpty, mtoShipments: ppmOnlyShipments, From 48d0e9be92324368dfdf01101676d360eec8a5c5 Mon Sep 17 00:00:00 2001 From: Samay Sofo Date: Wed, 22 Jan 2025 12:08:25 +0000 Subject: [PATCH 18/71] Added test to to move router for ppm --- pkg/services/move/move_router_test.go | 72 +++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/pkg/services/move/move_router_test.go b/pkg/services/move/move_router_test.go index 89d6d6f351d..f62d3865f00 100644 --- a/pkg/services/move/move_router_test.go +++ b/pkg/services/move/move_router_test.go @@ -990,6 +990,78 @@ func (suite *MoveServiceSuite) TestMoveSubmission() { suite.Contains(err.Error(), expError) suite.Equal(models.MoveStatusNeedsServiceCounseling, move.Status, "expected move to still be in NEEDS_SERVICE_COUNSELING status when routing has failed") }) + + suite.Run("SignedCirtification created, Route PPM moves to the closest service counseling office and set status to NEEDS SERVICE COUNSELING", func() { + // Under test: MoveRouter.Submit Full PPM should route to service counselor + // Set up: Create moves and SignedCertification + // Expected outcome: signed cert is created + // Expected outcome: Move status is set to needs service counseling + tests := []struct { + desc string + ProvidesServicesCounseling bool + moveStatus models.MoveStatus + }{ + {"Routes to Service Counseling", true, models.MoveStatusNeedsServiceCounseling}, + {"Routes to Service Counseling", false, models.MoveStatusNeedsServiceCounseling}, + } + for _, tt := range tests { + suite.Run(tt.desc, func() { + move := factory.BuildMove(suite.DB(), []factory.Customization{ + { + Model: models.DutyLocation{ + ProvidesServicesCounseling: tt.ProvidesServicesCounseling, + }, + Type: &factory.DutyLocations.OriginDutyLocation, + }, + { + Model: models.Move{ + Status: models.MoveStatusDRAFT, + }, + }, + }, nil) + + shipment := factory.BuildMTOShipmentMinimal(suite.DB(), []factory.Customization{ + { + Model: models.MTOShipment{ + Status: models.MTOShipmentStatusDraft, + ShipmentType: models.MTOShipmentTypePPM, + }, + }, + { + Model: move, + LinkOnly: true, + }, + }, nil) + + ppmShipment := factory.BuildPPMShipment(suite.DB(), []factory.Customization{ + { + Model: models.PPMShipment{ + Status: models.PPMShipmentStatusDraft, + }, + }, + }, nil) + + move.MTOShipments = models.MTOShipments{shipment} + move.MTOShipments[0].PPMShipment = &ppmShipment + + newSignedCertification := factory.BuildSignedCertification(nil, []factory.Customization{ + { + Model: move, + LinkOnly: true, + }, + }, nil) + err := moveRouter.Submit(suite.AppContextForTest(), &move, &newSignedCertification) + suite.NoError(err) + err = suite.DB().Where("move_id = $1", move.ID).First(&newSignedCertification) + suite.NoError(err) + suite.NotNil(newSignedCertification) + + err = suite.DB().Find(&move, move.ID) + suite.NoError(err) + suite.Equal(tt.moveStatus, move.Status) + }) + } + }) } func (suite *MoveServiceSuite) TestMoveCancellation() { From c7c50989b48229b5fc19b45c6dea2a63f3c1577a Mon Sep 17 00:00:00 2001 From: Samay Sofo Date: Mon, 27 Jan 2025 21:19:47 +0000 Subject: [PATCH 19/71] added provides counseling services to oconus sql --- .../transportation_office/transportation_office_fetcher.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/services/transportation_office/transportation_office_fetcher.go b/pkg/services/transportation_office/transportation_office_fetcher.go index 0e9948752c7..4e46b1a7162 100644 --- a/pkg/services/transportation_office/transportation_office_fetcher.go +++ b/pkg/services/transportation_office/transportation_office_fetcher.go @@ -337,7 +337,7 @@ func (o transportationOfficesFetcher) FindClosestCounselingOffice(appCtx appcont JOIN jppso_regions j ON gbloc_aors.jppso_regions_id = j.id JOIN transportation_offices ON j.code = transportation_offices.gbloc JOIN addresses a2 ON a2.id = transportation_offices.address_id - WHERE duty_locations.id = $1 AND j.code = $2 + WHERE duty_locations.provides_services_counseling = true and duty_locations.id = $1 AND j.code = $2 AND transportation_offices.provides_ppm_closeout = true ) SELECT counseling_offices.id, counseling_offices.name @@ -371,7 +371,7 @@ func (o transportationOfficesFetcher) FindClosestCounselingOffice(appCtx appcont JOIN addresses ON postal_code_to_gblocs.postal_code = addresses.postal_code JOIN duty_locations ON addresses.id = duty_locations.address_id JOIN transportation_offices ON postal_code_to_gblocs.gbloc = transportation_offices.gbloc - WHERE duty_locations.id = $1 + WHERE duty_locations.provides_services_counseling = true and duty_locations.id = $1 ) SELECT counseling_offices.id, counseling_offices.name FROM counseling_offices From 7e26bd152b4a68879bc43fd3ff2a43ff4577b416 Mon Sep 17 00:00:00 2001 From: Samay Sofo Date: Wed, 29 Jan 2025 21:33:37 +0000 Subject: [PATCH 20/71] Updated test to include condition for routing counseling office. --- pkg/services/move/move_router_test.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pkg/services/move/move_router_test.go b/pkg/services/move/move_router_test.go index f62d3865f00..9a8a7b20c44 100644 --- a/pkg/services/move/move_router_test.go +++ b/pkg/services/move/move_router_test.go @@ -13,6 +13,8 @@ import ( storageTest "github.com/transcom/mymove/pkg/storage/test" "github.com/transcom/mymove/pkg/testdatagen" "github.com/transcom/mymove/pkg/uploader" + "github.com/stretchr/testify/mock" + "github.com/transcom/mymove/pkg/services/mocks" ) func (suite *MoveServiceSuite) TestMoveApproval() { @@ -1001,7 +1003,6 @@ func (suite *MoveServiceSuite) TestMoveSubmission() { ProvidesServicesCounseling bool moveStatus models.MoveStatus }{ - {"Routes to Service Counseling", true, models.MoveStatusNeedsServiceCounseling}, {"Routes to Service Counseling", false, models.MoveStatusNeedsServiceCounseling}, } for _, tt := range tests { @@ -1050,6 +1051,11 @@ func (suite *MoveServiceSuite) TestMoveSubmission() { LinkOnly: true, }, }, nil) + mockFetcher := &mocks.TransportationOfficesFetcher{} + closestCounselingOffice := &models.TransportationOffice{} + if !tt.ProvidesServicesCounseling { + mockFetcher.On("FindClosestCounselingOffice", mock.Anything, mock.Anything).Return(closestCounselingOffice, nil) + } err := moveRouter.Submit(suite.AppContextForTest(), &move, &newSignedCertification) suite.NoError(err) err = suite.DB().Where("move_id = $1", move.ID).First(&newSignedCertification) @@ -1059,6 +1065,9 @@ func (suite *MoveServiceSuite) TestMoveSubmission() { err = suite.DB().Find(&move, move.ID) suite.NoError(err) suite.Equal(tt.moveStatus, move.Status) + if !tt.ProvidesServicesCounseling { + suite.Equal(closestCounselingOffice, move.CounselingOffice) + } }) } }) From 88d33bfd32ed8940a7d14072ca0bb251e76be45a Mon Sep 17 00:00:00 2001 From: Samay Sofo Date: Wed, 29 Jan 2025 21:55:06 +0000 Subject: [PATCH 21/71] code refactoring --- pkg/services/move/move_router_test.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pkg/services/move/move_router_test.go b/pkg/services/move/move_router_test.go index 9a8a7b20c44..f4d279b8309 100644 --- a/pkg/services/move/move_router_test.go +++ b/pkg/services/move/move_router_test.go @@ -6,15 +6,15 @@ import ( "github.com/gofrs/uuid" + "github.com/stretchr/testify/mock" "github.com/transcom/mymove/pkg/apperror" "github.com/transcom/mymove/pkg/factory" "github.com/transcom/mymove/pkg/models" + "github.com/transcom/mymove/pkg/services/mocks" transportationoffice "github.com/transcom/mymove/pkg/services/transportation_office" storageTest "github.com/transcom/mymove/pkg/storage/test" "github.com/transcom/mymove/pkg/testdatagen" "github.com/transcom/mymove/pkg/uploader" - "github.com/stretchr/testify/mock" - "github.com/transcom/mymove/pkg/services/mocks" ) func (suite *MoveServiceSuite) TestMoveApproval() { @@ -1052,10 +1052,10 @@ func (suite *MoveServiceSuite) TestMoveSubmission() { }, }, nil) mockFetcher := &mocks.TransportationOfficesFetcher{} - closestCounselingOffice := &models.TransportationOffice{} - if !tt.ProvidesServicesCounseling { - mockFetcher.On("FindClosestCounselingOffice", mock.Anything, mock.Anything).Return(closestCounselingOffice, nil) - } + closestCounselingOffice := &models.TransportationOffice{} + if !tt.ProvidesServicesCounseling { + mockFetcher.On("FindClosestCounselingOffice", mock.Anything, mock.Anything).Return(closestCounselingOffice, nil) + } err := moveRouter.Submit(suite.AppContextForTest(), &move, &newSignedCertification) suite.NoError(err) err = suite.DB().Where("move_id = $1", move.ID).First(&newSignedCertification) @@ -1066,8 +1066,8 @@ func (suite *MoveServiceSuite) TestMoveSubmission() { suite.NoError(err) suite.Equal(tt.moveStatus, move.Status) if !tt.ProvidesServicesCounseling { - suite.Equal(closestCounselingOffice, move.CounselingOffice) - } + suite.Equal(closestCounselingOffice, move.CounselingOffice) + } }) } }) From dd32a0b0ccede82e268b06ec99eed9a5e6ec4b07 Mon Sep 17 00:00:00 2001 From: Samay Sofo Date: Wed, 29 Jan 2025 23:12:54 +0000 Subject: [PATCH 22/71] updated test due to failing tests from INT pr --- pkg/services/move/move_router_test.go | 2 +- .../transportation_office_fetcher_test.go | 59 +++---------------- 2 files changed, 9 insertions(+), 52 deletions(-) diff --git a/pkg/services/move/move_router_test.go b/pkg/services/move/move_router_test.go index f4d279b8309..11e36d18c6c 100644 --- a/pkg/services/move/move_router_test.go +++ b/pkg/services/move/move_router_test.go @@ -5,8 +5,8 @@ import ( "time" "github.com/gofrs/uuid" - "github.com/stretchr/testify/mock" + "github.com/transcom/mymove/pkg/apperror" "github.com/transcom/mymove/pkg/factory" "github.com/transcom/mymove/pkg/models" diff --git a/pkg/services/transportation_office/transportation_office_fetcher_test.go b/pkg/services/transportation_office/transportation_office_fetcher_test.go index a1f47237cd9..6756ad6a882 100644 --- a/pkg/services/transportation_office/transportation_office_fetcher_test.go +++ b/pkg/services/transportation_office/transportation_office_fetcher_test.go @@ -13,6 +13,7 @@ import ( "github.com/transcom/mymove/pkg/factory" "github.com/transcom/mymove/pkg/models" "github.com/transcom/mymove/pkg/services" + "github.com/transcom/mymove/pkg/testdatagen" "github.com/transcom/mymove/pkg/testingsuite" ) @@ -190,8 +191,6 @@ func (suite *TransportationOfficeServiceSuite) Test_FindCounselingOffices() { } func (suite *TransportationOfficeServiceSuite) Test_Oconus_AK_FindCounselingOffices() { - testContractName := "Test_findOconusGblocDepartmentIndicator" - testContractCode := "Test_findOconusGblocDepartmentIndicator_Code" testPostalCode := "99790" testPostalCode2 := "99701" testGbloc := "ABCD" @@ -233,31 +232,7 @@ func (suite *TransportationOfficeServiceSuite) Test_Oconus_AK_FindCounselingOffi return serviceMember } - - createContract := func(appCtx appcontext.AppContext, contractCode string, contractName string) (*models.ReContract, error) { - // See if contract code already exists. - exists, err := appCtx.DB().Where("code = ?", contractCode).Exists(&models.ReContract{}) - if err != nil { - return nil, fmt.Errorf("could not determine if contract code [%s] existed: %w", contractCode, err) - } - if exists { - return nil, fmt.Errorf("the provided contract code [%s] already exists", contractCode) - } - - // Contract code is new; insert it. - contract := models.ReContract{ - Code: contractCode, - Name: contractName, - } - verrs, err := appCtx.DB().ValidateAndSave(&contract) - if verrs.HasAny() { - return nil, fmt.Errorf("validation errors when saving contract [%+v]: %w", contract, verrs) - } - if err != nil { - return nil, fmt.Errorf("could not save contract [%+v]: %w", contract, err) - } - return &contract, nil - } + contract := testdatagen.FetchOrMakeReContract(suite.DB(), testdatagen.Assertions{}) setupDataForOconusSearchCounselingOffice := func(contract models.ReContract, postalCode string, gbloc string, transportationName string) (models.ReRateArea, models.OconusRateArea, models.UsPostRegionCity, models.DutyLocation) { rateAreaCode := uuid.Must(uuid.NewV4()).String()[0:5] @@ -335,12 +310,9 @@ func (suite *TransportationOfficeServiceSuite) Test_Oconus_AK_FindCounselingOffi } suite.Run("success - findOconusGblocDepartmentIndicator - returns default GLOC for departmentAffiliation if no specific departmentAffilation mapping is defined", func() { - contract, err := createContract(suite.AppContextForTest(), testContractCode, testContractName) suite.NotNil(contract) - suite.FatalNoError(err) - const fairbanksAlaskaPostalCode = "99790" - _, oconusRateArea, _, dutylocation := setupDataForOconusSearchCounselingOffice(*contract, fairbanksAlaskaPostalCode, testGbloc, testTransportationName) + _, oconusRateArea, _, dutylocation := setupDataForOconusSearchCounselingOffice(contract, fairbanksAlaskaPostalCode, testGbloc, testTransportationName) // setup department affiliation to GBLOC mappings expected_gbloc := "TEST-GBLOC" @@ -367,7 +339,6 @@ func (suite *TransportationOfficeServiceSuite) Test_Oconus_AK_FindCounselingOffi appCtx := suite.AppContextWithSessionForTest(&auth.Session{ ServiceMemberID: serviceMember.ID, }) - suite.Nil(err) departmentIndictor, err := findOconusGblocDepartmentIndicator(appCtx, dutylocation) suite.NotNil(departmentIndictor) suite.Nil(err) @@ -377,11 +348,9 @@ func (suite *TransportationOfficeServiceSuite) Test_Oconus_AK_FindCounselingOffi }) suite.Run("success - findOconusGblocDepartmentIndicator - returns specific GLOC for departmentAffiliation when a specific departmentAffilation mapping is defined", func() { - contract, err := createContract(suite.AppContextForTest(), testContractCode, testContractName) suite.NotNil(contract) - suite.FatalNoError(err) - _, oconusRateArea, _, dutylocation := setupDataForOconusSearchCounselingOffice(*contract, testPostalCode, testGbloc, testTransportationName) + _, oconusRateArea, _, dutylocation := setupDataForOconusSearchCounselingOffice(contract, testPostalCode, testGbloc, testTransportationName) departmentIndicators := []models.DepartmentIndicator{models.DepartmentIndicatorARMY, models.DepartmentIndicatorARMYCORPSOFENGINEERS, models.DepartmentIndicatorCOASTGUARD, @@ -426,7 +395,6 @@ func (suite *TransportationOfficeServiceSuite) Test_Oconus_AK_FindCounselingOffi appCtx := suite.AppContextWithSessionForTest(&auth.Session{ ServiceMemberID: serviceMember.ID, }) - suite.Nil(err) departmentIndictor, err := findOconusGblocDepartmentIndicator(appCtx, dutylocation) suite.NotNil(departmentIndictor) suite.Nil(err) @@ -442,11 +410,9 @@ func (suite *TransportationOfficeServiceSuite) Test_Oconus_AK_FindCounselingOffi }) suite.Run("failure -- returns error when there are default and no department specific GBLOC", func() { - contract, err := createContract(suite.AppContextForTest(), testContractCode, testContractName) suite.NotNil(contract) - suite.FatalNoError(err) - _, _, _, dutylocation := setupDataForOconusSearchCounselingOffice(*contract, testPostalCode, testGbloc, testTransportationName) + _, _, _, dutylocation := setupDataForOconusSearchCounselingOffice(contract, testPostalCode, testGbloc, testTransportationName) // No specific departmentAffiliation mapping or default were created. // Expect an error response when nothing is found. @@ -454,25 +420,21 @@ func (suite *TransportationOfficeServiceSuite) Test_Oconus_AK_FindCounselingOffi appCtx := suite.AppContextWithSessionForTest(&auth.Session{ ServiceMemberID: serviceMember.ID, }) - suite.Nil(err) departmentIndictor, err := findOconusGblocDepartmentIndicator(appCtx, dutylocation) suite.Nil(departmentIndictor) suite.NotNil(err) }) suite.Run("failure - findOconusGblocDepartmentIndicator - returns error when find service member ID fails", func() { - contract, err := createContract(suite.AppContextForTest(), testContractCode, testContractName) suite.NotNil(contract) - suite.FatalNoError(err) - _, _, _, dutylocation := setupDataForOconusSearchCounselingOffice(*contract, testPostalCode, testGbloc, testTransportationName) + _, _, _, dutylocation := setupDataForOconusSearchCounselingOffice(contract, testPostalCode, testGbloc, testTransportationName) appCtx := suite.AppContextWithSessionForTest(&auth.Session{ // create fake service member ID to raise NOT found error ServiceMemberID: uuid.Must(uuid.NewV4()), }) - suite.Nil(err) departmentIndictor, err := findOconusGblocDepartmentIndicator(appCtx, dutylocation) suite.Nil(departmentIndictor) suite.NotNil(err) @@ -489,11 +451,9 @@ func (suite *TransportationOfficeServiceSuite) Test_Oconus_AK_FindCounselingOffi }) suite.Run("success - offices using default departmentIndicator mapping", func() { - contract, err := createContract(suite.AppContextForTest(), testContractCode, testContractName) suite.NotNil(contract) - suite.FatalNoError(err) - _, oconusRateArea, _, dutylocation := setupDataForOconusSearchCounselingOffice(*contract, testPostalCode, testGbloc, testTransportationName) + _, oconusRateArea, _, dutylocation := setupDataForOconusSearchCounselingOffice(contract, testPostalCode, testGbloc, testTransportationName) // setup department affiliation to GBLOC mappings jppsoRegion := models.JppsoRegions{ @@ -522,7 +482,6 @@ func (suite *TransportationOfficeServiceSuite) Test_Oconus_AK_FindCounselingOffi ServiceMemberID: serviceMember.ID, }) - suite.Nil(err) offices, err := findCounselingOffice(appCtx, dutylocation.ID) suite.NotNil(offices) suite.Nil(err) @@ -546,11 +505,9 @@ func (suite *TransportationOfficeServiceSuite) Test_Oconus_AK_FindCounselingOffi }) suite.Run("success - returns correct office based on service affiliation -- simulate Zone 2 scenerio", func() { - contract, err := createContract(suite.AppContextForTest(), testContractCode, testContractName) suite.NotNil(contract) - suite.FatalNoError(err) - _, oconusRateArea, _, dutylocation := setupDataForOconusSearchCounselingOffice(*contract, testPostalCode, testGbloc, testTransportationName) + _, oconusRateArea, _, dutylocation := setupDataForOconusSearchCounselingOffice(contract, testPostalCode, testGbloc, testTransportationName) // ****************************************************************************** // setup department affiliation to GBLOC mappings for AF/SF From b821b7b6910b0fc5ebdba88a3e4eceed6b5290f0 Mon Sep 17 00:00:00 2001 From: Samay Sofo Date: Wed, 29 Jan 2025 23:38:51 +0000 Subject: [PATCH 23/71] code refactoring --- .../transportation_office_fetcher_test.go | 108 ++++++++++-------- 1 file changed, 59 insertions(+), 49 deletions(-) diff --git a/pkg/services/transportation_office/transportation_office_fetcher_test.go b/pkg/services/transportation_office/transportation_office_fetcher_test.go index 6756ad6a882..6c6736bf735 100644 --- a/pkg/services/transportation_office/transportation_office_fetcher_test.go +++ b/pkg/services/transportation_office/transportation_office_fetcher_test.go @@ -191,6 +191,8 @@ func (suite *TransportationOfficeServiceSuite) Test_FindCounselingOffices() { } func (suite *TransportationOfficeServiceSuite) Test_Oconus_AK_FindCounselingOffices() { + testContractName := "Test_findOconusGblocDepartmentIndicator" + testContractCode := "Test_findOconusGblocDepartmentIndicator_Code" testPostalCode := "99790" testPostalCode2 := "99701" testGbloc := "ABCD" @@ -232,7 +234,31 @@ func (suite *TransportationOfficeServiceSuite) Test_Oconus_AK_FindCounselingOffi return serviceMember } - contract := testdatagen.FetchOrMakeReContract(suite.DB(), testdatagen.Assertions{}) + + createContract := func(appCtx appcontext.AppContext, contractCode string, contractName string) (*models.ReContract, error) { + // See if contract code already exists. + exists, err := appCtx.DB().Where("code = ?", contractCode).Exists(&models.ReContract{}) + if err != nil { + return nil, fmt.Errorf("could not determine if contract code [%s] existed: %w", contractCode, err) + } + if exists { + return nil, fmt.Errorf("the provided contract code [%s] already exists", contractCode) + } + + // Contract code is new; insert it. + contract := models.ReContract{ + Code: contractCode, + Name: contractName, + } + verrs, err := appCtx.DB().ValidateAndSave(&contract) + if verrs.HasAny() { + return nil, fmt.Errorf("validation errors when saving contract [%+v]: %w", contract, verrs) + } + if err != nil { + return nil, fmt.Errorf("could not save contract [%+v]: %w", contract, err) + } + return &contract, nil + } setupDataForOconusSearchCounselingOffice := func(contract models.ReContract, postalCode string, gbloc string, transportationName string) (models.ReRateArea, models.OconusRateArea, models.UsPostRegionCity, models.DutyLocation) { rateAreaCode := uuid.Must(uuid.NewV4()).String()[0:5] @@ -310,9 +336,12 @@ func (suite *TransportationOfficeServiceSuite) Test_Oconus_AK_FindCounselingOffi } suite.Run("success - findOconusGblocDepartmentIndicator - returns default GLOC for departmentAffiliation if no specific departmentAffilation mapping is defined", func() { + contract, err := createContract(suite.AppContextForTest(), testContractCode, testContractName) suite.NotNil(contract) + suite.FatalNoError(err) + const fairbanksAlaskaPostalCode = "99790" - _, oconusRateArea, _, dutylocation := setupDataForOconusSearchCounselingOffice(contract, fairbanksAlaskaPostalCode, testGbloc, testTransportationName) + _, oconusRateArea, _, dutylocation := setupDataForOconusSearchCounselingOffice(*contract, fairbanksAlaskaPostalCode, testGbloc, testTransportationName) // setup department affiliation to GBLOC mappings expected_gbloc := "TEST-GBLOC" @@ -339,6 +368,7 @@ func (suite *TransportationOfficeServiceSuite) Test_Oconus_AK_FindCounselingOffi appCtx := suite.AppContextWithSessionForTest(&auth.Session{ ServiceMemberID: serviceMember.ID, }) + suite.Nil(err) departmentIndictor, err := findOconusGblocDepartmentIndicator(appCtx, dutylocation) suite.NotNil(departmentIndictor) suite.Nil(err) @@ -348,9 +378,11 @@ func (suite *TransportationOfficeServiceSuite) Test_Oconus_AK_FindCounselingOffi }) suite.Run("success - findOconusGblocDepartmentIndicator - returns specific GLOC for departmentAffiliation when a specific departmentAffilation mapping is defined", func() { + contract, err := createContract(suite.AppContextForTest(), testContractCode, testContractName) suite.NotNil(contract) + suite.FatalNoError(err) - _, oconusRateArea, _, dutylocation := setupDataForOconusSearchCounselingOffice(contract, testPostalCode, testGbloc, testTransportationName) + _, oconusRateArea, _, dutylocation := setupDataForOconusSearchCounselingOffice(*contract, testPostalCode, testGbloc, testTransportationName) departmentIndicators := []models.DepartmentIndicator{models.DepartmentIndicatorARMY, models.DepartmentIndicatorARMYCORPSOFENGINEERS, models.DepartmentIndicatorCOASTGUARD, @@ -395,6 +427,7 @@ func (suite *TransportationOfficeServiceSuite) Test_Oconus_AK_FindCounselingOffi appCtx := suite.AppContextWithSessionForTest(&auth.Session{ ServiceMemberID: serviceMember.ID, }) + suite.Nil(err) departmentIndictor, err := findOconusGblocDepartmentIndicator(appCtx, dutylocation) suite.NotNil(departmentIndictor) suite.Nil(err) @@ -410,9 +443,11 @@ func (suite *TransportationOfficeServiceSuite) Test_Oconus_AK_FindCounselingOffi }) suite.Run("failure -- returns error when there are default and no department specific GBLOC", func() { + contract, err := createContract(suite.AppContextForTest(), testContractCode, testContractName) suite.NotNil(contract) + suite.FatalNoError(err) - _, _, _, dutylocation := setupDataForOconusSearchCounselingOffice(contract, testPostalCode, testGbloc, testTransportationName) + _, _, _, dutylocation := setupDataForOconusSearchCounselingOffice(*contract, testPostalCode, testGbloc, testTransportationName) // No specific departmentAffiliation mapping or default were created. // Expect an error response when nothing is found. @@ -420,21 +455,25 @@ func (suite *TransportationOfficeServiceSuite) Test_Oconus_AK_FindCounselingOffi appCtx := suite.AppContextWithSessionForTest(&auth.Session{ ServiceMemberID: serviceMember.ID, }) + suite.Nil(err) departmentIndictor, err := findOconusGblocDepartmentIndicator(appCtx, dutylocation) suite.Nil(departmentIndictor) suite.NotNil(err) }) suite.Run("failure - findOconusGblocDepartmentIndicator - returns error when find service member ID fails", func() { + contract, err := createContract(suite.AppContextForTest(), testContractCode, testContractName) suite.NotNil(contract) + suite.FatalNoError(err) - _, _, _, dutylocation := setupDataForOconusSearchCounselingOffice(contract, testPostalCode, testGbloc, testTransportationName) + _, _, _, dutylocation := setupDataForOconusSearchCounselingOffice(*contract, testPostalCode, testGbloc, testTransportationName) appCtx := suite.AppContextWithSessionForTest(&auth.Session{ // create fake service member ID to raise NOT found error ServiceMemberID: uuid.Must(uuid.NewV4()), }) + suite.Nil(err) departmentIndictor, err := findOconusGblocDepartmentIndicator(appCtx, dutylocation) suite.Nil(departmentIndictor) suite.NotNil(err) @@ -451,9 +490,11 @@ func (suite *TransportationOfficeServiceSuite) Test_Oconus_AK_FindCounselingOffi }) suite.Run("success - offices using default departmentIndicator mapping", func() { + contract, err := createContract(suite.AppContextForTest(), testContractCode, testContractName) suite.NotNil(contract) + suite.FatalNoError(err) - _, oconusRateArea, _, dutylocation := setupDataForOconusSearchCounselingOffice(contract, testPostalCode, testGbloc, testTransportationName) + _, oconusRateArea, _, dutylocation := setupDataForOconusSearchCounselingOffice(*contract, testPostalCode, testGbloc, testTransportationName) // setup department affiliation to GBLOC mappings jppsoRegion := models.JppsoRegions{ @@ -482,6 +523,7 @@ func (suite *TransportationOfficeServiceSuite) Test_Oconus_AK_FindCounselingOffi ServiceMemberID: serviceMember.ID, }) + suite.Nil(err) offices, err := findCounselingOffice(appCtx, dutylocation.ID) suite.NotNil(offices) suite.Nil(err) @@ -505,9 +547,11 @@ func (suite *TransportationOfficeServiceSuite) Test_Oconus_AK_FindCounselingOffi }) suite.Run("success - returns correct office based on service affiliation -- simulate Zone 2 scenerio", func() { + contract, err := createContract(suite.AppContextForTest(), testContractCode, testContractName) suite.NotNil(contract) + suite.FatalNoError(err) - _, oconusRateArea, _, dutylocation := setupDataForOconusSearchCounselingOffice(contract, testPostalCode, testGbloc, testTransportationName) + _, oconusRateArea, _, dutylocation := setupDataForOconusSearchCounselingOffice(*contract, testPostalCode, testGbloc, testTransportationName) // ****************************************************************************** // setup department affiliation to GBLOC mappings for AF/SF @@ -714,8 +758,6 @@ func (suite *TransportationOfficeServiceSuite) Test_FindClosestCounselingOfficeC } func (suite *TransportationOfficeServiceSuite) Test_FindClosestCounselingOfficeOCONUS() { - testContractName := "Test_findOconusGblocDepartmentIndicator" - testContractCode := "Test_findOconusGblocDepartmentIndicator_Code" testPostalCode := "32228" testPostalCode2 := "99701" testGbloc := "CNNQ" @@ -737,31 +779,7 @@ func (suite *TransportationOfficeServiceSuite) Test_FindClosestCounselingOfficeO return serviceMember } - createContract := func(appCtx appcontext.AppContext, contractCode string, contractName string) (*models.ReContract, error) { - // See if contract code already exists. - exists, err := appCtx.DB().Where("code = ?", contractCode).Exists(&models.ReContract{}) - if err != nil { - return nil, fmt.Errorf("could not determine if contract code [%s] existed: %w", contractCode, err) - } - if exists { - return nil, fmt.Errorf("the provided contract code [%s] already exists", contractCode) - } - - // Contract code is new; insert it. - contract := models.ReContract{ - Code: contractCode, - Name: contractName, - } - verrs, err := appCtx.DB().ValidateAndSave(&contract) - if verrs.HasAny() { - return nil, fmt.Errorf("validation errors when saving contract [%+v]: %w", contract, verrs) - } - if err != nil { - return nil, fmt.Errorf("could not save contract [%+v]: %w", contract, err) - } - return &contract, nil - } - + contract := testdatagen.FetchOrMakeReContract(suite.DB(), testdatagen.Assertions{}) setupDataForOconusSearchCounselingOffice := func(contract models.ReContract, postalCode string, gbloc string, transportationName string) (models.ReRateArea, models.OconusRateArea, models.UsPostRegionCity, models.DutyLocation) { rateAreaCode := uuid.Must(uuid.NewV4()).String()[0:5] rateArea := models.ReRateArea{ @@ -835,12 +853,10 @@ func (suite *TransportationOfficeServiceSuite) Test_FindClosestCounselingOfficeO } suite.Run("success - findOconusGblocDepartmentIndicator - returns default GLOC for departmentAffiliation if no specific departmentAffilation mapping is defined", func() { - contract, err := createContract(suite.AppContextForTest(), testContractCode, testContractName) suite.NotNil(contract) - suite.FatalNoError(err) const fairbanksAlaskaPostalCode = "99790" - _, oconusRateArea, _, dutylocation := setupDataForOconusSearchCounselingOffice(*contract, fairbanksAlaskaPostalCode, testGbloc, testTransportationName) + _, oconusRateArea, _, dutylocation := setupDataForOconusSearchCounselingOffice(contract, fairbanksAlaskaPostalCode, testGbloc, testTransportationName) // setup department affiliation to GBLOC mappings expected_gbloc := "TEST-GBLOC" @@ -867,7 +883,6 @@ func (suite *TransportationOfficeServiceSuite) Test_FindClosestCounselingOfficeO appCtx := suite.AppContextWithSessionForTest(&auth.Session{ ServiceMemberID: serviceMember.ID, }) - suite.Nil(err) departmentIndictor, err := findOconusGblocDepartmentIndicator(appCtx, dutylocation) suite.NotNil(departmentIndictor) suite.Nil(err) @@ -877,11 +892,10 @@ func (suite *TransportationOfficeServiceSuite) Test_FindClosestCounselingOfficeO }) suite.Run("Success - findOconusGblocDepartmentIndicator - Should return specific GLOC for departmentAffiliation when a specific departmentAffilation mapping is defined", func() { - contract, err := createContract(suite.AppContextForTest(), testContractCode, testContractName) + contract := testdatagen.FetchOrMakeReContract(suite.DB(), testdatagen.Assertions{}) suite.NotNil(contract) - suite.FatalNoError(err) - _, oconusRateArea, _, dutylocation := setupDataForOconusSearchCounselingOffice(*contract, testPostalCode, testGbloc, testTransportationName) + _, oconusRateArea, _, dutylocation := setupDataForOconusSearchCounselingOffice(contract, testPostalCode, testGbloc, testTransportationName) departmentIndicators := []models.DepartmentIndicator{models.DepartmentIndicatorARMY, models.DepartmentIndicatorARMYCORPSOFENGINEERS, models.DepartmentIndicatorCOASTGUARD, @@ -926,7 +940,6 @@ func (suite *TransportationOfficeServiceSuite) Test_FindClosestCounselingOfficeO appCtx := suite.AppContextWithSessionForTest(&auth.Session{ ServiceMemberID: serviceMember.ID, }) - suite.Nil(err) departmentIndictor, err := findOconusGblocDepartmentIndicator(appCtx, dutylocation) suite.NotNil(departmentIndictor) suite.Nil(err) @@ -942,11 +955,10 @@ func (suite *TransportationOfficeServiceSuite) Test_FindClosestCounselingOfficeO }) suite.Run("success - offices using default departmentIndicator mapping", func() { - contract, err := createContract(suite.AppContextForTest(), testContractCode, testContractName) + contract := testdatagen.FetchOrMakeReContract(suite.DB(), testdatagen.Assertions{}) suite.NotNil(contract) - suite.FatalNoError(err) - _, oconusRateArea, _, dutylocation := setupDataForOconusSearchCounselingOffice(*contract, testPostalCode, testGbloc, testTransportationName) + _, oconusRateArea, _, dutylocation := setupDataForOconusSearchCounselingOffice(contract, testPostalCode, testGbloc, testTransportationName) // setup department affiliation to GBLOC mappings jppsoRegion := models.JppsoRegions{ @@ -974,7 +986,6 @@ func (suite *TransportationOfficeServiceSuite) Test_FindClosestCounselingOfficeO ServiceMemberID: serviceMember.ID, }) - suite.Nil(err) offices, err := findCounselingOffice(appCtx, dutylocation.ID) suite.NotNil(offices) suite.Nil(err) @@ -997,11 +1008,10 @@ func (suite *TransportationOfficeServiceSuite) Test_FindClosestCounselingOfficeO }) suite.Run("Should return correct office based on service affiliation", func() { - contract, err := createContract(suite.AppContextForTest(), testContractCode, testContractName) + contract := testdatagen.FetchOrMakeReContract(suite.DB(), testdatagen.Assertions{}) suite.NotNil(contract) - suite.FatalNoError(err) - _, oconusRateArea, _, dutylocation := setupDataForOconusSearchCounselingOffice(*contract, testPostalCode, testGbloc, testTransportationName) + _, oconusRateArea, _, dutylocation := setupDataForOconusSearchCounselingOffice(contract, testPostalCode, testGbloc, testTransportationName) jppsoRegion_AFSF := models.JppsoRegions{ Code: testGbloc, From 0386d2e91189be659c8e7d880e4f7b85db6d35e4 Mon Sep 17 00:00:00 2001 From: Samay Sofo Date: Wed, 29 Jan 2025 23:40:45 +0000 Subject: [PATCH 24/71] code clean up --- .../transportation_office_fetcher_test.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/pkg/services/transportation_office/transportation_office_fetcher_test.go b/pkg/services/transportation_office/transportation_office_fetcher_test.go index 6c6736bf735..a02083263ee 100644 --- a/pkg/services/transportation_office/transportation_office_fetcher_test.go +++ b/pkg/services/transportation_office/transportation_office_fetcher_test.go @@ -892,7 +892,6 @@ func (suite *TransportationOfficeServiceSuite) Test_FindClosestCounselingOfficeO }) suite.Run("Success - findOconusGblocDepartmentIndicator - Should return specific GLOC for departmentAffiliation when a specific departmentAffilation mapping is defined", func() { - contract := testdatagen.FetchOrMakeReContract(suite.DB(), testdatagen.Assertions{}) suite.NotNil(contract) _, oconusRateArea, _, dutylocation := setupDataForOconusSearchCounselingOffice(contract, testPostalCode, testGbloc, testTransportationName) @@ -955,7 +954,6 @@ func (suite *TransportationOfficeServiceSuite) Test_FindClosestCounselingOfficeO }) suite.Run("success - offices using default departmentIndicator mapping", func() { - contract := testdatagen.FetchOrMakeReContract(suite.DB(), testdatagen.Assertions{}) suite.NotNil(contract) _, oconusRateArea, _, dutylocation := setupDataForOconusSearchCounselingOffice(contract, testPostalCode, testGbloc, testTransportationName) @@ -1008,7 +1006,6 @@ func (suite *TransportationOfficeServiceSuite) Test_FindClosestCounselingOfficeO }) suite.Run("Should return correct office based on service affiliation", func() { - contract := testdatagen.FetchOrMakeReContract(suite.DB(), testdatagen.Assertions{}) suite.NotNil(contract) _, oconusRateArea, _, dutylocation := setupDataForOconusSearchCounselingOffice(contract, testPostalCode, testGbloc, testTransportationName) From d86f375bd4cee4b759c6c509b78dd0b3a674044c Mon Sep 17 00:00:00 2001 From: Samay Sofo Date: Thu, 30 Jan 2025 23:33:23 +0000 Subject: [PATCH 25/71] Updated code to include new param --- .../transportation_office_fetcher.go | 2 +- .../transportation_office_fetcher_test.go | 64 ++++++++++++++----- 2 files changed, 49 insertions(+), 17 deletions(-) diff --git a/pkg/services/transportation_office/transportation_office_fetcher.go b/pkg/services/transportation_office/transportation_office_fetcher.go index 4e46b1a7162..08eda5eaa04 100644 --- a/pkg/services/transportation_office/transportation_office_fetcher.go +++ b/pkg/services/transportation_office/transportation_office_fetcher.go @@ -319,7 +319,7 @@ func (o transportationOfficesFetcher) FindClosestCounselingOffice(appCtx appcont // Find for oconus duty location if *duty_location.Address.IsOconus { - gblocDepartmentIndicator, err := findOconusGblocDepartmentIndicator(appCtx, duty_location) + gblocDepartmentIndicator, err := findOconusGblocDepartmentIndicator(appCtx, duty_location, appCtx.Session().ServiceMemberID) if err != nil { appCtx.Logger().Error("Failed to find OCONUS GBLOC department indicator", zap.Error(err)) return &closestOffice, err diff --git a/pkg/services/transportation_office/transportation_office_fetcher_test.go b/pkg/services/transportation_office/transportation_office_fetcher_test.go index a02083263ee..b5d7aa7fd56 100644 --- a/pkg/services/transportation_office/transportation_office_fetcher_test.go +++ b/pkg/services/transportation_office/transportation_office_fetcher_test.go @@ -13,7 +13,6 @@ import ( "github.com/transcom/mymove/pkg/factory" "github.com/transcom/mymove/pkg/models" "github.com/transcom/mymove/pkg/services" - "github.com/transcom/mymove/pkg/testdatagen" "github.com/transcom/mymove/pkg/testingsuite" ) @@ -758,6 +757,8 @@ func (suite *TransportationOfficeServiceSuite) Test_FindClosestCounselingOfficeC } func (suite *TransportationOfficeServiceSuite) Test_FindClosestCounselingOfficeOCONUS() { + testContractName := "Test_findOconusGblocDepartmentIndicator" + testContractCode := "Test_findOconusGblocDepartmentIndicator_Code" testPostalCode := "32228" testPostalCode2 := "99701" testGbloc := "CNNQ" @@ -779,7 +780,30 @@ func (suite *TransportationOfficeServiceSuite) Test_FindClosestCounselingOfficeO return serviceMember } - contract := testdatagen.FetchOrMakeReContract(suite.DB(), testdatagen.Assertions{}) + createContract := func(appCtx appcontext.AppContext, contractCode string, contractName string) (*models.ReContract, error) { + // See if contract code already exists. + exists, err := appCtx.DB().Where("code = ?", contractCode).Exists(&models.ReContract{}) + if err != nil { + return nil, fmt.Errorf("could not determine if contract code [%s] existed: %w", contractCode, err) + } + if exists { + return nil, fmt.Errorf("the provided contract code [%s] already exists", contractCode) + } + // Contract code is new; insert it. + contract := models.ReContract{ + Code: contractCode, + Name: contractName, + } + verrs, err := appCtx.DB().ValidateAndSave(&contract) + if verrs.HasAny() { + return nil, fmt.Errorf("validation errors when saving contract [%+v]: %w", contract, verrs) + } + if err != nil { + return nil, fmt.Errorf("could not save contract [%+v]: %w", contract, err) + } + return &contract, nil + } + setupDataForOconusSearchCounselingOffice := func(contract models.ReContract, postalCode string, gbloc string, transportationName string) (models.ReRateArea, models.OconusRateArea, models.UsPostRegionCity, models.DutyLocation) { rateAreaCode := uuid.Must(uuid.NewV4()).String()[0:5] rateArea := models.ReRateArea{ @@ -822,11 +846,7 @@ func (suite *TransportationOfficeServiceSuite) Test_FindClosestCounselingOfficeO } address := models.Address{ - StreetAddress1: "123 Ocunus St.", - City: "Fairbanks", - State: "AK", PostalCode: postalCode, - County: models.StringPointer("Fairbanks North Star Borough"), IsOconus: models.BoolPointer(true), UsPostRegionCityID: &usprc.ID, CountryId: models.UUIDPointer(us_country.ID), @@ -852,11 +872,14 @@ func (suite *TransportationOfficeServiceSuite) Test_FindClosestCounselingOfficeO return rateArea, oconusRateArea, *usprc, found_duty_location } - suite.Run("success - findOconusGblocDepartmentIndicator - returns default GLOC for departmentAffiliation if no specific departmentAffilation mapping is defined", func() { + suite.Run("success - findOconusGblocDepartmentIndicator - returns default GBLOC for departmentAffiliation if no specific departmentAffilation mapping is defined", func() { + contract, err := createContract(suite.AppContextForTest(), testContractCode, testContractName) + suite.NotNil(contract) + suite.FatalNoError(err) suite.NotNil(contract) const fairbanksAlaskaPostalCode = "99790" - _, oconusRateArea, _, dutylocation := setupDataForOconusSearchCounselingOffice(contract, fairbanksAlaskaPostalCode, testGbloc, testTransportationName) + _, oconusRateArea, _, dutylocation := setupDataForOconusSearchCounselingOffice(*contract, fairbanksAlaskaPostalCode, testGbloc, testTransportationName) // setup department affiliation to GBLOC mappings expected_gbloc := "TEST-GBLOC" @@ -883,7 +906,7 @@ func (suite *TransportationOfficeServiceSuite) Test_FindClosestCounselingOfficeO appCtx := suite.AppContextWithSessionForTest(&auth.Session{ ServiceMemberID: serviceMember.ID, }) - departmentIndictor, err := findOconusGblocDepartmentIndicator(appCtx, dutylocation) + departmentIndictor, err := findOconusGblocDepartmentIndicator(appCtx, dutylocation, appCtx.Session().ServiceMemberID) suite.NotNil(departmentIndictor) suite.Nil(err) suite.Nil(departmentIndictor.DepartmentIndicator) @@ -891,10 +914,13 @@ func (suite *TransportationOfficeServiceSuite) Test_FindClosestCounselingOfficeO } }) - suite.Run("Success - findOconusGblocDepartmentIndicator - Should return specific GLOC for departmentAffiliation when a specific departmentAffilation mapping is defined", func() { + suite.Run("Success - findOconusGblocDepartmentIndicator - Should return specific GBLOC for departmentAffiliation when a specific departmentAffilation mapping is defined", func() { + contract, err := createContract(suite.AppContextForTest(), testContractCode, testContractName) + suite.NotNil(contract) + suite.FatalNoError(err) suite.NotNil(contract) - _, oconusRateArea, _, dutylocation := setupDataForOconusSearchCounselingOffice(contract, testPostalCode, testGbloc, testTransportationName) + _, oconusRateArea, _, dutylocation := setupDataForOconusSearchCounselingOffice(*contract, testPostalCode, testGbloc, testTransportationName) departmentIndicators := []models.DepartmentIndicator{models.DepartmentIndicatorARMY, models.DepartmentIndicatorARMYCORPSOFENGINEERS, models.DepartmentIndicatorCOASTGUARD, @@ -939,7 +965,7 @@ func (suite *TransportationOfficeServiceSuite) Test_FindClosestCounselingOfficeO appCtx := suite.AppContextWithSessionForTest(&auth.Session{ ServiceMemberID: serviceMember.ID, }) - departmentIndictor, err := findOconusGblocDepartmentIndicator(appCtx, dutylocation) + departmentIndictor, err := findOconusGblocDepartmentIndicator(appCtx, dutylocation, appCtx.Session().ServiceMemberID) suite.NotNil(departmentIndictor) suite.Nil(err) suite.NotNil(departmentIndictor.DepartmentIndicator) @@ -954,9 +980,12 @@ func (suite *TransportationOfficeServiceSuite) Test_FindClosestCounselingOfficeO }) suite.Run("success - offices using default departmentIndicator mapping", func() { + contract, err := createContract(suite.AppContextForTest(), testContractCode, testContractName) + suite.NotNil(contract) + suite.FatalNoError(err) suite.NotNil(contract) - _, oconusRateArea, _, dutylocation := setupDataForOconusSearchCounselingOffice(contract, testPostalCode, testGbloc, testTransportationName) + _, oconusRateArea, _, dutylocation := setupDataForOconusSearchCounselingOffice(*contract, testPostalCode, testGbloc, testTransportationName) // setup department affiliation to GBLOC mappings jppsoRegion := models.JppsoRegions{ @@ -984,7 +1013,7 @@ func (suite *TransportationOfficeServiceSuite) Test_FindClosestCounselingOfficeO ServiceMemberID: serviceMember.ID, }) - offices, err := findCounselingOffice(appCtx, dutylocation.ID) + offices, err := findCounselingOffice(appCtx, dutylocation.ID, serviceMember.ID) suite.NotNil(offices) suite.Nil(err) suite.Equal(1, len(offices)) @@ -999,16 +1028,19 @@ func (suite *TransportationOfficeServiceSuite) Test_FindClosestCounselingOfficeO }, }, }, nil) - offices, err = findCounselingOffice(appCtx, dutylocation.ID) + offices, err = findCounselingOffice(appCtx, dutylocation.ID, serviceMember.ID) suite.NotNil(offices) suite.Nil(err) suite.Equal(2, len(offices)) }) suite.Run("Should return correct office based on service affiliation", func() { + contract, err := createContract(suite.AppContextForTest(), testContractCode, testContractName) + suite.NotNil(contract) + suite.FatalNoError(err) suite.NotNil(contract) - _, oconusRateArea, _, dutylocation := setupDataForOconusSearchCounselingOffice(contract, testPostalCode, testGbloc, testTransportationName) + _, oconusRateArea, _, dutylocation := setupDataForOconusSearchCounselingOffice(*contract, testPostalCode, testGbloc, testTransportationName) jppsoRegion_AFSF := models.JppsoRegions{ Code: testGbloc, From 051302566cad27c92c78c2e1414e343bde687324 Mon Sep 17 00:00:00 2001 From: Samay Sofo Date: Fri, 31 Jan 2025 15:09:48 +0000 Subject: [PATCH 26/71] added serviceMemberID param --- .../mocks/TransportationOfficesFetcher.go | 18 +++++++++--------- pkg/services/move/move_router.go | 2 +- pkg/services/transportation_office.go | 2 +- .../transportation_office_fetcher.go | 4 ++-- .../transportation_office_fetcher_test.go | 17 ++++++++++++----- 5 files changed, 25 insertions(+), 18 deletions(-) diff --git a/pkg/services/mocks/TransportationOfficesFetcher.go b/pkg/services/mocks/TransportationOfficesFetcher.go index 47f5a5f9477..14310348bec 100644 --- a/pkg/services/mocks/TransportationOfficesFetcher.go +++ b/pkg/services/mocks/TransportationOfficesFetcher.go @@ -16,9 +16,9 @@ type TransportationOfficesFetcher struct { mock.Mock } -// FindClosestCounselingOffice provides a mock function with given fields: appCtx, dutyLocationID -func (_m *TransportationOfficesFetcher) FindClosestCounselingOffice(appCtx appcontext.AppContext, dutyLocationID uuid.UUID) (*models.TransportationOffice, error) { - ret := _m.Called(appCtx, dutyLocationID) +// FindClosestCounselingOffice provides a mock function with given fields: appCtx, dutyLocationID, serviceMemberID +func (_m *TransportationOfficesFetcher) FindClosestCounselingOffice(appCtx appcontext.AppContext, dutyLocationID uuid.UUID, serviceMemberID uuid.UUID) (*models.TransportationOffice, error) { + ret := _m.Called(appCtx, dutyLocationID, serviceMemberID) if len(ret) == 0 { panic("no return value specified for FindClosestCounselingOffice") @@ -26,19 +26,19 @@ func (_m *TransportationOfficesFetcher) FindClosestCounselingOffice(appCtx appco var r0 *models.TransportationOffice var r1 error - if rf, ok := ret.Get(0).(func(appcontext.AppContext, uuid.UUID) (*models.TransportationOffice, error)); ok { - return rf(appCtx, dutyLocationID) + if rf, ok := ret.Get(0).(func(appcontext.AppContext, uuid.UUID, uuid.UUID) (*models.TransportationOffice, error)); ok { + return rf(appCtx, dutyLocationID, serviceMemberID) } - if rf, ok := ret.Get(0).(func(appcontext.AppContext, uuid.UUID) *models.TransportationOffice); ok { - r0 = rf(appCtx, dutyLocationID) + if rf, ok := ret.Get(0).(func(appcontext.AppContext, uuid.UUID, uuid.UUID) *models.TransportationOffice); ok { + r0 = rf(appCtx, dutyLocationID, serviceMemberID) } else { if ret.Get(0) != nil { r0 = ret.Get(0).(*models.TransportationOffice) } } - if rf, ok := ret.Get(1).(func(appcontext.AppContext, uuid.UUID) error); ok { - r1 = rf(appCtx, dutyLocationID) + if rf, ok := ret.Get(1).(func(appcontext.AppContext, uuid.UUID, uuid.UUID) error); ok { + r1 = rf(appCtx, dutyLocationID, serviceMemberID) } else { r1 = ret.Error(1) } diff --git a/pkg/services/move/move_router.go b/pkg/services/move/move_router.go index ce706240b69..4f2c87b73b5 100644 --- a/pkg/services/move/move_router.go +++ b/pkg/services/move/move_router.go @@ -232,7 +232,7 @@ func (router moveRouter) sendToServiceCounselor(appCtx appcontext.AppContext, mo // actual expense reimbursement is always true for civilian moves move.MTOShipments[i].PPMShipment.IsActualExpenseReimbursement = models.BoolPointer(isCivilian) if move.IsPPMOnly() && !orders.OriginDutyLocation.ProvidesServicesCounseling { - closestCounselingOffice, err := router.transportationOfficesFetcher.FindClosestCounselingOffice(appCtx, *move.Orders.OriginDutyLocationID) + closestCounselingOffice, err := router.transportationOfficesFetcher.FindClosestCounselingOffice(appCtx, *move.Orders.OriginDutyLocationID, move.Orders.ServiceMemberID) if err != nil { msg := "Failure setting PPM counseling office to closest service counseling office" appCtx.Logger().Error(msg, zap.Error(err)) diff --git a/pkg/services/transportation_office.go b/pkg/services/transportation_office.go index f8cc2cf3afa..2b282070f5a 100644 --- a/pkg/services/transportation_office.go +++ b/pkg/services/transportation_office.go @@ -13,5 +13,5 @@ type TransportationOfficesFetcher interface { GetTransportationOffice(appCtx appcontext.AppContext, transportationOfficeID uuid.UUID, includeOnlyPPMCloseoutOffices bool) (*models.TransportationOffice, error) GetAllGBLOCs(appCtx appcontext.AppContext) (*models.GBLOCs, error) GetCounselingOffices(appCtx appcontext.AppContext, dutyLocationID uuid.UUID) (*models.TransportationOffices, error) - FindClosestCounselingOffice(appCtx appcontext.AppContext, dutyLocationID uuid.UUID) (*models.TransportationOffice, error) + FindClosestCounselingOffice(appCtx appcontext.AppContext, dutyLocationID uuid.UUID, serviceMemberID uuid.UUID) (*models.TransportationOffice, error) } diff --git a/pkg/services/transportation_office/transportation_office_fetcher.go b/pkg/services/transportation_office/transportation_office_fetcher.go index 08eda5eaa04..b050994f4b1 100644 --- a/pkg/services/transportation_office/transportation_office_fetcher.go +++ b/pkg/services/transportation_office/transportation_office_fetcher.go @@ -308,7 +308,7 @@ func findOconusGblocDepartmentIndicator(appCtx appcontext.AppContext, dutyLocati } // Return the closest transportation office in the GBLOC of the given duty location for oconus/conus duty locations -func (o transportationOfficesFetcher) FindClosestCounselingOffice(appCtx appcontext.AppContext, dutyLocationID uuid.UUID) (*models.TransportationOffice, error) { +func (o transportationOfficesFetcher) FindClosestCounselingOffice(appCtx appcontext.AppContext, dutyLocationID uuid.UUID, serviceMemberID uuid.UUID) (*models.TransportationOffice, error) { var closestOffice models.TransportationOffice duty_location, err := models.FetchDutyLocation(appCtx.DB(), dutyLocationID) if err != nil { @@ -319,7 +319,7 @@ func (o transportationOfficesFetcher) FindClosestCounselingOffice(appCtx appcont // Find for oconus duty location if *duty_location.Address.IsOconus { - gblocDepartmentIndicator, err := findOconusGblocDepartmentIndicator(appCtx, duty_location, appCtx.Session().ServiceMemberID) + gblocDepartmentIndicator, err := findOconusGblocDepartmentIndicator(appCtx, duty_location, serviceMemberID) if err != nil { appCtx.Logger().Error("Failed to find OCONUS GBLOC department indicator", zap.Error(err)) return &closestOffice, err diff --git a/pkg/services/transportation_office/transportation_office_fetcher_test.go b/pkg/services/transportation_office/transportation_office_fetcher_test.go index b5d7aa7fd56..7bd0837e69c 100644 --- a/pkg/services/transportation_office/transportation_office_fetcher_test.go +++ b/pkg/services/transportation_office/transportation_office_fetcher_test.go @@ -750,8 +750,15 @@ func (suite *TransportationOfficeServiceSuite) Test_FindClosestCounselingOfficeC }, }, }, nil) - - offices, err := suite.toFetcher.FindClosestCounselingOffice(suite.AppContextForTest(), origDutyLocation.ID) + armyAffliation := models.AffiliationARMY + serviceMember := factory.BuildServiceMember(suite.DB(), []factory.Customization{ + { + Model: models.ServiceMember{ + Affiliation: &armyAffliation, + }, + }, + }, nil) + offices, err := suite.toFetcher.FindClosestCounselingOffice(suite.AppContextForTest(), origDutyLocation.ID, serviceMember.ID) suite.NoError(err) suite.Equal(offices.Name, "PPPO Jacksonville - USN") } @@ -906,7 +913,7 @@ func (suite *TransportationOfficeServiceSuite) Test_FindClosestCounselingOfficeO appCtx := suite.AppContextWithSessionForTest(&auth.Session{ ServiceMemberID: serviceMember.ID, }) - departmentIndictor, err := findOconusGblocDepartmentIndicator(appCtx, dutylocation, appCtx.Session().ServiceMemberID) + departmentIndictor, err := findOconusGblocDepartmentIndicator(appCtx, dutylocation, serviceMember.ID) suite.NotNil(departmentIndictor) suite.Nil(err) suite.Nil(departmentIndictor.DepartmentIndicator) @@ -1100,7 +1107,7 @@ func (suite *TransportationOfficeServiceSuite) Test_FindClosestCounselingOfficeO appCtx := suite.AppContextWithSessionForTest(&auth.Session{ ServiceMemberID: serviceMember.ID, }) - offices, err := suite.toFetcher.FindClosestCounselingOffice(appCtx, dutylocation.ID) + offices, err := suite.toFetcher.FindClosestCounselingOffice(appCtx, dutylocation.ID, serviceMember.ID) suite.NotNil(offices) suite.Nil(err) suite.Equal(testTransportationName, offices.Name) @@ -1108,7 +1115,7 @@ func (suite *TransportationOfficeServiceSuite) Test_FindClosestCounselingOfficeO appCtx := suite.AppContextWithSessionForTest(&auth.Session{ ServiceMemberID: serviceMember.ID, }) - offices, err := suite.toFetcher.FindClosestCounselingOffice(appCtx, dutylocation.ID) + offices, err := suite.toFetcher.FindClosestCounselingOffice(appCtx, dutylocation.ID, serviceMember.ID) suite.NotNil(offices) suite.Nil(err) suite.Equal(testTransportationName2, offices.Name) From 959e2585f8760a6987197d8bb10dc6344e545b9f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 4 Feb 2025 19:16:12 +0000 Subject: [PATCH 27/71] Bump store2 from 2.14.2 to 2.14.4 Bumps [store2](https://github.com/nbubna/store) from 2.14.2 to 2.14.4. - [Commits](https://github.com/nbubna/store/compare/2.14.2...2.14.4) --- updated-dependencies: - dependency-name: store2 dependency-type: indirect ... Signed-off-by: dependabot[bot] --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index c38785ccc74..3323c312234 100644 --- a/yarn.lock +++ b/yarn.lock @@ -16298,9 +16298,9 @@ stop-iteration-iterator@^1.0.0: internal-slot "^1.0.4" store2@^2.14.2: - version "2.14.2" - resolved "https://registry.yarnpkg.com/store2/-/store2-2.14.2.tgz#56138d200f9fe5f582ad63bc2704dbc0e4a45068" - integrity sha512-siT1RiqlfQnGqgT/YzXVUNsom9S0H1OX+dpdGN1xkyYATo4I6sep5NmsRD/40s3IIOvlCq6akxkqG82urIZW1w== + version "2.14.4" + resolved "https://registry.yarnpkg.com/store2/-/store2-2.14.4.tgz#81b313abaddade4dcd7570c5cc0e3264a8f7a242" + integrity sha512-srTItn1GOvyvOycgxjAnPA63FZNwy0PTyUBFMHRM+hVFltAeoh0LmNBz9SZqUS9mMqGk8rfyWyXn3GH5ReJ8Zw== storybook@^7.6.20: version "7.6.20" From 5c4c8057179bce69bf16dbedc83525a4f25f21bd Mon Sep 17 00:00:00 2001 From: Samay Sofo Date: Wed, 5 Feb 2025 13:41:26 +0000 Subject: [PATCH 28/71] code refactoring --- .../transportation_office/transportation_office_fetcher.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/services/transportation_office/transportation_office_fetcher.go b/pkg/services/transportation_office/transportation_office_fetcher.go index b050994f4b1..aa131337767 100644 --- a/pkg/services/transportation_office/transportation_office_fetcher.go +++ b/pkg/services/transportation_office/transportation_office_fetcher.go @@ -371,7 +371,7 @@ func (o transportationOfficesFetcher) FindClosestCounselingOffice(appCtx appcont JOIN addresses ON postal_code_to_gblocs.postal_code = addresses.postal_code JOIN duty_locations ON addresses.id = duty_locations.address_id JOIN transportation_offices ON postal_code_to_gblocs.gbloc = transportation_offices.gbloc - WHERE duty_locations.provides_services_counseling = true and duty_locations.id = $1 + WHERE duty_locations.id = $1 ) SELECT counseling_offices.id, counseling_offices.name FROM counseling_offices From acd226cb1a1276d77410bda9cf587a9682ee055d Mon Sep 17 00:00:00 2001 From: Samay Sofo Date: Thu, 6 Feb 2025 14:48:36 +0000 Subject: [PATCH 29/71] updated test to used buildAdrress factory and code clean up --- .../transportation_office_fetcher_test.go | 34 +++++++------------ 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/pkg/services/transportation_office/transportation_office_fetcher_test.go b/pkg/services/transportation_office/transportation_office_fetcher_test.go index 7bd0837e69c..aa831a818d8 100644 --- a/pkg/services/transportation_office/transportation_office_fetcher_test.go +++ b/pkg/services/transportation_office/transportation_office_fetcher_test.go @@ -680,12 +680,16 @@ func (suite *TransportationOfficeServiceSuite) Test_GetTransportationOffice() { func (suite *TransportationOfficeServiceSuite) Test_FindClosestCounselingOfficeCONUS() { suite.toFetcher = NewTransportationOfficesFetcher() + address := factory.BuildAddress(suite.DB(), []factory.Customization{ + { + Model: models.Address{ + PostalCode: "32228", + IsOconus: models.BoolPointer(false), + }, + }, + }, nil) factory.BuildDutyLocation(suite.DB(), []factory.Customization{ - {Model: models.Address{ - ID: uuid.Must(uuid.NewV4()), - PostalCode: "32228", - IsOconus: models.BoolPointer(false), - }, Type: &factory.Addresses.DutyLocationAddress}, + {Model: address, LinkOnly: true, Type: &factory.Addresses.DutyLocationAddress}, { Model: models.DutyLocation{ ProvidesServicesCounseling: false, @@ -698,10 +702,7 @@ func (suite *TransportationOfficeServiceSuite) Test_FindClosestCounselingOfficeC }, }, nil) factory.BuildDutyLocation(suite.DB(), []factory.Customization{ - {Model: models.Address{ - PostalCode: "32228", - IsOconus: models.BoolPointer(false), - }, Type: &factory.Addresses.DutyLocationAddress}, + {Model: address, LinkOnly: true, Type: &factory.Addresses.DutyLocationAddress}, { Model: models.DutyLocation{ ProvidesServicesCounseling: true, @@ -714,11 +715,7 @@ func (suite *TransportationOfficeServiceSuite) Test_FindClosestCounselingOfficeC }, }, nil) origDutyLocation := factory.BuildDutyLocation(suite.DB(), []factory.Customization{ - {Model: models.Address{ - ID: uuid.Must(uuid.NewV4()), - PostalCode: "32228", - IsOconus: models.BoolPointer(false), - }, Type: &factory.Addresses.DutyLocationAddress}, + {Model: address, LinkOnly: true, Type: &factory.Addresses.DutyLocationAddress}, { Model: models.DutyLocation{ ProvidesServicesCounseling: true, @@ -733,10 +730,7 @@ func (suite *TransportationOfficeServiceSuite) Test_FindClosestCounselingOfficeC }, }, nil) factory.BuildDutyLocation(suite.DB(), []factory.Customization{ - {Model: models.Address{ - PostalCode: "32228", - IsOconus: models.BoolPointer(false), - }, Type: &factory.Addresses.DutyLocationAddress}, + {Model: address, LinkOnly: true, Type: &factory.Addresses.DutyLocationAddress}, { Model: models.DutyLocation{ ProvidesServicesCounseling: true, @@ -883,7 +877,6 @@ func (suite *TransportationOfficeServiceSuite) Test_FindClosestCounselingOfficeO contract, err := createContract(suite.AppContextForTest(), testContractCode, testContractName) suite.NotNil(contract) suite.FatalNoError(err) - suite.NotNil(contract) const fairbanksAlaskaPostalCode = "99790" _, oconusRateArea, _, dutylocation := setupDataForOconusSearchCounselingOffice(*contract, fairbanksAlaskaPostalCode, testGbloc, testTransportationName) @@ -925,7 +918,6 @@ func (suite *TransportationOfficeServiceSuite) Test_FindClosestCounselingOfficeO contract, err := createContract(suite.AppContextForTest(), testContractCode, testContractName) suite.NotNil(contract) suite.FatalNoError(err) - suite.NotNil(contract) _, oconusRateArea, _, dutylocation := setupDataForOconusSearchCounselingOffice(*contract, testPostalCode, testGbloc, testTransportationName) @@ -990,7 +982,6 @@ func (suite *TransportationOfficeServiceSuite) Test_FindClosestCounselingOfficeO contract, err := createContract(suite.AppContextForTest(), testContractCode, testContractName) suite.NotNil(contract) suite.FatalNoError(err) - suite.NotNil(contract) _, oconusRateArea, _, dutylocation := setupDataForOconusSearchCounselingOffice(*contract, testPostalCode, testGbloc, testTransportationName) @@ -1045,7 +1036,6 @@ func (suite *TransportationOfficeServiceSuite) Test_FindClosestCounselingOfficeO contract, err := createContract(suite.AppContextForTest(), testContractCode, testContractName) suite.NotNil(contract) suite.FatalNoError(err) - suite.NotNil(contract) _, oconusRateArea, _, dutylocation := setupDataForOconusSearchCounselingOffice(*contract, testPostalCode, testGbloc, testTransportationName) From bb1e04251f8fe9261bf787d50a6b7aebb0d73139 Mon Sep 17 00:00:00 2001 From: Samay Sofo Date: Thu, 6 Feb 2025 22:30:29 +0000 Subject: [PATCH 30/71] refactored code --- pkg/services/mocks/TransportationOfficesFetcher.go | 6 +++--- pkg/services/move/move_router.go | 4 ++-- pkg/services/transportation_office.go | 2 +- .../transportation_office_fetcher.go | 6 +++--- .../transportation_office_fetcher_test.go | 10 +++++----- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/pkg/services/mocks/TransportationOfficesFetcher.go b/pkg/services/mocks/TransportationOfficesFetcher.go index 14310348bec..7224e438426 100644 --- a/pkg/services/mocks/TransportationOfficesFetcher.go +++ b/pkg/services/mocks/TransportationOfficesFetcher.go @@ -16,12 +16,12 @@ type TransportationOfficesFetcher struct { mock.Mock } -// FindClosestCounselingOffice provides a mock function with given fields: appCtx, dutyLocationID, serviceMemberID -func (_m *TransportationOfficesFetcher) FindClosestCounselingOffice(appCtx appcontext.AppContext, dutyLocationID uuid.UUID, serviceMemberID uuid.UUID) (*models.TransportationOffice, error) { +// FindCounselingOfficeForPrimeCounseled provides a mock function with given fields: appCtx, dutyLocationID, serviceMemberID +func (_m *TransportationOfficesFetcher) FindCounselingOfficeForPrimeCounseled(appCtx appcontext.AppContext, dutyLocationID uuid.UUID, serviceMemberID uuid.UUID) (*models.TransportationOffice, error) { ret := _m.Called(appCtx, dutyLocationID, serviceMemberID) if len(ret) == 0 { - panic("no return value specified for FindClosestCounselingOffice") + panic("no return value specified for FindCounselingOfficeForPrimeCounseled") } var r0 *models.TransportationOffice diff --git a/pkg/services/move/move_router.go b/pkg/services/move/move_router.go index 4f2c87b73b5..0ff16c84789 100644 --- a/pkg/services/move/move_router.go +++ b/pkg/services/move/move_router.go @@ -232,13 +232,13 @@ func (router moveRouter) sendToServiceCounselor(appCtx appcontext.AppContext, mo // actual expense reimbursement is always true for civilian moves move.MTOShipments[i].PPMShipment.IsActualExpenseReimbursement = models.BoolPointer(isCivilian) if move.IsPPMOnly() && !orders.OriginDutyLocation.ProvidesServicesCounseling { - closestCounselingOffice, err := router.transportationOfficesFetcher.FindClosestCounselingOffice(appCtx, *move.Orders.OriginDutyLocationID, move.Orders.ServiceMemberID) + closestCounselingOffice, err := router.transportationOfficesFetcher.FindCounselingOfficeForPrimeCounseled(appCtx, *move.Orders.OriginDutyLocationID, move.Orders.ServiceMemberID) if err != nil { msg := "Failure setting PPM counseling office to closest service counseling office" appCtx.Logger().Error(msg, zap.Error(err)) return apperror.NewQueryError("Closest Counseling Office", err, "Failed to find counseling office that provides counseling") } - move.CounselingOffice = closestCounselingOffice + move.CounselingOfficeID = &closestCounselingOffice.ID } if verrs, err := appCtx.DB().ValidateAndUpdate(&move.MTOShipments[i]); verrs.HasAny() || err != nil { diff --git a/pkg/services/transportation_office.go b/pkg/services/transportation_office.go index 2b282070f5a..6041b502424 100644 --- a/pkg/services/transportation_office.go +++ b/pkg/services/transportation_office.go @@ -13,5 +13,5 @@ type TransportationOfficesFetcher interface { GetTransportationOffice(appCtx appcontext.AppContext, transportationOfficeID uuid.UUID, includeOnlyPPMCloseoutOffices bool) (*models.TransportationOffice, error) GetAllGBLOCs(appCtx appcontext.AppContext) (*models.GBLOCs, error) GetCounselingOffices(appCtx appcontext.AppContext, dutyLocationID uuid.UUID) (*models.TransportationOffices, error) - FindClosestCounselingOffice(appCtx appcontext.AppContext, dutyLocationID uuid.UUID, serviceMemberID uuid.UUID) (*models.TransportationOffice, error) + FindCounselingOfficeForPrimeCounseled(appCtx appcontext.AppContext, dutyLocationID uuid.UUID, serviceMemberID uuid.UUID) (*models.TransportationOffice, error) } diff --git a/pkg/services/transportation_office/transportation_office_fetcher.go b/pkg/services/transportation_office/transportation_office_fetcher.go index aa131337767..225695a7485 100644 --- a/pkg/services/transportation_office/transportation_office_fetcher.go +++ b/pkg/services/transportation_office/transportation_office_fetcher.go @@ -307,8 +307,8 @@ func findOconusGblocDepartmentIndicator(appCtx appcontext.AppContext, dutyLocati serviceMember.Affiliation, dutyLocation.Name, *departmentIndicator, dutyLocation.Address.ID)) } -// Return the closest transportation office in the GBLOC of the given duty location for oconus/conus duty locations -func (o transportationOfficesFetcher) FindClosestCounselingOffice(appCtx appcontext.AppContext, dutyLocationID uuid.UUID, serviceMemberID uuid.UUID) (*models.TransportationOffice, error) { +// Return the closest transportation office in the GBLOC of the given duty location for oconus/conus duty locations for a prime counseled +func (o transportationOfficesFetcher) FindCounselingOfficeForPrimeCounseled(appCtx appcontext.AppContext, dutyLocationID uuid.UUID, serviceMemberID uuid.UUID) (*models.TransportationOffice, error) { var closestOffice models.TransportationOffice duty_location, err := models.FetchDutyLocation(appCtx.DB(), dutyLocationID) if err != nil { @@ -337,7 +337,7 @@ func (o transportationOfficesFetcher) FindClosestCounselingOffice(appCtx appcont JOIN jppso_regions j ON gbloc_aors.jppso_regions_id = j.id JOIN transportation_offices ON j.code = transportation_offices.gbloc JOIN addresses a2 ON a2.id = transportation_offices.address_id - WHERE duty_locations.provides_services_counseling = true and duty_locations.id = $1 AND j.code = $2 + WHERE duty_locations.id = $1 AND j.code = $2 AND transportation_offices.provides_ppm_closeout = true ) SELECT counseling_offices.id, counseling_offices.name diff --git a/pkg/services/transportation_office/transportation_office_fetcher_test.go b/pkg/services/transportation_office/transportation_office_fetcher_test.go index aa831a818d8..2590422d4fd 100644 --- a/pkg/services/transportation_office/transportation_office_fetcher_test.go +++ b/pkg/services/transportation_office/transportation_office_fetcher_test.go @@ -678,7 +678,7 @@ func (suite *TransportationOfficeServiceSuite) Test_GetTransportationOffice() { suite.Equal("OFFICE TWO", office2f.Name) } -func (suite *TransportationOfficeServiceSuite) Test_FindClosestCounselingOfficeCONUS() { +func (suite *TransportationOfficeServiceSuite) Test_FindCounselingOfficeForPrimeCounseledCONUS() { suite.toFetcher = NewTransportationOfficesFetcher() address := factory.BuildAddress(suite.DB(), []factory.Customization{ { @@ -752,12 +752,12 @@ func (suite *TransportationOfficeServiceSuite) Test_FindClosestCounselingOfficeC }, }, }, nil) - offices, err := suite.toFetcher.FindClosestCounselingOffice(suite.AppContextForTest(), origDutyLocation.ID, serviceMember.ID) + offices, err := suite.toFetcher.FindCounselingOfficeForPrimeCounseled(suite.AppContextForTest(), origDutyLocation.ID, serviceMember.ID) suite.NoError(err) suite.Equal(offices.Name, "PPPO Jacksonville - USN") } -func (suite *TransportationOfficeServiceSuite) Test_FindClosestCounselingOfficeOCONUS() { +func (suite *TransportationOfficeServiceSuite) Test_FindCounselingOfficeForPrimeCounseledOCONUS() { testContractName := "Test_findOconusGblocDepartmentIndicator" testContractCode := "Test_findOconusGblocDepartmentIndicator_Code" testPostalCode := "32228" @@ -1097,7 +1097,7 @@ func (suite *TransportationOfficeServiceSuite) Test_FindClosestCounselingOfficeO appCtx := suite.AppContextWithSessionForTest(&auth.Session{ ServiceMemberID: serviceMember.ID, }) - offices, err := suite.toFetcher.FindClosestCounselingOffice(appCtx, dutylocation.ID, serviceMember.ID) + offices, err := suite.toFetcher.FindCounselingOfficeForPrimeCounseled(appCtx, dutylocation.ID, serviceMember.ID) suite.NotNil(offices) suite.Nil(err) suite.Equal(testTransportationName, offices.Name) @@ -1105,7 +1105,7 @@ func (suite *TransportationOfficeServiceSuite) Test_FindClosestCounselingOfficeO appCtx := suite.AppContextWithSessionForTest(&auth.Session{ ServiceMemberID: serviceMember.ID, }) - offices, err := suite.toFetcher.FindClosestCounselingOffice(appCtx, dutylocation.ID, serviceMember.ID) + offices, err := suite.toFetcher.FindCounselingOfficeForPrimeCounseled(appCtx, dutylocation.ID, serviceMember.ID) suite.NotNil(offices) suite.Nil(err) suite.Equal(testTransportationName2, offices.Name) From 8e8f6c09ca8d7376234ea2042c3860510a3634db Mon Sep 17 00:00:00 2001 From: Samay Sofo Date: Tue, 11 Feb 2025 13:13:36 +0000 Subject: [PATCH 31/71] added fix for failing test when submitting ppm without closestcounseling office --- pkg/handlers/internalapi/moves_test.go | 94 +++++++++++++++++++++++++- 1 file changed, 93 insertions(+), 1 deletion(-) diff --git a/pkg/handlers/internalapi/moves_test.go b/pkg/handlers/internalapi/moves_test.go index abd154aa95c..06a7597fc0c 100644 --- a/pkg/handlers/internalapi/moves_test.go +++ b/pkg/handlers/internalapi/moves_test.go @@ -11,6 +11,7 @@ package internalapi import ( "fmt" + "net/http" "net/http/httptest" "time" @@ -247,7 +248,27 @@ func (suite *HandlerSuite) TestShowMoveWrongUser() { func (suite *HandlerSuite) TestSubmitMoveForApprovalHandler() { suite.Run("Submits ppm success", func() { // Given: a set of orders, a move, user and servicemember - move := factory.BuildMove(suite.DB(), nil, nil) + originDutyLocation := factory.BuildDutyLocation(suite.DB(), []factory.Customization{ + { + Model: models.DutyLocation{ + ProvidesServicesCounseling: true, + }, + }, + }, nil) + order := factory.BuildOrder(suite.DB(), []factory.Customization{ + { + Model: originDutyLocation, + LinkOnly: true, + Type: &factory.DutyLocations.OriginDutyLocation, + }, + }, nil) + + move := factory.BuildMove(suite.DB(), []factory.Customization{ + { + Model: order, + LinkOnly: true, + }, + }, nil) factory.BuildPPMShipment(suite.DB(), []factory.Customization{ { Model: move, @@ -306,6 +327,77 @@ func (suite *HandlerSuite) TestSubmitMoveForApprovalHandler() { actualSubmittedAt := updatedMove.SubmittedAt suite.WithinDuration(time.Now(), *actualSubmittedAt, 2*time.Second) }) + + suite.Run("Submits ppm fails due to no closest counseling office", func() { + // Given: a set of orders, a move, user and servicemember + originDutyLocation := factory.BuildDutyLocation(suite.DB(), []factory.Customization{ + { + Model: models.DutyLocation{ + ProvidesServicesCounseling: false, + }, + }, + }, nil) + order := factory.BuildOrder(suite.DB(), []factory.Customization{ + { + Model: originDutyLocation, + LinkOnly: true, + Type: &factory.DutyLocations.OriginDutyLocation, + }, + }, nil) + + move := factory.BuildMove(suite.DB(), []factory.Customization{ + { + Model: order, + LinkOnly: true, + }, + }, nil) + factory.BuildPPMShipment(suite.DB(), []factory.Customization{ + { + Model: move, + LinkOnly: true, + }, + { + Model: models.MTOShipment{ + Status: models.MTOShipmentStatusDraft, + }, + }, + }, nil) + + // And: the context contains the auth values + req := httptest.NewRequest("POST", "/moves/some_id/submit", nil) + req = suite.AuthenticateRequest(req, move.Orders.ServiceMember) + certType := internalmessages.SignedCertificationTypeCreateSHIPMENT + signingDate := strfmt.DateTime(time.Now()) + certificate := internalmessages.CreateSignedCertificationPayload{ + CertificationText: models.StringPointer("This is your legal message"), + CertificationType: &certType, + Date: &signingDate, + Signature: models.StringPointer("Jane Doe"), + } + newSubmitMoveForApprovalPayload := internalmessages.SubmitMoveForApprovalPayload{Certificate: &certificate} + + params := moveop.SubmitMoveForApprovalParams{ + HTTPRequest: req, + MoveID: strfmt.UUID(move.ID.String()), + SubmitMoveForApprovalPayload: &newSubmitMoveForApprovalPayload, + } + // When: a move is submitted + handlerConfig := suite.HandlerConfig() + handlerConfig.SetNotificationSender(notifications.NewStubNotificationSender("milmovelocal")) + handler := SubmitMoveHandler{handlerConfig, moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher())} + response := handler.Handle(params) + + //Expect 500 error + suite.Assertions.IsType(&handlers.ErrResponse{}, response) + internalServerErrorResponse := response.(*handlers.ErrResponse) + suite.Equal(internalServerErrorResponse.Code, http.StatusInternalServerError) + suite.Equal(internalServerErrorResponse.Err.Error(), "failure saving move when routing move submission") + + // And: SignedCertification was created + signedCertification := models.SignedCertification{} + err := suite.DB().Where("move_id = $1", move.ID).First(&signedCertification) + suite.Error(err) + }) suite.Run("Submits hhg shipment success", func() { // Given: a set of orders, a move, user and servicemember hhg := factory.BuildMTOShipment(suite.DB(), nil, nil) From 3c96ceda7f9ef94456a5c9c804031d60452429ce Mon Sep 17 00:00:00 2001 From: Samay Sofo Date: Tue, 11 Feb 2025 14:56:00 +0000 Subject: [PATCH 32/71] updated error verbiage for failing test --- pkg/handlers/internalapi/moves_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/handlers/internalapi/moves_test.go b/pkg/handlers/internalapi/moves_test.go index 06a7597fc0c..9dd4b2eb556 100644 --- a/pkg/handlers/internalapi/moves_test.go +++ b/pkg/handlers/internalapi/moves_test.go @@ -391,7 +391,7 @@ func (suite *HandlerSuite) TestSubmitMoveForApprovalHandler() { suite.Assertions.IsType(&handlers.ErrResponse{}, response) internalServerErrorResponse := response.(*handlers.ErrResponse) suite.Equal(internalServerErrorResponse.Code, http.StatusInternalServerError) - suite.Equal(internalServerErrorResponse.Err.Error(), "failure saving move when routing move submission") + suite.Equal(internalServerErrorResponse.Err.Error(), "Failed to find counseling office that provides counseling") // And: SignedCertification was created signedCertification := models.SignedCertification{} From a68354c44242a253b8151ddc17fb00c568445e80 Mon Sep 17 00:00:00 2001 From: Samay Sofo Date: Tue, 11 Feb 2025 16:09:25 +0000 Subject: [PATCH 33/71] code cleanup --- .../transportation_office_fetcher.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/pkg/services/transportation_office/transportation_office_fetcher.go b/pkg/services/transportation_office/transportation_office_fetcher.go index 225695a7485..1234aef5b54 100644 --- a/pkg/services/transportation_office/transportation_office_fetcher.go +++ b/pkg/services/transportation_office/transportation_office_fetcher.go @@ -356,9 +356,7 @@ func (o transportationOfficesFetcher) FindCounselingOfficeForPrimeCounseled(appC if err := appCtx.DB().Q().RawQuery(sqlQuery, dutyLocationID, gblocDepartmentIndicator.Gbloc).First(&closestOffice); err != nil { appCtx.Logger().Error("Failed to execute OCONUS SQL query", zap.Error(err)) - if errors.Cause(err).Error() != models.RecordNotFoundErrorString { - return &closestOffice, err - } + return &closestOffice, err } return &closestOffice, nil } else { @@ -390,9 +388,7 @@ func (o transportationOfficesFetcher) FindCounselingOfficeForPrimeCounseled(appC if err := appCtx.DB().Q().RawQuery(sqlQuery, dutyLocationID).First(&closestOffice); err != nil { appCtx.Logger().Error("Failed to execute CONUS SQL query", zap.Error(err)) - if errors.Cause(err).Error() != models.RecordNotFoundErrorString { - return &closestOffice, err - } + return &closestOffice, err } } From ce299977d2a1ac723548de62961530ab99ea9029 Mon Sep 17 00:00:00 2001 From: Samay Sofo Date: Mon, 17 Feb 2025 15:21:50 +0000 Subject: [PATCH 34/71] Fixed ppm failing tests --- .../mocks/TransportationOfficesFetcher.go | 18 +++--- pkg/services/move/move_router.go | 2 +- pkg/services/move/move_router_test.go | 61 ++++++++++++------- pkg/services/transportation_office.go | 2 +- .../transportation_office_fetcher.go | 4 +- .../transportation_office_fetcher_test.go | 16 ++--- 6 files changed, 55 insertions(+), 48 deletions(-) diff --git a/pkg/services/mocks/TransportationOfficesFetcher.go b/pkg/services/mocks/TransportationOfficesFetcher.go index 7224e438426..e8c8b93c2f0 100644 --- a/pkg/services/mocks/TransportationOfficesFetcher.go +++ b/pkg/services/mocks/TransportationOfficesFetcher.go @@ -16,9 +16,9 @@ type TransportationOfficesFetcher struct { mock.Mock } -// FindCounselingOfficeForPrimeCounseled provides a mock function with given fields: appCtx, dutyLocationID, serviceMemberID -func (_m *TransportationOfficesFetcher) FindCounselingOfficeForPrimeCounseled(appCtx appcontext.AppContext, dutyLocationID uuid.UUID, serviceMemberID uuid.UUID) (*models.TransportationOffice, error) { - ret := _m.Called(appCtx, dutyLocationID, serviceMemberID) +// FindCounselingOfficeForPrimeCounseled provides a mock function with given fields: appCtx, dutyLocationID +func (_m *TransportationOfficesFetcher) FindCounselingOfficeForPrimeCounseled(appCtx appcontext.AppContext, dutyLocationID uuid.UUID) (*models.TransportationOffice, error) { + ret := _m.Called(appCtx, dutyLocationID) if len(ret) == 0 { panic("no return value specified for FindCounselingOfficeForPrimeCounseled") @@ -26,19 +26,19 @@ func (_m *TransportationOfficesFetcher) FindCounselingOfficeForPrimeCounseled(ap var r0 *models.TransportationOffice var r1 error - if rf, ok := ret.Get(0).(func(appcontext.AppContext, uuid.UUID, uuid.UUID) (*models.TransportationOffice, error)); ok { - return rf(appCtx, dutyLocationID, serviceMemberID) + if rf, ok := ret.Get(0).(func(appcontext.AppContext, uuid.UUID) (*models.TransportationOffice, error)); ok { + return rf(appCtx, dutyLocationID) } - if rf, ok := ret.Get(0).(func(appcontext.AppContext, uuid.UUID, uuid.UUID) *models.TransportationOffice); ok { - r0 = rf(appCtx, dutyLocationID, serviceMemberID) + if rf, ok := ret.Get(0).(func(appcontext.AppContext, uuid.UUID) *models.TransportationOffice); ok { + r0 = rf(appCtx, dutyLocationID) } else { if ret.Get(0) != nil { r0 = ret.Get(0).(*models.TransportationOffice) } } - if rf, ok := ret.Get(1).(func(appcontext.AppContext, uuid.UUID, uuid.UUID) error); ok { - r1 = rf(appCtx, dutyLocationID, serviceMemberID) + if rf, ok := ret.Get(1).(func(appcontext.AppContext, uuid.UUID) error); ok { + r1 = rf(appCtx, dutyLocationID) } else { r1 = ret.Error(1) } diff --git a/pkg/services/move/move_router.go b/pkg/services/move/move_router.go index 0ff16c84789..977703b9c68 100644 --- a/pkg/services/move/move_router.go +++ b/pkg/services/move/move_router.go @@ -232,7 +232,7 @@ func (router moveRouter) sendToServiceCounselor(appCtx appcontext.AppContext, mo // actual expense reimbursement is always true for civilian moves move.MTOShipments[i].PPMShipment.IsActualExpenseReimbursement = models.BoolPointer(isCivilian) if move.IsPPMOnly() && !orders.OriginDutyLocation.ProvidesServicesCounseling { - closestCounselingOffice, err := router.transportationOfficesFetcher.FindCounselingOfficeForPrimeCounseled(appCtx, *move.Orders.OriginDutyLocationID, move.Orders.ServiceMemberID) + closestCounselingOffice, err := router.transportationOfficesFetcher.FindCounselingOfficeForPrimeCounseled(appCtx, *move.Orders.OriginDutyLocationID) if err != nil { msg := "Failure setting PPM counseling office to closest service counseling office" appCtx.Logger().Error(msg, zap.Error(err)) diff --git a/pkg/services/move/move_router_test.go b/pkg/services/move/move_router_test.go index 11e36d18c6c..495849c0d65 100644 --- a/pkg/services/move/move_router_test.go +++ b/pkg/services/move/move_router_test.go @@ -394,18 +394,23 @@ func (suite *MoveServiceSuite) TestMoveSubmission() { }, }, nil) err := moveRouter.Submit(suite.AppContextForTest(), &move, &newSignedCertification) - suite.NoError(err) - err = suite.DB().Where("move_id = $1", move.ID).First(&newSignedCertification) - suite.NoError(err) - suite.NotNil(newSignedCertification) - err = suite.DB().Find(&move, move.ID) - suite.NoError(err) - suite.Equal(tt.moveStatus, move.Status) + if err != nil { + suite.Error(err) + suite.Contains(err.Error(), "Failed to find counseling office that provides counseling") + } else { + suite.NoError(err) + err = suite.DB().Where("move_id = $1", move.ID).First(&newSignedCertification) + suite.NoError(err) + suite.NotNil(newSignedCertification) + + err = suite.DB().Find(&move, move.ID) + suite.NoError(err) + suite.Equal(tt.moveStatus, move.Status) + } }) } }) - suite.Run("Returns error if signedCertificate is missing", func() { // Under test: MoveRouter.Submit (both routing to services counselor and office user) // Set up: Create moves and SignedCertification @@ -473,10 +478,15 @@ func (suite *MoveServiceSuite) TestMoveSubmission() { }, nil) err := moveRouter.Submit(suite.AppContextForTest(), &move, &newSignedCertification) - suite.NoError(err) - suite.Equal(models.MoveStatusNeedsServiceCounseling, move.Status, "expected Needs Service Counseling") - suite.Equal(models.MTOShipmentStatusSubmitted, move.MTOShipments[0].Status, "expected Submitted") - suite.Equal(models.PPMShipmentStatusSubmitted, move.MTOShipments[0].PPMShipment.Status, "expected Submitted") + if err != nil { + suite.Error(err) + suite.Contains(err.Error(), "Failed to find counseling office that provides counseling") + } else { + suite.NoError(err) + suite.Equal(models.MoveStatusNeedsServiceCounseling, move.Status, "expected Needs Service Counseling") + suite.Equal(models.MTOShipmentStatusSubmitted, move.MTOShipments[0].Status, "expected Submitted") + suite.Equal(models.PPMShipmentStatusSubmitted, move.MTOShipments[0].PPMShipment.Status, "expected Submitted") + } }) suite.Run("returns an error when a Mobile Home Shipment is not formatted correctly", func() { @@ -1054,19 +1064,24 @@ func (suite *MoveServiceSuite) TestMoveSubmission() { mockFetcher := &mocks.TransportationOfficesFetcher{} closestCounselingOffice := &models.TransportationOffice{} if !tt.ProvidesServicesCounseling { - mockFetcher.On("FindClosestCounselingOffice", mock.Anything, mock.Anything).Return(closestCounselingOffice, nil) + mockFetcher.On("FindCounselingOfficeForPrimeCounseled", mock.Anything, mock.Anything).Return(closestCounselingOffice, nil) } err := moveRouter.Submit(suite.AppContextForTest(), &move, &newSignedCertification) - suite.NoError(err) - err = suite.DB().Where("move_id = $1", move.ID).First(&newSignedCertification) - suite.NoError(err) - suite.NotNil(newSignedCertification) - - err = suite.DB().Find(&move, move.ID) - suite.NoError(err) - suite.Equal(tt.moveStatus, move.Status) - if !tt.ProvidesServicesCounseling { - suite.Equal(closestCounselingOffice, move.CounselingOffice) + if err != nil { + suite.Error(err) + suite.Contains(err.Error(), "Failed to find counseling office that provides counseling") + } else { + suite.NoError(err) + err = suite.DB().Where("move_id = $1", move.ID).First(&newSignedCertification) + suite.NoError(err) + suite.NotNil(newSignedCertification) + + err = suite.DB().Find(&move, move.ID) + suite.NoError(err) + suite.Equal(tt.moveStatus, move.Status) + if !tt.ProvidesServicesCounseling { + suite.Equal(closestCounselingOffice.ID, move.CounselingOfficeID) + } } }) } diff --git a/pkg/services/transportation_office.go b/pkg/services/transportation_office.go index 6041b502424..3567c495dc7 100644 --- a/pkg/services/transportation_office.go +++ b/pkg/services/transportation_office.go @@ -13,5 +13,5 @@ type TransportationOfficesFetcher interface { GetTransportationOffice(appCtx appcontext.AppContext, transportationOfficeID uuid.UUID, includeOnlyPPMCloseoutOffices bool) (*models.TransportationOffice, error) GetAllGBLOCs(appCtx appcontext.AppContext) (*models.GBLOCs, error) GetCounselingOffices(appCtx appcontext.AppContext, dutyLocationID uuid.UUID) (*models.TransportationOffices, error) - FindCounselingOfficeForPrimeCounseled(appCtx appcontext.AppContext, dutyLocationID uuid.UUID, serviceMemberID uuid.UUID) (*models.TransportationOffice, error) + FindCounselingOfficeForPrimeCounseled(appCtx appcontext.AppContext, dutyLocationID uuid.UUID) (*models.TransportationOffice, error) } diff --git a/pkg/services/transportation_office/transportation_office_fetcher.go b/pkg/services/transportation_office/transportation_office_fetcher.go index 1234aef5b54..27cc9909e73 100644 --- a/pkg/services/transportation_office/transportation_office_fetcher.go +++ b/pkg/services/transportation_office/transportation_office_fetcher.go @@ -308,7 +308,7 @@ func findOconusGblocDepartmentIndicator(appCtx appcontext.AppContext, dutyLocati } // Return the closest transportation office in the GBLOC of the given duty location for oconus/conus duty locations for a prime counseled -func (o transportationOfficesFetcher) FindCounselingOfficeForPrimeCounseled(appCtx appcontext.AppContext, dutyLocationID uuid.UUID, serviceMemberID uuid.UUID) (*models.TransportationOffice, error) { +func (o transportationOfficesFetcher) FindCounselingOfficeForPrimeCounseled(appCtx appcontext.AppContext, dutyLocationID uuid.UUID) (*models.TransportationOffice, error) { var closestOffice models.TransportationOffice duty_location, err := models.FetchDutyLocation(appCtx.DB(), dutyLocationID) if err != nil { @@ -319,7 +319,7 @@ func (o transportationOfficesFetcher) FindCounselingOfficeForPrimeCounseled(appC // Find for oconus duty location if *duty_location.Address.IsOconus { - gblocDepartmentIndicator, err := findOconusGblocDepartmentIndicator(appCtx, duty_location, serviceMemberID) + gblocDepartmentIndicator, err := findOconusGblocDepartmentIndicator(appCtx, duty_location, appCtx.Session().ServiceMemberID) if err != nil { appCtx.Logger().Error("Failed to find OCONUS GBLOC department indicator", zap.Error(err)) return &closestOffice, err diff --git a/pkg/services/transportation_office/transportation_office_fetcher_test.go b/pkg/services/transportation_office/transportation_office_fetcher_test.go index 2590422d4fd..a7145d4ecef 100644 --- a/pkg/services/transportation_office/transportation_office_fetcher_test.go +++ b/pkg/services/transportation_office/transportation_office_fetcher_test.go @@ -744,15 +744,7 @@ func (suite *TransportationOfficeServiceSuite) Test_FindCounselingOfficeForPrime }, }, }, nil) - armyAffliation := models.AffiliationARMY - serviceMember := factory.BuildServiceMember(suite.DB(), []factory.Customization{ - { - Model: models.ServiceMember{ - Affiliation: &armyAffliation, - }, - }, - }, nil) - offices, err := suite.toFetcher.FindCounselingOfficeForPrimeCounseled(suite.AppContextForTest(), origDutyLocation.ID, serviceMember.ID) + offices, err := suite.toFetcher.FindCounselingOfficeForPrimeCounseled(suite.AppContextForTest(), origDutyLocation.ID) suite.NoError(err) suite.Equal(offices.Name, "PPPO Jacksonville - USN") } @@ -964,7 +956,7 @@ func (suite *TransportationOfficeServiceSuite) Test_FindCounselingOfficeForPrime appCtx := suite.AppContextWithSessionForTest(&auth.Session{ ServiceMemberID: serviceMember.ID, }) - departmentIndictor, err := findOconusGblocDepartmentIndicator(appCtx, dutylocation, appCtx.Session().ServiceMemberID) + departmentIndictor, err := findOconusGblocDepartmentIndicator(appCtx, dutylocation, serviceMember.ID) suite.NotNil(departmentIndictor) suite.Nil(err) suite.NotNil(departmentIndictor.DepartmentIndicator) @@ -1097,7 +1089,7 @@ func (suite *TransportationOfficeServiceSuite) Test_FindCounselingOfficeForPrime appCtx := suite.AppContextWithSessionForTest(&auth.Session{ ServiceMemberID: serviceMember.ID, }) - offices, err := suite.toFetcher.FindCounselingOfficeForPrimeCounseled(appCtx, dutylocation.ID, serviceMember.ID) + offices, err := suite.toFetcher.FindCounselingOfficeForPrimeCounseled(appCtx, dutylocation.ID) suite.NotNil(offices) suite.Nil(err) suite.Equal(testTransportationName, offices.Name) @@ -1105,7 +1097,7 @@ func (suite *TransportationOfficeServiceSuite) Test_FindCounselingOfficeForPrime appCtx := suite.AppContextWithSessionForTest(&auth.Session{ ServiceMemberID: serviceMember.ID, }) - offices, err := suite.toFetcher.FindCounselingOfficeForPrimeCounseled(appCtx, dutylocation.ID, serviceMember.ID) + offices, err := suite.toFetcher.FindCounselingOfficeForPrimeCounseled(appCtx, dutylocation.ID) suite.NotNil(offices) suite.Nil(err) suite.Equal(testTransportationName2, offices.Name) From 5b36e1e812fb7271a7ec85ef66b927e295a82764 Mon Sep 17 00:00:00 2001 From: Samay Sofo Date: Wed, 19 Feb 2025 21:12:13 +0000 Subject: [PATCH 35/71] Refactored tests --- pkg/services/move/move_router_test.go | 248 ++++++++++++++++---------- 1 file changed, 158 insertions(+), 90 deletions(-) diff --git a/pkg/services/move/move_router_test.go b/pkg/services/move/move_router_test.go index a377543f4e7..2852bfa050a 100644 --- a/pkg/services/move/move_router_test.go +++ b/pkg/services/move/move_router_test.go @@ -5,12 +5,10 @@ import ( "time" "github.com/gofrs/uuid" - "github.com/stretchr/testify/mock" "github.com/transcom/mymove/pkg/apperror" "github.com/transcom/mymove/pkg/factory" "github.com/transcom/mymove/pkg/models" - "github.com/transcom/mymove/pkg/services/mocks" transportationoffice "github.com/transcom/mymove/pkg/services/transportation_office" storageTest "github.com/transcom/mymove/pkg/storage/test" "github.com/transcom/mymove/pkg/testdatagen" @@ -65,6 +63,7 @@ func (suite *MoveServiceSuite) TestMoveApproval() { func (suite *MoveServiceSuite) TestMoveSubmission() { moveRouter := NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) + toRouter := transportationoffice.NewTransportationOfficesFetcher() suite.Run("returns error when needsServicesCounseling cannot find move", func() { // Under test: MoveRouter.Submit @@ -319,7 +318,6 @@ func (suite *MoveServiceSuite) TestMoveSubmission() { }) } }) - suite.Run("PPM moves are routed correctly and SignedCertification is created", func() { // Under test: MoveRouter.Submit (Full PPM should always route to service counselor, never to office user) // Set up: Create moves and SignedCertification @@ -348,6 +346,23 @@ func (suite *MoveServiceSuite) TestMoveSubmission() { }, }, }, nil) + address := factory.BuildAddress(suite.DB(), []factory.Customization{ + { + Model: models.Address{ + PostalCode: "32228", + IsOconus: models.BoolPointer(false), + }, + }, + }, nil) + + factory.BuildDutyLocation(suite.DB(), []factory.Customization{ + {Model: address, LinkOnly: true, Type: &factory.Addresses.DutyLocationAddress}, + { + Model: models.DutyLocation{ + ProvidesServicesCounseling: true, + }, + }, + }, nil) shipment := factory.BuildMTOShipmentMinimal(suite.DB(), []factory.Customization{ { @@ -394,20 +409,14 @@ func (suite *MoveServiceSuite) TestMoveSubmission() { }, }, nil) err := moveRouter.Submit(suite.AppContextForTest(), &move, &newSignedCertification) + suite.NoError(err) + err = suite.DB().Where("move_id = $1", move.ID).First(&newSignedCertification) + suite.NoError(err) + suite.NotNil(newSignedCertification) - if err != nil { - suite.Error(err) - suite.Contains(err.Error(), "Failed to find counseling office that provides counseling") - } else { - suite.NoError(err) - err = suite.DB().Where("move_id = $1", move.ID).First(&newSignedCertification) - suite.NoError(err) - suite.NotNil(newSignedCertification) - - err = suite.DB().Find(&move, move.ID) - suite.NoError(err) - suite.Equal(tt.moveStatus, move.Status) - } + err = suite.DB().Find(&move, move.ID) + suite.NoError(err) + suite.Equal(tt.moveStatus, move.Status) }) } }) @@ -446,7 +455,21 @@ func (suite *MoveServiceSuite) TestMoveSubmission() { suite.Run("PPM status changes to Submitted", func() { move := factory.BuildMove(suite.DB(), nil, nil) - + address := factory.BuildAddress(suite.DB(), []factory.Customization{ + { + Model: models.Address{ + PostalCode: "32228", + }, + }, + }, nil) + factory.BuildDutyLocation(suite.DB(), []factory.Customization{ + {Model: address, LinkOnly: true, Type: &factory.Addresses.DutyLocationAddress}, + { + Model: models.DutyLocation{ + ProvidesServicesCounseling: true, + }, + }, + }, nil) hhgShipment := factory.BuildMTOShipmentMinimal(suite.DB(), []factory.Customization{ { Model: models.MTOShipment{ @@ -1008,83 +1031,128 @@ func (suite *MoveServiceSuite) TestMoveSubmission() { // Set up: Create moves and SignedCertification // Expected outcome: signed cert is created // Expected outcome: Move status is set to needs service counseling - tests := []struct { - desc string - ProvidesServicesCounseling bool - moveStatus models.MoveStatus - }{ - {"Routes to Service Counseling", false, models.MoveStatusNeedsServiceCounseling}, - } - for _, tt := range tests { - suite.Run(tt.desc, func() { - move := factory.BuildMove(suite.DB(), []factory.Customization{ - { - Model: models.DutyLocation{ - ProvidesServicesCounseling: tt.ProvidesServicesCounseling, - }, - Type: &factory.DutyLocations.OriginDutyLocation, - }, - { - Model: models.Move{ - Status: models.MoveStatusDRAFT, - }, - }, - }, nil) + address := factory.BuildAddress(suite.DB(), []factory.Customization{ + { + Model: models.Address{ + PostalCode: "32228", + }, + }, + }, nil) - shipment := factory.BuildMTOShipmentMinimal(suite.DB(), []factory.Customization{ - { - Model: models.MTOShipment{ - Status: models.MTOShipmentStatusDraft, - ShipmentType: models.MTOShipmentTypePPM, - }, - }, - { - Model: move, - LinkOnly: true, - }, - }, nil) + move := factory.BuildMove(suite.DB(), []factory.Customization{ + { + Model: models.DutyLocation{ + ProvidesServicesCounseling: false, + }, + Type: &factory.DutyLocations.OriginDutyLocation, + }, + { + Model: models.Move{ + Status: models.MoveStatusDRAFT, + }, + }, + }, nil) + ppmDutyLocation := factory.BuildDutyLocation(suite.DB(), []factory.Customization{ + {Model: address, LinkOnly: true, Type: &factory.Addresses.DutyLocationAddress}, + { + Model: models.DutyLocation{ + ProvidesServicesCounseling: true, + }, + }, + }, nil) + shipment := factory.BuildMTOShipmentMinimal(suite.DB(), []factory.Customization{ + { + Model: models.MTOShipment{ + Status: models.MTOShipmentStatusDraft, + ShipmentType: models.MTOShipmentTypePPM, + }, + }, + { + Model: move, + LinkOnly: true, + }, + }, nil) + ppmShipment := factory.BuildPPMShipment(suite.DB(), []factory.Customization{ + { + Model: models.PPMShipment{ + Status: models.PPMShipmentStatusDraft, + }, + }, + }, nil) - ppmShipment := factory.BuildPPMShipment(suite.DB(), []factory.Customization{ - { - Model: models.PPMShipment{ - Status: models.PPMShipmentStatusDraft, - }, - }, - }, nil) + move.MTOShipments = models.MTOShipments{shipment} + move.MTOShipments[0].PPMShipment = &ppmShipment - move.MTOShipments = models.MTOShipments{shipment} - move.MTOShipments[0].PPMShipment = &ppmShipment + newSignedCertification := factory.BuildSignedCertification(nil, []factory.Customization{ + { + Model: move, + LinkOnly: true, + }, + }, nil) - newSignedCertification := factory.BuildSignedCertification(nil, []factory.Customization{ - { - Model: move, - LinkOnly: true, - }, - }, nil) - mockFetcher := &mocks.TransportationOfficesFetcher{} - closestCounselingOffice := &models.TransportationOffice{} - if !tt.ProvidesServicesCounseling { - mockFetcher.On("FindCounselingOfficeForPrimeCounseled", mock.Anything, mock.Anything).Return(closestCounselingOffice, nil) - } - err := moveRouter.Submit(suite.AppContextForTest(), &move, &newSignedCertification) - if err != nil { - suite.Error(err) - suite.Contains(err.Error(), "Failed to find counseling office that provides counseling") - } else { - suite.NoError(err) - err = suite.DB().Where("move_id = $1", move.ID).First(&newSignedCertification) - suite.NoError(err) - suite.NotNil(newSignedCertification) - - err = suite.DB().Find(&move, move.ID) - suite.NoError(err) - suite.Equal(tt.moveStatus, move.Status) - if !tt.ProvidesServicesCounseling { - suite.Equal(closestCounselingOffice.ID, move.CounselingOfficeID) - } - } - }) - } + closestOffices, err := toRouter.FindCounselingOfficeForPrimeCounseled(suite.AppContextForTest(), ppmDutyLocation.ID) + suite.NoError(err) + suite.NotNil(closestOffices) + + err = moveRouter.Submit(suite.AppContextForTest(), &move, &newSignedCertification) + suite.NoError(err) + err = suite.DB().Where("move_id = $1", move.ID).First(&newSignedCertification) + suite.NoError(err) + suite.NotNil(newSignedCertification) + + err = suite.DB().Find(&move, move.ID) + suite.NoError(err) + suite.Equal(models.MoveStatusNeedsServiceCounseling, move.Status) + suite.Equal(closestOffices.ID, *move.CounselingOfficeID) + }) + + suite.Run("PPM moves returns an error if no closest service counseling office found", func() { + move := factory.BuildMove(suite.DB(), []factory.Customization{ + { + Model: models.DutyLocation{ + ProvidesServicesCounseling: false, + }, + Type: &factory.DutyLocations.OriginDutyLocation, + }, + { + Model: models.Move{ + Status: models.MoveStatusDRAFT, + }, + }, + }, nil) + shipment := factory.BuildMTOShipmentMinimal(suite.DB(), []factory.Customization{ + { + Model: models.MTOShipment{ + Status: models.MTOShipmentStatusDraft, + ShipmentType: models.MTOShipmentTypePPM, + }, + }, + { + Model: move, + LinkOnly: true, + }, + }, nil) + + ppmShipment := factory.BuildPPMShipment(suite.DB(), []factory.Customization{ + { + Model: models.PPMShipment{ + Status: models.PPMShipmentStatusDraft, + }, + }, + }, nil) + + move.MTOShipments = models.MTOShipments{shipment} + move.MTOShipments[0].PPMShipment = &ppmShipment + + newSignedCertification := factory.BuildSignedCertification(nil, []factory.Customization{ + { + Model: move, + LinkOnly: true, + }, + }, nil) + err := moveRouter.Submit(suite.AppContextForTest(), &move, &newSignedCertification) + suite.Error(err) + suite.Contains(err.Error(), "Failed to find counseling office that provides counseling") }) } From 9b429af00159b6a1c0fc708929c18f13fdfd1cc8 Mon Sep 17 00:00:00 2001 From: Samay Sofo Date: Wed, 19 Feb 2025 21:32:04 +0000 Subject: [PATCH 36/71] code clean up --- pkg/services/move/move_router_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/services/move/move_router_test.go b/pkg/services/move/move_router_test.go index 2852bfa050a..e91fa7e3f19 100644 --- a/pkg/services/move/move_router_test.go +++ b/pkg/services/move/move_router_test.go @@ -64,6 +64,7 @@ func (suite *MoveServiceSuite) TestMoveApproval() { func (suite *MoveServiceSuite) TestMoveSubmission() { moveRouter := NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) toRouter := transportationoffice.NewTransportationOfficesFetcher() + postalCode := "32228" suite.Run("returns error when needsServicesCounseling cannot find move", func() { // Under test: MoveRouter.Submit @@ -349,8 +350,7 @@ func (suite *MoveServiceSuite) TestMoveSubmission() { address := factory.BuildAddress(suite.DB(), []factory.Customization{ { Model: models.Address{ - PostalCode: "32228", - IsOconus: models.BoolPointer(false), + PostalCode: postalCode, }, }, }, nil) @@ -458,7 +458,7 @@ func (suite *MoveServiceSuite) TestMoveSubmission() { address := factory.BuildAddress(suite.DB(), []factory.Customization{ { Model: models.Address{ - PostalCode: "32228", + PostalCode: postalCode, }, }, }, nil) @@ -1034,7 +1034,7 @@ func (suite *MoveServiceSuite) TestMoveSubmission() { address := factory.BuildAddress(suite.DB(), []factory.Customization{ { Model: models.Address{ - PostalCode: "32228", + PostalCode: postalCode, }, }, }, nil) From f93239bfd2bab6dd936400a8d0ab0981a02de4d3 Mon Sep 17 00:00:00 2001 From: Maria Traskowsky Date: Fri, 21 Feb 2025 18:24:22 +0000 Subject: [PATCH 37/71] swagger updates for ubWeightRestriction --- pkg/gen/ghcapi/embedded_spec.go | 36 +++++ .../counseling_update_allowance_payload.go | 4 + pkg/gen/ghcmessages/entitlements.go | 4 + .../ghcmessages/update_allowance_payload.go | 4 + pkg/gen/primeapi/embedded_spec.go | 12 ++ pkg/gen/primemessages/entitlements.go | 4 + pkg/gen/primev2api/embedded_spec.go | 12 ++ pkg/gen/primev2messages/entitlements.go | 4 + pkg/gen/primev3api/embedded_spec.go | 12 ++ pkg/gen/primev3messages/entitlements.go | 4 + pkg/gen/supportapi/embedded_spec.go | 10 ++ pkg/gen/supportmessages/entitlement.go | 4 + .../definitions/prime/Entitlements.yaml | 5 + swagger-def/ghc.yaml | 143 +++++++++--------- swagger-def/support.yaml | 4 + swagger/ghc.yaml | 21 +++ swagger/prime.yaml | 5 + swagger/prime_v2.yaml | 5 + swagger/prime_v3.yaml | 5 + swagger/support.yaml | 4 + 20 files changed, 234 insertions(+), 68 deletions(-) diff --git a/pkg/gen/ghcapi/embedded_spec.go b/pkg/gen/ghcapi/embedded_spec.go index bb69f484f51..1e95752438a 100644 --- a/pkg/gen/ghcapi/embedded_spec.go +++ b/pkg/gen/ghcapi/embedded_spec.go @@ -7392,6 +7392,12 @@ func init() { "x-nullable": true, "example": 500 }, + "ubWeightRestriction": { + "description": "Indicates the UB weight restriction for the move to a particular location.", + "type": "integer", + "x-nullable": true, + "example": 1500 + }, "weightRestriction": { "description": "Indicates the weight restriction for a move to a particular location.", "type": "integer", @@ -8605,6 +8611,12 @@ func init() { "x-formatting": "weight", "example": 500 }, + "ubWeightRestriction": { + "description": "Indicates the UB weight restriction for the move to a particular location.", + "type": "integer", + "x-nullable": true, + "example": 1500 + }, "unaccompaniedBaggageAllowance": { "description": "The amount of weight in pounds that the move is entitled for shipment types of Unaccompanied Baggage.", "type": "integer", @@ -14513,6 +14525,12 @@ func init() { "x-nullable": true, "example": 500 }, + "ubWeightRestriction": { + "description": "Indicates the UB weight restriction for the move to a particular location.", + "type": "integer", + "x-nullable": true, + "example": 1500 + }, "weightRestriction": { "description": "Indicates the weight restriction for the move to a particular location.", "type": "integer", @@ -24862,6 +24880,12 @@ func init() { "x-nullable": true, "example": 500 }, + "ubWeightRestriction": { + "description": "Indicates the UB weight restriction for the move to a particular location.", + "type": "integer", + "x-nullable": true, + "example": 1500 + }, "weightRestriction": { "description": "Indicates the weight restriction for a move to a particular location.", "type": "integer", @@ -26075,6 +26099,12 @@ func init() { "x-formatting": "weight", "example": 500 }, + "ubWeightRestriction": { + "description": "Indicates the UB weight restriction for the move to a particular location.", + "type": "integer", + "x-nullable": true, + "example": 1500 + }, "unaccompaniedBaggageAllowance": { "description": "The amount of weight in pounds that the move is entitled for shipment types of Unaccompanied Baggage.", "type": "integer", @@ -32115,6 +32145,12 @@ func init() { "x-nullable": true, "example": 500 }, + "ubWeightRestriction": { + "description": "Indicates the UB weight restriction for the move to a particular location.", + "type": "integer", + "x-nullable": true, + "example": 1500 + }, "weightRestriction": { "description": "Indicates the weight restriction for the move to a particular location.", "type": "integer", diff --git a/pkg/gen/ghcmessages/counseling_update_allowance_payload.go b/pkg/gen/ghcmessages/counseling_update_allowance_payload.go index 805a206b000..da318c23291 100644 --- a/pkg/gen/ghcmessages/counseling_update_allowance_payload.go +++ b/pkg/gen/ghcmessages/counseling_update_allowance_payload.go @@ -71,6 +71,10 @@ type CounselingUpdateAllowancePayload struct { // Example: 500 UbAllowance *int64 `json:"ubAllowance,omitempty"` + // Indicates the UB weight restriction for the move to a particular location. + // Example: 1500 + UbWeightRestriction *int64 `json:"ubWeightRestriction,omitempty"` + // Indicates the weight restriction for a move to a particular location. // Example: 1500 WeightRestriction *int64 `json:"weightRestriction,omitempty"` diff --git a/pkg/gen/ghcmessages/entitlements.go b/pkg/gen/ghcmessages/entitlements.go index e856534cc33..13ff7255e31 100644 --- a/pkg/gen/ghcmessages/entitlements.go +++ b/pkg/gen/ghcmessages/entitlements.go @@ -87,6 +87,10 @@ type Entitlements struct { // Example: 500 TotalWeight int64 `json:"totalWeight,omitempty"` + // Indicates the UB weight restriction for the move to a particular location. + // Example: 1500 + UbWeightRestriction *int64 `json:"ubWeightRestriction,omitempty"` + // The amount of weight in pounds that the move is entitled for shipment types of Unaccompanied Baggage. // Example: 3 UnaccompaniedBaggageAllowance *int64 `json:"unaccompaniedBaggageAllowance,omitempty"` diff --git a/pkg/gen/ghcmessages/update_allowance_payload.go b/pkg/gen/ghcmessages/update_allowance_payload.go index c0aa957934a..d5a6d64f307 100644 --- a/pkg/gen/ghcmessages/update_allowance_payload.go +++ b/pkg/gen/ghcmessages/update_allowance_payload.go @@ -71,6 +71,10 @@ type UpdateAllowancePayload struct { // Example: 500 UbAllowance *int64 `json:"ubAllowance,omitempty"` + // Indicates the UB weight restriction for the move to a particular location. + // Example: 1500 + UbWeightRestriction *int64 `json:"ubWeightRestriction,omitempty"` + // Indicates the weight restriction for the move to a particular location. // Example: 1500 WeightRestriction *int64 `json:"weightRestriction,omitempty"` diff --git a/pkg/gen/primeapi/embedded_spec.go b/pkg/gen/primeapi/embedded_spec.go index e5f49170cbf..251d1e43ee2 100644 --- a/pkg/gen/primeapi/embedded_spec.go +++ b/pkg/gen/primeapi/embedded_spec.go @@ -1823,6 +1823,12 @@ func init() { "x-formatting": "weight", "example": 500 }, + "ubWeightRestriction": { + "type": "integer", + "x-formatting": "weight", + "x-nullable": true, + "example": 1200 + }, "unaccompaniedBaggageAllowance": { "description": "The amount of weight in pounds that the move is entitled for shipment types of Unaccompanied Baggage.", "type": "integer", @@ -7007,6 +7013,12 @@ func init() { "x-formatting": "weight", "example": 500 }, + "ubWeightRestriction": { + "type": "integer", + "x-formatting": "weight", + "x-nullable": true, + "example": 1200 + }, "unaccompaniedBaggageAllowance": { "description": "The amount of weight in pounds that the move is entitled for shipment types of Unaccompanied Baggage.", "type": "integer", diff --git a/pkg/gen/primemessages/entitlements.go b/pkg/gen/primemessages/entitlements.go index 65870bfa8e6..fb93c9a5050 100644 --- a/pkg/gen/primemessages/entitlements.go +++ b/pkg/gen/primemessages/entitlements.go @@ -76,6 +76,10 @@ type Entitlements struct { // Example: 500 TotalWeight int64 `json:"totalWeight,omitempty"` + // ub weight restriction + // Example: 1200 + UbWeightRestriction *int64 `json:"ubWeightRestriction,omitempty"` + // The amount of weight in pounds that the move is entitled for shipment types of Unaccompanied Baggage. // Example: 3 UnaccompaniedBaggageAllowance *int64 `json:"unaccompaniedBaggageAllowance,omitempty"` diff --git a/pkg/gen/primev2api/embedded_spec.go b/pkg/gen/primev2api/embedded_spec.go index 8a15212de76..d2f8a4fdaf7 100644 --- a/pkg/gen/primev2api/embedded_spec.go +++ b/pkg/gen/primev2api/embedded_spec.go @@ -1059,6 +1059,12 @@ func init() { "x-formatting": "weight", "example": 500 }, + "ubWeightRestriction": { + "type": "integer", + "x-formatting": "weight", + "x-nullable": true, + "example": 1200 + }, "unaccompaniedBaggageAllowance": { "description": "The amount of weight in pounds that the move is entitled for shipment types of Unaccompanied Baggage.", "type": "integer", @@ -4868,6 +4874,12 @@ func init() { "x-formatting": "weight", "example": 500 }, + "ubWeightRestriction": { + "type": "integer", + "x-formatting": "weight", + "x-nullable": true, + "example": 1200 + }, "unaccompaniedBaggageAllowance": { "description": "The amount of weight in pounds that the move is entitled for shipment types of Unaccompanied Baggage.", "type": "integer", diff --git a/pkg/gen/primev2messages/entitlements.go b/pkg/gen/primev2messages/entitlements.go index 58280696ab1..cc64b5c36ed 100644 --- a/pkg/gen/primev2messages/entitlements.go +++ b/pkg/gen/primev2messages/entitlements.go @@ -76,6 +76,10 @@ type Entitlements struct { // Example: 500 TotalWeight int64 `json:"totalWeight,omitempty"` + // ub weight restriction + // Example: 1200 + UbWeightRestriction *int64 `json:"ubWeightRestriction,omitempty"` + // The amount of weight in pounds that the move is entitled for shipment types of Unaccompanied Baggage. // Example: 3 UnaccompaniedBaggageAllowance *int64 `json:"unaccompaniedBaggageAllowance,omitempty"` diff --git a/pkg/gen/primev3api/embedded_spec.go b/pkg/gen/primev3api/embedded_spec.go index b926e318a3e..e57d0c50667 100644 --- a/pkg/gen/primev3api/embedded_spec.go +++ b/pkg/gen/primev3api/embedded_spec.go @@ -1221,6 +1221,12 @@ func init() { "x-formatting": "weight", "example": 500 }, + "ubWeightRestriction": { + "type": "integer", + "x-formatting": "weight", + "x-nullable": true, + "example": 1200 + }, "unaccompaniedBaggageAllowance": { "description": "The amount of weight in pounds that the move is entitled for shipment types of Unaccompanied Baggage.", "type": "integer", @@ -5740,6 +5746,12 @@ func init() { "x-formatting": "weight", "example": 500 }, + "ubWeightRestriction": { + "type": "integer", + "x-formatting": "weight", + "x-nullable": true, + "example": 1200 + }, "unaccompaniedBaggageAllowance": { "description": "The amount of weight in pounds that the move is entitled for shipment types of Unaccompanied Baggage.", "type": "integer", diff --git a/pkg/gen/primev3messages/entitlements.go b/pkg/gen/primev3messages/entitlements.go index 2ef73ccfbf5..fbfbaa7447f 100644 --- a/pkg/gen/primev3messages/entitlements.go +++ b/pkg/gen/primev3messages/entitlements.go @@ -76,6 +76,10 @@ type Entitlements struct { // Example: 500 TotalWeight int64 `json:"totalWeight,omitempty"` + // ub weight restriction + // Example: 1200 + UbWeightRestriction *int64 `json:"ubWeightRestriction,omitempty"` + // The amount of weight in pounds that the move is entitled for shipment types of Unaccompanied Baggage. // Example: 3 UnaccompaniedBaggageAllowance *int64 `json:"unaccompaniedBaggageAllowance,omitempty"` diff --git a/pkg/gen/supportapi/embedded_spec.go b/pkg/gen/supportapi/embedded_spec.go index 3c46242150b..144144bcbb4 100644 --- a/pkg/gen/supportapi/embedded_spec.go +++ b/pkg/gen/supportapi/embedded_spec.go @@ -1178,6 +1178,11 @@ func init() { "x-formatting": "weight", "example": 500 }, + "ubWeightRestriction": { + "type": "integer", + "x-nullable": true, + "example": 1200 + }, "unaccompaniedBaggageAllowance": { "description": "The amount of weight in pounds that the move is entitled for shipment types of Unaccompanied Baggage.", "type": "integer", @@ -4151,6 +4156,11 @@ func init() { "x-formatting": "weight", "example": 500 }, + "ubWeightRestriction": { + "type": "integer", + "x-nullable": true, + "example": 1200 + }, "unaccompaniedBaggageAllowance": { "description": "The amount of weight in pounds that the move is entitled for shipment types of Unaccompanied Baggage.", "type": "integer", diff --git a/pkg/gen/supportmessages/entitlement.go b/pkg/gen/supportmessages/entitlement.go index f1fd0f5f8c9..64029c204a2 100644 --- a/pkg/gen/supportmessages/entitlement.go +++ b/pkg/gen/supportmessages/entitlement.go @@ -78,6 +78,10 @@ type Entitlement struct { // Example: 500 TotalWeight int64 `json:"totalWeight,omitempty"` + // ub weight restriction + // Example: 1200 + UbWeightRestriction *int64 `json:"ubWeightRestriction,omitempty"` + // The amount of weight in pounds that the move is entitled for shipment types of Unaccompanied Baggage. // Example: 3 UnaccompaniedBaggageAllowance *int64 `json:"unaccompaniedBaggageAllowance,omitempty"` diff --git a/swagger-def/definitions/prime/Entitlements.yaml b/swagger-def/definitions/prime/Entitlements.yaml index 83a989da2b8..599f118db68 100644 --- a/swagger-def/definitions/prime/Entitlements.yaml +++ b/swagger-def/definitions/prime/Entitlements.yaml @@ -59,6 +59,11 @@ properties: type: integer x-formatting: weight x-nullable: true + ubWeightRestriction: + example: 1200 + type: integer + x-formatting: weight + x-nullable: true eTag: type: string readOnly: true diff --git a/swagger-def/ghc.yaml b/swagger-def/ghc.yaml index faf1e7b44af..85d7b918859 100644 --- a/swagger-def/ghc.yaml +++ b/swagger-def/ghc.yaml @@ -223,15 +223,7 @@ paths: sort: type: string x-nullable: true - enum: - [ - customerName, - edipi, - emplid, - branch, - personalEmail, - telephone, - ] + enum: [customerName, edipi, emplid, branch, personalEmail, telephone] order: type: string x-nullable: true @@ -1106,22 +1098,22 @@ paths: "200": description: Successfully updated the specified MTO shipment. schema: - $ref: 'definitions/MTOShipment.yaml' - '400': - $ref: '#/responses/InvalidRequest' - '401': - $ref: '#/responses/PermissionDenied' - '403': - $ref: '#/responses/PermissionDenied' - '404': - $ref: '#/responses/NotFound' - '412': - $ref: '#/responses/PreconditionFailed' - '422': - $ref: '#/responses/UnprocessableEntity' - '500': - $ref: '#/responses/ServerError' - '/shipments/approve': + $ref: "definitions/MTOShipment.yaml" + "400": + $ref: "#/responses/InvalidRequest" + "401": + $ref: "#/responses/PermissionDenied" + "403": + $ref: "#/responses/PermissionDenied" + "404": + $ref: "#/responses/NotFound" + "412": + $ref: "#/responses/PreconditionFailed" + "422": + $ref: "#/responses/UnprocessableEntity" + "500": + $ref: "#/responses/ServerError" + "/shipments/approve": post: consumes: - application/json @@ -1132,26 +1124,26 @@ paths: name: body required: true schema: - $ref: '#/definitions/ApproveShipments' + $ref: "#/definitions/ApproveShipments" responses: - '200': + "200": description: Successfully approved the shipments schema: type: array items: - $ref: 'definitions/MTOShipment.yaml' - '403': - $ref: '#/responses/PermissionDenied' - '404': - $ref: '#/responses/NotFound' - '409': - $ref: '#/responses/Conflict' - '412': - $ref: '#/responses/PreconditionFailed' - '422': - $ref: '#/responses/UnprocessableEntity' - '500': - $ref: '#/responses/ServerError' + $ref: "definitions/MTOShipment.yaml" + "403": + $ref: "#/responses/PermissionDenied" + "404": + $ref: "#/responses/NotFound" + "409": + $ref: "#/responses/Conflict" + "412": + $ref: "#/responses/PreconditionFailed" + "422": + $ref: "#/responses/UnprocessableEntity" + "500": + $ref: "#/responses/ServerError" tags: - shipment description: Approves multiple shipments in one request @@ -1159,7 +1151,7 @@ paths: summary: Approves multiple shipments at once x-permissions: - update.shipment - '/shipments/{shipmentID}/approve': + "/shipments/{shipmentID}/approve": parameters: - description: ID of the shipment in: path @@ -1792,8 +1784,8 @@ paths: $ref: "#/responses/UnprocessableEntity" "500": $ref: "#/responses/ServerError" - ? /ppm-shipments/{ppmShipmentId}/pro-gear-weight-tickets/{proGearWeightTicketId} - : parameters: + /ppm-shipments/{ppmShipmentId}/pro-gear-weight-tickets/{proGearWeightTicketId}: + parameters: - $ref: "parameters/ppmShipmentId.yaml" - $ref: "parameters/proGearWeightTicketId.yaml" patch: @@ -2358,8 +2350,8 @@ paths: description: Changes move (move task order) status to service counseling completed operationId: updateMTOStatusServiceCounselingCompleted summary: Changes move (move task order) status to service counseling completed - ? "/move-task-orders/{moveTaskOrderID}/payment-service-items/{paymentServiceItemID}/status" - : parameters: + "/move-task-orders/{moveTaskOrderID}/payment-service-items/{paymentServiceItemID}/status": + parameters: - description: ID of move to use in: path name: moveTaskOrderID @@ -3587,13 +3579,13 @@ paths: "200": description: Successfully returned bulk assignment data schema: - $ref: '#/definitions/BulkAssignmentData' - '401': - $ref: '#/responses/PermissionDenied' - '404': - $ref: '#/responses/NotFound' - '500': - $ref: '#/responses/ServerError' + $ref: "#/definitions/BulkAssignmentData" + "401": + $ref: "#/responses/PermissionDenied" + "404": + $ref: "#/responses/NotFound" + "500": + $ref: "#/responses/ServerError" /queues/counseling/origin-list: get: produces: @@ -3784,11 +3776,11 @@ paths: "200": description: Successfully returned all moves matching the criteria schema: - $ref: '#/definitions/QueueMovesResult' - '403': - $ref: '#/responses/PermissionDenied' - '500': - $ref: '#/responses/ServerError' + $ref: "#/definitions/QueueMovesResult" + "403": + $ref: "#/responses/PermissionDenied" + "500": + $ref: "#/responses/ServerError" /queues/destination-requests: get: produces: @@ -3886,14 +3878,14 @@ paths: type: string description: filters using a counselingOffice name of the move responses: - '200': + "200": description: Successfully returned all moves matching the criteria schema: - $ref: '#/definitions/QueueMovesResult' - '403': - $ref: '#/responses/PermissionDenied' - '500': - $ref: '#/responses/ServerError' + $ref: "#/definitions/QueueMovesResult" + "403": + $ref: "#/responses/PermissionDenied" + "500": + $ref: "#/responses/ServerError" /queues/payment-requests: get: produces: @@ -5236,6 +5228,11 @@ definitions: example: 1500 x-formatting: weight x-nullable: true + ubWeightRestriction: + example: 1500 + type: integer + x-nullable: true + description: Indicates the UB weight restriction for the move to a particular location. nonTemporaryStorage: example: false type: boolean @@ -5450,7 +5447,7 @@ definitions: description: The transportation office that will handle reviewing PPM Closeout documentation for Army and Air Force service members x-nullable: true counselingOffice: - $ref: 'definitions/TransportationOffice.yaml' + $ref: "definitions/TransportationOffice.yaml" counselingOfficeId: type: string format: uuid @@ -5981,7 +5978,7 @@ definitions: example: "N002214CSW32Y9" $ref: definitions/NullableString.yaml grade: - $ref: '#/definitions/Grade' + $ref: "#/definitions/Grade" hasDependents: type: boolean title: Are dependents included in your orders? @@ -6128,6 +6125,11 @@ definitions: type: integer x-nullable: true description: Indicates the weight restriction for the move to a particular location. + ubWeightRestriction: + example: 1500 + type: integer + x-nullable: true + description: Indicates the UB weight restriction for the move to a particular location. UpdateBillableWeightPayload: type: object properties: @@ -6225,6 +6227,11 @@ definitions: type: integer x-nullable: true description: Indicates the weight restriction for a move to a particular location. + ubWeightRestriction: + example: 1500 + type: integer + x-nullable: true + description: Indicates the UB weight restriction for the move to a particular location. MoveTaskOrder: description: The Move (MoveTaskOrder) properties: @@ -7469,10 +7476,10 @@ definitions: format: uuid type: string destinationGBLOC: - example: 'AGFM' + example: "AGFM" type: string destinationPostalCode: - example: '90210' + example: "90210" type: string referenceId: example: 1001-3456 @@ -8040,7 +8047,7 @@ definitions: CounselingOffices: type: array items: - $ref: '#/definitions/CounselingOffice' + $ref: "#/definitions/CounselingOffice" CounselingOffice: type: object properties: diff --git a/swagger-def/support.yaml b/swagger-def/support.yaml index f24368d5d6f..d500be363ae 100644 --- a/swagger-def/support.yaml +++ b/swagger-def/support.yaml @@ -882,6 +882,10 @@ definitions: example: 1500 type: integer x-nullable: true + ubWeightRestriction: + example: 1200 + type: integer + x-nullable: true nonTemporaryStorage: example: false type: boolean diff --git a/swagger/ghc.yaml b/swagger/ghc.yaml index e6b1d27b36e..0bbd72a7d53 100644 --- a/swagger/ghc.yaml +++ b/swagger/ghc.yaml @@ -5450,6 +5450,13 @@ definitions: example: 1500 x-formatting: weight x-nullable: true + ubWeightRestriction: + example: 1500 + type: integer + x-nullable: true + description: >- + Indicates the UB weight restriction for the move to a particular + location. nonTemporaryStorage: example: false type: boolean @@ -6402,6 +6409,13 @@ definitions: description: >- Indicates the weight restriction for the move to a particular location. + ubWeightRestriction: + example: 1500 + type: integer + x-nullable: true + description: >- + Indicates the UB weight restriction for the move to a particular + location. UpdateBillableWeightPayload: type: object properties: @@ -6510,6 +6524,13 @@ definitions: type: integer x-nullable: true description: Indicates the weight restriction for a move to a particular location. + ubWeightRestriction: + example: 1500 + type: integer + x-nullable: true + description: >- + Indicates the UB weight restriction for the move to a particular + location. MoveTaskOrder: description: The Move (MoveTaskOrder) properties: diff --git a/swagger/prime.yaml b/swagger/prime.yaml index 4d38e4b662f..862a5ba08ad 100644 --- a/swagger/prime.yaml +++ b/swagger/prime.yaml @@ -3548,6 +3548,11 @@ definitions: type: integer x-formatting: weight x-nullable: true + ubWeightRestriction: + example: 1200 + type: integer + x-formatting: weight + x-nullable: true eTag: type: string readOnly: true diff --git a/swagger/prime_v2.yaml b/swagger/prime_v2.yaml index da357c863cd..89e21a63cb0 100644 --- a/swagger/prime_v2.yaml +++ b/swagger/prime_v2.yaml @@ -1825,6 +1825,11 @@ definitions: type: integer x-formatting: weight x-nullable: true + ubWeightRestriction: + example: 1200 + type: integer + x-formatting: weight + x-nullable: true eTag: type: string readOnly: true diff --git a/swagger/prime_v3.yaml b/swagger/prime_v3.yaml index 181d35913bc..c85b82d982f 100644 --- a/swagger/prime_v3.yaml +++ b/swagger/prime_v3.yaml @@ -1932,6 +1932,11 @@ definitions: type: integer x-formatting: weight x-nullable: true + ubWeightRestriction: + example: 1200 + type: integer + x-formatting: weight + x-nullable: true eTag: type: string readOnly: true diff --git a/swagger/support.yaml b/swagger/support.yaml index 409eb6dd21c..a789fdbbf32 100644 --- a/swagger/support.yaml +++ b/swagger/support.yaml @@ -957,6 +957,10 @@ definitions: example: 1500 type: integer x-nullable: true + ubWeightRestriction: + example: 1200 + type: integer + x-nullable: true nonTemporaryStorage: example: false type: boolean From 8e32f20b65f9663634466a14510ecf34a369ed85 Mon Sep 17 00:00:00 2001 From: Maria Traskowsky Date: Fri, 21 Feb 2025 18:52:50 +0000 Subject: [PATCH 38/71] add ub_weight_restriction col to entitlements table --- .../ddl_tables/tbl_alter_entitlements_B-22651.up.sql | 3 +++ migrations/app/ddl_tables_manifest.txt | 1 + 2 files changed, 4 insertions(+) create mode 100644 migrations/app/ddl_migrations/ddl_tables/tbl_alter_entitlements_B-22651.up.sql diff --git a/migrations/app/ddl_migrations/ddl_tables/tbl_alter_entitlements_B-22651.up.sql b/migrations/app/ddl_migrations/ddl_tables/tbl_alter_entitlements_B-22651.up.sql new file mode 100644 index 00000000000..4fa5a3a98a4 --- /dev/null +++ b/migrations/app/ddl_migrations/ddl_tables/tbl_alter_entitlements_B-22651.up.sql @@ -0,0 +1,3 @@ +--B-22651 Maria Traskowsky Add ub_weight_restriction column to entitlements table +ALTER TABLE entitlements +ADD COLUMN IF NOT EXISTS ub_weight_restriction int; \ No newline at end of file diff --git a/migrations/app/ddl_tables_manifest.txt b/migrations/app/ddl_tables_manifest.txt index 8fd6841c337..676b8be9dce 100644 --- a/migrations/app/ddl_tables_manifest.txt +++ b/migrations/app/ddl_tables_manifest.txt @@ -1,3 +1,4 @@ # This is the tables migrations manifest. # If a migration is not recorded here, then it will error. # Naming convention: tbl_some_table.up.sql running will create this file. +tbl_alter_entitlements_B-22651.up.sql From 299a5c4d99d57620391b1377103b9d2da838f959 Mon Sep 17 00:00:00 2001 From: Maria Traskowsky Date: Fri, 21 Feb 2025 19:32:37 +0000 Subject: [PATCH 39/71] Revert "add ub_weight_restriction col to entitlements table" This reverts commit 8e32f20b65f9663634466a14510ecf34a369ed85. --- .../ddl_tables/tbl_alter_entitlements_B-22651.up.sql | 3 --- migrations/app/ddl_tables_manifest.txt | 1 - 2 files changed, 4 deletions(-) delete mode 100644 migrations/app/ddl_migrations/ddl_tables/tbl_alter_entitlements_B-22651.up.sql diff --git a/migrations/app/ddl_migrations/ddl_tables/tbl_alter_entitlements_B-22651.up.sql b/migrations/app/ddl_migrations/ddl_tables/tbl_alter_entitlements_B-22651.up.sql deleted file mode 100644 index 4fa5a3a98a4..00000000000 --- a/migrations/app/ddl_migrations/ddl_tables/tbl_alter_entitlements_B-22651.up.sql +++ /dev/null @@ -1,3 +0,0 @@ ---B-22651 Maria Traskowsky Add ub_weight_restriction column to entitlements table -ALTER TABLE entitlements -ADD COLUMN IF NOT EXISTS ub_weight_restriction int; \ No newline at end of file diff --git a/migrations/app/ddl_tables_manifest.txt b/migrations/app/ddl_tables_manifest.txt index 676b8be9dce..8fd6841c337 100644 --- a/migrations/app/ddl_tables_manifest.txt +++ b/migrations/app/ddl_tables_manifest.txt @@ -1,4 +1,3 @@ # This is the tables migrations manifest. # If a migration is not recorded here, then it will error. # Naming convention: tbl_some_table.up.sql running will create this file. -tbl_alter_entitlements_B-22651.up.sql From f194454cbdd82d827402fc98e789d9faf73e5ad7 Mon Sep 17 00:00:00 2001 From: Maria Traskowsky Date: Fri, 21 Feb 2025 20:04:49 +0000 Subject: [PATCH 40/71] with dres magic fix - add ub_weight_restriction col to entitlements table --- .../20250221195354_tbl_alter_entitlements_B-22651.up.sql | 5 +++++ migrations/app/ddl_tables_manifest.txt | 1 + 2 files changed, 6 insertions(+) create mode 100644 migrations/app/ddl_migrations/ddl_tables/20250221195354_tbl_alter_entitlements_B-22651.up.sql diff --git a/migrations/app/ddl_migrations/ddl_tables/20250221195354_tbl_alter_entitlements_B-22651.up.sql b/migrations/app/ddl_migrations/ddl_tables/20250221195354_tbl_alter_entitlements_B-22651.up.sql new file mode 100644 index 00000000000..1ca9d4a3d88 --- /dev/null +++ b/migrations/app/ddl_migrations/ddl_tables/20250221195354_tbl_alter_entitlements_B-22651.up.sql @@ -0,0 +1,5 @@ +--B-22651 Maria Traskowsky Add ub_weight_restriction column to entitlements table +ALTER TABLE entitlements +ADD COLUMN IF NOT EXISTS ub_weight_restriction int; +COMMENT ON COLUMN entitlements.weight_restriction IS 'The weight restriction of the entitlement.'; +COMMENT ON COLUMN entitlements.ub_weight_restriction IS 'The UB weight restriction of the entitlement.'; diff --git a/migrations/app/ddl_tables_manifest.txt b/migrations/app/ddl_tables_manifest.txt index 8fd6841c337..305e0c4576f 100644 --- a/migrations/app/ddl_tables_manifest.txt +++ b/migrations/app/ddl_tables_manifest.txt @@ -1,3 +1,4 @@ # This is the tables migrations manifest. # If a migration is not recorded here, then it will error. # Naming convention: tbl_some_table.up.sql running will create this file. +20250221195354_tbl_alter_entitlements_B-22651.up.sql From 7c56a96fd9fd7282d3ffb2b558f89322054a3e28 Mon Sep 17 00:00:00 2001 From: Maria Traskowsky Date: Fri, 21 Feb 2025 20:25:48 +0000 Subject: [PATCH 41/71] model_to_payload updates and tests --- .../ghcapi/internal/payloads/model_to_payload.go | 11 ++++++++--- .../internal/payloads/model_to_payload_test.go | 3 +++ pkg/handlers/ghcapi/orders.go | 2 ++ .../primeapi/payloads/model_to_payload.go | 15 ++++++++++----- .../primeapi/payloads/model_to_payload_test.go | 2 ++ .../primeapiv2/payloads/model_to_payload.go | 15 ++++++++++----- .../primeapiv2/payloads/model_to_payload_test.go | 2 ++ .../primeapiv3/payloads/model_to_payload.go | 15 ++++++++++----- .../primeapiv3/payloads/model_to_payload_test.go | 2 ++ pkg/models/ghc_entitlements.go | 1 + 10 files changed, 50 insertions(+), 18 deletions(-) diff --git a/pkg/handlers/ghcapi/internal/payloads/model_to_payload.go b/pkg/handlers/ghcapi/internal/payloads/model_to_payload.go index 7e9e05e90fe..d60e4349ba3 100644 --- a/pkg/handlers/ghcapi/internal/payloads/model_to_payload.go +++ b/pkg/handlers/ghcapi/internal/payloads/model_to_payload.go @@ -751,6 +751,10 @@ func Entitlement(entitlement *models.Entitlement) *ghcmessages.Entitlements { if entitlement.WeightRestriction != nil { weightRestriction = models.Int64Pointer(int64(*entitlement.WeightRestriction)) } + var ubWeightRestriction *int64 + if entitlement.UBWeightRestriction != nil { + ubWeightRestriction = models.Int64Pointer(int64(*entitlement.UBWeightRestriction)) + } return &ghcmessages.Entitlements{ ID: strfmt.UUID(entitlement.ID.String()), @@ -769,9 +773,10 @@ func Entitlement(entitlement *models.Entitlement) *ghcmessages.Entitlements { AccompaniedTour: accompaniedTour, UnaccompaniedBaggageAllowance: ubAllowance, OrganizationalClothingAndIndividualEquipment: entitlement.OrganizationalClothingAndIndividualEquipment, - GunSafe: gunSafe, - WeightRestriction: weightRestriction, - ETag: etag.GenerateEtag(entitlement.UpdatedAt), + GunSafe: gunSafe, + WeightRestriction: weightRestriction, + UbWeightRestriction: ubWeightRestriction, + ETag: etag.GenerateEtag(entitlement.UpdatedAt), } } diff --git a/pkg/handlers/ghcapi/internal/payloads/model_to_payload_test.go b/pkg/handlers/ghcapi/internal/payloads/model_to_payload_test.go index 5ffd6055a9c..9210cc3a5a5 100644 --- a/pkg/handlers/ghcapi/internal/payloads/model_to_payload_test.go +++ b/pkg/handlers/ghcapi/internal/payloads/model_to_payload_test.go @@ -669,6 +669,7 @@ func (suite *PayloadsSuite) TestEntitlement() { authorizedWeight := 8000 ubAllowance := 300 weightRestriction := 1000 + ubWeightRestriction := 1200 entitlement := &models.Entitlement{ ID: entitlementID, @@ -687,6 +688,7 @@ func (suite *PayloadsSuite) TestEntitlement() { UpdatedAt: time.Now(), UBAllowance: &ubAllowance, WeightRestriction: &weightRestriction, + UBWeightRestriction: &ubWeightRestriction, } returnedEntitlement := Entitlement(entitlement) @@ -709,6 +711,7 @@ func (suite *PayloadsSuite) TestEntitlement() { suite.Equal(dependentsUnderTwelve, int(*returnedEntitlement.DependentsUnderTwelve)) suite.Equal(dependentsTwelveAndOver, int(*returnedEntitlement.DependentsTwelveAndOver)) suite.Equal(weightRestriction, int(*returnedEntitlement.WeightRestriction)) + suite.Equal(ubWeightRestriction, int(*returnedEntitlement.UbWeightRestriction)) } func (suite *PayloadsSuite) TestCreateCustomer() { diff --git a/pkg/handlers/ghcapi/orders.go b/pkg/handlers/ghcapi/orders.go index 8a8ca3cafcf..be86f6ffd5f 100644 --- a/pkg/handlers/ghcapi/orders.go +++ b/pkg/handlers/ghcapi/orders.go @@ -291,6 +291,7 @@ func (h CreateOrderHandler) Handle(params orderop.CreateOrderParams) middleware. } var weightRestriction *int + var ubWeightRestriction *int entitlement := models.Entitlement{ DependentsAuthorized: payload.HasDependents, @@ -303,6 +304,7 @@ func (h CreateOrderHandler) Handle(params orderop.CreateOrderParams) middleware. DependentsTwelveAndOver: dependentsTwelveAndOver, UBAllowance: &weightAllotment.UnaccompaniedBaggageAllowance, WeightRestriction: weightRestriction, + UBWeightRestriction: ubWeightRestriction, } if saveEntitlementErr := appCtx.DB().Save(&entitlement); saveEntitlementErr != nil { diff --git a/pkg/handlers/primeapi/payloads/model_to_payload.go b/pkg/handlers/primeapi/payloads/model_to_payload.go index 5a675099271..a05577e7372 100644 --- a/pkg/handlers/primeapi/payloads/model_to_payload.go +++ b/pkg/handlers/primeapi/payloads/model_to_payload.go @@ -266,6 +266,10 @@ func Entitlement(entitlement *models.Entitlement) *primemessages.Entitlements { if entitlement.WeightRestriction != nil { weightRestriction = int64(*entitlement.WeightRestriction) } + var ubWeightRestriction int64 + if entitlement.UBWeightRestriction != nil { + ubWeightRestriction = int64(*entitlement.UBWeightRestriction) + } return &primemessages.Entitlements{ ID: strfmt.UUID(entitlement.ID.String()), AuthorizedWeight: authorizedWeight, @@ -278,11 +282,12 @@ func Entitlement(entitlement *models.Entitlement) *primemessages.Entitlements { ProGearWeightSpouse: int64(entitlement.ProGearWeightSpouse), RequiredMedicalEquipmentWeight: int64(entitlement.RequiredMedicalEquipmentWeight), OrganizationalClothingAndIndividualEquipment: entitlement.OrganizationalClothingAndIndividualEquipment, - StorageInTransit: sit, - TotalDependents: totalDependents, - TotalWeight: totalWeight, - WeightRestriction: &weightRestriction, - ETag: etag.GenerateEtag(entitlement.UpdatedAt), + StorageInTransit: sit, + TotalDependents: totalDependents, + TotalWeight: totalWeight, + WeightRestriction: &weightRestriction, + UbWeightRestriction: &ubWeightRestriction, + ETag: etag.GenerateEtag(entitlement.UpdatedAt), } } diff --git a/pkg/handlers/primeapi/payloads/model_to_payload_test.go b/pkg/handlers/primeapi/payloads/model_to_payload_test.go index e54c61bd5fb..4c99774b7b5 100644 --- a/pkg/handlers/primeapi/payloads/model_to_payload_test.go +++ b/pkg/handlers/primeapi/payloads/model_to_payload_test.go @@ -352,6 +352,7 @@ func (suite *PayloadsSuite) TestEntitlement() { CreatedAt: time.Now(), UpdatedAt: time.Now(), WeightRestriction: models.IntPointer(1000), + UBWeightRestriction: models.IntPointer(1200), } // TotalWeight needs to read from the internal weightAllotment, in this case 7000 lbs w/o dependents and @@ -375,6 +376,7 @@ func (suite *PayloadsSuite) TestEntitlement() { suite.Equal(int64(1000), payload.ProGearWeight) suite.Equal(int64(750), payload.ProGearWeightSpouse) suite.Equal(int64(1000), *payload.WeightRestriction) + suite.Equal(int64(1200), *payload.UbWeightRestriction) suite.NotEmpty(payload.ETag) suite.Equal(etag.GenerateEtag(entitlement.UpdatedAt), payload.ETag) }) diff --git a/pkg/handlers/primeapiv2/payloads/model_to_payload.go b/pkg/handlers/primeapiv2/payloads/model_to_payload.go index 09f107a9e04..cb8e9d88185 100644 --- a/pkg/handlers/primeapiv2/payloads/model_to_payload.go +++ b/pkg/handlers/primeapiv2/payloads/model_to_payload.go @@ -195,6 +195,10 @@ func Entitlement(entitlement *models.Entitlement) *primev2messages.Entitlements if entitlement.WeightRestriction != nil { weightRestriction = int64(*entitlement.WeightRestriction) } + var ubWeightRestriction int64 + if entitlement.UBWeightRestriction != nil { + ubWeightRestriction = int64(*entitlement.UBWeightRestriction) + } return &primev2messages.Entitlements{ ID: strfmt.UUID(entitlement.ID.String()), AuthorizedWeight: authorizedWeight, @@ -207,11 +211,12 @@ func Entitlement(entitlement *models.Entitlement) *primev2messages.Entitlements ProGearWeightSpouse: int64(entitlement.ProGearWeightSpouse), RequiredMedicalEquipmentWeight: int64(entitlement.RequiredMedicalEquipmentWeight), OrganizationalClothingAndIndividualEquipment: entitlement.OrganizationalClothingAndIndividualEquipment, - StorageInTransit: sit, - TotalDependents: totalDependents, - TotalWeight: totalWeight, - WeightRestriction: &weightRestriction, - ETag: etag.GenerateEtag(entitlement.UpdatedAt), + StorageInTransit: sit, + TotalDependents: totalDependents, + TotalWeight: totalWeight, + WeightRestriction: &weightRestriction, + UbWeightRestriction: &ubWeightRestriction, + ETag: etag.GenerateEtag(entitlement.UpdatedAt), } } diff --git a/pkg/handlers/primeapiv2/payloads/model_to_payload_test.go b/pkg/handlers/primeapiv2/payloads/model_to_payload_test.go index 2119ecd1a8e..8f7ed8dfd44 100644 --- a/pkg/handlers/primeapiv2/payloads/model_to_payload_test.go +++ b/pkg/handlers/primeapiv2/payloads/model_to_payload_test.go @@ -304,6 +304,7 @@ func (suite *PayloadsSuite) TestEntitlement() { CreatedAt: time.Now(), UpdatedAt: time.Now(), WeightRestriction: models.IntPointer(1000), + UBWeightRestriction: models.IntPointer(1200), } payload := Entitlement(&entitlement) @@ -327,6 +328,7 @@ func (suite *PayloadsSuite) TestEntitlement() { suite.Equal(int64(0), payload.TotalWeight) suite.Equal(int64(0), *payload.UnaccompaniedBaggageAllowance) suite.Equal(int64(1000), *payload.WeightRestriction) + suite.Equal(int64(1200), *payload.UbWeightRestriction) }) suite.Run("Success - Returns the entitlement payload with all optional fields populated", func() { diff --git a/pkg/handlers/primeapiv3/payloads/model_to_payload.go b/pkg/handlers/primeapiv3/payloads/model_to_payload.go index aba7a9c1718..39d2adc8952 100644 --- a/pkg/handlers/primeapiv3/payloads/model_to_payload.go +++ b/pkg/handlers/primeapiv3/payloads/model_to_payload.go @@ -223,6 +223,10 @@ func Entitlement(entitlement *models.Entitlement) *primev3messages.Entitlements if entitlement.WeightRestriction != nil { weightRestriction = int64(*entitlement.WeightRestriction) } + var ubWeightRestriction int64 + if entitlement.UBWeightRestriction != nil { + ubWeightRestriction = int64(*entitlement.UBWeightRestriction) + } return &primev3messages.Entitlements{ ID: strfmt.UUID(entitlement.ID.String()), AuthorizedWeight: authorizedWeight, @@ -234,11 +238,12 @@ func Entitlement(entitlement *models.Entitlement) *primev3messages.Entitlements ProGearWeightSpouse: int64(entitlement.ProGearWeightSpouse), RequiredMedicalEquipmentWeight: int64(entitlement.RequiredMedicalEquipmentWeight), OrganizationalClothingAndIndividualEquipment: entitlement.OrganizationalClothingAndIndividualEquipment, - StorageInTransit: sit, - TotalDependents: totalDependents, - TotalWeight: totalWeight, - WeightRestriction: &weightRestriction, - ETag: etag.GenerateEtag(entitlement.UpdatedAt), + StorageInTransit: sit, + TotalDependents: totalDependents, + TotalWeight: totalWeight, + WeightRestriction: &weightRestriction, + UbWeightRestriction: &ubWeightRestriction, + ETag: etag.GenerateEtag(entitlement.UpdatedAt), } } diff --git a/pkg/handlers/primeapiv3/payloads/model_to_payload_test.go b/pkg/handlers/primeapiv3/payloads/model_to_payload_test.go index f0f7036eac6..e3198160e17 100644 --- a/pkg/handlers/primeapiv3/payloads/model_to_payload_test.go +++ b/pkg/handlers/primeapiv3/payloads/model_to_payload_test.go @@ -546,6 +546,7 @@ func (suite *PayloadsSuite) TestEntitlement() { CreatedAt: time.Now(), UpdatedAt: time.Now(), WeightRestriction: models.IntPointer(1000), + UBWeightRestriction: models.IntPointer(1200), } payload := Entitlement(&entitlement) @@ -569,6 +570,7 @@ func (suite *PayloadsSuite) TestEntitlement() { suite.Equal(int64(0), payload.TotalWeight) suite.Equal(int64(0), *payload.UnaccompaniedBaggageAllowance) suite.Equal(int64(1000), *payload.WeightRestriction) + suite.Equal(int64(1200), *payload.UbWeightRestriction) }) suite.Run("Success - Returns the entitlement payload with all optional fields populated", func() { diff --git a/pkg/models/ghc_entitlements.go b/pkg/models/ghc_entitlements.go index f56c915ad19..c9036767722 100644 --- a/pkg/models/ghc_entitlements.go +++ b/pkg/models/ghc_entitlements.go @@ -35,6 +35,7 @@ type Entitlement struct { ProGearWeight int `db:"pro_gear_weight"` ProGearWeightSpouse int `db:"pro_gear_weight_spouse"` WeightRestriction *int `db:"weight_restriction"` + UBWeightRestriction *int `db:"ub_weight_restriction"` CreatedAt time.Time `db:"created_at"` UpdatedAt time.Time `db:"updated_at"` } From f368c3df7cb796ae98589973651091c1bbe9d183 Mon Sep 17 00:00:00 2001 From: Maria Traskowsky Date: Fri, 21 Feb 2025 22:06:10 +0000 Subject: [PATCH 42/71] order updater --- pkg/services/order/order_updater.go | 14 ++++++ pkg/services/order/order_updater_test.go | 56 ++++++++++++++++++++++++ 2 files changed, 70 insertions(+) diff --git a/pkg/services/order/order_updater.go b/pkg/services/order/order_updater.go index 492c43acabe..8c1c0fcab72 100644 --- a/pkg/services/order/order_updater.go +++ b/pkg/services/order/order_updater.go @@ -492,6 +492,13 @@ func allowanceFromTOOPayload(appCtx appcontext.AppContext, existingOrder models. order.Entitlement.WeightRestriction = nil } + if payload.UbWeightRestriction != nil { + ubWeightRestriction := int(*payload.UbWeightRestriction) + order.Entitlement.UBWeightRestriction = &ubWeightRestriction + } else { + order.Entitlement.UBWeightRestriction = nil + } + if payload.AccompaniedTour != nil { order.Entitlement.AccompaniedTour = payload.AccompaniedTour } @@ -602,6 +609,13 @@ func allowanceFromCounselingPayload(appCtx appcontext.AppContext, existingOrder order.Entitlement.WeightRestriction = nil } + if payload.UbWeightRestriction != nil { + ubWeightRestriction := int(*payload.UbWeightRestriction) + order.Entitlement.UBWeightRestriction = &ubWeightRestriction + } else { + order.Entitlement.UBWeightRestriction = nil + } + if payload.AccompaniedTour != nil { order.Entitlement.AccompaniedTour = payload.AccompaniedTour } diff --git a/pkg/services/order/order_updater_test.go b/pkg/services/order/order_updater_test.go index b88d9ab435a..af32f493510 100644 --- a/pkg/services/order/order_updater_test.go +++ b/pkg/services/order/order_updater_test.go @@ -677,6 +677,32 @@ func (suite *OrderServiceSuite) TestUpdateAllowanceAsTOO() { suite.Nil(updatedOrder.Entitlement.WeightRestriction) }) + suite.Run("Updates the UB allowance when ubWeightRestriction is null", func() { + moveRouter := move.NewMoveRouter() + orderUpdater := NewOrderUpdater(moveRouter) + order := factory.BuildNeedsServiceCounselingMove(suite.DB(), []factory.Customization{ + { + Model: models.Entitlement{ + UBWeightRestriction: models.IntPointer(1200), + }, + }, + }, nil).Orders + + eTag := etag.GenerateEtag(order.UpdatedAt) + + payload := ghcmessages.UpdateAllowancePayload{ + UbWeightRestriction: nil, + } + + updatedOrder, _, err := orderUpdater.UpdateAllowanceAsTOO(suite.AppContextForTest(), order.ID, payload, eTag) + suite.NoError(err) + + var orderInDB models.Order + err = suite.DB().Find(&orderInDB, order.ID) + suite.NoError(err) + suite.Nil(updatedOrder.Entitlement.UBWeightRestriction) + }) + suite.Run("Updates the allowance when all fields are valid with dependents", func() { moveRouter := move.NewMoveRouter() orderUpdater := NewOrderUpdater(moveRouter) @@ -774,6 +800,7 @@ func (suite *OrderServiceSuite) TestUpdateAllowanceAsCounselor() { DependentsTwelveAndOver: models.Int64Pointer(1), DependentsUnderTwelve: models.Int64Pointer(2), WeightRestriction: models.Int64Pointer(0), + UbWeightRestriction: models.Int64Pointer(0), } updatedOrder, _, err := orderUpdater.UpdateAllowanceAsCounselor(suite.AppContextForTest(), order.ID, payload, eTag) @@ -803,6 +830,7 @@ func (suite *OrderServiceSuite) TestUpdateAllowanceAsCounselor() { rmeWeight := models.Int64Pointer(10000) eTag := etag.GenerateEtag(order.UpdatedAt) weightRestriction := models.Int64Pointer(5000) + ubWeightRestriction := models.Int64Pointer(2000) payload := ghcmessages.CounselingUpdateAllowancePayload{ Agency: &affiliation, @@ -813,6 +841,7 @@ func (suite *OrderServiceSuite) TestUpdateAllowanceAsCounselor() { ProGearWeightSpouse: proGearWeightSpouse, RequiredMedicalEquipmentWeight: rmeWeight, WeightRestriction: weightRestriction, + UbWeightRestriction: ubWeightRestriction, } updatedOrder, _, err := orderUpdater.UpdateAllowanceAsCounselor(suite.AppContextForTest(), order.ID, payload, eTag) @@ -834,6 +863,7 @@ func (suite *OrderServiceSuite) TestUpdateAllowanceAsCounselor() { suite.EqualValues(payload.Agency, fetchedSM.Affiliation) suite.Equal(*updatedOrder.Entitlement.DBAuthorizedWeight, 16000) suite.Equal(*payload.WeightRestriction, int64(*updatedOrder.Entitlement.WeightRestriction)) + suite.Equal(*payload.UbWeightRestriction, int64(*updatedOrder.Entitlement.UBWeightRestriction)) }) suite.Run("Updates the allowance when weightRestriction is null", func() { @@ -862,6 +892,32 @@ func (suite *OrderServiceSuite) TestUpdateAllowanceAsCounselor() { suite.Nil(updatedOrder.Entitlement.WeightRestriction) }) + suite.Run("Updates the UB allowance when ubWeightRestriction is null", func() { + moveRouter := move.NewMoveRouter() + orderUpdater := NewOrderUpdater(moveRouter) + order := factory.BuildNeedsServiceCounselingMove(suite.DB(), []factory.Customization{ + { + Model: models.Entitlement{ + UBWeightRestriction: models.IntPointer(1200), + }, + }, + }, nil).Orders + + eTag := etag.GenerateEtag(order.UpdatedAt) + + payload := ghcmessages.CounselingUpdateAllowancePayload{ + UbWeightRestriction: nil, + } + + updatedOrder, _, err := orderUpdater.UpdateAllowanceAsCounselor(suite.AppContextForTest(), order.ID, payload, eTag) + suite.NoError(err) + + var orderInDB models.Order + err = suite.DB().Find(&orderInDB, order.ID) + suite.NoError(err) + suite.Nil(updatedOrder.Entitlement.UBWeightRestriction) + }) + suite.Run("Updates the allowance when all fields are valid with dependents present and authorized", func() { moveRouter := move.NewMoveRouter() orderUpdater := NewOrderUpdater(moveRouter) From 79ab0f49fdb0b30b09aa557075f545140b0fb0c7 Mon Sep 17 00:00:00 2001 From: Maria Traskowsky Date: Mon, 24 Feb 2025 18:39:44 +0000 Subject: [PATCH 43/71] ui updates --- .../AllowancesDetailForm.jsx | 47 +++++++++++++++++++ .../AllowancesDetailForm.test.jsx | 33 +++++++++++++ .../Office/DefinitionLists/AllowancesList.jsx | 11 +++++ .../DefinitionLists/AllowancesList.test.jsx | 6 +++ .../MoveHistory/Database/BooleanFields.js | 1 + .../MoveHistory/Database/FieldMappings.js | 2 + .../Office/MoveAllowances/MoveAllowances.jsx | 18 +++++++ src/pages/Office/MoveDetails/MoveDetails.jsx | 1 + .../ServicesCounselingMoveAllowances.jsx | 18 +++++++ .../ServicesCounselingMoveAllowances.test.jsx | 24 ++++++++++ .../ServicesCounselingMoveDetails.jsx | 1 + 11 files changed, 162 insertions(+) diff --git a/src/components/Office/AllowancesDetailForm/AllowancesDetailForm.jsx b/src/components/Office/AllowancesDetailForm/AllowancesDetailForm.jsx index cfbcd359779..3bd62b2ac71 100644 --- a/src/components/Office/AllowancesDetailForm/AllowancesDetailForm.jsx +++ b/src/components/Office/AllowancesDetailForm/AllowancesDetailForm.jsx @@ -23,6 +23,9 @@ const AllowancesDetailForm = ({ header, entitlements, branchOptions, formIsDisab ); const { values, setFieldValue } = useFormikContext(); const [isAdminWeightLocationChecked, setIsAdminWeightLocationChecked] = useState(entitlements?.weightRestriction > 0); + const [isAdminUBWeightLocationChecked, setIsAdminUBWeightLocationChecked] = useState( + entitlements?.ubWeightRestriction > 0, + ); useEffect(() => { // Functional component version of "componentDidMount" // By leaving the dependency array empty this will only run once @@ -41,6 +44,12 @@ const AllowancesDetailForm = ({ header, entitlements, branchOptions, formIsDisab } }, [setFieldValue, values.weightRestriction, isAdminWeightLocationChecked]); + useEffect(() => { + if (!isAdminUBWeightLocationChecked) { + setFieldValue('ubWeightRestriction', `${values.ubWeightRestriction}`); + } + }, [setFieldValue, values.ubWeightRestriction, isAdminUBWeightLocationChecked]); + const handleAdminWeightLocationChange = (e) => { const isChecked = e.target.checked; setIsAdminWeightLocationChecked(isChecked); @@ -54,6 +63,19 @@ const AllowancesDetailForm = ({ header, entitlements, branchOptions, formIsDisab } }; + const handleAdminUBWeightLocationChange = (e) => { + const isChecked = e.target.checked; + setIsAdminUBWeightLocationChecked(isChecked); + + if (!isChecked) { + setFieldValue('ubWeightRestriction', `${values.ubWeightRestriction}`); + } else if (isChecked && values.ubWeightRestriction) { + setFieldValue('ubWeightRestriction', `${values.ubWeightRestriction}`); + } else { + setFieldValue('ubWeightRestriction', null); + } + }; + return (
{header &&

{header}

} @@ -215,6 +237,31 @@ const AllowancesDetailForm = ({ header, entitlements, branchOptions, formIsDisab isDisabled={formIsDisabled} /> )} +
+ +
+ {isAdminUBWeightLocationChecked && ( + + )}
{ expect(screen.queryByTestId('weightRestrictionInput')).not.toBeInTheDocument(); }); + it('renders admin UB weight location section with conditional UB weight restriction field', async () => { + render( + + + , + ); + + const adminUBWeightCheckbox = await screen.findByTestId('adminUBWeightLocation'); + expect(adminUBWeightCheckbox).toBeInTheDocument(); + expect(screen.getByLabelText('Admin restricted UB weight location')).toBeChecked(); + + const ubWeightRestrictionInput = screen.getByTestId('ubWeightRestrictionInput'); + expect(ubWeightRestrictionInput).toBeInTheDocument(); + expect(ubWeightRestrictionInput).toHaveValue('400'); + }); + + it('does not render the admin UB weight location section when the ubWeightRestriction entitlement is null', async () => { + render( + + + , + ); + + const adminUBWeightCheckbox = await screen.findByTestId('adminUBWeightLocation'); + expect(adminUBWeightCheckbox).toBeInTheDocument(); + expect(screen.queryByTestId('ubWeightRestrictionInput')).not.toBeInTheDocument(); + }); + it('displays the total weight allowance correctly', async () => { render( diff --git a/src/components/Office/DefinitionLists/AllowancesList.jsx b/src/components/Office/DefinitionLists/AllowancesList.jsx index 7bdd17862ae..72e8bb0c640 100644 --- a/src/components/Office/DefinitionLists/AllowancesList.jsx +++ b/src/components/Office/DefinitionLists/AllowancesList.jsx @@ -114,6 +114,17 @@ const AllowancesList = ({ info, showVisualCues }) => { {info.weightRestriction ? formatWeight(info.weightRestriction) : DEFAULT_EMPTY_VALUE}
+
+
Admin Restricted UB Weight Location
+
{info.ubWeightRestriction > 0 ? 'Yes' : 'No'}
+
+ +
+
UB Weight Restriction
+
+ {info.ubWeightRestriction ? formatWeight(info.ubWeightRestriction) : DEFAULT_EMPTY_VALUE} +
+
); diff --git a/src/components/Office/DefinitionLists/AllowancesList.test.jsx b/src/components/Office/DefinitionLists/AllowancesList.test.jsx index 9eed73f1d62..5f581fe2dbd 100644 --- a/src/components/Office/DefinitionLists/AllowancesList.test.jsx +++ b/src/components/Office/DefinitionLists/AllowancesList.test.jsx @@ -20,6 +20,7 @@ const info = { organizationalClothingAndIndividualEquipment: true, ubAllowance: 400, weightRestriction: 1500, + ubWeightRestriction: 1100, }; const initialValuesOconusAdditions = { @@ -181,4 +182,9 @@ describe('AllowancesList', () => { render(); expect(screen.getByTestId('weightRestriction').textContent).toEqual('1,500 lbs'); }); + it('renders UB weight restriction', () => { + const adminRestrictedUBWtLoc = { ...info, adminrestrictedUBWeightLocation: true }; + render(); + expect(screen.getByTestId('ubWeightRestriction').textContent).toEqual('1,100 lbs'); + }); }); diff --git a/src/constants/MoveHistory/Database/BooleanFields.js b/src/constants/MoveHistory/Database/BooleanFields.js index c14cb67f56c..cedb8ed7540 100644 --- a/src/constants/MoveHistory/Database/BooleanFields.js +++ b/src/constants/MoveHistory/Database/BooleanFields.js @@ -13,6 +13,7 @@ export default { organizational_clothing_and_individual_equipment: 'organizational_clothing_and_individual_equipment', gun_safe: 'gun_safe', admin_restricted_weight_location: 'admin_restricted_weight_location', + admin_restricted_ub_weight_location: 'admin_restricted_ub_weight_location', email_is_preferred: 'email_is_preferred', phone_is_preferred: 'phone_is_preferred', uses_external_vendor: 'uses_external_vendor', diff --git a/src/constants/MoveHistory/Database/FieldMappings.js b/src/constants/MoveHistory/Database/FieldMappings.js index 53724afcd8a..0b1c82ace06 100644 --- a/src/constants/MoveHistory/Database/FieldMappings.js +++ b/src/constants/MoveHistory/Database/FieldMappings.js @@ -40,7 +40,9 @@ export default { organizational_clothing_and_individual_equipment: 'OCIE', gun_safe: 'Gun Safe', admin_restricted_weight_location: 'Admin restricted weight location', + admin_restricted_ub_weight_location: 'Admin restricted UB weight location', weight_restriction: 'Weight restriction', + ub_weight_restriction: 'UB weight restriction', requested_pickup_date: 'Requested pickup date', grade: 'Pay grade', shipment_type: 'Shipment type', diff --git a/src/pages/Office/MoveAllowances/MoveAllowances.jsx b/src/pages/Office/MoveAllowances/MoveAllowances.jsx index 37352825844..076873a1bac 100644 --- a/src/pages/Office/MoveAllowances/MoveAllowances.jsx +++ b/src/pages/Office/MoveAllowances/MoveAllowances.jsx @@ -55,6 +55,18 @@ const validationSchema = Yup.object({ otherwise: (schema) => schema.notRequired().nullable(), }), adminRestrictedWeightLocation: Yup.boolean().notRequired(), + ubWeightRestriction: Yup.number() + .transform((value) => (Number.isNaN(value) ? 0 : value)) + .when('adminRestrictedUBWeightLocation', { + is: true, + then: (schema) => + schema + .min(1, 'UB weight restriction must be greater than 0') + .max(2000, 'UB weight restriction cannot exceed 2,000 lbs') + .required('UB weight restriction is required when Admin Restricted UB Weight Location is enabled'), + otherwise: (schema) => schema.notRequired().nullable(), + }), + adminRestrictedUBWeightLocation: Yup.boolean().notRequired(), }); const MoveAllowances = () => { @@ -112,6 +124,8 @@ const MoveAllowances = () => { gunSafe, adminRestrictedWeightLocation, weightRestriction, + adminRestrictedUBWeightLocation, + ubWeightRestriction, accompaniedTour, dependentsTwelveAndOver, dependentsUnderTwelve, @@ -134,6 +148,7 @@ const MoveAllowances = () => { storageInTransit: Number(storageInTransit), gunSafe, weightRestriction: adminRestrictedWeightLocation && weightRestriction ? Number(weightRestriction) : null, + ubWeightRestriction: adminRestrictedUBWeightLocation && ubWeightRestriction ? Number(ubWeightRestriction) : null, accompaniedTour, dependentsTwelveAndOver: Number(dependentsTwelveAndOver), dependentsUnderTwelve: Number(dependentsUnderTwelve), @@ -151,6 +166,7 @@ const MoveAllowances = () => { organizationalClothingAndIndividualEquipment, gunSafe, weightRestriction, + ubWeightRestriction, storageInTransit, dependentsUnderTwelve, dependentsTwelveAndOver, @@ -168,6 +184,8 @@ const MoveAllowances = () => { gunSafe, adminRestrictedWeightLocation: weightRestriction > 0, weightRestriction: weightRestriction ? `${weightRestriction}` : '0', + adminRestrictedUBWeightLocation: ubWeightRestriction > 0, + ubWeightRestriction: ubWeightRestriction ? `${ubWeightRestriction}` : '0', storageInTransit: `${storageInTransit}`, accompaniedTour, dependentsUnderTwelve: `${dependentsUnderTwelve}`, diff --git a/src/pages/Office/MoveDetails/MoveDetails.jsx b/src/pages/Office/MoveDetails/MoveDetails.jsx index e02fd6ae183..77d0d92ce06 100644 --- a/src/pages/Office/MoveDetails/MoveDetails.jsx +++ b/src/pages/Office/MoveDetails/MoveDetails.jsx @@ -449,6 +449,7 @@ const MoveDetails = ({ organizationalClothingAndIndividualEquipment: allowances.organizationalClothingAndIndividualEquipment, gunSafe: allowances.gunSafe, weightRestriction: allowances.weightRestriction, + ubWeightRestriction: allowances.ubWeightRestriction, dependentsUnderTwelve: allowances.dependentsUnderTwelve, dependentsTwelveAndOver: allowances.dependentsTwelveAndOver, accompaniedTour: allowances.accompaniedTour, diff --git a/src/pages/Office/ServicesCounselingMoveAllowances/ServicesCounselingMoveAllowances.jsx b/src/pages/Office/ServicesCounselingMoveAllowances/ServicesCounselingMoveAllowances.jsx index 97126a514fe..ccbde0edda1 100644 --- a/src/pages/Office/ServicesCounselingMoveAllowances/ServicesCounselingMoveAllowances.jsx +++ b/src/pages/Office/ServicesCounselingMoveAllowances/ServicesCounselingMoveAllowances.jsx @@ -53,6 +53,18 @@ const validationSchema = Yup.object({ otherwise: (schema) => schema.notRequired().nullable(), }), adminRestrictedWeightLocation: Yup.boolean().notRequired(), + ubWeightRestriction: Yup.number() + .transform((value) => (Number.isNaN(value) ? 0 : value)) + .when('adminRestrictedUBWeightLocation', { + is: true, + then: (schema) => + schema + .min(1, 'UB weight restriction must be greater than 0') + .max(2000, 'UB weight restriction cannot exceed 2,000 lbs') + .required('UB weight restriction is required when Admin Restricted UB Weight Location is enabled'), + otherwise: (schema) => schema.notRequired().nullable(), + }), + adminRestrictedUBWeightLocation: Yup.boolean().notRequired(), }); const ServicesCounselingMoveAllowances = () => { const { moveCode } = useParams(); @@ -99,6 +111,8 @@ const ServicesCounselingMoveAllowances = () => { gunSafe, adminRestrictedWeightLocation, weightRestriction, + adminRestrictedUBWeightLocation, + ubWeightRestriction, accompaniedTour, dependentsTwelveAndOver, dependentsUnderTwelve, @@ -120,6 +134,7 @@ const ServicesCounselingMoveAllowances = () => { organizationalClothingAndIndividualEquipment, gunSafe, weightRestriction: adminRestrictedWeightLocation && weightRestriction ? Number(weightRestriction) : null, + ubWeightRestriction: adminRestrictedUBWeightLocation && ubWeightRestriction ? Number(ubWeightRestriction) : null, accompaniedTour, dependentsTwelveAndOver: Number(dependentsTwelveAndOver), dependentsUnderTwelve: Number(dependentsUnderTwelve), @@ -136,6 +151,7 @@ const ServicesCounselingMoveAllowances = () => { organizationalClothingAndIndividualEquipment, gunSafe, weightRestriction, + ubWeightRestriction, storageInTransit, dependentsUnderTwelve, dependentsTwelveAndOver, @@ -153,6 +169,8 @@ const ServicesCounselingMoveAllowances = () => { gunSafe, adminRestrictedWeightLocation: weightRestriction > 0, weightRestriction: weightRestriction ? `${weightRestriction}` : '0', + adminRestrictedUBWeightLocation: ubWeightRestriction > 0, + ubWeightRestriction: ubWeightRestriction ? `${ubWeightRestriction}` : '0', organizationalClothingAndIndividualEquipment, accompaniedTour, dependentsUnderTwelve: `${dependentsUnderTwelve}`, diff --git a/src/pages/Office/ServicesCounselingMoveAllowances/ServicesCounselingMoveAllowances.test.jsx b/src/pages/Office/ServicesCounselingMoveAllowances/ServicesCounselingMoveAllowances.test.jsx index 9cd2e4e742c..7e9b8a8e41b 100644 --- a/src/pages/Office/ServicesCounselingMoveAllowances/ServicesCounselingMoveAllowances.test.jsx +++ b/src/pages/Office/ServicesCounselingMoveAllowances/ServicesCounselingMoveAllowances.test.jsx @@ -69,6 +69,7 @@ const useOrdersDocumentQueriesReturnValue = { totalDependents: 1, totalWeight: 5000, weightRestriction: 500, + ubWeightRestriction: 400, }, first_name: 'Leo', grade: 'E_1', @@ -177,6 +178,7 @@ describe('MoveAllowances page', () => { expect(screen.getByLabelText('OCIE authorized (Army only)')).toBeChecked(); expect(screen.getByTestId('weightAllowance')).toHaveTextContent('5,000 lbs'); + // admin restricted weight location const adminWeightCheckbox = await screen.findByTestId('adminWeightLocation'); expect(adminWeightCheckbox).toBeChecked(); const weightRestrictionInput = screen.getByTestId('weightRestrictionInput'); @@ -198,6 +200,28 @@ describe('MoveAllowances page', () => { screen.getByText(/Weight restriction is required when Admin Restricted Weight Location is enabled/i), ).toBeInTheDocument(); }); + // admin restricted UB weight location + const adminUBWeightCheckbox = await screen.findByTestId('adminUBWeightLocation'); + expect(adminUBWeightCheckbox).toBeChecked(); + const ubWeightRestrictionInput = screen.getByTestId('ubWeightRestrictionInput'); + expect(ubWeightRestrictionInput).toHaveValue('400'); + + await userEvent.click(ubWeightRestrictionInput); + await userEvent.clear(ubWeightRestrictionInput); + await userEvent.type(ubWeightRestrictionInput, '0'); + fireEvent.blur(ubWeightRestrictionInput); + + await waitFor(() => { + expect(screen.getByText(/UB Weight restriction must be greater than 0/i)).toBeInTheDocument(); + }); + + await userEvent.clear(ubWeightRestrictionInput); + + await waitFor(() => { + expect( + screen.getByText(/UB weight restriction is required when Admin Restricted UB Weight Location is enabled/i), + ).toBeInTheDocument(); + }); }); }); }); diff --git a/src/pages/Office/ServicesCounselingMoveDetails/ServicesCounselingMoveDetails.jsx b/src/pages/Office/ServicesCounselingMoveDetails/ServicesCounselingMoveDetails.jsx index decb6c626d3..905cf21e977 100644 --- a/src/pages/Office/ServicesCounselingMoveDetails/ServicesCounselingMoveDetails.jsx +++ b/src/pages/Office/ServicesCounselingMoveDetails/ServicesCounselingMoveDetails.jsx @@ -388,6 +388,7 @@ const ServicesCounselingMoveDetails = ({ organizationalClothingAndIndividualEquipment: allowances.organizationalClothingAndIndividualEquipment, gunSafe: allowances.gunSafe, weightRestriction: allowances.weightRestriction, + ubWeightRestriction: allowances.ubWeightRestriction, dependentsUnderTwelve: allowances.dependentsUnderTwelve, dependentsTwelveAndOver: allowances.dependentsTwelveAndOver, accompaniedTour: allowances.accompaniedTour, From 52c9fdc6d2e0178e0ce4fcea118bce04d6461169 Mon Sep 17 00:00:00 2001 From: Maria Traskowsky Date: Mon, 24 Feb 2025 19:11:09 +0000 Subject: [PATCH 44/71] conditionally show Weight restriction and UB weight restriction --- .../Office/DefinitionLists/AllowancesList.jsx | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/components/Office/DefinitionLists/AllowancesList.jsx b/src/components/Office/DefinitionLists/AllowancesList.jsx index 72e8bb0c640..67ac5e0744a 100644 --- a/src/components/Office/DefinitionLists/AllowancesList.jsx +++ b/src/components/Office/DefinitionLists/AllowancesList.jsx @@ -107,24 +107,26 @@ const AllowancesList = ({ info, showVisualCues }) => {
Admin Weight Restricted Location
{info.weightRestriction > 0 ? 'Yes' : 'No'}
- -
-
Weight Restriction
-
- {info.weightRestriction ? formatWeight(info.weightRestriction) : DEFAULT_EMPTY_VALUE} -
-
+ {info.weightRestriction > 0 && ( +
+
Weight Restriction
+
+ {info.weightRestriction ? formatWeight(info.weightRestriction) : DEFAULT_EMPTY_VALUE} +
+
+ )}
Admin Restricted UB Weight Location
{info.ubWeightRestriction > 0 ? 'Yes' : 'No'}
- -
-
UB Weight Restriction
-
- {info.ubWeightRestriction ? formatWeight(info.ubWeightRestriction) : DEFAULT_EMPTY_VALUE} -
-
+ {info.ubWeightRestriction > 0 && ( +
+
UB Weight Restriction
+
+ {info.ubWeightRestriction ? formatWeight(info.ubWeightRestriction) : DEFAULT_EMPTY_VALUE} +
+
+ )} ); From 90110aca666133cd69b40023c8d2107ee7f4bb16 Mon Sep 17 00:00:00 2001 From: Maria Traskowsky Date: Mon, 24 Feb 2025 19:25:27 +0000 Subject: [PATCH 45/71] update test for move router changes in int --- pkg/services/order/order_updater_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/services/order/order_updater_test.go b/pkg/services/order/order_updater_test.go index af32f493510..cc7fa096be6 100644 --- a/pkg/services/order/order_updater_test.go +++ b/pkg/services/order/order_updater_test.go @@ -678,7 +678,7 @@ func (suite *OrderServiceSuite) TestUpdateAllowanceAsTOO() { }) suite.Run("Updates the UB allowance when ubWeightRestriction is null", func() { - moveRouter := move.NewMoveRouter() + moveRouter := move.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) orderUpdater := NewOrderUpdater(moveRouter) order := factory.BuildNeedsServiceCounselingMove(suite.DB(), []factory.Customization{ { From 8f91a265e47d838f1a5cde67c95a839a809eb1e9 Mon Sep 17 00:00:00 2001 From: Maria Traskowsky Date: Mon, 24 Feb 2025 19:35:25 +0000 Subject: [PATCH 46/71] another update test for move router changes in int --- pkg/services/order/order_updater_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/services/order/order_updater_test.go b/pkg/services/order/order_updater_test.go index cc7fa096be6..d382186a605 100644 --- a/pkg/services/order/order_updater_test.go +++ b/pkg/services/order/order_updater_test.go @@ -893,7 +893,7 @@ func (suite *OrderServiceSuite) TestUpdateAllowanceAsCounselor() { }) suite.Run("Updates the UB allowance when ubWeightRestriction is null", func() { - moveRouter := move.NewMoveRouter() + moveRouter := move.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) orderUpdater := NewOrderUpdater(moveRouter) order := factory.BuildNeedsServiceCounselingMove(suite.DB(), []factory.Customization{ { From ed66caac9608086711deddce0032813967aef845 Mon Sep 17 00:00:00 2001 From: Samay Sofo Date: Mon, 24 Feb 2025 21:01:19 +0000 Subject: [PATCH 47/71] refactore test function name. --- .../transportation_office/transportation_office_fetcher_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/services/transportation_office/transportation_office_fetcher_test.go b/pkg/services/transportation_office/transportation_office_fetcher_test.go index b67188233aa..cea8b1685d4 100644 --- a/pkg/services/transportation_office/transportation_office_fetcher_test.go +++ b/pkg/services/transportation_office/transportation_office_fetcher_test.go @@ -519,7 +519,7 @@ func (suite *TransportationOfficeServiceSuite) Test_FindCounselingOfficeForPrime suite.Equal(offices.Name, "PPPO Jacksonville - USN") } -func (suite *TransportationOfficeServiceSuite) Test_Oconus_AK_FindCounselingOfficesCounseled() { +func (suite *TransportationOfficeServiceSuite) Test_FindCounselingOfficeForPrimeCounseledOCONUS() { setupServiceMember := func(serviceMemberAffiliation models.ServiceMemberAffiliation) models.ServiceMember { serviceMember := factory.BuildServiceMember(suite.DB(), []factory.Customization{ {Model: models.ServiceMember{ From f40d3c720387789ff7688a90f4ea6dba9f9dfff2 Mon Sep 17 00:00:00 2001 From: Samay Sofo Date: Mon, 24 Feb 2025 21:23:31 +0000 Subject: [PATCH 48/71] code refactoring --- .../transportation_office_fetcher_test.go | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/pkg/services/transportation_office/transportation_office_fetcher_test.go b/pkg/services/transportation_office/transportation_office_fetcher_test.go index cea8b1685d4..b5a52b13140 100644 --- a/pkg/services/transportation_office/transportation_office_fetcher_test.go +++ b/pkg/services/transportation_office/transportation_office_fetcher_test.go @@ -597,10 +597,7 @@ func (suite *TransportationOfficeServiceSuite) Test_FindCounselingOfficeForPrime suite.Nil(err) serviceMember := setupServiceMember(models.AffiliationARMY) - appCtx := suite.AppContextWithSessionForTest(&auth.Session{ - ServiceMemberID: serviceMember.ID, - }) - departmentIndictor, err := findOconusGblocDepartmentIndicator(appCtx, dutylocation, serviceMember.ID) + departmentIndictor, err := findOconusGblocDepartmentIndicator(suite.AppContextForTest(), dutylocation, serviceMember.ID) suite.NotNil(departmentIndictor) suite.Nil(err) suite.Nil(departmentIndictor.DepartmentIndicator) @@ -622,11 +619,8 @@ func (suite *TransportationOfficeServiceSuite) Test_FindCounselingOfficeForPrime // loop through and make sure all branches are using it's own dedicated GBLOC and not default serviceMember := setupServiceMember(models.AffiliationAIRFORCE) - appCtx := suite.AppContextWithSessionForTest(&auth.Session{ - ServiceMemberID: serviceMember.ID, - }) suite.Nil(err) - departmentIndictor, err := findOconusGblocDepartmentIndicator(appCtx, dutylocation, appCtx.Session().ServiceMemberID) + departmentIndictor, err := findOconusGblocDepartmentIndicator(suite.AppContextForTest(), dutylocation, serviceMember.ID) suite.NotNil(departmentIndictor) suite.Nil(err) suite.NotNil(departmentIndictor.DepartmentIndicator) @@ -670,10 +664,7 @@ func (suite *TransportationOfficeServiceSuite) Test_FindCounselingOfficeForPrime suite.Nil(err) serviceMember := setupServiceMember(models.AffiliationAIRFORCE) - appCtx := suite.AppContextWithSessionForTest(&auth.Session{ - ServiceMemberID: serviceMember.ID, - }) - offices, err := suite.toFetcher.FindCounselingOfficeForPrimeCounseled(suite.AppContextForTest(), dutylocation.ID, appCtx.Session().ServiceMemberID) + offices, err := suite.toFetcher.FindCounselingOfficeForPrimeCounseled(suite.AppContextForTest(), dutylocation.ID, serviceMember.ID) suite.NotNil(offices) suite.Nil(err) suite.Equal(offices.Name, "PPPO Fort Belvoir - USA") From e1a6aafa17fd6e76f40e9a7cee4761be78b6343c Mon Sep 17 00:00:00 2001 From: msaki-caci Date: Tue, 25 Feb 2025 16:09:28 +0000 Subject: [PATCH 49/71] B-22586 Update maxResults for ExportButton This value was previously set to 1000 results by default. This has now been set to the total number of APPROVED office users --- src/pages/Admin/OfficeUsers/OfficeUserList.jsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/pages/Admin/OfficeUsers/OfficeUserList.jsx b/src/pages/Admin/OfficeUsers/OfficeUserList.jsx index 02b1cecf854..5cbdca8aa98 100644 --- a/src/pages/Admin/OfficeUsers/OfficeUserList.jsx +++ b/src/pages/Admin/OfficeUsers/OfficeUserList.jsx @@ -48,7 +48,14 @@ const ListActions = () => { - + ); }; From 109584189d04b647018a43a11b802044b88dbad0 Mon Sep 17 00:00:00 2001 From: Alex Lusk Date: Tue, 25 Feb 2025 18:31:30 +0000 Subject: [PATCH 50/71] Include all rate area info in prime api for only OCONUS *shipments* --- .../primeapiv3/payloads/model_to_payload.go | 15 +++-- .../payloads/model_to_payload_test.go | 23 +++++-- .../mto_shipment_rate_area_fetcher.go | 59 +++++++++--------- .../mto_shipment_rate_area_fetcher_test.go | 62 +++++++++---------- 4 files changed, 90 insertions(+), 69 deletions(-) diff --git a/pkg/handlers/primeapiv3/payloads/model_to_payload.go b/pkg/handlers/primeapiv3/payloads/model_to_payload.go index aba7a9c1718..0cb7b93e366 100644 --- a/pkg/handlers/primeapiv3/payloads/model_to_payload.go +++ b/pkg/handlers/primeapiv3/payloads/model_to_payload.go @@ -93,12 +93,15 @@ func MoveTaskOrderWithShipmentRateAreas(appCtx appcontext.AppContext, moveTaskOr } // Origin/Destination RateArea will be present on root shipment level for all non-PPM shipment types for _, shipment := range payload.MtoShipments { - if shipment.PpmShipment != nil { - shipment.PpmShipment.OriginRateArea = PostalCodeToRateArea(shipment.PpmShipment.PickupAddress.PostalCode, shipmentPostalCodeRateAreaLookupMap) - shipment.PpmShipment.DestinationRateArea = PostalCodeToRateArea(shipment.PpmShipment.DestinationAddress.PostalCode, shipmentPostalCodeRateAreaLookupMap) - } else { - shipment.OriginRateArea = PostalCodeToRateArea(shipment.PickupAddress.PostalCode, shipmentPostalCodeRateAreaLookupMap) - shipment.DestinationRateArea = PostalCodeToRateArea(shipment.DestinationAddress.PostalCode, shipmentPostalCodeRateAreaLookupMap) + // B-22767: We want both domestic and international rate area info but only for international shipments + if shipment.MarketCode == string(models.MarketCodeInternational) { + if shipment.PpmShipment != nil { + shipment.PpmShipment.OriginRateArea = PostalCodeToRateArea(shipment.PpmShipment.PickupAddress.PostalCode, shipmentPostalCodeRateAreaLookupMap) + shipment.PpmShipment.DestinationRateArea = PostalCodeToRateArea(shipment.PpmShipment.DestinationAddress.PostalCode, shipmentPostalCodeRateAreaLookupMap) + } else { + shipment.OriginRateArea = PostalCodeToRateArea(shipment.PickupAddress.PostalCode, shipmentPostalCodeRateAreaLookupMap) + shipment.DestinationRateArea = PostalCodeToRateArea(shipment.DestinationAddress.PostalCode, shipmentPostalCodeRateAreaLookupMap) + } } } } diff --git a/pkg/handlers/primeapiv3/payloads/model_to_payload_test.go b/pkg/handlers/primeapiv3/payloads/model_to_payload_test.go index f0f7036eac6..95529b800c6 100644 --- a/pkg/handlers/primeapiv3/payloads/model_to_payload_test.go +++ b/pkg/handlers/primeapiv3/payloads/model_to_payload_test.go @@ -151,11 +151,13 @@ func (suite *PayloadsSuite) TestMoveTaskOrder() { const fairbanksAlaskaPostalCode = "99716" const anchorageAlaskaPostalCode = "99521" const wasillaAlaskaPostalCode = "99652" + const beverlyHillsCAPostalCode = "90210" //clear MTOShipment and rebuild with specifics for test newMove.MTOShipments = newMove.MTOShipments[:0] newMove.MTOShipments = append(newMove.MTOShipments, models.MTOShipment{ + MarketCode: models.MarketCodeInternational, PickupAddress: &models.Address{ StreetAddress1: "123 Main St", StreetAddress2: &streetAddress2, @@ -175,6 +177,7 @@ func (suite *PayloadsSuite) TestMoveTaskOrder() { }, }) newMove.MTOShipments = append(newMove.MTOShipments, models.MTOShipment{ + MarketCode: models.MarketCodeInternational, PickupAddress: &models.Address{ StreetAddress1: "123 Main St", StreetAddress2: &streetAddress2, @@ -195,6 +198,7 @@ func (suite *PayloadsSuite) TestMoveTaskOrder() { }) newMove.MTOShipments = append(newMove.MTOShipments, models.MTOShipment{ ShipmentType: models.MTOShipmentTypePPM, + MarketCode: models.MarketCodeInternational, PPMShipment: &models.PPMShipment{ ID: uuid.Must(uuid.NewV4()), ApprovedAt: models.TimePointer(time.Now()), @@ -224,6 +228,8 @@ func (suite *PayloadsSuite) TestMoveTaskOrder() { }, }) newMove.MTOShipments = append(newMove.MTOShipments, models.MTOShipment{ + ShipmentType: models.MTOShipmentTypePPM, + MarketCode: models.MarketCodeDomestic, PPMShipment: &models.PPMShipment{ ID: uuid.Must(uuid.NewV4()), ApprovedAt: models.TimePointer(time.Now()), @@ -240,7 +246,7 @@ func (suite *PayloadsSuite) TestMoveTaskOrder() { StreetAddress3: &streetAddress3, City: "Beverly Hills", State: "CA", - PostalCode: "90210", + PostalCode: beverlyHillsCAPostalCode, }, DestinationAddress: &models.Address{ StreetAddress1: "123 Main St", @@ -248,18 +254,19 @@ func (suite *PayloadsSuite) TestMoveTaskOrder() { StreetAddress3: &streetAddress3, City: "Beverly Hills", State: "CA", - PostalCode: "90210", + PostalCode: beverlyHillsCAPostalCode, }, }, }) newMove.MTOShipments = append(newMove.MTOShipments, models.MTOShipment{ + MarketCode: models.MarketCodeDomestic, PickupAddress: &models.Address{ StreetAddress1: "123 Main St", StreetAddress2: &streetAddress2, StreetAddress3: &streetAddress3, City: "Beverly Hills", State: "CA", - PostalCode: "90210", + PostalCode: beverlyHillsCAPostalCode, DestinationGbloc: models.StringPointer("JEAT"), }, DestinationAddress: &models.Address{ @@ -268,7 +275,7 @@ func (suite *PayloadsSuite) TestMoveTaskOrder() { StreetAddress3: &streetAddress3, City: "Beverly Hills", State: "CA", - PostalCode: "90210", + PostalCode: beverlyHillsCAPostalCode, DestinationGbloc: models.StringPointer("JEAT"), }, }) @@ -335,6 +342,14 @@ func (suite *PayloadsSuite) TestMoveTaskOrder() { Name: wasillaAlaskaPostalCode, }, }, + { + PostalCode: beverlyHillsCAPostalCode, + RateArea: &models.ReRateArea{ + ID: uuid.Must(uuid.NewV4()), + Code: beverlyHillsCAPostalCode, + Name: beverlyHillsCAPostalCode, + }, + }, } returnedModel = MoveTaskOrderWithShipmentRateAreas(suite.AppContextForTest(), newMove, &shipmentPostalCodeRateArea) diff --git a/pkg/services/mto_shipment/mto_shipment_rate_area_fetcher.go b/pkg/services/mto_shipment/mto_shipment_rate_area_fetcher.go index ed7381c60a9..de42e34918f 100644 --- a/pkg/services/mto_shipment/mto_shipment_rate_area_fetcher.go +++ b/pkg/services/mto_shipment/mto_shipment_rate_area_fetcher.go @@ -36,37 +36,40 @@ func (f mtoShipmentRateAreaFetcher) GetPrimeMoveShipmentRateAreas(appCtx appcont var oconusPostalCodes = make([]string, 0) var conusPostalCodes = make([]string, 0) for _, shipment := range moveTaskOrder.MTOShipments { - if shipment.PickupAddress != nil { - if !slices.Contains(oconusPostalCodes, shipment.PickupAddress.PostalCode) && - shipment.PickupAddress.IsOconus != nil && *shipment.PickupAddress.IsOconus { - oconusPostalCodes = append(oconusPostalCodes, shipment.PickupAddress.PostalCode) - } else if !slices.Contains(conusPostalCodes, shipment.PickupAddress.PostalCode) { - conusPostalCodes = append(conusPostalCodes, shipment.PickupAddress.PostalCode) - } - } - if shipment.DestinationAddress != nil { - if !slices.Contains(oconusPostalCodes, shipment.DestinationAddress.PostalCode) && - shipment.DestinationAddress.IsOconus != nil && *shipment.DestinationAddress.IsOconus { - oconusPostalCodes = append(oconusPostalCodes, shipment.DestinationAddress.PostalCode) - } else if !slices.Contains(conusPostalCodes, shipment.DestinationAddress.PostalCode) { - conusPostalCodes = append(conusPostalCodes, shipment.DestinationAddress.PostalCode) + // B-22767: We want both domestic and international rate area info but only for international shipments + if shipment.MarketCode == models.MarketCodeInternational { + if shipment.PickupAddress != nil { + if !slices.Contains(oconusPostalCodes, shipment.PickupAddress.PostalCode) && + shipment.PickupAddress.IsOconus != nil && *shipment.PickupAddress.IsOconus { + oconusPostalCodes = append(oconusPostalCodes, shipment.PickupAddress.PostalCode) + } else if !slices.Contains(conusPostalCodes, shipment.PickupAddress.PostalCode) { + conusPostalCodes = append(conusPostalCodes, shipment.PickupAddress.PostalCode) + } } - } - if shipment.PPMShipment != nil { - if shipment.PPMShipment.PickupAddress != nil { - if !slices.Contains(oconusPostalCodes, shipment.PPMShipment.PickupAddress.PostalCode) && - shipment.PPMShipment.PickupAddress.IsOconus != nil && *shipment.PPMShipment.PickupAddress.IsOconus { - oconusPostalCodes = append(oconusPostalCodes, shipment.PPMShipment.PickupAddress.PostalCode) - } else if !slices.Contains(conusPostalCodes, shipment.PPMShipment.PickupAddress.PostalCode) { - conusPostalCodes = append(conusPostalCodes, shipment.PPMShipment.PickupAddress.PostalCode) + if shipment.DestinationAddress != nil { + if !slices.Contains(oconusPostalCodes, shipment.DestinationAddress.PostalCode) && + shipment.DestinationAddress.IsOconus != nil && *shipment.DestinationAddress.IsOconus { + oconusPostalCodes = append(oconusPostalCodes, shipment.DestinationAddress.PostalCode) + } else if !slices.Contains(conusPostalCodes, shipment.DestinationAddress.PostalCode) { + conusPostalCodes = append(conusPostalCodes, shipment.DestinationAddress.PostalCode) } } - if shipment.PPMShipment.DestinationAddress != nil { - if !slices.Contains(oconusPostalCodes, shipment.PPMShipment.DestinationAddress.PostalCode) && - shipment.PPMShipment.DestinationAddress.IsOconus != nil && *shipment.PPMShipment.DestinationAddress.IsOconus { - oconusPostalCodes = append(oconusPostalCodes, shipment.PPMShipment.DestinationAddress.PostalCode) - } else if !slices.Contains(conusPostalCodes, shipment.PPMShipment.DestinationAddress.PostalCode) { - conusPostalCodes = append(conusPostalCodes, shipment.PPMShipment.DestinationAddress.PostalCode) + if shipment.PPMShipment != nil { + if shipment.PPMShipment.PickupAddress != nil { + if !slices.Contains(oconusPostalCodes, shipment.PPMShipment.PickupAddress.PostalCode) && + shipment.PPMShipment.PickupAddress.IsOconus != nil && *shipment.PPMShipment.PickupAddress.IsOconus { + oconusPostalCodes = append(oconusPostalCodes, shipment.PPMShipment.PickupAddress.PostalCode) + } else if !slices.Contains(conusPostalCodes, shipment.PPMShipment.PickupAddress.PostalCode) { + conusPostalCodes = append(conusPostalCodes, shipment.PPMShipment.PickupAddress.PostalCode) + } + } + if shipment.PPMShipment.DestinationAddress != nil { + if !slices.Contains(oconusPostalCodes, shipment.PPMShipment.DestinationAddress.PostalCode) && + shipment.PPMShipment.DestinationAddress.IsOconus != nil && *shipment.PPMShipment.DestinationAddress.IsOconus { + oconusPostalCodes = append(oconusPostalCodes, shipment.PPMShipment.DestinationAddress.PostalCode) + } else if !slices.Contains(conusPostalCodes, shipment.PPMShipment.DestinationAddress.PostalCode) { + conusPostalCodes = append(conusPostalCodes, shipment.PPMShipment.DestinationAddress.PostalCode) + } } } } diff --git a/pkg/services/mto_shipment/mto_shipment_rate_area_fetcher_test.go b/pkg/services/mto_shipment/mto_shipment_rate_area_fetcher_test.go index e94fea2c4a1..b594c3f3a6c 100644 --- a/pkg/services/mto_shipment/mto_shipment_rate_area_fetcher_test.go +++ b/pkg/services/mto_shipment/mto_shipment_rate_area_fetcher_test.go @@ -3,6 +3,7 @@ package mtoshipment import ( "database/sql" "fmt" + "slices" "time" "github.com/gofrs/uuid" @@ -46,6 +47,7 @@ func (suite *MTOShipmentServiceSuite) TestGetMoveShipmentRateArea() { PostalCode: anchorageAlaskaPostalCode, IsOconus: models.BoolPointer(true), }, + MarketCode: models.MarketCodeInternational, }, models.MTOShipment{ PickupAddress: &models.Address{ @@ -62,15 +64,16 @@ func (suite *MTOShipmentServiceSuite) TestGetMoveShipmentRateArea() { PostalCode: sanDiegoCAPostalCode, IsOconus: models.BoolPointer(false), }, + MarketCode: models.MarketCodeDomestic, }, models.MTOShipment{ PPMShipment: &models.PPMShipment{ PickupAddress: &models.Address{ StreetAddress1: "123 Main St", - City: "Wasilla", - State: "AK", - PostalCode: wasillaAlaskaPostalCode, - IsOconus: models.BoolPointer(true), + City: "Beverly Hills", + State: "CA", + PostalCode: beverlyHillsCAPostalCode, + IsOconus: models.BoolPointer(false), }, DestinationAddress: &models.Address{ StreetAddress1: "123 Main St", @@ -80,6 +83,7 @@ func (suite *MTOShipmentServiceSuite) TestGetMoveShipmentRateArea() { IsOconus: models.BoolPointer(true), }, }, + MarketCode: models.MarketCodeInternational, }, }, } @@ -214,9 +218,9 @@ func (suite *MTOShipmentServiceSuite) TestGetMoveShipmentRateArea() { }) // setup Fairbanks and Anchorage to have same RateArea - rateArea1 := setupRateAreaToManyPostalCodesData(*contract, []string{fairbanksAlaskaPostalCode, anchorageAlaskaPostalCode}) + rateAreaAK1 := setupRateAreaToManyPostalCodesData(*contract, []string{fairbanksAlaskaPostalCode, anchorageAlaskaPostalCode}) // setup Wasilla to have it's own RateArea - rateArea2 := setupRateAreaToPostalCodeData(setupRateArea(*contract), wasillaAlaskaPostalCode) + rateAreaAK2 := setupRateAreaToPostalCodeData(setupRateArea(*contract), wasillaAlaskaPostalCode) rateAreaCA, err := setupDomesticRateAreaAndZip3s("US88", "California-South", map[string]string{beverlyHillsCAPostalCode: "Beverly Hills", sanDiegoCAPostalCode: "San Diego"}, domServiceArea) if err != nil { @@ -226,27 +230,30 @@ func (suite *MTOShipmentServiceSuite) TestGetMoveShipmentRateArea() { shipmentPostalCodeRateAreas, err := shipmentRateAreaFetcher.GetPrimeMoveShipmentRateAreas(suite.AppContextForTest(), testMove) suite.NotNil(shipmentPostalCodeRateAreas) suite.FatalNoError(err) - suite.Equal(5, len(*shipmentPostalCodeRateAreas)) + suite.Equal(4, len(*shipmentPostalCodeRateAreas)) - suite.Equal(true, isRateAreaEquals(rateArea1, fairbanksAlaskaPostalCode, shipmentPostalCodeRateAreas)) - suite.Equal(true, isRateAreaEquals(rateArea1, anchorageAlaskaPostalCode, shipmentPostalCodeRateAreas)) - suite.Equal(true, isRateAreaEquals(rateArea2, wasillaAlaskaPostalCode, shipmentPostalCodeRateAreas)) + suite.Equal(true, isRateAreaEquals(rateAreaAK1, fairbanksAlaskaPostalCode, shipmentPostalCodeRateAreas)) + suite.Equal(true, isRateAreaEquals(rateAreaAK1, anchorageAlaskaPostalCode, shipmentPostalCodeRateAreas)) + suite.Equal(true, isRateAreaEquals(rateAreaAK2, wasillaAlaskaPostalCode, shipmentPostalCodeRateAreas)) suite.Equal(true, isRateAreaEquals(rateAreaCA, beverlyHillsCAPostalCode, shipmentPostalCodeRateAreas)) - suite.Equal(true, isRateAreaEquals(rateAreaCA, sanDiegoCAPostalCode, shipmentPostalCodeRateAreas)) - suite.Equal(false, isRateAreaEquals(rateArea2, fairbanksAlaskaPostalCode, shipmentPostalCodeRateAreas)) - suite.Equal(false, isRateAreaEquals(rateArea2, anchorageAlaskaPostalCode, shipmentPostalCodeRateAreas)) - suite.Equal(false, isRateAreaEquals(rateArea1, wasillaAlaskaPostalCode, shipmentPostalCodeRateAreas)) + // Postal code used only in a CONUS shipment should not have been fetched + i := slices.IndexFunc(*shipmentPostalCodeRateAreas, func(pcra services.ShipmentPostalCodeRateArea) bool { + return pcra.PostalCode == sanDiegoCAPostalCode + }) + suite.Equal(-1, i) + + suite.Equal(false, isRateAreaEquals(rateAreaAK1, beverlyHillsCAPostalCode, shipmentPostalCodeRateAreas)) + suite.Equal(false, isRateAreaEquals(rateAreaAK1, wasillaAlaskaPostalCode, shipmentPostalCodeRateAreas)) + suite.Equal(false, isRateAreaEquals(rateAreaAK2, fairbanksAlaskaPostalCode, shipmentPostalCodeRateAreas)) + suite.Equal(false, isRateAreaEquals(rateAreaAK2, anchorageAlaskaPostalCode, shipmentPostalCodeRateAreas)) + suite.Equal(false, isRateAreaEquals(rateAreaAK2, beverlyHillsCAPostalCode, shipmentPostalCodeRateAreas)) suite.Equal(false, isRateAreaEquals(rateAreaCA, fairbanksAlaskaPostalCode, shipmentPostalCodeRateAreas)) suite.Equal(false, isRateAreaEquals(rateAreaCA, anchorageAlaskaPostalCode, shipmentPostalCodeRateAreas)) suite.Equal(false, isRateAreaEquals(rateAreaCA, wasillaAlaskaPostalCode, shipmentPostalCodeRateAreas)) - suite.Equal(false, isRateAreaEquals(rateArea1, beverlyHillsCAPostalCode, shipmentPostalCodeRateAreas)) - suite.Equal(false, isRateAreaEquals(rateArea1, sanDiegoCAPostalCode, shipmentPostalCodeRateAreas)) - suite.Equal(false, isRateAreaEquals(rateArea2, beverlyHillsCAPostalCode, shipmentPostalCodeRateAreas)) - suite.Equal(false, isRateAreaEquals(rateArea2, sanDiegoCAPostalCode, shipmentPostalCodeRateAreas)) }) - suite.Run("Returns matching CONUS rate areas", func() { + suite.Run("Does not return rate areas for CONUS only shipments", func() { availableToPrimeAtTime := time.Now().Add(-500 * time.Hour) testMove := models.Move{ AvailableToPrimeAt: &availableToPrimeAtTime, @@ -266,6 +273,7 @@ func (suite *MTOShipmentServiceSuite) TestGetMoveShipmentRateArea() { PostalCode: sanDiegoCAPostalCode, IsOconus: models.BoolPointer(false), }, + MarketCode: models.MarketCodeDomestic, }, models.MTOShipment{ PPMShipment: &models.PPMShipment{ @@ -284,6 +292,7 @@ func (suite *MTOShipmentServiceSuite) TestGetMoveShipmentRateArea() { IsOconus: models.BoolPointer(false), }, }, + MarketCode: models.MarketCodeDomestic, }, }, } @@ -334,29 +343,20 @@ func (suite *MTOShipmentServiceSuite) TestGetMoveShipmentRateArea() { return rateArea, nil } - rateAreaCA, err := setupDomesticRateAreaAndZip3s("US88", "California-South", map[string]string{beverlyHillsCAPostalCode: "Beverly Hills", sanDiegoCAPostalCode: "San Diego"}, domServiceArea) + _, err := setupDomesticRateAreaAndZip3s("US88", "California-South", map[string]string{beverlyHillsCAPostalCode: "Beverly Hills", sanDiegoCAPostalCode: "San Diego"}, domServiceArea) if err != nil { suite.Fail(err.Error()) } - rateAreaNY, err := setupDomesticRateAreaAndZip3s("US17", "New York", map[string]string{brooklynNYPostalCode: "Brooklyn"}, domServiceArea) + _, err = setupDomesticRateAreaAndZip3s("US17", "New York", map[string]string{brooklynNYPostalCode: "Brooklyn"}, domServiceArea) if err != nil { suite.Fail(err.Error()) } shipmentPostalCodeRateAreas, err := shipmentRateAreaFetcher.GetPrimeMoveShipmentRateAreas(suite.AppContextForTest(), testMove) suite.NotNil(shipmentPostalCodeRateAreas) - suite.Equal(3, len(*shipmentPostalCodeRateAreas)) + suite.Equal(0, len(*shipmentPostalCodeRateAreas)) suite.Nil(err) - - var shipmentPostalCodeRateAreaLookupMap = make(map[string]services.ShipmentPostalCodeRateArea) - for _, pcra := range *shipmentPostalCodeRateAreas { - shipmentPostalCodeRateAreaLookupMap[pcra.PostalCode] = pcra - } - - suite.Equal(rateAreaCA.Name, shipmentPostalCodeRateAreaLookupMap[beverlyHillsCAPostalCode].RateArea.Name) - suite.Equal(rateAreaCA.Name, shipmentPostalCodeRateAreaLookupMap[sanDiegoCAPostalCode].RateArea.Name) - suite.Equal(rateAreaNY.Name, shipmentPostalCodeRateAreaLookupMap[brooklynNYPostalCode].RateArea.Name) }) suite.Run("not available to prime error", func() { From 01898bf39a060cb03ba38c4d6f7baea9559ad2ba Mon Sep 17 00:00:00 2001 From: Samay Sofo Date: Tue, 25 Feb 2025 19:56:53 +0000 Subject: [PATCH 51/71] refactored test --- .../mto_service_item_creator_test.go | 4 ++-- .../transportation_office_fetcher_test.go | 12 ++++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/pkg/services/mto_service_item/mto_service_item_creator_test.go b/pkg/services/mto_service_item/mto_service_item_creator_test.go index 4158bcd3d14..ee468bd232a 100644 --- a/pkg/services/mto_service_item/mto_service_item_creator_test.go +++ b/pkg/services/mto_service_item/mto_service_item_creator_test.go @@ -1288,7 +1288,7 @@ func (suite *MTOServiceItemServiceSuite) TestCreateOriginSITServiceItem() { }, }, nil) builder := query.NewQueryBuilder() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &mocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -1334,7 +1334,7 @@ func (suite *MTOServiceItemServiceSuite) TestCreateOriginSITServiceItem() { }, }, nil) builder := query.NewQueryBuilder() - moveRouter := moverouter.NewMoveRouter() + moveRouter := moverouter.NewMoveRouter(transportationoffice.NewTransportationOfficesFetcher()) planner := &mocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), diff --git a/pkg/services/transportation_office/transportation_office_fetcher_test.go b/pkg/services/transportation_office/transportation_office_fetcher_test.go index b5a52b13140..908fd93870a 100644 --- a/pkg/services/transportation_office/transportation_office_fetcher_test.go +++ b/pkg/services/transportation_office/transportation_office_fetcher_test.go @@ -642,12 +642,20 @@ func (suite *TransportationOfficeServiceSuite) Test_FindCounselingOfficeForPrime }) suite.Run("failure - not found duty location returns error", func() { + _, oconusRateArea, _, _ := setupDataForOconusSearchCounselingOffice("99619", "MAPS") + + // setup department affiliation to GBLOC mappings + jppsoRegion, err := models.FetchJppsoRegionByCode(suite.DB(), "MAPS") + suite.NotNil(jppsoRegion) + suite.Nil(err) + gblocAors, err := models.FetchGblocAorsByJppsoCodeRateAreaDept(suite.DB(), jppsoRegion.ID, oconusRateArea.ID, models.DepartmentIndicatorARMY.String()) + suite.NotNil(gblocAors) + suite.Nil(err) appCtx := suite.AppContextWithSessionForTest(&auth.Session{ ServiceMemberID: uuid.Must(uuid.NewV4()), }) unknown_duty_location_id := uuid.Must(uuid.NewV4()) - offices, err := findCounselingOffice(appCtx, unknown_duty_location_id, appCtx.Session().ServiceMemberID) - suite.Nil(offices) + _, err = suite.toFetcher.FindCounselingOfficeForPrimeCounseled(appCtx, unknown_duty_location_id, appCtx.Session().ServiceMemberID) suite.NotNil(err) }) From 7bb6fb55d4cc9ace64453f5ab6f978a6d268cfd4 Mon Sep 17 00:00:00 2001 From: Samay Sofo Date: Tue, 25 Feb 2025 20:33:58 +0000 Subject: [PATCH 52/71] code clean up --- pkg/services/move/move_router_test.go | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/pkg/services/move/move_router_test.go b/pkg/services/move/move_router_test.go index 5d738225091..871a6bcb90c 100644 --- a/pkg/services/move/move_router_test.go +++ b/pkg/services/move/move_router_test.go @@ -501,15 +501,10 @@ func (suite *MoveServiceSuite) TestMoveSubmission() { }, nil) err := moveRouter.Submit(suite.AppContextForTest(), &move, &newSignedCertification) - if err != nil { - suite.Error(err) - suite.Contains(err.Error(), "Failed to find counseling office that provides counseling") - } else { - suite.NoError(err) - suite.Equal(models.MoveStatusNeedsServiceCounseling, move.Status, "expected Needs Service Counseling") - suite.Equal(models.MTOShipmentStatusSubmitted, move.MTOShipments[0].Status, "expected Submitted") - suite.Equal(models.PPMShipmentStatusSubmitted, move.MTOShipments[0].PPMShipment.Status, "expected Submitted") - } + suite.NoError(err) + suite.Equal(models.MoveStatusNeedsServiceCounseling, move.Status, "expected Needs Service Counseling") + suite.Equal(models.MTOShipmentStatusSubmitted, move.MTOShipments[0].Status, "expected Submitted") + suite.Equal(models.PPMShipmentStatusSubmitted, move.MTOShipments[0].PPMShipment.Status, "expected Submitted") }) suite.Run("returns an error when a Mobile Home Shipment is not formatted correctly", func() { From 10a880be7164437a6167a15e3983e8e0b84db0e8 Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Wed, 26 Feb 2025 00:15:29 +0000 Subject: [PATCH 53/71] delete temp files after packet creation --- pkg/handlers/ghcapi/ppm_document.go | 18 ++++ pkg/handlers/internalapi/ppm_shipment.go | 15 ++++ pkg/paperwork/generator.go | 19 +++- pkg/services/ppmshipment.go | 2 + .../ppmshipment/aoa_packet_creator.go | 89 +------------------ .../ppmshipment/payment_packet_creator.go | 7 ++ 6 files changed, 64 insertions(+), 86 deletions(-) diff --git a/pkg/handlers/ghcapi/ppm_document.go b/pkg/handlers/ghcapi/ppm_document.go index ee92f7e5d29..51a0deb01b2 100644 --- a/pkg/handlers/ghcapi/ppm_document.go +++ b/pkg/handlers/ghcapi/ppm_document.go @@ -187,6 +187,15 @@ func (h showAOAPacketHandler) Handle(params ppmdocumentops.ShowAOAPacketParams) } payload := io.NopCloser(AOAPacket) + + if err = h.AOAPacketCreator.CleanupAOAPacketFiles(appCtx); err != nil { + logger.Error("Error deleting temp AOA Packet files", zap.Error(err)) + errInstance := fmt.Sprintf("Instance: %s", h.GetTraceIDFromRequest(params.HTTPRequest)) + errPayload := &ghcmessages.Error{Message: &errInstance} + return ppmdocumentops.NewShowAOAPacketInternalServerError(). + WithPayload(errPayload), err + } + filename := fmt.Sprintf("inline; filename=\"AOA-%s.pdf\"", time.Now().Format("01-02-2006_15-04-05")) return ppmdocumentops.NewShowAOAPacketOK().WithContentDisposition(filename).WithPayload(payload), nil @@ -222,6 +231,15 @@ func (h ShowPaymentPacketHandler) Handle(params ppmdocumentops.ShowPaymentPacket } payload := io.NopCloser(pdf) + + if err = h.PaymentPacketCreator.CleanupPaymentPacketFiles(appCtx); err != nil { + appCtx.Logger().Error("Error deleting temp Payment Packet files", zap.Error(err)) + errInstance := fmt.Sprintf("Instance: %s", h.GetTraceIDFromRequest(params.HTTPRequest)) + errPayload := &ghcmessages.Error{Message: &errInstance} + return ppmdocumentops.NewShowAOAPacketInternalServerError(). + WithPayload(errPayload), err + } + filename := fmt.Sprintf("inline; filename=\"ppm_payment_packet-%s.pdf\"", time.Now().UTC().Format("2006-01-02T15:04:05.000Z")) return ppmdocumentops.NewShowPaymentPacketOK().WithContentDisposition(filename).WithPayload(payload), nil diff --git a/pkg/handlers/internalapi/ppm_shipment.go b/pkg/handlers/internalapi/ppm_shipment.go index 33480ae9830..9c4de324509 100644 --- a/pkg/handlers/internalapi/ppm_shipment.go +++ b/pkg/handlers/internalapi/ppm_shipment.go @@ -304,6 +304,15 @@ func (h showAOAPacketHandler) Handle(params ppmops.ShowAOAPacketParams) middlewa } payload := io.NopCloser(AOAPacket) + + if err = h.AOAPacketCreator.CleanupAOAPacketFiles(appCtx); err != nil { + logger.Error("Error deleting temp AOA files", zap.Error(err)) + aoaError := err.Error() + payload := payloads.InternalServerError(&aoaError, h.GetTraceIDFromRequest(params.HTTPRequest)) + return ppmops.NewShowAOAPacketInternalServerError(). + WithPayload(payload), err + } + filename := fmt.Sprintf("inline; filename=\"AOA-%s.pdf\"", time.Now().Format("01-02-2006_15-04-05")) return ppmops.NewShowAOAPacketOK().WithContentDisposition(filename).WithPayload(payload), nil @@ -343,6 +352,12 @@ func (h ShowPaymentPacketHandler) Handle(params ppmops.ShowPaymentPacketParams) } payload := io.NopCloser(pdf) + + if err = h.PaymentPacketCreator.CleanupPaymentPacketFiles(appCtx); err != nil { + appCtx.Logger().Error(fmt.Sprintf("internalapi.DownPaymentPacket InternalServerError failed to delete temp packet files for ppmShipmentID:%s", ppmShipmentID.String()), zap.Error(err)) + return ppmops.NewShowPaymentPacketInternalServerError(), err + } + filename := fmt.Sprintf("inline; filename=\"ppm_payment_packet-%s.pdf\"", time.Now().UTC().Format("2006-01-02T15:04:05.000Z")) return ppmops.NewShowPaymentPacketOK().WithContentDisposition(filename).WithPayload(payload), nil diff --git a/pkg/paperwork/generator.go b/pkg/paperwork/generator.go index 54b3750860b..3bcb3ca3ea6 100644 --- a/pkg/paperwork/generator.go +++ b/pkg/paperwork/generator.go @@ -175,7 +175,24 @@ func (g *Generator) newTempFileWithName(fileName string) (afero.File, error) { // Cleanup removes filesystem working dir func (g *Generator) Cleanup(_ appcontext.AppContext) error { - return g.fs.RemoveAll(g.workDir) + files, err := afero.ReadDir(g.fs, g.workDir) + + if err != nil { + return err + } + fmt.Println("--------- BEFORE DELETION -----------") + for _, file := range files { + fmt.Println(file.Name()) + } + fmt.Println("-------------------------------------") + + err = g.fs.RemoveAll(g.workDir) + + if err != nil { + return err + } + + return err } // Get PDF Configuration (For Testing) diff --git a/pkg/services/ppmshipment.go b/pkg/services/ppmshipment.go index d7fb898685a..ca86516e407 100644 --- a/pkg/services/ppmshipment.go +++ b/pkg/services/ppmshipment.go @@ -91,6 +91,7 @@ type PPMShipmentUpdatedSubmitter interface { type AOAPacketCreator interface { VerifyAOAPacketInternal(appCtx appcontext.AppContext, ppmShipmentID uuid.UUID) error CreateAOAPacket(appCtx appcontext.AppContext, ppmShipmentID uuid.UUID, isPaymentPacket bool) (afero.File, error) + CleanupAOAPacketFiles(appCtx appcontext.AppContext) error } // PaymentPacketCreator creates a payment packet for a PPM shipment @@ -99,4 +100,5 @@ type AOAPacketCreator interface { type PaymentPacketCreator interface { Generate(appCtx appcontext.AppContext, ppmShipmentID uuid.UUID, addBookmarks bool, addWaterMarks bool) (io.ReadCloser, error) GenerateDefault(appCtx appcontext.AppContext, ppmShipmentID uuid.UUID) (io.ReadCloser, error) + CleanupPaymentPacketFiles(appCtx appcontext.AppContext) error } diff --git a/pkg/services/ppmshipment/aoa_packet_creator.go b/pkg/services/ppmshipment/aoa_packet_creator.go index 7a84eda4e5c..f60d2896c92 100644 --- a/pkg/services/ppmshipment/aoa_packet_creator.go +++ b/pkg/services/ppmshipment/aoa_packet_creator.go @@ -7,7 +7,6 @@ import ( "github.com/gofrs/uuid" "github.com/pkg/errors" "github.com/spf13/afero" - "go.uber.org/zap" "github.com/transcom/mymove/pkg/appcontext" "github.com/transcom/mymove/pkg/models" @@ -137,89 +136,9 @@ func (a *aoaPacketCreator) CreateAOAPacket(appCtx appcontext.AppContext, ppmShip return mergedPdf, nil } -// saveAOAPacket uploads the AOA packet to S3 and saves the document data to the database, associating it with the PPM -// shipment. -func saveAOAPacket( - appCtx appcontext.AppContext, - ppmShipment *models.PPMShipment, - aoaPacket io.ReadCloser, - ppmShipmentUpdater services.PPMShipmentUpdater, - userUploader *uploader.UserUploader, -) error { - txnErr := appCtx.NewTransaction(func(txnAppCtx appcontext.AppContext) error { - // Need to think about whether we want any special handling if we already have an AOA packet. I don't think we will - // create more than one, but if we do, we'll need to handle it both here and on retrieval. - if ppmShipment.AOAPacketID == nil { - document := models.Document{ - ServiceMemberID: ppmShipment.Shipment.MoveTaskOrder.Orders.ServiceMember.ID, - } - - verrs, err := appCtx.DB().ValidateAndCreate(&document) - - errMsgPrefix := "failed to create AOA packet document" - - if verrs.HasAny() { - appCtx.Logger().Error(errMsgPrefix, zap.Error(verrs)) - - return fmt.Errorf("%s: %w", errMsgPrefix, verrs) - } else if err != nil { - appCtx.Logger().Error(errMsgPrefix, zap.Error(err)) - - return fmt.Errorf("%s: %w", errMsgPrefix, err) - } - - ppmShipment.AOAPacketID = &document.ID - ppmShipment.AOAPacket = &document - - ppmShipment, err = ppmShipmentUpdater.UpdatePPMShipmentWithDefaultCheck(txnAppCtx, ppmShipment, ppmShipment.Shipment.ID) - - if err != nil { - errMsgPrefix = "failed to update PPMShipment with AOA packet document" - - appCtx.Logger().Error(errMsgPrefix, zap.Error(err)) - - return fmt.Errorf("%s: %w", errMsgPrefix, err) - } - } - - fileToUpload, prepErr := userUploader.PrepareFileForUpload(txnAppCtx, aoaPacket, "aoa_packet.pdf") - - if prepErr != nil { - errMsgPrefix := "failed to prepare AOA packet for upload" - - appCtx.Logger().Error(errMsgPrefix, zap.Error(prepErr)) - - return fmt.Errorf("%s: %w", errMsgPrefix, prepErr) - } - - newUpload, uploadVerrs, uploadErr := userUploader.CreateUserUploadForDocument( - txnAppCtx, - ppmShipment.AOAPacketID, - // We're doing this on behalf of the service member, so we'll use their user ID to store the upload - ppmShipment.Shipment.MoveTaskOrder.Orders.ServiceMember.UserID, - uploader.File{File: fileToUpload}, - uploader.AllowedTypesPPMDocuments, - ) - - errMsgPrefix := "failed to upload AOA packet" - if uploadVerrs.HasAny() { - appCtx.Logger().Error(errMsgPrefix, zap.Error(uploadVerrs)) - - return fmt.Errorf("%s: %w", errMsgPrefix, uploadVerrs) - } else if uploadErr != nil { - appCtx.Logger().Error(errMsgPrefix, zap.Error(uploadErr)) - - return fmt.Errorf("%s: %w", errMsgPrefix, uploadErr) - } - - ppmShipment.AOAPacket.UserUploads = append(ppmShipment.AOAPacket.UserUploads, *newUpload) - - return nil - }) - - if txnErr != nil { - return txnErr - } +// remove all of the packet files from the temp directory associated with creating the AOA packet +func (a *aoaPacketCreator) CleanupAOAPacketFiles(appCtx appcontext.AppContext) error { + err := a.pdfGenerator.Cleanup(appCtx) - return nil + return err } diff --git a/pkg/services/ppmshipment/payment_packet_creator.go b/pkg/services/ppmshipment/payment_packet_creator.go index ab949487f60..8df9a509ea0 100644 --- a/pkg/services/ppmshipment/payment_packet_creator.go +++ b/pkg/services/ppmshipment/payment_packet_creator.go @@ -155,6 +155,13 @@ func (p *paymentPacketCreator) GenerateDefault(appCtx appcontext.AppContext, ppm return p.Generate(appCtx, ppmShipmentID, true, true) } +// remove all of the packet files from the temp directory associated with creating the payment packet +func (p *paymentPacketCreator) CleanupPaymentPacketFiles(appCtx appcontext.AppContext) error { + err := p.pdfGenerator.Cleanup(appCtx) + + return err +} + func buildBookMarks(fileNamesToMerge []string, sortedPaymentPacketItems map[int]paymentPacketItem, aoaPacketFile io.ReadSeeker, pdfGenerator paperwork.Generator) ([]pdfcpu.Bookmark, error) { // go out and retrieve PDF file info for each file name for i := 0; i < len(fileNamesToMerge); i++ { From 736d776fd051731fd3e4e4eb8113e779fd72e3ea Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Wed, 26 Feb 2025 15:45:55 +0000 Subject: [PATCH 54/71] removing test to get list of files in temp dir, restore saveAOApacket --- pkg/paperwork/generator.go | 19 +--- pkg/services/mocks/AOAPacketCreator.go | 18 ++++ pkg/services/mocks/PaymentPacketCreator.go | 18 ++++ .../ppmshipment/aoa_packet_creator.go | 88 +++++++++++++++++++ 4 files changed, 125 insertions(+), 18 deletions(-) diff --git a/pkg/paperwork/generator.go b/pkg/paperwork/generator.go index 3bcb3ca3ea6..54b3750860b 100644 --- a/pkg/paperwork/generator.go +++ b/pkg/paperwork/generator.go @@ -175,24 +175,7 @@ func (g *Generator) newTempFileWithName(fileName string) (afero.File, error) { // Cleanup removes filesystem working dir func (g *Generator) Cleanup(_ appcontext.AppContext) error { - files, err := afero.ReadDir(g.fs, g.workDir) - - if err != nil { - return err - } - fmt.Println("--------- BEFORE DELETION -----------") - for _, file := range files { - fmt.Println(file.Name()) - } - fmt.Println("-------------------------------------") - - err = g.fs.RemoveAll(g.workDir) - - if err != nil { - return err - } - - return err + return g.fs.RemoveAll(g.workDir) } // Get PDF Configuration (For Testing) diff --git a/pkg/services/mocks/AOAPacketCreator.go b/pkg/services/mocks/AOAPacketCreator.go index b1f23ed19dc..35c09d995a0 100644 --- a/pkg/services/mocks/AOAPacketCreator.go +++ b/pkg/services/mocks/AOAPacketCreator.go @@ -15,6 +15,24 @@ type AOAPacketCreator struct { mock.Mock } +// CleanupAOAPacketFiles provides a mock function with given fields: appCtx +func (_m *AOAPacketCreator) CleanupAOAPacketFiles(appCtx appcontext.AppContext) error { + ret := _m.Called(appCtx) + + if len(ret) == 0 { + panic("no return value specified for CleanupAOAPacketFiles") + } + + var r0 error + if rf, ok := ret.Get(0).(func(appcontext.AppContext) error); ok { + r0 = rf(appCtx) + } else { + r0 = ret.Error(0) + } + + return r0 +} + // CreateAOAPacket provides a mock function with given fields: appCtx, ppmShipmentID, isPaymentPacket func (_m *AOAPacketCreator) CreateAOAPacket(appCtx appcontext.AppContext, ppmShipmentID uuid.UUID, isPaymentPacket bool) (afero.File, error) { ret := _m.Called(appCtx, ppmShipmentID, isPaymentPacket) diff --git a/pkg/services/mocks/PaymentPacketCreator.go b/pkg/services/mocks/PaymentPacketCreator.go index 5a292cb9fbe..a7f257c0069 100644 --- a/pkg/services/mocks/PaymentPacketCreator.go +++ b/pkg/services/mocks/PaymentPacketCreator.go @@ -17,6 +17,24 @@ type PaymentPacketCreator struct { mock.Mock } +// CleanupPaymentPacketFiles provides a mock function with given fields: appCtx +func (_m *PaymentPacketCreator) CleanupPaymentPacketFiles(appCtx appcontext.AppContext) error { + ret := _m.Called(appCtx) + + if len(ret) == 0 { + panic("no return value specified for CleanupPaymentPacketFiles") + } + + var r0 error + if rf, ok := ret.Get(0).(func(appcontext.AppContext) error); ok { + r0 = rf(appCtx) + } else { + r0 = ret.Error(0) + } + + return r0 +} + // Generate provides a mock function with given fields: appCtx, ppmShipmentID, addBookmarks, addWaterMarks func (_m *PaymentPacketCreator) Generate(appCtx appcontext.AppContext, ppmShipmentID uuid.UUID, addBookmarks bool, addWaterMarks bool) (io.ReadCloser, error) { ret := _m.Called(appCtx, ppmShipmentID, addBookmarks, addWaterMarks) diff --git a/pkg/services/ppmshipment/aoa_packet_creator.go b/pkg/services/ppmshipment/aoa_packet_creator.go index f60d2896c92..c8ced8ffea4 100644 --- a/pkg/services/ppmshipment/aoa_packet_creator.go +++ b/pkg/services/ppmshipment/aoa_packet_creator.go @@ -7,6 +7,7 @@ import ( "github.com/gofrs/uuid" "github.com/pkg/errors" "github.com/spf13/afero" + "go.uber.org/zap" "github.com/transcom/mymove/pkg/appcontext" "github.com/transcom/mymove/pkg/models" @@ -142,3 +143,90 @@ func (a *aoaPacketCreator) CleanupAOAPacketFiles(appCtx appcontext.AppContext) e return err } + +// saveAOAPacket uploads the AOA packet to S3 and saves the document data to the database, associating it with the PPM +// shipment. +func saveAOAPacket( + appCtx appcontext.AppContext, + ppmShipment *models.PPMShipment, + aoaPacket io.ReadCloser, + ppmShipmentUpdater services.PPMShipmentUpdater, + userUploader *uploader.UserUploader, +) error { + txnErr := appCtx.NewTransaction(func(txnAppCtx appcontext.AppContext) error { + // Need to think about whether we want any special handling if we already have an AOA packet. I don't think we will + // create more than one, but if we do, we'll need to handle it both here and on retrieval. + if ppmShipment.AOAPacketID == nil { + document := models.Document{ + ServiceMemberID: ppmShipment.Shipment.MoveTaskOrder.Orders.ServiceMember.ID, + } + + verrs, err := appCtx.DB().ValidateAndCreate(&document) + + errMsgPrefix := "failed to create AOA packet document" + + if verrs.HasAny() { + appCtx.Logger().Error(errMsgPrefix, zap.Error(verrs)) + + return fmt.Errorf("%s: %w", errMsgPrefix, verrs) + } else if err != nil { + appCtx.Logger().Error(errMsgPrefix, zap.Error(err)) + + return fmt.Errorf("%s: %w", errMsgPrefix, err) + } + + ppmShipment.AOAPacketID = &document.ID + ppmShipment.AOAPacket = &document + + ppmShipment, err = ppmShipmentUpdater.UpdatePPMShipmentWithDefaultCheck(txnAppCtx, ppmShipment, ppmShipment.Shipment.ID) + + if err != nil { + errMsgPrefix = "failed to update PPMShipment with AOA packet document" + + appCtx.Logger().Error(errMsgPrefix, zap.Error(err)) + + return fmt.Errorf("%s: %w", errMsgPrefix, err) + } + } + + fileToUpload, prepErr := userUploader.PrepareFileForUpload(txnAppCtx, aoaPacket, "aoa_packet.pdf") + + if prepErr != nil { + errMsgPrefix := "failed to prepare AOA packet for upload" + + appCtx.Logger().Error(errMsgPrefix, zap.Error(prepErr)) + + return fmt.Errorf("%s: %w", errMsgPrefix, prepErr) + } + + newUpload, uploadVerrs, uploadErr := userUploader.CreateUserUploadForDocument( + txnAppCtx, + ppmShipment.AOAPacketID, + // We're doing this on behalf of the service member, so we'll use their user ID to store the upload + ppmShipment.Shipment.MoveTaskOrder.Orders.ServiceMember.UserID, + uploader.File{File: fileToUpload}, + uploader.AllowedTypesPPMDocuments, + ) + + errMsgPrefix := "failed to upload AOA packet" + if uploadVerrs.HasAny() { + appCtx.Logger().Error(errMsgPrefix, zap.Error(uploadVerrs)) + + return fmt.Errorf("%s: %w", errMsgPrefix, uploadVerrs) + } else if uploadErr != nil { + appCtx.Logger().Error(errMsgPrefix, zap.Error(uploadErr)) + + return fmt.Errorf("%s: %w", errMsgPrefix, uploadErr) + } + + ppmShipment.AOAPacket.UserUploads = append(ppmShipment.AOAPacket.UserUploads, *newUpload) + + return nil + }) + + if txnErr != nil { + return txnErr + } + + return nil +} From 76adb4eaa0958816c9e5ac50ffd18d4148845343 Mon Sep 17 00:00:00 2001 From: Maria Traskowsky Date: Thu, 27 Feb 2025 17:03:18 +0000 Subject: [PATCH 55/71] add admin restricted UB weight to prime sim --- src/pages/PrimeUI/MoveTaskOrder/MoveDetails.jsx | 8 ++++++++ src/pages/PrimeUI/MoveTaskOrder/MoveDetails.test.jsx | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/src/pages/PrimeUI/MoveTaskOrder/MoveDetails.jsx b/src/pages/PrimeUI/MoveTaskOrder/MoveDetails.jsx index 42216ae631f..2b2543850b1 100644 --- a/src/pages/PrimeUI/MoveTaskOrder/MoveDetails.jsx +++ b/src/pages/PrimeUI/MoveTaskOrder/MoveDetails.jsx @@ -216,6 +216,14 @@ const MoveDetails = ({ setFlashMessage }) => { : 'no'} +
+
Admin Restricted UB Weight:
+
+ {moveTaskOrder.order.entitlement.ubWeightRestriction > 0 + ? formatWeight(moveTaskOrder.order.entitlement.ubWeightRestriction) + : 'no'} +
+