From 30f639a594545fd8f9004a0e17b1ad0f5315328d Mon Sep 17 00:00:00 2001 From: Daniel Jordan Date: Wed, 4 Dec 2024 21:11:45 +0000 Subject: [PATCH] initial fat commit, migration added for prod only, tests and functionality added --- migrations/app/migrations_manifest.txt | 1 + ...pm_max_and_estimated_incentives_prd.up.sql | 4 + pkg/factory/ppm_shipment_factory.go | 3 + pkg/factory/ppm_shipment_factory_test.go | 5 ++ pkg/handlers/adminapi/api.go | 5 +- pkg/handlers/adminapi/moves_test.go | 3 +- pkg/handlers/ghcapi/api.go | 4 +- .../internal/payloads/model_to_payload.go | 1 + pkg/handlers/ghcapi/move_task_order_test.go | 12 ++- pkg/handlers/ghcapi/mto_shipment_test.go | 16 ++-- pkg/handlers/ghcapi/orders_test.go | 3 +- pkg/handlers/internalapi/api.go | 2 +- pkg/handlers/internalapi/mto_shipment_test.go | 2 +- pkg/handlers/primeapi/api.go | 7 +- pkg/handlers/primeapi/move_task_order_test.go | 6 +- pkg/handlers/primeapi/mto_shipment_test.go | 3 +- pkg/handlers/primeapiv2/api.go | 5 +- pkg/handlers/primeapiv2/mto_shipment_test.go | 2 +- pkg/handlers/primeapiv3/api.go | 5 +- pkg/handlers/primeapiv3/mto_shipment_test.go | 2 +- pkg/handlers/supportapi/api.go | 5 +- .../supportapi/move_task_order_test.go | 6 +- .../move_task_order_fetcher.go | 1 + .../move_task_order_updater.go | 48 ++++++++++- .../move_task_order_updater_test.go | 80 +++++++++++++++---- .../mto_shipment/shipment_deleter_test.go | 6 +- pkg/services/ppmshipment/ppm_estimator.go | 2 +- pkg/testdatagen/scenario/shared.go | 15 +++- .../DefinitionLists/PPMShipmentInfoList.jsx | 10 +++ .../PPMShipmentInfoList.test.jsx | 11 ++- .../ServicesCounselingMoveDetails.jsx | 1 + 31 files changed, 219 insertions(+), 57 deletions(-) create mode 100644 migrations/app/secure/20241204210208_retroactive_update_of_ppm_max_and_estimated_incentives_prd.up.sql diff --git a/migrations/app/migrations_manifest.txt b/migrations/app/migrations_manifest.txt index 325df87cb39..43f9c24c03e 100644 --- a/migrations/app/migrations_manifest.txt +++ b/migrations/app/migrations_manifest.txt @@ -1048,3 +1048,4 @@ 20241127133504_add_indexes_speed_up_counseling_offices.up.sql 20241202163059_create_test_sequence_dev_env.up.sql 20241203024453_add_ppm_max_incentive_column.up.sql +20241204210208_retroactive_update_of_ppm_max_and_estimated_incentives_prd.up.sql diff --git a/migrations/app/secure/20241204210208_retroactive_update_of_ppm_max_and_estimated_incentives_prd.up.sql b/migrations/app/secure/20241204210208_retroactive_update_of_ppm_max_and_estimated_incentives_prd.up.sql new file mode 100644 index 00000000000..c389c370433 --- /dev/null +++ b/migrations/app/secure/20241204210208_retroactive_update_of_ppm_max_and_estimated_incentives_prd.up.sql @@ -0,0 +1,4 @@ +-- Local test migration. +-- This will be run on development environments. +-- It should mirror what you intend to apply on loadtest/demo/exp/stg/prd +-- DO NOT include any sensitive data. diff --git a/pkg/factory/ppm_shipment_factory.go b/pkg/factory/ppm_shipment_factory.go index 5a784916749..0306aebe547 100644 --- a/pkg/factory/ppm_shipment_factory.go +++ b/pkg/factory/ppm_shipment_factory.go @@ -71,6 +71,7 @@ func buildPPMShipmentWithBuildType(db *pop.Connection, customs []Customization, ppmShipment.ProGearWeight = models.PoundPointer(unit.Pound(1987)) ppmShipment.SpouseProGearWeight = models.PoundPointer(unit.Pound(498)) ppmShipment.EstimatedIncentive = models.CentPointer(unit.Cents(1000000)) + ppmShipment.MaxIncentive = models.CentPointer(unit.Cents(2000000)) ppmShipment.HasRequestedAdvance = models.BoolPointer(true) ppmShipment.AdvanceAmountRequested = models.CentPointer(unit.Cents(598700)) } @@ -869,12 +870,14 @@ func AddSignedCertificationToPPMShipment(db *pop.Connection, ppmShipment *models func GetTraitPPMShipmentReadyForPaymentRequest() []Customization { estimatedWeight := unit.Pound(200) estimateIncentive := unit.Cents(1000) + maxIncentive := unit.Cents(2000) return []Customization{ { Model: models.PPMShipment{ Status: models.PPMShipmentStatusWaitingOnCustomer, EstimatedWeight: &estimatedWeight, EstimatedIncentive: &estimateIncentive, + MaxIncentive: &maxIncentive, }, }, { diff --git a/pkg/factory/ppm_shipment_factory_test.go b/pkg/factory/ppm_shipment_factory_test.go index 98980603488..a2e45375ce5 100644 --- a/pkg/factory/ppm_shipment_factory_test.go +++ b/pkg/factory/ppm_shipment_factory_test.go @@ -24,6 +24,7 @@ func (suite *FactorySuite) TestBuildPPMShipment() { ProGearWeight: models.PoundPointer(unit.Pound(1987)), SpouseProGearWeight: models.PoundPointer(unit.Pound(498)), EstimatedIncentive: models.CentPointer(unit.Cents(1000000)), + MaxIncentive: models.CentPointer(unit.Cents(2000000)), HasRequestedAdvance: models.BoolPointer(true), AdvanceAmountRequested: models.CentPointer(unit.Cents(598700)), PickupAddress: &models.Address{ @@ -76,6 +77,7 @@ func (suite *FactorySuite) TestBuildPPMShipment() { suite.Equal(defaultPPM.ProGearWeight, ppmShipment.ProGearWeight) suite.Equal(defaultPPM.SpouseProGearWeight, ppmShipment.SpouseProGearWeight) suite.Equal(defaultPPM.EstimatedIncentive, ppmShipment.EstimatedIncentive) + suite.Equal(defaultPPM.MaxIncentive, ppmShipment.MaxIncentive) suite.Equal(defaultPPM.HasRequestedAdvance, ppmShipment.HasRequestedAdvance) suite.Equal(defaultPPM.AdvanceAmountRequested, ppmShipment.AdvanceAmountRequested) }) @@ -103,6 +105,7 @@ func (suite *FactorySuite) TestBuildPPMShipment() { suite.Nil(ppmShipment.ProGearWeight) suite.Nil(ppmShipment.SpouseProGearWeight) suite.Nil(ppmShipment.EstimatedIncentive) + suite.Nil(ppmShipment.MaxIncentive) suite.Nil(ppmShipment.HasRequestedAdvance) suite.Nil(ppmShipment.AdvanceAmountRequested) }) @@ -122,6 +125,7 @@ func (suite *FactorySuite) TestBuildPPMShipment() { EstimatedWeight: models.PoundPointer(unit.Pound(3000)), SpouseProGearWeight: models.PoundPointer(unit.Pound(123)), EstimatedIncentive: models.CentPointer(unit.Cents(1005000)), + MaxIncentive: models.CentPointer(unit.Cents(2005000)), HasRequestedAdvance: models.BoolPointer(true), AdvanceAmountRequested: models.CentPointer(unit.Cents(600000)), SITExpected: models.BoolPointer(true), @@ -150,6 +154,7 @@ func (suite *FactorySuite) TestBuildPPMShipment() { suite.Equal(customPPM.ProGearWeight, ppmShipment.ProGearWeight) suite.Equal(customPPM.SpouseProGearWeight, ppmShipment.SpouseProGearWeight) suite.Equal(customPPM.EstimatedIncentive, ppmShipment.EstimatedIncentive) + suite.Equal(customPPM.MaxIncentive, ppmShipment.MaxIncentive) suite.Equal(customPPM.HasRequestedAdvance, ppmShipment.HasRequestedAdvance) suite.Equal(customPPM.AdvanceAmountRequested, ppmShipment.AdvanceAmountRequested) // Check that the address and phoneline were customized diff --git a/pkg/handlers/adminapi/api.go b/pkg/handlers/adminapi/api.go index 89399c145c4..34d6729a0f2 100644 --- a/pkg/handlers/adminapi/api.go +++ b/pkg/handlers/adminapi/api.go @@ -8,6 +8,7 @@ import ( "github.com/transcom/mymove/pkg/gen/adminapi" adminops "github.com/transcom/mymove/pkg/gen/adminapi/adminoperations" "github.com/transcom/mymove/pkg/handlers" + paymentrequest "github.com/transcom/mymove/pkg/payment_request" adminuser "github.com/transcom/mymove/pkg/services/admin_user" "github.com/transcom/mymove/pkg/services/clientcert" electronicorder "github.com/transcom/mymove/pkg/services/electronic_order" @@ -21,6 +22,7 @@ import ( "github.com/transcom/mymove/pkg/services/organization" "github.com/transcom/mymove/pkg/services/pagination" prsff "github.com/transcom/mymove/pkg/services/payment_request" + "github.com/transcom/mymove/pkg/services/ppmshipment" "github.com/transcom/mymove/pkg/services/query" requestedofficeusers "github.com/transcom/mymove/pkg/services/requested_office_users" "github.com/transcom/mymove/pkg/services/roles" @@ -47,6 +49,7 @@ func NewAdminAPI(handlerConfig handlers.HandlerConfig) *adminops.MymoveAPI { queryBuilder := query.NewQueryBuilder() officeUpdater := officeuser.NewOfficeUserUpdater(queryBuilder) adminUpdater := adminuser.NewAdminUserUpdater(queryBuilder) + ppmEstimator := ppmshipment.NewEstimatePPM(handlerConfig.DTODPlanner(), &paymentrequest.RequestPaymentHelper{}) adminAPI.ServeError = handlers.ServeCustomError @@ -214,7 +217,7 @@ func NewAdminAPI(handlerConfig handlers.HandlerConfig) *adminops.MymoveAPI { movetaskorder.NewMoveTaskOrderUpdater( queryBuilder, mtoserviceitem.NewMTOServiceItemCreator(handlerConfig.HHGPlanner(), queryBuilder, moveRouter, ghcrateengine.NewDomesticUnpackPricer(), ghcrateengine.NewDomesticPackPricer(), ghcrateengine.NewDomesticLinehaulPricer(), ghcrateengine.NewDomesticShorthaulPricer(), ghcrateengine.NewDomesticOriginPricer(), ghcrateengine.NewDomesticDestinationPricer(), ghcrateengine.NewFuelSurchargePricer()), - moveRouter, signedCertificationCreator, signedCertificationUpdater, + moveRouter, signedCertificationCreator, signedCertificationUpdater, ppmEstimator, ), } diff --git a/pkg/handlers/adminapi/moves_test.go b/pkg/handlers/adminapi/moves_test.go index 8d94c95ee70..81e166a35e8 100644 --- a/pkg/handlers/adminapi/moves_test.go +++ b/pkg/handlers/adminapi/moves_test.go @@ -108,6 +108,7 @@ func (suite *HandlerSuite) TestUpdateMoveHandler() { return mockUpdater } + ppmEstimator := &mocks.PPMEstimator{} setupHandler := func() UpdateMoveHandler { builder := query.NewQueryBuilder() moveRouter := move.NewMoveRouter() @@ -122,7 +123,7 @@ func (suite *HandlerSuite) TestUpdateMoveHandler() { movetaskorder.NewMoveTaskOrderUpdater( builder, mtoserviceitem.NewMTOServiceItemCreator(planner, builder, moveRouter, ghcrateengine.NewDomesticUnpackPricer(), ghcrateengine.NewDomesticPackPricer(), ghcrateengine.NewDomesticLinehaulPricer(), ghcrateengine.NewDomesticShorthaulPricer(), ghcrateengine.NewDomesticOriginPricer(), ghcrateengine.NewDomesticDestinationPricer(), ghcrateengine.NewFuelSurchargePricer()), - moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), + moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), ppmEstimator, ), } } diff --git a/pkg/handlers/ghcapi/api.go b/pkg/handlers/ghcapi/api.go index c0ed5fa3cec..ced82280530 100644 --- a/pkg/handlers/ghcapi/api.go +++ b/pkg/handlers/ghcapi/api.go @@ -78,13 +78,13 @@ func NewGhcAPIHandler(handlerConfig handlers.HandlerConfig) *ghcops.MymoveAPI { newTransportaionOfficeAssignmentUpdater := transportaionofficeassignments.NewTransportaionOfficeAssignmentUpdater() signedCertificationCreator := signedcertification.NewSignedCertificationCreator() signedCertificationUpdater := signedcertification.NewSignedCertificationUpdater() + ppmEstimator := ppmshipment.NewEstimatePPM(handlerConfig.DTODPlanner(), &paymentrequesthelper.RequestPaymentHelper{}) moveTaskOrderUpdater := movetaskorder.NewMoveTaskOrderUpdater( queryBuilder, mtoserviceitem.NewMTOServiceItemCreator(handlerConfig.HHGPlanner(), queryBuilder, moveRouter, ghcrateengine.NewDomesticUnpackPricer(), ghcrateengine.NewDomesticPackPricer(), ghcrateengine.NewDomesticLinehaulPricer(), ghcrateengine.NewDomesticShorthaulPricer(), ghcrateengine.NewDomesticOriginPricer(), ghcrateengine.NewDomesticDestinationPricer(), ghcrateengine.NewFuelSurchargePricer()), - moveRouter, signedCertificationCreator, signedCertificationUpdater, + moveRouter, signedCertificationCreator, signedCertificationUpdater, ppmEstimator, ) - ppmEstimator := ppmshipment.NewEstimatePPM(handlerConfig.DTODPlanner(), &paymentrequesthelper.RequestPaymentHelper{}) ppmCloseoutFetcher := ppmcloseout.NewPPMCloseoutFetcher(handlerConfig.DTODPlanner(), &paymentrequesthelper.RequestPaymentHelper{}, ppmEstimator) SSWPPMComputer := shipmentsummaryworksheet.NewSSWPPMComputer(ppmCloseoutFetcher) uploadCreator := upload.NewUploadCreator(handlerConfig.FileStorer()) diff --git a/pkg/handlers/ghcapi/internal/payloads/model_to_payload.go b/pkg/handlers/ghcapi/internal/payloads/model_to_payload.go index 0c108e64937..be7119c1a55 100644 --- a/pkg/handlers/ghcapi/internal/payloads/model_to_payload.go +++ b/pkg/handlers/ghcapi/internal/payloads/model_to_payload.go @@ -982,6 +982,7 @@ func PPMShipment(_ storage.FileStorer, ppmShipment *models.PPMShipment) *ghcmess ProGearWeight: handlers.FmtPoundPtr(ppmShipment.ProGearWeight), SpouseProGearWeight: handlers.FmtPoundPtr(ppmShipment.SpouseProGearWeight), EstimatedIncentive: handlers.FmtCost(ppmShipment.EstimatedIncentive), + MaxIncentive: handlers.FmtCost(ppmShipment.MaxIncentive), HasRequestedAdvance: ppmShipment.HasRequestedAdvance, AdvanceAmountRequested: handlers.FmtCost(ppmShipment.AdvanceAmountRequested), HasReceivedAdvance: ppmShipment.HasReceivedAdvance, diff --git a/pkg/handlers/ghcapi/move_task_order_test.go b/pkg/handlers/ghcapi/move_task_order_test.go index 85232a4dc1d..10e9630fc44 100644 --- a/pkg/handlers/ghcapi/move_task_order_test.go +++ b/pkg/handlers/ghcapi/move_task_order_test.go @@ -75,6 +75,7 @@ func (suite *HandlerSuite) TestGetMoveTaskOrderHandlerIntegration() { } func (suite *HandlerSuite) TestUpdateMoveTaskOrderHandlerIntegrationSuccess() { + ppmEstimator := &mocks.PPMEstimator{} setupPricerData := func() { contract := testdatagen.FetchOrMakeReContract(suite.DB(), testdatagen.Assertions{}) @@ -193,7 +194,7 @@ func (suite *HandlerSuite) TestUpdateMoveTaskOrderHandlerIntegrationSuccess() { // setup the handler handler := UpdateMoveTaskOrderStatusHandlerFunc{handlerConfig, - movetaskorder.NewMoveTaskOrderUpdater(queryBuilder, siCreator, moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil)), + movetaskorder.NewMoveTaskOrderUpdater(queryBuilder, siCreator, moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), ppmEstimator), } // Validate incoming payload: no body to validate @@ -306,6 +307,7 @@ func (suite *HandlerSuite) TestUpdateMoveTaskOrderHandlerIntegrationWithIncomple handlerConfig := suite.HandlerConfig() queryBuilder := query.NewQueryBuilder() moveRouter := moverouter.NewMoveRouter() + ppmEstimator := &mocks.PPMEstimator{} planner := &routemocks.Planner{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), @@ -342,7 +344,7 @@ func (suite *HandlerSuite) TestUpdateMoveTaskOrderHandlerIntegrationWithIncomple // make the request handler := UpdateMoveTaskOrderStatusHandlerFunc{handlerConfig, - movetaskorder.NewMoveTaskOrderUpdater(queryBuilder, siCreator, moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil)), + movetaskorder.NewMoveTaskOrderUpdater(queryBuilder, siCreator, moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), ppmEstimator), } // Validate incoming payload: no body to validate @@ -364,6 +366,7 @@ func (suite *HandlerSuite) TestUpdateMoveTaskOrderHandlerIntegrationWithIncomple } func (suite *HandlerSuite) TestUpdateMTOStatusServiceCounselingCompletedHandler() { + ppmEstimator := &mocks.PPMEstimator{} setUpSignedCertificationCreatorMock := func(returnValue ...interface{}) services.SignedCertificationCreator { mockCreator := &mocks.SignedCertificationCreator{} @@ -402,7 +405,7 @@ func (suite *HandlerSuite) TestUpdateMTOStatusServiceCounselingCompletedHandler( siCreator := mtoserviceitem.NewMTOServiceItemCreator(planner, queryBuilder, moveRouter, ghcrateengine.NewDomesticUnpackPricer(), ghcrateengine.NewDomesticPackPricer(), ghcrateengine.NewDomesticLinehaulPricer(), ghcrateengine.NewDomesticShorthaulPricer(), ghcrateengine.NewDomesticOriginPricer(), ghcrateengine.NewDomesticDestinationPricer(), ghcrateengine.NewFuelSurchargePricer()) handler := UpdateMTOStatusServiceCounselingCompletedHandlerFunc{ handlerConfig, - movetaskorder.NewMoveTaskOrderUpdater(queryBuilder, siCreator, moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil)), + movetaskorder.NewMoveTaskOrderUpdater(queryBuilder, siCreator, moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), ppmEstimator), } return handler } @@ -599,6 +602,7 @@ func (suite *HandlerSuite) TestUpdateMTOStatusServiceCounselingCompletedHandler( } func (suite *HandlerSuite) TestUpdateMoveTIORemarksHandler() { + ppmEstimator := &mocks.PPMEstimator{} setupTestData := func() (models.Move, UpdateMoveTIORemarksHandlerFunc, models.User) { moveTaskOrder := factory.BuildMove(suite.DB(), []factory.Customization{ { @@ -646,7 +650,7 @@ func (suite *HandlerSuite) TestUpdateMoveTIORemarksHandler() { siCreator := mtoserviceitem.NewMTOServiceItemCreator(planner, queryBuilder, moveRouter, ghcrateengine.NewDomesticUnpackPricer(), ghcrateengine.NewDomesticPackPricer(), ghcrateengine.NewDomesticLinehaulPricer(), ghcrateengine.NewDomesticShorthaulPricer(), ghcrateengine.NewDomesticOriginPricer(), ghcrateengine.NewDomesticDestinationPricer(), ghcrateengine.NewFuelSurchargePricer()) handler := UpdateMoveTIORemarksHandlerFunc{ handlerConfig, - movetaskorder.NewMoveTaskOrderUpdater(queryBuilder, siCreator, moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil)), + movetaskorder.NewMoveTaskOrderUpdater(queryBuilder, siCreator, moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), ppmEstimator), } return moveTaskOrder, handler, requestUser } diff --git a/pkg/handlers/ghcapi/mto_shipment_test.go b/pkg/handlers/ghcapi/mto_shipment_test.go index fc00fb3feec..f6e1945eec7 100644 --- a/pkg/handlers/ghcapi/mto_shipment_test.go +++ b/pkg/handlers/ghcapi/mto_shipment_test.go @@ -3142,7 +3142,7 @@ func (suite *HandlerSuite) TestCreateMTOShipmentHandler() { moveTaskOrderUpdater := movetaskorder.NewMoveTaskOrderUpdater( builder, mtoserviceitem.NewMTOServiceItemCreator(planner, builder, moveRouter, ghcrateengine.NewDomesticUnpackPricer(), ghcrateengine.NewDomesticPackPricer(), ghcrateengine.NewDomesticLinehaulPricer(), ghcrateengine.NewDomesticShorthaulPricer(), ghcrateengine.NewDomesticOriginPricer(), ghcrateengine.NewDomesticDestinationPricer(), ghcrateengine.NewFuelSurchargePricer()), - moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), + moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), &ppmEstimator, ) shipmentCreator := shipmentorchestrator.NewShipmentCreator(creator, ppmCreator, boatCreator, mobileHomeCreator, shipmentRouter, moveTaskOrderUpdater) sitStatus := sitstatus.NewShipmentSITStatus() @@ -3226,7 +3226,7 @@ func (suite *HandlerSuite) TestCreateMTOShipmentHandler() { moveTaskOrderUpdater := movetaskorder.NewMoveTaskOrderUpdater( builder, mtoserviceitem.NewMTOServiceItemCreator(planner, builder, moveRouter, ghcrateengine.NewDomesticUnpackPricer(), ghcrateengine.NewDomesticPackPricer(), ghcrateengine.NewDomesticLinehaulPricer(), ghcrateengine.NewDomesticShorthaulPricer(), ghcrateengine.NewDomesticOriginPricer(), ghcrateengine.NewDomesticDestinationPricer(), ghcrateengine.NewFuelSurchargePricer()), - moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), + moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), &ppmEstimator, ) shipmentCreator := shipmentorchestrator.NewShipmentCreator(creator, ppmCreator, boatCreator, mobileHomeCreator, shipmentRouter, moveTaskOrderUpdater) sitStatus := sitstatus.NewShipmentSITStatus() @@ -3282,7 +3282,7 @@ func (suite *HandlerSuite) TestCreateMTOShipmentHandler() { moveTaskOrderUpdater := movetaskorder.NewMoveTaskOrderUpdater( builder, mtoserviceitem.NewMTOServiceItemCreator(planner, builder, moveRouter, ghcrateengine.NewDomesticUnpackPricer(), ghcrateengine.NewDomesticPackPricer(), ghcrateengine.NewDomesticLinehaulPricer(), ghcrateengine.NewDomesticShorthaulPricer(), ghcrateengine.NewDomesticOriginPricer(), ghcrateengine.NewDomesticDestinationPricer(), ghcrateengine.NewFuelSurchargePricer()), - moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), + moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), &ppmEstimator, ) shipmentCreator := shipmentorchestrator.NewShipmentCreator(creator, ppmCreator, boatCreator, mobileHomeCreator, shipmentRouter, moveTaskOrderUpdater) sitStatus := sitstatus.NewShipmentSITStatus() @@ -3334,7 +3334,7 @@ func (suite *HandlerSuite) TestCreateMTOShipmentHandler() { moveTaskOrderUpdater := movetaskorder.NewMoveTaskOrderUpdater( builder, mtoserviceitem.NewMTOServiceItemCreator(planner, builder, moveRouter, ghcrateengine.NewDomesticUnpackPricer(), ghcrateengine.NewDomesticPackPricer(), ghcrateengine.NewDomesticLinehaulPricer(), ghcrateengine.NewDomesticShorthaulPricer(), ghcrateengine.NewDomesticOriginPricer(), ghcrateengine.NewDomesticDestinationPricer(), ghcrateengine.NewFuelSurchargePricer()), - moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), + moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), &ppmEstimator, ) shipmentCreator := shipmentorchestrator.NewShipmentCreator(creator, ppmCreator, boatCreator, mobileHomeCreator, shipmentRouter, moveTaskOrderUpdater) sitStatus := sitstatus.NewShipmentSITStatus() @@ -3381,7 +3381,7 @@ func (suite *HandlerSuite) TestCreateMTOShipmentHandler() { moveTaskOrderUpdater := movetaskorder.NewMoveTaskOrderUpdater( builder, mtoserviceitem.NewMTOServiceItemCreator(planner, builder, moveRouter, ghcrateengine.NewDomesticUnpackPricer(), ghcrateengine.NewDomesticPackPricer(), ghcrateengine.NewDomesticLinehaulPricer(), ghcrateengine.NewDomesticShorthaulPricer(), ghcrateengine.NewDomesticOriginPricer(), ghcrateengine.NewDomesticDestinationPricer(), ghcrateengine.NewFuelSurchargePricer()), - moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), + moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), &ppmEstimator, ) shipmentCreator := shipmentorchestrator.NewShipmentCreator(creator, ppmCreator, boatCreator, mobileHomeCreator, shipmentRouter, moveTaskOrderUpdater) sitStatus := sitstatus.NewShipmentSITStatus() @@ -3466,7 +3466,7 @@ 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), + moveservices.NewMoveRouter(), setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), &ppmEstimator, ) shipmentCreator := shipmentorchestrator.NewShipmentCreator(creator, ppmCreator, boatCreator, mobileHomeCreator, shipmentRouter, moveTaskOrderUpdater) sitStatus := sitstatus.NewShipmentSITStatus() @@ -3676,7 +3676,7 @@ 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), + moveservices.NewMoveRouter(), setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), &ppmEstimator, ) shipmentCreator := shipmentorchestrator.NewShipmentCreator(creator, ppmshipment.NewPPMShipmentCreator(&ppmEstimator, addressCreator), boatCreator, mobileHomeCreator, shipmentRouter, moveTaskOrderUpdater) handler := CreateMTOShipmentHandler{ @@ -3826,7 +3826,7 @@ 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), + moveservices.NewMoveRouter(), setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), &ppmEstimator, ) shipmentCreator := shipmentorchestrator.NewShipmentCreator(creator, ppmshipment.NewPPMShipmentCreator(&ppmEstimator, addressCreator), boatCreator, mobileHomeCreator, shipmentRouter, moveTaskOrderUpdater) handler := CreateMTOShipmentHandler{ diff --git a/pkg/handlers/ghcapi/orders_test.go b/pkg/handlers/ghcapi/orders_test.go index 6be28b76967..93fdc901600 100644 --- a/pkg/handlers/ghcapi/orders_test.go +++ b/pkg/handlers/ghcapi/orders_test.go @@ -425,10 +425,11 @@ func (suite *HandlerSuite) TestUpdateOrderHandlerWithAmendedUploads() { return mockUpdater } + ppmEstimator := &mocks.PPMEstimator{} moveTaskOrderUpdater := movetaskorder.NewMoveTaskOrderUpdater( queryBuilder, mtoserviceitem.NewMTOServiceItemCreator(planner, queryBuilder, moveRouter, ghcrateengine.NewDomesticUnpackPricer(), ghcrateengine.NewDomesticPackPricer(), ghcrateengine.NewDomesticLinehaulPricer(), ghcrateengine.NewDomesticShorthaulPricer(), ghcrateengine.NewDomesticOriginPricer(), ghcrateengine.NewDomesticDestinationPricer(), ghcrateengine.NewFuelSurchargePricer()), - moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), + moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), ppmEstimator, ) issueDate, _ := time.Parse("2006-01-02", "2020-08-01") diff --git a/pkg/handlers/internalapi/api.go b/pkg/handlers/internalapi/api.go index cf7833eb80a..eb5386c4356 100644 --- a/pkg/handlers/internalapi/api.go +++ b/pkg/handlers/internalapi/api.go @@ -196,7 +196,7 @@ func NewInternalAPI(handlerConfig handlers.HandlerConfig) *internalops.MymoveAPI moveTaskOrderUpdater := movetaskorder.NewMoveTaskOrderUpdater( builder, mtoserviceitem.NewMTOServiceItemCreator(handlerConfig.HHGPlanner(), builder, moveRouter, ghcrateengine.NewDomesticUnpackPricer(), ghcrateengine.NewDomesticPackPricer(), ghcrateengine.NewDomesticLinehaulPricer(), ghcrateengine.NewDomesticShorthaulPricer(), ghcrateengine.NewDomesticOriginPricer(), ghcrateengine.NewDomesticDestinationPricer(), ghcrateengine.NewFuelSurchargePricer()), - moveRouter, signedCertificationCreator, signedCertificationUpdater, + moveRouter, signedCertificationCreator, signedCertificationUpdater, ppmEstimator, ) boatShipmentCreator := boatshipment.NewBoatShipmentCreator() mobileHomeShipmentCreator := mobilehomeshipment.NewMobileHomeShipmentCreator() diff --git a/pkg/handlers/internalapi/mto_shipment_test.go b/pkg/handlers/internalapi/mto_shipment_test.go index fca0de04f0b..4d2b557286f 100644 --- a/pkg/handlers/internalapi/mto_shipment_test.go +++ b/pkg/handlers/internalapi/mto_shipment_test.go @@ -108,7 +108,7 @@ func (suite *HandlerSuite) TestCreateMTOShipmentHandlerV1() { testMTOShipmentObjects.builder, mtoserviceitem.NewMTOServiceItemCreator(planner, testMTOShipmentObjects.builder, testMTOShipmentObjects.moveRouter, ghcrateengine.NewDomesticUnpackPricer(), ghcrateengine.NewDomesticPackPricer(), ghcrateengine.NewDomesticLinehaulPricer(), ghcrateengine.NewDomesticShorthaulPricer(), ghcrateengine.NewDomesticOriginPricer(), ghcrateengine.NewDomesticDestinationPricer(), ghcrateengine.NewFuelSurchargePricer()), testMTOShipmentObjects.moveRouter, - setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), + setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), &ppmEstimator, ) shipmentCreator := shipmentorchestrator.NewShipmentCreator(mtoShipmentCreator, ppmShipmentCreator, boatShipmentCreator, mobileHomeShipmentCreator, shipmentRouter, moveTaskOrderUpdater) diff --git a/pkg/handlers/primeapi/api.go b/pkg/handlers/primeapi/api.go index 25afdb43b77..79b7ff621c8 100644 --- a/pkg/handlers/primeapi/api.go +++ b/pkg/handlers/primeapi/api.go @@ -9,6 +9,7 @@ import ( "github.com/transcom/mymove/pkg/gen/primeapi/primeoperations" "github.com/transcom/mymove/pkg/handlers" paperwork "github.com/transcom/mymove/pkg/paperwork" + paymentrequesthelper "github.com/transcom/mymove/pkg/payment_request" "github.com/transcom/mymove/pkg/services/address" "github.com/transcom/mymove/pkg/services/fetch" "github.com/transcom/mymove/pkg/services/ghcrateengine" @@ -20,6 +21,7 @@ import ( order "github.com/transcom/mymove/pkg/services/order" paperwork_service "github.com/transcom/mymove/pkg/services/paperwork" paymentrequest "github.com/transcom/mymove/pkg/services/payment_request" + "github.com/transcom/mymove/pkg/services/ppmshipment" "github.com/transcom/mymove/pkg/services/query" "github.com/transcom/mymove/pkg/services/reweigh" shipmentaddressupdate "github.com/transcom/mymove/pkg/services/shipment_address_update" @@ -45,6 +47,7 @@ func NewPrimeAPI(handlerConfig handlers.HandlerConfig) *primeoperations.MymoveAP shipmentFetcher := mtoshipment.NewMTOShipmentFetcher() moveWeights := move.NewMoveWeights(mtoshipment.NewShipmentReweighRequester()) uploadCreator := upload.NewUploadCreator(handlerConfig.FileStorer()) + ppmEstimator := ppmshipment.NewEstimatePPM(handlerConfig.DTODPlanner(), &paymentrequesthelper.RequestPaymentHelper{}) serviceItemUpdater := mtoserviceitem.NewMTOServiceItemUpdater(handlerConfig.HHGPlanner(), queryBuilder, moveRouter, shipmentFetcher, addressCreator, ghcrateengine.NewDomesticUnpackPricer(), ghcrateengine.NewDomesticLinehaulPricer(), ghcrateengine.NewDomesticDestinationPricer(), ghcrateengine.NewFuelSurchargePricer(), ghcrateengine.NewDomesticDestinationSITDeliveryPricer(), ghcrateengine.NewDomesticOriginSITFuelSurchargePricer()) userUploader, err := uploader.NewUserUploader(handlerConfig.FileStorer(), uploader.MaxCustomerUserUploadFileSizeLimit) @@ -115,7 +118,7 @@ func NewPrimeAPI(handlerConfig handlers.HandlerConfig) *primeoperations.MymoveAP moveTaskOrderUpdater := movetaskorder.NewMoveTaskOrderUpdater( queryBuilder, mtoserviceitem.NewMTOServiceItemCreator(handlerConfig.HHGPlanner(), queryBuilder, moveRouter, ghcrateengine.NewDomesticUnpackPricer(), ghcrateengine.NewDomesticPackPricer(), ghcrateengine.NewDomesticLinehaulPricer(), ghcrateengine.NewDomesticShorthaulPricer(), ghcrateengine.NewDomesticOriginPricer(), ghcrateengine.NewDomesticDestinationPricer(), ghcrateengine.NewFuelSurchargePricer()), - moveRouter, signedCertificationCreator, signedCertificationUpdater, + moveRouter, signedCertificationCreator, signedCertificationUpdater, ppmEstimator, ) primeAPI.MtoShipmentDeleteMTOShipmentHandler = DeleteMTOShipmentHandler{ @@ -142,7 +145,7 @@ func NewPrimeAPI(handlerConfig handlers.HandlerConfig) *primeoperations.MymoveAP movetaskorder.NewMoveTaskOrderUpdater( queryBuilder, mtoserviceitem.NewMTOServiceItemCreator(handlerConfig.HHGPlanner(), queryBuilder, moveRouter, ghcrateengine.NewDomesticUnpackPricer(), ghcrateengine.NewDomesticPackPricer(), ghcrateengine.NewDomesticLinehaulPricer(), ghcrateengine.NewDomesticShorthaulPricer(), ghcrateengine.NewDomesticOriginPricer(), ghcrateengine.NewDomesticDestinationPricer(), ghcrateengine.NewFuelSurchargePricer()), - moveRouter, signedCertificationCreator, signedCertificationUpdater, + moveRouter, signedCertificationCreator, signedCertificationUpdater, ppmEstimator, ), movetaskorder.NewMoveTaskOrderChecker(), } diff --git a/pkg/handlers/primeapi/move_task_order_test.go b/pkg/handlers/primeapi/move_task_order_test.go index a2c50a5813c..2bfa5abfbcc 100644 --- a/pkg/handlers/primeapi/move_task_order_test.go +++ b/pkg/handlers/primeapi/move_task_order_test.go @@ -1737,8 +1737,9 @@ func (suite *HandlerSuite) TestUpdateMTOPostCounselingInfo() { return mockUpdater } + ppmEstimator := &mocks.PPMEstimator{} siCreator := mtoserviceitem.NewMTOServiceItemCreator(planner, queryBuilder, moveRouter, ghcrateengine.NewDomesticUnpackPricer(), ghcrateengine.NewDomesticPackPricer(), ghcrateengine.NewDomesticLinehaulPricer(), ghcrateengine.NewDomesticShorthaulPricer(), ghcrateengine.NewDomesticOriginPricer(), ghcrateengine.NewDomesticDestinationPricer(), ghcrateengine.NewFuelSurchargePricer()) - updater := movetaskorder.NewMoveTaskOrderUpdater(queryBuilder, siCreator, moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil)) + updater := movetaskorder.NewMoveTaskOrderUpdater(queryBuilder, siCreator, moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), ppmEstimator) mtoChecker := movetaskorder.NewMoveTaskOrderChecker() handler := UpdateMTOPostCounselingInformationHandler{ @@ -1820,8 +1821,9 @@ func (suite *HandlerSuite) TestUpdateMTOPostCounselingInfo() { return mockUpdater } + ppmEstimator := &mocks.PPMEstimator{} siCreator := mtoserviceitem.NewMTOServiceItemCreator(planner, queryBuilder, moveRouter, ghcrateengine.NewDomesticUnpackPricer(), ghcrateengine.NewDomesticPackPricer(), ghcrateengine.NewDomesticLinehaulPricer(), ghcrateengine.NewDomesticShorthaulPricer(), ghcrateengine.NewDomesticOriginPricer(), ghcrateengine.NewDomesticDestinationPricer(), ghcrateengine.NewFuelSurchargePricer()) - updater := movetaskorder.NewMoveTaskOrderUpdater(queryBuilder, siCreator, moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil)) + updater := movetaskorder.NewMoveTaskOrderUpdater(queryBuilder, siCreator, moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), ppmEstimator) handler := UpdateMTOPostCounselingInformationHandler{ suite.HandlerConfig(), fetcher, diff --git a/pkg/handlers/primeapi/mto_shipment_test.go b/pkg/handlers/primeapi/mto_shipment_test.go index df2939988a8..5b602de7873 100644 --- a/pkg/handlers/primeapi/mto_shipment_test.go +++ b/pkg/handlers/primeapi/mto_shipment_test.go @@ -441,10 +441,11 @@ func (suite *HandlerSuite) TestDeleteMTOShipmentHandler() { return mockUpdater } + ppmEstimator := &mocks.PPMEstimator{} moveTaskOrderUpdater := movetaskorder.NewMoveTaskOrderUpdater( builder, mtoserviceitem.NewMTOServiceItemCreator(planner, builder, moveRouter, ghcrateengine.NewDomesticUnpackPricer(), ghcrateengine.NewDomesticPackPricer(), ghcrateengine.NewDomesticLinehaulPricer(), ghcrateengine.NewDomesticShorthaulPricer(), ghcrateengine.NewDomesticOriginPricer(), ghcrateengine.NewDomesticDestinationPricer(), ghcrateengine.NewFuelSurchargePricer()), - moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), + moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), ppmEstimator, ) deleter := mtoshipment.NewPrimeShipmentDeleter(moveTaskOrderUpdater) handlerConfig := suite.HandlerConfig() diff --git a/pkg/handlers/primeapiv2/api.go b/pkg/handlers/primeapiv2/api.go index 362e07dbb0f..dedf3e218ac 100644 --- a/pkg/handlers/primeapiv2/api.go +++ b/pkg/handlers/primeapiv2/api.go @@ -49,12 +49,13 @@ func NewPrimeAPI(handlerConfig handlers.HandlerConfig) *primev2operations.Mymove signedCertificationCreator := signedcertification.NewSignedCertificationCreator() signedCertificationUpdater := signedcertification.NewSignedCertificationUpdater() + ppmEstimator := ppmshipment.NewEstimatePPM(handlerConfig.DTODPlanner(), &paymentrequesthelper.RequestPaymentHelper{}) + moveTaskOrderUpdater := movetaskorder.NewMoveTaskOrderUpdater( queryBuilder, mtoserviceitem.NewMTOServiceItemCreator(handlerConfig.HHGPlanner(), queryBuilder, moveRouter, ghcrateengine.NewDomesticUnpackPricer(), ghcrateengine.NewDomesticPackPricer(), ghcrateengine.NewDomesticLinehaulPricer(), ghcrateengine.NewDomesticShorthaulPricer(), ghcrateengine.NewDomesticOriginPricer(), ghcrateengine.NewDomesticDestinationPricer(), ghcrateengine.NewFuelSurchargePricer()), - moveRouter, signedCertificationCreator, signedCertificationUpdater, + moveRouter, signedCertificationCreator, signedCertificationUpdater, ppmEstimator, ) - ppmEstimator := ppmshipment.NewEstimatePPM(handlerConfig.DTODPlanner(), &paymentrequesthelper.RequestPaymentHelper{}) mtoShipmentCreator := mtoshipment.NewMTOShipmentCreatorV2(builder, fetcher, moveRouter, addressCreator) ppmShipmentCreator := ppmshipment.NewPPMShipmentCreator(ppmEstimator, addressCreator) diff --git a/pkg/handlers/primeapiv2/mto_shipment_test.go b/pkg/handlers/primeapiv2/mto_shipment_test.go index 151fff9352f..314dc9c3a5f 100644 --- a/pkg/handlers/primeapiv2/mto_shipment_test.go +++ b/pkg/handlers/primeapiv2/mto_shipment_test.go @@ -82,7 +82,7 @@ func (suite *HandlerSuite) TestCreateMTOShipmentHandler() { moveTaskOrderUpdater := movetaskorder.NewMoveTaskOrderUpdater( builder, mtoserviceitem.NewMTOServiceItemCreator(planner, builder, moveRouter, ghcrateengine.NewDomesticUnpackPricer(), ghcrateengine.NewDomesticPackPricer(), ghcrateengine.NewDomesticLinehaulPricer(), ghcrateengine.NewDomesticShorthaulPricer(), ghcrateengine.NewDomesticOriginPricer(), ghcrateengine.NewDomesticDestinationPricer(), ghcrateengine.NewFuelSurchargePricer()), - moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), + moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), &ppmEstimator, ) shipmentCreator := shipmentorchestrator.NewShipmentCreator(mtoShipmentCreator, ppmShipmentCreator, boatShipmentCreator, mobileHomeShipmentCreator, shipmentRouter, moveTaskOrderUpdater) mockCreator := mocks.ShipmentCreator{} diff --git a/pkg/handlers/primeapiv3/api.go b/pkg/handlers/primeapiv3/api.go index 7d441a87818..8365d280068 100644 --- a/pkg/handlers/primeapiv3/api.go +++ b/pkg/handlers/primeapiv3/api.go @@ -51,12 +51,13 @@ func NewPrimeAPI(handlerConfig handlers.HandlerConfig) *primev3operations.Mymove signedCertificationCreator := signedcertification.NewSignedCertificationCreator() signedCertificationUpdater := signedcertification.NewSignedCertificationUpdater() + ppmEstimator := ppmshipment.NewEstimatePPM(handlerConfig.DTODPlanner(), &paymentrequesthelper.RequestPaymentHelper{}) + moveTaskOrderUpdater := movetaskorder.NewMoveTaskOrderUpdater( queryBuilder, mtoserviceitem.NewMTOServiceItemCreator(handlerConfig.HHGPlanner(), queryBuilder, moveRouter, ghcrateengine.NewDomesticUnpackPricer(), ghcrateengine.NewDomesticPackPricer(), ghcrateengine.NewDomesticLinehaulPricer(), ghcrateengine.NewDomesticShorthaulPricer(), ghcrateengine.NewDomesticOriginPricer(), ghcrateengine.NewDomesticDestinationPricer(), ghcrateengine.NewFuelSurchargePricer()), - moveRouter, signedCertificationCreator, signedCertificationUpdater, + moveRouter, signedCertificationCreator, signedCertificationUpdater, ppmEstimator, ) - ppmEstimator := ppmshipment.NewEstimatePPM(handlerConfig.DTODPlanner(), &paymentrequesthelper.RequestPaymentHelper{}) mtoShipmentCreator := mtoshipment.NewMTOShipmentCreatorV2(builder, fetcher, moveRouter, addressCreator) ppmShipmentCreator := ppmshipment.NewPPMShipmentCreator(ppmEstimator, addressCreator) diff --git a/pkg/handlers/primeapiv3/mto_shipment_test.go b/pkg/handlers/primeapiv3/mto_shipment_test.go index 71d1d07f37c..c0443c77eb2 100644 --- a/pkg/handlers/primeapiv3/mto_shipment_test.go +++ b/pkg/handlers/primeapiv3/mto_shipment_test.go @@ -88,7 +88,7 @@ func (suite *HandlerSuite) TestCreateMTOShipmentHandler() { moveTaskOrderUpdater := movetaskorder.NewMoveTaskOrderUpdater( builder, mtoserviceitem.NewMTOServiceItemCreator(planner, builder, moveRouter, ghcrateengine.NewDomesticUnpackPricer(), ghcrateengine.NewDomesticPackPricer(), ghcrateengine.NewDomesticLinehaulPricer(), ghcrateengine.NewDomesticShorthaulPricer(), ghcrateengine.NewDomesticOriginPricer(), ghcrateengine.NewDomesticDestinationPricer(), ghcrateengine.NewFuelSurchargePricer()), - moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), + moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), &ppmEstimator, ) shipmentCreator := shipmentorchestrator.NewShipmentCreator(mtoShipmentCreator, ppmShipmentCreator, boatShipmentCreator, mobileHomeShipmentCreator, shipmentRouter, moveTaskOrderUpdater) mockCreator := mocks.ShipmentCreator{} diff --git a/pkg/handlers/supportapi/api.go b/pkg/handlers/supportapi/api.go index 1aba70b9c72..0e6232c0312 100644 --- a/pkg/handlers/supportapi/api.go +++ b/pkg/handlers/supportapi/api.go @@ -10,6 +10,7 @@ import ( "github.com/transcom/mymove/pkg/gen/supportapi" supportops "github.com/transcom/mymove/pkg/gen/supportapi/supportoperations" "github.com/transcom/mymove/pkg/handlers" + paymentrequesthelper "github.com/transcom/mymove/pkg/payment_request" "github.com/transcom/mymove/pkg/services/address" "github.com/transcom/mymove/pkg/services/fetch" "github.com/transcom/mymove/pkg/services/ghcrateengine" @@ -20,6 +21,7 @@ import ( mtoserviceitem "github.com/transcom/mymove/pkg/services/mto_service_item" mtoshipment "github.com/transcom/mymove/pkg/services/mto_shipment" paymentrequest "github.com/transcom/mymove/pkg/services/payment_request" + "github.com/transcom/mymove/pkg/services/ppmshipment" "github.com/transcom/mymove/pkg/services/query" signedcertification "github.com/transcom/mymove/pkg/services/signed_certification" internalmovetaskorder "github.com/transcom/mymove/pkg/services/support/move_task_order" @@ -48,12 +50,13 @@ func NewSupportAPIHandler(handlerConfig handlers.HandlerConfig) http.Handler { signedCertificationCreator := signedcertification.NewSignedCertificationCreator() signedCertificationUpdater := signedcertification.NewSignedCertificationUpdater() + ppmEstimator := ppmshipment.NewEstimatePPM(handlerConfig.DTODPlanner(), &paymentrequesthelper.RequestPaymentHelper{}) supportAPI.MoveTaskOrderMakeMoveTaskOrderAvailableHandler = MakeMoveTaskOrderAvailableHandlerFunc{ handlerConfig, movetaskorder.NewMoveTaskOrderUpdater( queryBuilder, mtoserviceitem.NewMTOServiceItemCreator(handlerConfig.HHGPlanner(), queryBuilder, moveRouter, ghcrateengine.NewDomesticUnpackPricer(), ghcrateengine.NewDomesticPackPricer(), ghcrateengine.NewDomesticLinehaulPricer(), ghcrateengine.NewDomesticShorthaulPricer(), ghcrateengine.NewDomesticOriginPricer(), ghcrateengine.NewDomesticDestinationPricer(), ghcrateengine.NewFuelSurchargePricer()), - moveRouter, signedCertificationCreator, signedCertificationUpdater, + moveRouter, signedCertificationCreator, signedCertificationUpdater, ppmEstimator, ), } diff --git a/pkg/handlers/supportapi/move_task_order_test.go b/pkg/handlers/supportapi/move_task_order_test.go index 08046e198d6..f10fde1438e 100644 --- a/pkg/handlers/supportapi/move_task_order_test.go +++ b/pkg/handlers/supportapi/move_task_order_test.go @@ -202,9 +202,10 @@ func (suite *HandlerSuite) TestMakeMoveAvailableHandlerIntegrationSuccess() { siCreator := mtoserviceitem.NewMTOServiceItemCreator(planner, queryBuilder, moveRouter, ghcrateengine.NewDomesticUnpackPricer(), ghcrateengine.NewDomesticPackPricer(), ghcrateengine.NewDomesticLinehaulPricer(), ghcrateengine.NewDomesticShorthaulPricer(), ghcrateengine.NewDomesticOriginPricer(), ghcrateengine.NewDomesticDestinationPricer(), ghcrateengine.NewFuelSurchargePricer()) + ppmEstimator := &mocks.PPMEstimator{} // make the request handler := MakeMoveTaskOrderAvailableHandlerFunc{handlerConfig, - movetaskorder.NewMoveTaskOrderUpdater(queryBuilder, siCreator, moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil)), + movetaskorder.NewMoveTaskOrderUpdater(queryBuilder, siCreator, moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), ppmEstimator), } response := handler.Handle(params) @@ -416,10 +417,11 @@ func (suite *HandlerSuite) TestCreateMoveTaskOrderRequestHandler() { siCreator := mtoserviceitem.NewMTOServiceItemCreator(planner, queryBuilder, moveRouter, ghcrateengine.NewDomesticUnpackPricer(), ghcrateengine.NewDomesticPackPricer(), ghcrateengine.NewDomesticLinehaulPricer(), ghcrateengine.NewDomesticShorthaulPricer(), ghcrateengine.NewDomesticOriginPricer(), ghcrateengine.NewDomesticDestinationPricer(), ghcrateengine.NewFuelSurchargePricer()) + ppmEstimator := &mocks.PPMEstimator{} // Submit the request to approve the MTO approvalHandler := MakeMoveTaskOrderAvailableHandlerFunc{ suite.HandlerConfig(), - movetaskorder.NewMoveTaskOrderUpdater(queryBuilder, siCreator, moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil)), + movetaskorder.NewMoveTaskOrderUpdater(queryBuilder, siCreator, moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), ppmEstimator), } approvalResponse := approvalHandler.Handle(approvalParams) diff --git a/pkg/services/move_task_order/move_task_order_fetcher.go b/pkg/services/move_task_order/move_task_order_fetcher.go index d0e4cdd8563..7a2227505b1 100644 --- a/pkg/services/move_task_order/move_task_order_fetcher.go +++ b/pkg/services/move_task_order/move_task_order_fetcher.go @@ -159,6 +159,7 @@ func (f moveTaskOrderFetcher) FetchMoveTaskOrder(appCtx appcontext.AppContext, s "MTOShipments.StorageFacility.Address", "MTOShipments.DeliveryAddressUpdate", "MTOShipments.DeliveryAddressUpdate.OriginalAddress.Country", + "MTOShipments.PPMShipment", "Orders.ServiceMember", "Orders.ServiceMember.ResidentialAddress.Country", "Orders.Entitlement", diff --git a/pkg/services/move_task_order/move_task_order_updater.go b/pkg/services/move_task_order/move_task_order_updater.go index 2193251209f..71389da1a3a 100644 --- a/pkg/services/move_task_order/move_task_order_updater.go +++ b/pkg/services/move_task_order/move_task_order_updater.go @@ -1,6 +1,7 @@ package movetaskorder import ( + "database/sql" "fmt" "time" @@ -10,6 +11,7 @@ import ( "github.com/transcom/mymove/pkg/appcontext" "github.com/transcom/mymove/pkg/apperror" + "github.com/transcom/mymove/pkg/db/utilities" "github.com/transcom/mymove/pkg/etag" "github.com/transcom/mymove/pkg/models" "github.com/transcom/mymove/pkg/services" @@ -24,11 +26,12 @@ type moveTaskOrderUpdater struct { moveRouter services.MoveRouter signedCertificationCreator services.SignedCertificationCreator signedCertificationUpdater services.SignedCertificationUpdater + estimator services.PPMEstimator } // NewMoveTaskOrderUpdater creates a new struct with the service dependencies -func NewMoveTaskOrderUpdater(builder UpdateMoveTaskOrderQueryBuilder, serviceItemCreator services.MTOServiceItemCreator, moveRouter services.MoveRouter, signedCertificationCreator services.SignedCertificationCreator, signedCertificationUpdater services.SignedCertificationUpdater) services.MoveTaskOrderUpdater { - return &moveTaskOrderUpdater{moveTaskOrderFetcher{}, builder, serviceItemCreator, moveRouter, signedCertificationCreator, signedCertificationUpdater} +func NewMoveTaskOrderUpdater(builder UpdateMoveTaskOrderQueryBuilder, serviceItemCreator services.MTOServiceItemCreator, moveRouter services.MoveRouter, signedCertificationCreator services.SignedCertificationCreator, signedCertificationUpdater services.SignedCertificationUpdater, estimator services.PPMEstimator) services.MoveTaskOrderUpdater { + return &moveTaskOrderUpdater{moveTaskOrderFetcher{}, builder, serviceItemCreator, moveRouter, signedCertificationCreator, signedCertificationUpdater, estimator} } // UpdateStatusServiceCounselingCompleted updates the status on the move (move task order) to service counseling completed @@ -87,6 +90,47 @@ func (o moveTaskOrderUpdater) UpdateStatusServiceCounselingCompleted(appCtx appc return err } + var ppm models.PPMShipment + err := appCtx.DB().Scope(utilities.ExcludeDeletedScope()). + EagerPreload( + "Shipment", + "WeightTickets", + "MovingExpenses", + "ProgearWeightTickets", + "W2Address.Country", + "PickupAddress.Country", + "SecondaryPickupAddress.Country", + "TertiaryPickupAddress.Country", + "DestinationAddress.Country", + "SecondaryDestinationAddress.Country", + "TertiaryDestinationAddress.Country", + ). + Where("shipment_id = ?", move.MTOShipments[i].ID).First(&ppm) + + if err != nil { + switch err { + case sql.ErrNoRows: + return apperror.NewNotFoundError(move.MTOShipments[i].ID, "while looking for PPMShipment by MTO ShipmentID") + default: + return apperror.NewQueryError("PPMShipment", err, "unable to find PPMShipment") + } + } + // if the customer has their max incentive empty in the db, we need to update this value before proceeding + if ppm.MaxIncentive == nil { + estimatedIncentive, estimatedSITCost, err := o.estimator.EstimateIncentiveWithDefaultChecks(appCtx, ppm, &ppm) + if err != nil { + return err + } + move.MTOShipments[i].PPMShipment.EstimatedIncentive = estimatedIncentive + move.MTOShipments[i].PPMShipment.SITEstimatedCost = estimatedSITCost + + maxIncentive, err := o.estimator.MaxIncentive(appCtx, ppm, &ppm) + if err != nil { + return err + } + move.MTOShipments[i].PPMShipment.MaxIncentive = maxIncentive + } + move.MTOShipments[i].PPMShipment.Status = models.PPMShipmentStatusWaitingOnCustomer now := time.Now() move.MTOShipments[i].PPMShipment.ApprovedAt = &now 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 6f0fbaba6c5..bd1e001e494 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 @@ -28,6 +28,7 @@ func (suite *MoveTaskOrderServiceSuite) TestMoveTaskOrderUpdater_UpdateStatusSer moveRouter := moverouter.NewMoveRouter() queryBuilder := query.NewQueryBuilder() planner := &routemocks.Planner{} + ppmEstimator := &mocks.PPMEstimator{} setUpSignedCertificationCreatorMock := func(returnValue ...interface{}) services.SignedCertificationCreator { mockCreator := &mocks.SignedCertificationCreator{} @@ -62,7 +63,7 @@ func (suite *MoveTaskOrderServiceSuite) TestMoveTaskOrderUpdater_UpdateStatusSer mtoUpdater := mt.NewMoveTaskOrderUpdater( queryBuilder, mtoserviceitem.NewMTOServiceItemCreator(planner, queryBuilder, moveRouter, ghcrateengine.NewDomesticUnpackPricer(), ghcrateengine.NewDomesticPackPricer(), ghcrateengine.NewDomesticLinehaulPricer(), ghcrateengine.NewDomesticShorthaulPricer(), ghcrateengine.NewDomesticOriginPricer(), ghcrateengine.NewDomesticDestinationPricer(), ghcrateengine.NewFuelSurchargePricer()), - moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), + moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), ppmEstimator, ) suite.Run("Move status is updated successfully (with HHG shipment)", func() { @@ -91,7 +92,7 @@ func (suite *MoveTaskOrderServiceSuite) TestMoveTaskOrderUpdater_UpdateStatusSer mtoUpdater2 := mt.NewMoveTaskOrderUpdater( queryBuilder, mtoserviceitem.NewMTOServiceItemCreator(planner, queryBuilder, moveRouter, ghcrateengine.NewDomesticUnpackPricer(), ghcrateengine.NewDomesticPackPricer(), ghcrateengine.NewDomesticLinehaulPricer(), ghcrateengine.NewDomesticShorthaulPricer(), ghcrateengine.NewDomesticOriginPricer(), ghcrateengine.NewDomesticDestinationPricer(), ghcrateengine.NewFuelSurchargePricer()), - moveRouter, signedcertification.NewSignedCertificationCreator(), signedcertification.NewSignedCertificationUpdater(), + moveRouter, signedcertification.NewSignedCertificationCreator(), signedcertification.NewSignedCertificationUpdater(), ppmEstimator, ) sm := factory.BuildServiceMember(suite.DB(), nil, nil) session := suite.AppContextWithSessionForTest(&auth.Session{ @@ -128,6 +129,49 @@ func (suite *MoveTaskOrderServiceSuite) TestMoveTaskOrderUpdater_UpdateStatusSer } }) + suite.Run("Move/shipment/PPM statuses are updated and estimated and max incentives are recalculated when conditions are met", func() { + mtoUpdater2 := mt.NewMoveTaskOrderUpdater( + queryBuilder, + mtoserviceitem.NewMTOServiceItemCreator(planner, queryBuilder, moveRouter, ghcrateengine.NewDomesticUnpackPricer(), ghcrateengine.NewDomesticPackPricer(), ghcrateengine.NewDomesticLinehaulPricer(), ghcrateengine.NewDomesticShorthaulPricer(), ghcrateengine.NewDomesticOriginPricer(), ghcrateengine.NewDomesticDestinationPricer(), ghcrateengine.NewFuelSurchargePricer()), + moveRouter, signedcertification.NewSignedCertificationCreator(), signedcertification.NewSignedCertificationUpdater(), ppmEstimator, + ) + sm := factory.BuildServiceMember(suite.DB(), nil, nil) + session := suite.AppContextWithSessionForTest(&auth.Session{ + ApplicationName: auth.OfficeApp, + OfficeUserID: sm.User.ID, + UserID: sm.User.ID, + FirstName: "Nelson", + LastName: "Muntz", + }) + move := factory.BuildNeedsServiceCounselingMove(suite.DB(), nil, nil) + factory.BuildPPMShipment(suite.DB(), []factory.Customization{ + { + Model: move, + LinkOnly: true, + }, + { + Model: models.PPMShipment{ + EstimatedIncentive: nil, + MaxIncentive: nil, + }, + }, + }, nil) + eTag := etag.GenerateEtag(move.UpdatedAt) + + actualMTO, err := mtoUpdater2.UpdateStatusServiceCounselingCompleted(session, move.ID, eTag) + + suite.NoError(err) + suite.NotZero(actualMTO.ID) + suite.NotNil(actualMTO.ServiceCounselingCompletedAt) + suite.Equal(models.MoveStatusAPPROVED, actualMTO.Status) + for _, shipment := range actualMTO.MTOShipments { + suite.Equal(models.MTOShipmentStatusApproved, shipment.Status) + ppmShipment := *shipment.PPMShipment + suite.NotNil(ppmShipment.EstimatedIncentive) + suite.NotNil(ppmShipment.MaxIncentive) + } + }) + suite.Run("Move/shipment/PPM statuses are updated successfully (with HHG and PPM shipment)", func() { session := suite.AppContextWithSessionForTest(&auth.Session{ ApplicationName: auth.OfficeApp, @@ -297,6 +341,7 @@ func (suite *MoveTaskOrderServiceSuite) TestMoveTaskOrderUpdater_UpdatePostCouns queryBuilder := query.NewQueryBuilder() moveRouter := moverouter.NewMoveRouter() planner := &routemocks.Planner{} + ppmEstimator := &mocks.PPMEstimator{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), mock.Anything, @@ -331,7 +376,7 @@ func (suite *MoveTaskOrderServiceSuite) TestMoveTaskOrderUpdater_UpdatePostCouns mtoUpdater := mt.NewMoveTaskOrderUpdater( queryBuilder, mtoserviceitem.NewMTOServiceItemCreator(planner, queryBuilder, moveRouter, ghcrateengine.NewDomesticUnpackPricer(), ghcrateengine.NewDomesticPackPricer(), ghcrateengine.NewDomesticLinehaulPricer(), ghcrateengine.NewDomesticShorthaulPricer(), ghcrateengine.NewDomesticOriginPricer(), ghcrateengine.NewDomesticDestinationPricer(), ghcrateengine.NewFuelSurchargePricer()), - moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), + moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), ppmEstimator, ) suite.Run("MTO post counseling information is updated successfully", func() { @@ -463,6 +508,7 @@ func (suite *MoveTaskOrderServiceSuite) TestMoveTaskOrderUpdater_ShowHide() { queryBuilder := query.NewQueryBuilder() moveRouter := moverouter.NewMoveRouter() planner := &routemocks.Planner{} + ppmEstimator := &mocks.PPMEstimator{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), mock.Anything, @@ -497,7 +543,7 @@ func (suite *MoveTaskOrderServiceSuite) TestMoveTaskOrderUpdater_ShowHide() { updater := mt.NewMoveTaskOrderUpdater( queryBuilder, mtoserviceitem.NewMTOServiceItemCreator(planner, queryBuilder, moveRouter, ghcrateengine.NewDomesticUnpackPricer(), ghcrateengine.NewDomesticPackPricer(), ghcrateengine.NewDomesticLinehaulPricer(), ghcrateengine.NewDomesticShorthaulPricer(), ghcrateengine.NewDomesticOriginPricer(), ghcrateengine.NewDomesticDestinationPricer(), ghcrateengine.NewFuelSurchargePricer()), - moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), + moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), ppmEstimator, ) // Case: Move successfully deactivated @@ -602,6 +648,7 @@ func (suite *MoveTaskOrderServiceSuite) TestMoveTaskOrderUpdater_ShowHide() { } func (suite *MoveTaskOrderServiceSuite) TestMoveTaskOrderUpdater_MakeAvailableToPrime() { + ppmEstimator := &mocks.PPMEstimator{} setUpSignedCertificationCreatorMock := func(returnValue ...interface{}) services.SignedCertificationCreator { mockCreator := &mocks.SignedCertificationCreator{} @@ -667,7 +714,7 @@ func (suite *MoveTaskOrderServiceSuite) TestMoveTaskOrderUpdater_MakeAvailableTo mockserviceItemCreator := &mocks.MTOServiceItemCreator{} queryBuilder := query.NewQueryBuilder() moveRouter := moverouter.NewMoveRouter() - mtoUpdater := mt.NewMoveTaskOrderUpdater(queryBuilder, mockserviceItemCreator, moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil)) + 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) eTag := etag.GenerateEtag(move.UpdatedAt) @@ -687,7 +734,7 @@ func (suite *MoveTaskOrderServiceSuite) TestMoveTaskOrderUpdater_MakeAvailableTo mockserviceItemCreator := &mocks.MTOServiceItemCreator{} queryBuilder := query.NewQueryBuilder() moveRouter := moverouter.NewMoveRouter() - mtoUpdater := mt.NewMoveTaskOrderUpdater(queryBuilder, mockserviceItemCreator, moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil)) + mtoUpdater := mt.NewMoveTaskOrderUpdater(queryBuilder, mockserviceItemCreator, moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), ppmEstimator) move := factory.BuildSubmittedMove(suite.DB(), nil, nil) @@ -709,7 +756,7 @@ func (suite *MoveTaskOrderServiceSuite) TestMoveTaskOrderUpdater_MakeAvailableTo mock.Anything, ).Return(400, nil) 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)) + mtoUpdater := mt.NewMoveTaskOrderUpdater(queryBuilder, serviceItemCreator, moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), ppmEstimator) move := factory.BuildMoveWithShipment(suite.DB(), nil, nil) eTag := etag.GenerateEtag(move.UpdatedAt) @@ -747,7 +794,7 @@ func (suite *MoveTaskOrderServiceSuite) TestMoveTaskOrderUpdater_MakeAvailableTo mock.Anything, ).Return(400, nil) 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)) + mtoUpdater := mt.NewMoveTaskOrderUpdater(queryBuilder, serviceItemCreator, moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), ppmEstimator) move := factory.BuildMoveWithShipment(suite.DB(), nil, nil) eTag := etag.GenerateEtag(move.UpdatedAt) @@ -776,7 +823,7 @@ func (suite *MoveTaskOrderServiceSuite) TestMoveTaskOrderUpdater_MakeAvailableTo moveRouter := moverouter.NewMoveRouter() 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)) + mtoUpdater := mt.NewMoveTaskOrderUpdater(queryBuilder, serviceItemCreator, moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), ppmEstimator) move := factory.BuildMoveWithShipment(suite.DB(), nil, nil) eTag := etag.GenerateEtag(move.UpdatedAt) @@ -804,7 +851,7 @@ func (suite *MoveTaskOrderServiceSuite) TestMoveTaskOrderUpdater_MakeAvailableTo queryBuilder := query.NewQueryBuilder() moveRouter := moverouter.NewMoveRouter() mockserviceItemCreator := &mocks.MTOServiceItemCreator{} - mtoUpdater := mt.NewMoveTaskOrderUpdater(queryBuilder, mockserviceItemCreator, moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil)) + mtoUpdater := mt.NewMoveTaskOrderUpdater(queryBuilder, mockserviceItemCreator, moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), ppmEstimator) move := factory.BuildMoveWithShipment(suite.DB(), nil, nil) eTag := etag.GenerateEtag(move.UpdatedAt) @@ -827,7 +874,7 @@ func (suite *MoveTaskOrderServiceSuite) TestMoveTaskOrderUpdater_MakeAvailableTo mockserviceItemCreator := &mocks.MTOServiceItemCreator{} queryBuilder := query.NewQueryBuilder() moveRouter := moverouter.NewMoveRouter() - mtoUpdater := mt.NewMoveTaskOrderUpdater(queryBuilder, mockserviceItemCreator, moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil)) + mtoUpdater := mt.NewMoveTaskOrderUpdater(queryBuilder, mockserviceItemCreator, moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), ppmEstimator) orderWithoutDefaults := factory.BuildOrderWithoutDefaults(suite.DB(), nil, nil) move := factory.BuildServiceCounselingCompletedMove(suite.DB(), []factory.Customization{ @@ -852,6 +899,7 @@ func (suite *MoveTaskOrderServiceSuite) TestMoveTaskOrderUpdater_MakeAvailableTo } func (suite *MoveTaskOrderServiceSuite) TestMoveTaskOrderUpdater_BillableWeightsReviewedAt() { + ppmEstimator := &mocks.PPMEstimator{} setUpSignedCertificationCreatorMock := func(returnValue ...interface{}) services.SignedCertificationCreator { mockCreator := &mocks.SignedCertificationCreator{} @@ -881,7 +929,7 @@ func (suite *MoveTaskOrderServiceSuite) TestMoveTaskOrderUpdater_BillableWeights mockserviceItemCreator := &mocks.MTOServiceItemCreator{} queryBuilder := query.NewQueryBuilder() moveRouter := moverouter.NewMoveRouter() - mtoUpdater := mt.NewMoveTaskOrderUpdater(queryBuilder, mockserviceItemCreator, moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil)) + 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) @@ -895,7 +943,7 @@ func (suite *MoveTaskOrderServiceSuite) TestMoveTaskOrderUpdater_BillableWeights mockserviceItemCreator := &mocks.MTOServiceItemCreator{} queryBuilder := query.NewQueryBuilder() moveRouter := moverouter.NewMoveRouter() - mtoUpdater := mt.NewMoveTaskOrderUpdater(queryBuilder, mockserviceItemCreator, moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil)) + mtoUpdater := mt.NewMoveTaskOrderUpdater(queryBuilder, mockserviceItemCreator, moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), ppmEstimator) move := factory.BuildSubmittedMove(suite.DB(), nil, nil) @@ -909,6 +957,7 @@ func (suite *MoveTaskOrderServiceSuite) TestMoveTaskOrderUpdater_BillableWeights func (suite *MoveTaskOrderServiceSuite) TestMoveTaskOrderUpdater_TIORemarks() { remarks := "Reweigh requested" mockserviceItemCreator := &mocks.MTOServiceItemCreator{} + ppmEstimator := &mocks.PPMEstimator{} queryBuilder := query.NewQueryBuilder() moveRouter := moverouter.NewMoveRouter() @@ -937,7 +986,7 @@ func (suite *MoveTaskOrderServiceSuite) TestMoveTaskOrderUpdater_TIORemarks() { return mockUpdater } - mtoUpdater := mt.NewMoveTaskOrderUpdater(queryBuilder, mockserviceItemCreator, moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil)) + mtoUpdater := mt.NewMoveTaskOrderUpdater(queryBuilder, mockserviceItemCreator, moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), ppmEstimator) suite.Run("Service item creator is not called if move fails to get approved", func() { move := factory.BuildMove(suite.DB(), nil, nil) eTag := etag.GenerateEtag(move.UpdatedAt) @@ -987,6 +1036,7 @@ func (suite *MoveTaskOrderServiceSuite) TestMoveTaskOrderUpdater_UpdatePPMType() queryBuilder := query.NewQueryBuilder() moveRouter := moverouter.NewMoveRouter() planner := &routemocks.Planner{} + ppmEstimator := &mocks.PPMEstimator{} planner.On("ZipTransitDistance", mock.AnythingOfType("*appcontext.appContext"), mock.Anything, @@ -1021,7 +1071,7 @@ func (suite *MoveTaskOrderServiceSuite) TestMoveTaskOrderUpdater_UpdatePPMType() updater := mt.NewMoveTaskOrderUpdater( queryBuilder, mtoserviceitem.NewMTOServiceItemCreator(planner, queryBuilder, moveRouter, ghcrateengine.NewDomesticUnpackPricer(), ghcrateengine.NewDomesticPackPricer(), ghcrateengine.NewDomesticLinehaulPricer(), ghcrateengine.NewDomesticShorthaulPricer(), ghcrateengine.NewDomesticOriginPricer(), ghcrateengine.NewDomesticDestinationPricer(), ghcrateengine.NewFuelSurchargePricer()), - moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), + moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), ppmEstimator, ) // Case: When there is only PPM shipment diff --git a/pkg/services/mto_shipment/shipment_deleter_test.go b/pkg/services/mto_shipment/shipment_deleter_test.go index 6c4df8daeb0..1e0ca2796f6 100644 --- a/pkg/services/mto_shipment/shipment_deleter_test.go +++ b/pkg/services/mto_shipment/shipment_deleter_test.go @@ -56,10 +56,11 @@ func (suite *MTOShipmentServiceSuite) TestShipmentDeleter() { return mockUpdater } + ppmEstimator := &mocks.PPMEstimator{} moveTaskOrderUpdater := movetaskorder.NewMoveTaskOrderUpdater( builder, mtoserviceitem.NewMTOServiceItemCreator(planner, builder, moveRouter, ghcrateengine.NewDomesticUnpackPricer(), ghcrateengine.NewDomesticPackPricer(), ghcrateengine.NewDomesticLinehaulPricer(), ghcrateengine.NewDomesticShorthaulPricer(), ghcrateengine.NewDomesticOriginPricer(), ghcrateengine.NewDomesticDestinationPricer(), ghcrateengine.NewFuelSurchargePricer()), - moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), + moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), ppmEstimator, ) suite.Run("Returns an error when shipment is not found", func() { shipmentDeleter := NewShipmentDeleter(moveTaskOrderUpdater, moveRouter) @@ -285,10 +286,11 @@ func (suite *MTOShipmentServiceSuite) TestPrimeShipmentDeleter() { return mockUpdater } + ppmEstimator := &mocks.PPMEstimator{} moveTaskOrderUpdater := movetaskorder.NewMoveTaskOrderUpdater( builder, mtoserviceitem.NewMTOServiceItemCreator(planner, builder, moveRouter, ghcrateengine.NewDomesticUnpackPricer(), ghcrateengine.NewDomesticPackPricer(), ghcrateengine.NewDomesticLinehaulPricer(), ghcrateengine.NewDomesticShorthaulPricer(), ghcrateengine.NewDomesticOriginPricer(), ghcrateengine.NewDomesticDestinationPricer(), ghcrateengine.NewFuelSurchargePricer()), - moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), + moveRouter, setUpSignedCertificationCreatorMock(nil, nil), setUpSignedCertificationUpdaterMock(nil, nil), ppmEstimator, ) suite.Run("Doesn't return an error when allowed to delete a shipment", func() { shipmentDeleter := NewPrimeShipmentDeleter(moveTaskOrderUpdater) diff --git a/pkg/services/ppmshipment/ppm_estimator.go b/pkg/services/ppmshipment/ppm_estimator.go index 0125fb5c395..e49d7846bbe 100644 --- a/pkg/services/ppmshipment/ppm_estimator.go +++ b/pkg/services/ppmshipment/ppm_estimator.go @@ -130,7 +130,7 @@ func (f *estimatePPM) PriceBreakdown(appCtx appcontext.AppContext, ppmShipment * } func shouldSkipEstimatingIncentive(newPPMShipment *models.PPMShipment, oldPPMShipment *models.PPMShipment) bool { - if oldPPMShipment.Status != models.PPMShipmentStatusDraft && oldPPMShipment.EstimatedIncentive != nil && *newPPMShipment.EstimatedIncentive == 0 { + if oldPPMShipment.Status != models.PPMShipmentStatusDraft && oldPPMShipment.EstimatedIncentive != nil && *newPPMShipment.EstimatedIncentive == 0 || oldPPMShipment.MaxIncentive == nil { return false } else { return oldPPMShipment.ExpectedDepartureDate.Equal(newPPMShipment.ExpectedDepartureDate) && diff --git a/pkg/testdatagen/scenario/shared.go b/pkg/testdatagen/scenario/shared.go index 7b4b2bb4e22..ff96a3c6362 100644 --- a/pkg/testdatagen/scenario/shared.go +++ b/pkg/testdatagen/scenario/shared.go @@ -17,8 +17,10 @@ import ( "github.com/transcom/mymove/pkg/factory" fakedata "github.com/transcom/mymove/pkg/fakedata_approved" "github.com/transcom/mymove/pkg/gen/internalmessages" + "github.com/transcom/mymove/pkg/handlers" "github.com/transcom/mymove/pkg/models" "github.com/transcom/mymove/pkg/models/roles" + paymentrequesthelper "github.com/transcom/mymove/pkg/payment_request" "github.com/transcom/mymove/pkg/random" routemocks "github.com/transcom/mymove/pkg/route/mocks" "github.com/transcom/mymove/pkg/services" @@ -28,6 +30,7 @@ import ( mtoserviceitem "github.com/transcom/mymove/pkg/services/mto_service_item" mtoshipment "github.com/transcom/mymove/pkg/services/mto_shipment" paymentrequest "github.com/transcom/mymove/pkg/services/payment_request" + "github.com/transcom/mymove/pkg/services/ppmshipment" "github.com/transcom/mymove/pkg/services/query" signedcertification "github.com/transcom/mymove/pkg/services/signed_certification" "github.com/transcom/mymove/pkg/testdatagen" @@ -4214,7 +4217,9 @@ func createHHGWithOriginSITServiceItems( signedCertificationCreator := signedcertification.NewSignedCertificationCreator() signedCertificationUpdater := signedcertification.NewSignedCertificationUpdater() - mtoUpdater := movetaskorder.NewMoveTaskOrderUpdater(queryBuilder, serviceItemCreator, moveRouter, signedCertificationCreator, signedCertificationUpdater) + handlerConfig := handlers.Config{} + ppmEstimator := ppmshipment.NewEstimatePPM(handlerConfig.DTODPlanner(), &paymentrequesthelper.RequestPaymentHelper{}) + mtoUpdater := movetaskorder.NewMoveTaskOrderUpdater(queryBuilder, serviceItemCreator, moveRouter, signedCertificationCreator, signedCertificationUpdater, ppmEstimator) _, approveErr := mtoUpdater.MakeAvailableToPrime(appCtx, move.ID, etag.GenerateEtag(move.UpdatedAt), true, true) if approveErr != nil { @@ -4480,7 +4485,9 @@ func createHHGWithDestinationSITServiceItems(appCtx appcontext.AppContext, prime ////////////////////////////////////////////////// signedCertificationCreator := signedcertification.NewSignedCertificationCreator() signedCertificationUpdater := signedcertification.NewSignedCertificationUpdater() - mtoUpdater := movetaskorder.NewMoveTaskOrderUpdater(queryBuilder, serviceItemCreator, moveRouter, signedCertificationCreator, signedCertificationUpdater) + handlerConfig := handlers.Config{} + ppmEstimator := ppmshipment.NewEstimatePPM(handlerConfig.DTODPlanner(), &paymentrequesthelper.RequestPaymentHelper{}) + mtoUpdater := movetaskorder.NewMoveTaskOrderUpdater(queryBuilder, serviceItemCreator, moveRouter, signedCertificationCreator, signedCertificationUpdater, ppmEstimator) _, approveErr := mtoUpdater.MakeAvailableToPrime(appCtx, move.ID, etag.GenerateEtag(move.UpdatedAt), true, true) // AvailableToPrimeAt is set to the current time when a move is approved, we need to update it to fall within the @@ -4886,7 +4893,9 @@ func createHHGWithPaymentServiceItems( ////////////////////////////////////////////////// signedCertificationCreator := signedcertification.NewSignedCertificationCreator() signedCertificationUpdater := signedcertification.NewSignedCertificationUpdater() - mtoUpdater := movetaskorder.NewMoveTaskOrderUpdater(queryBuilder, serviceItemCreator, moveRouter, signedCertificationCreator, signedCertificationUpdater) + handlerConfig := handlers.Config{} + ppmEstimator := ppmshipment.NewEstimatePPM(handlerConfig.DTODPlanner(), &paymentrequesthelper.RequestPaymentHelper{}) + mtoUpdater := movetaskorder.NewMoveTaskOrderUpdater(queryBuilder, serviceItemCreator, moveRouter, signedCertificationCreator, signedCertificationUpdater, ppmEstimator) _, approveErr := mtoUpdater.MakeAvailableToPrime(appCtx, move.ID, etag.GenerateEtag(move.UpdatedAt), true, true) // AvailableToPrimeAt is set to the current time when a move is approved, we need to update it to fall within the diff --git a/src/components/Office/DefinitionLists/PPMShipmentInfoList.jsx b/src/components/Office/DefinitionLists/PPMShipmentInfoList.jsx index cbdea94f4e5..921b354a4ad 100644 --- a/src/components/Office/DefinitionLists/PPMShipmentInfoList.jsx +++ b/src/components/Office/DefinitionLists/PPMShipmentInfoList.jsx @@ -36,6 +36,7 @@ const PPMShipmentInfoList = ({ status, destinationAddress, estimatedIncentive, + maxIncentive, estimatedWeight, expectedDepartureDate, actualMoveDate, @@ -208,6 +209,14 @@ const PPMShipmentInfoList = ({ ); + const maxIncentiveElementFlags = getDisplayFlags('estimatedIncentive'); + const maxIncentiveElement = ( +
+
Max Incentive
+
{maxIncentive ? `$${formatCentsTruncateWhole(maxIncentive)}` : '-'}
+
+ ); + const hasRequestedAdvanceElementFlags = getDisplayFlags('hasRequestedAdvance'); const hasRequestedAdvanceElement = (
@@ -292,6 +301,7 @@ const PPMShipmentInfoList = ({ {showElement(proGearWeightElementFlags) && proGearWeightElement} {showElement(spouseProGearElementFlags) && spouseProGearElement} {showElement(estimatedIncentiveElementFlags) && estimatedIncentiveElement} + {showElement(maxIncentiveElementFlags) && maxIncentiveElement} {hasRequestedAdvanceElement} {hasRequestedAdvance === true && advanceStatusElement} {(advanceStatus === ADVANCE_STATUSES.APPROVED.apiValue || advanceStatus === ADVANCE_STATUSES.EDITED.apiValue) && diff --git a/src/components/Office/DefinitionLists/PPMShipmentInfoList.test.jsx b/src/components/Office/DefinitionLists/PPMShipmentInfoList.test.jsx index c3bdbf16254..38ada146779 100644 --- a/src/components/Office/DefinitionLists/PPMShipmentInfoList.test.jsx +++ b/src/components/Office/DefinitionLists/PPMShipmentInfoList.test.jsx @@ -24,7 +24,7 @@ afterEach(() => { const renderWithPermissions = (shipment) => { render( - + , ); }; @@ -65,6 +65,15 @@ describe('PPMShipmentInfoList', () => { expect(screen.getByText('Closeout office')).toBeInTheDocument(); }); + it('renders estimated and max incentives', () => { + renderWithPermissions({ ppmShipment: { estimatedIncentive: 100000, maxIncentive: 200000 } }); + expect(screen.getByTestId('estimatedIncentive')).toBeInTheDocument(); + expect(screen.getByText('Estimated Incentive')).toBeInTheDocument(); + + expect(screen.getByTestId('maxIncentive')).toBeInTheDocument(); + expect(screen.getByText('Max Incentive')).toBeInTheDocument(); + }); + it('PPM Download AOA Paperwork - success with Approved', async () => { const mockResponse = { ok: true, diff --git a/src/pages/Office/ServicesCounselingMoveDetails/ServicesCounselingMoveDetails.jsx b/src/pages/Office/ServicesCounselingMoveDetails/ServicesCounselingMoveDetails.jsx index f5832565551..72e34c80d33 100644 --- a/src/pages/Office/ServicesCounselingMoveDetails/ServicesCounselingMoveDetails.jsx +++ b/src/pages/Office/ServicesCounselingMoveDetails/ServicesCounselingMoveDetails.jsx @@ -449,6 +449,7 @@ const ServicesCounselingMoveDetails = ({ onSuccess: (data) => { queryClient.setQueryData([MOVES, data.locator], data); queryClient.invalidateQueries([MOVES, data.locator]); + queryClient.invalidateQueries({ queryKey: [MTO_SHIPMENTS] }); setAlertMessage('Move submitted.'); setAlertType('success'); },