diff --git a/package.json b/package.json index dd62ac38317..5181af460f9 100644 --- a/package.json +++ b/package.json @@ -73,7 +73,7 @@ "redux-thunk": "^2.4.2", "regenerator-runtime": "^0.13.11", "reselect": "^4.1.8", - "sass": "^1.63.6", + "sass": "^1.77.6", "swagger-client": "^3.18.5", "swagger-ui-dist": "^5.2.0", "uswds": "2.13.3", diff --git a/pkg/services/order/order_fetcher.go b/pkg/services/order/order_fetcher.go index 0547c9f1e49..7cd76f07867 100644 --- a/pkg/services/order/order_fetcher.go +++ b/pkg/services/order/order_fetcher.go @@ -175,7 +175,7 @@ func (f orderFetcher) ListOrders(appCtx appcontext.AppContext, officeUserID uuid if *params.NeedsPPMCloseout { query.InnerJoin("ppm_shipments", "ppm_shipments.shipment_id = mto_shipments.id"). LeftJoin("transportation_offices as closeout_to", "closeout_to.id = moves.closeout_office_id"). - Where("ppm_shipments.status IN (?)", models.PPMShipmentStatusWaitingOnCustomer, models.PPMShipmentStatusNeedsCloseout, models.PPMShipmentStatusCloseoutComplete). + Where("ppm_shipments.status IN (?)", models.PPMShipmentStatusWaitingOnCustomer, models.PPMShipmentStatusNeedsCloseout). Where("service_members.affiliation NOT IN (?)", models.AffiliationNAVY, models.AffiliationMARINES, models.AffiliationCOASTGUARD) } else { query.LeftJoin("ppm_shipments", "ppm_shipments.shipment_id = mto_shipments.id"). diff --git a/pkg/services/order/order_fetcher_test.go b/pkg/services/order/order_fetcher_test.go index 83f3a68b44c..e44ce4730bf 100644 --- a/pkg/services/order/order_fetcher_test.go +++ b/pkg/services/order/order_fetcher_test.go @@ -633,9 +633,87 @@ func (suite *OrderServiceSuite) TestListOrdersUSMCGBLOC() { }) } +func getMoveNeedsServiceCounseling(suite *OrderServiceSuite, showMove bool, affiliation models.ServiceMemberAffiliation) models.Move { + nonCloseoutMove := factory.BuildMove(suite.DB(), []factory.Customization{ + { + Model: models.Move{ + Status: models.MoveStatusNeedsServiceCounseling, + Show: &showMove, + }, + }, + { + Model: models.ServiceMember{ + Affiliation: &affiliation, + }, + }, + }, nil) + + return nonCloseoutMove +} + +func getSubmittedMove(suite *OrderServiceSuite, showMove bool, affiliation models.ServiceMemberAffiliation) models.Move { + move := factory.BuildMove(suite.DB(), []factory.Customization{ + { + Model: models.Move{ + Status: models.MoveStatusSUBMITTED, + Show: &showMove, + }, + }, + { + Model: models.ServiceMember{ + Affiliation: &affiliation, + }, + }, + }, nil) + return move +} + +func buildPPMShipmentNeedsCloseout(suite *OrderServiceSuite, move models.Move) models.PPMShipment { + ppm := factory.BuildMinimalPPMShipment(suite.DB(), []factory.Customization{ + { + Model: models.PPMShipment{ + Status: models.PPMShipmentStatusNeedsCloseout, + }, + }, + { + Model: move, + LinkOnly: true, + }, + }, nil) + return ppm +} + +func buildPPMShipmentDraft(suite *OrderServiceSuite, move models.Move) models.PPMShipment { + ppm := factory.BuildMinimalPPMShipment(suite.DB(), []factory.Customization{ + { + Model: models.PPMShipment{ + Status: models.PPMShipmentStatusDraft, + }, + }, + { + Model: move, + LinkOnly: true, + }, + }, nil) + return ppm +} + +func buildPPMShipmentCloseoutComplete(suite *OrderServiceSuite, move models.Move) models.PPMShipment { + ppm := factory.BuildMinimalPPMShipment(suite.DB(), []factory.Customization{ + { + Model: models.PPMShipment{ + Status: models.PPMShipmentStatusCloseoutComplete, + }, + }, + { + Model: move, + LinkOnly: true, + }, + }, nil) + return ppm +} func (suite *OrderServiceSuite) TestListOrdersPPMCloseoutForArmyAirforce() { orderFetcher := NewOrderFetcher() - showMove := true var session auth.Session @@ -650,84 +728,14 @@ func (suite *OrderServiceSuite) TestListOrdersPPMCloseoutForArmyAirforce() { AccessToken: "fakeAccessToken", } - army := models.AffiliationARMY - move := factory.BuildMove(suite.DB(), []factory.Customization{ - { - Model: models.Move{ - Status: models.MoveStatusNeedsServiceCounseling, - Show: &showMove, - }, - }, - { - Model: models.ServiceMember{ - Affiliation: &army, - }, - }, - }, nil) - factory.BuildMinimalPPMShipment(suite.DB(), []factory.Customization{ - { - Model: models.PPMShipment{ - Status: models.PPMShipmentStatusNeedsCloseout, - }, - }, - { - Model: move, - LinkOnly: true, - }, - }, nil) - // Moves that are not ready for closeout should not show in this queue - af := models.AffiliationAIRFORCE - afMove := factory.BuildMove(suite.DB(), []factory.Customization{ - { - Model: models.Move{ - Status: models.MoveStatusNeedsServiceCounseling, - Show: &showMove, - }, - }, - { - Model: models.ServiceMember{ - Affiliation: &af, - }, - }, - }, nil) - factory.BuildMinimalPPMShipment(suite.DB(), []factory.Customization{ - { - Model: models.PPMShipment{ - Status: models.PPMShipmentStatusDraft, - }, - }, - { - Model: afMove, - LinkOnly: true, - }, - }, nil) - // Coast guard moves should not show up in our office user's closeout queue - cg := models.AffiliationCOASTGUARD - cgMove := factory.BuildMove(suite.DB(), []factory.Customization{ - { - Model: models.Move{ - Status: models.MoveStatusNeedsServiceCounseling, - Show: &showMove, - }, - }, - { - Model: models.ServiceMember{ - Affiliation: &cg, - }, - }, - }, nil) + move := getMoveNeedsServiceCounseling(suite, true, models.AffiliationARMY) + buildPPMShipmentNeedsCloseout(suite, move) - factory.BuildMinimalPPMShipment(suite.DB(), []factory.Customization{ - { - Model: models.PPMShipment{ - Status: models.PPMShipmentStatusNeedsCloseout, - }, - }, - { - Model: cgMove, - LinkOnly: true, - }, - }, nil) + afMove := getMoveNeedsServiceCounseling(suite, true, models.AffiliationAIRFORCE) + buildPPMShipmentDraft(suite, afMove) + + cgMove := getMoveNeedsServiceCounseling(suite, true, models.AffiliationCOASTGUARD) + buildPPMShipmentNeedsCloseout(suite, cgMove) params := services.ListOrderParams{PerPage: models.Int64Pointer(9), Page: models.Int64Pointer(1), NeedsPPMCloseout: models.BoolPointer(true), Status: []string{string(models.MoveStatusNeedsServiceCounseling)}} moves, _, err := orderFetcher.ListOrders(suite.AppContextWithSessionForTest(&session), officeUserSC.ID, ¶ms) @@ -748,58 +756,13 @@ func (suite *OrderServiceSuite) TestListOrdersPPMCloseoutForArmyAirforce() { AccessToken: "fakeAccessToken", } - // PPM moves that need closeout should not show up in counseling queue - army := models.AffiliationARMY - closeoutMove := factory.BuildMove(suite.DB(), []factory.Customization{ - { - Model: models.Move{ - Status: models.MoveStatusNeedsServiceCounseling, - Show: &showMove, - }, - }, - { - Model: models.ServiceMember{ - Affiliation: &army, - }, - }, - }, nil) - factory.BuildMinimalPPMShipment(suite.DB(), []factory.Customization{ - { - Model: models.PPMShipment{ - Status: models.PPMShipmentStatusNeedsCloseout, - }, - }, - { - Model: closeoutMove, - LinkOnly: true, - }, - }, nil) + closeoutMove := getMoveNeedsServiceCounseling(suite, true, models.AffiliationARMY) + buildPPMShipmentCloseoutComplete(suite, closeoutMove) + // PPM moves that are not in one of the closeout statuses - airforce := models.AffiliationAIRFORCE - nonCloseoutMove := factory.BuildMove(suite.DB(), []factory.Customization{ - { - Model: models.Move{ - Status: models.MoveStatusNeedsServiceCounseling, - Show: &showMove, - }, - }, - { - Model: models.ServiceMember{ - Affiliation: &airforce, - }, - }, - }, nil) - factory.BuildMinimalPPMShipment(suite.DB(), []factory.Customization{ - { - Model: models.PPMShipment{ - Status: models.PPMShipmentStatusDraft, - }, - }, - { - Model: nonCloseoutMove, - LinkOnly: true, - }, - }, nil) + nonCloseoutMove := getMoveNeedsServiceCounseling(suite, true, models.AffiliationAIRFORCE) + buildPPMShipmentDraft(suite, nonCloseoutMove) + params := services.ListOrderParams{PerPage: models.Int64Pointer(9), Page: models.Int64Pointer(1), NeedsPPMCloseout: models.BoolPointer(false), Status: []string{string(models.MoveStatusNeedsServiceCounseling)}} moves, _, err := orderFetcher.ListOrders(suite.AppContextWithSessionForTest(&session), officeUserSC.ID, ¶ms) @@ -812,62 +775,16 @@ func (suite *OrderServiceSuite) TestListOrdersPPMCloseoutForArmyAirforce() { func (suite *OrderServiceSuite) TestListOrdersPPMCloseoutForNavyCoastGuardAndMarines() { orderFetcher := NewOrderFetcher() - showMove := true suite.Run("returns Navy order for NAVY office user when there's a ppm shipment in closeout", func() { - navy := models.AffiliationNAVY // It doesn't matter what the Origin GBLOC is for the move. Only the navy // affiliation matters for SC who are tied to the NAVY GBLOC. - move := factory.BuildMove(suite.DB(), []factory.Customization{ - { - Model: models.Move{ - Status: models.MoveStatusSUBMITTED, - Show: &showMove, - }, - }, - { - Model: models.ServiceMember{ - Affiliation: &navy, - }, - }, - }, nil) - factory.BuildMinimalPPMShipment(suite.DB(), []factory.Customization{ - { - Model: models.PPMShipment{ - Status: models.PPMShipmentStatusNeedsCloseout, - }, - }, - { - Model: move, - LinkOnly: true, - }, - }, nil) + move := getSubmittedMove(suite, true, models.AffiliationNAVY) + buildPPMShipmentNeedsCloseout(suite, move) + + cgMove := getSubmittedMove(suite, true, models.AffiliationCOASTGUARD) + buildPPMShipmentNeedsCloseout(suite, cgMove) - cg := models.AffiliationCOASTGUARD - cgMove := factory.BuildMove(suite.DB(), []factory.Customization{ - { - Model: models.Move{ - Status: models.MoveStatusSUBMITTED, - Show: &showMove, - }, - }, - { - Model: models.ServiceMember{ - Affiliation: &cg, - }, - }, - }, nil) - factory.BuildMinimalPPMShipment(suite.DB(), []factory.Customization{ - { - Model: models.PPMShipment{ - Status: models.PPMShipmentStatusNeedsCloseout, - }, - }, - { - Model: cgMove, - LinkOnly: true, - }, - }, nil) officeUserSC := factory.BuildOfficeUserWithRoles(suite.DB(), []factory.Customization{ { Model: models.TransportationOffice{ @@ -894,58 +811,14 @@ func (suite *OrderServiceSuite) TestListOrdersPPMCloseoutForNavyCoastGuardAndMar }) suite.Run("returns TVCB order for TVCB office user when there's a ppm shipment in closeout", func() { - marines := models.AffiliationMARINES // It doesn't matter what the Origin GBLOC is for the move. Only the marines // affiliation matters for SC who are tied to the TVCB GBLOC. - move := factory.BuildMove(suite.DB(), []factory.Customization{ - { - Model: models.Move{ - Status: models.MoveStatusSUBMITTED, - Show: &showMove, - }, - }, - { - Model: models.ServiceMember{ - Affiliation: &marines, - }, - }, - }, nil) - factory.BuildMinimalPPMShipment(suite.DB(), []factory.Customization{ - { - Model: models.PPMShipment{ - Status: models.PPMShipmentStatusNeedsCloseout, - }, - }, - { - Model: move, - LinkOnly: true, - }, - }, nil) - army := models.AffiliationARMY - nonMarineMove := factory.BuildMove(suite.DB(), []factory.Customization{ - { - Model: models.Move{ - Status: models.MoveStatusSUBMITTED, - Show: &showMove, - }, - }, - { - Model: models.ServiceMember{ - Affiliation: &army, - }, - }, - }, nil) - factory.BuildMinimalPPMShipment(suite.DB(), []factory.Customization{ - { - Model: models.PPMShipment{ - Status: models.PPMShipmentStatusNeedsCloseout, - }, - }, - { - Model: nonMarineMove, - LinkOnly: true, - }, - }, nil) + move := getSubmittedMove(suite, true, models.AffiliationMARINES) + buildPPMShipmentNeedsCloseout(suite, move) + + nonMarineMove := getSubmittedMove(suite, true, models.AffiliationARMY) + buildPPMShipmentNeedsCloseout(suite, nonMarineMove) + officeUserSC := factory.BuildOfficeUserWithRoles(suite.DB(), []factory.Customization{ { Model: models.TransportationOffice{ @@ -972,58 +845,14 @@ func (suite *OrderServiceSuite) TestListOrdersPPMCloseoutForNavyCoastGuardAndMar }) suite.Run("returns coast guard order for USCG office user when there's a ppm shipment in closeout and filters out non coast guard moves", func() { - cg := models.AffiliationCOASTGUARD // It doesn't matter what the Origin GBLOC is for the move. Only the coast guard // affiliation matters for SC who are tied to the USCG GBLOC. - move := factory.BuildMove(suite.DB(), []factory.Customization{ - { - Model: models.Move{ - Status: models.MoveStatusSUBMITTED, - Show: &showMove, - }, - }, - { - Model: models.ServiceMember{ - Affiliation: &cg, - }, - }, - }, nil) - factory.BuildMinimalPPMShipment(suite.DB(), []factory.Customization{ - { - Model: models.PPMShipment{ - Status: models.PPMShipmentStatusNeedsCloseout, - }, - }, - { - Model: move, - LinkOnly: true, - }, - }, nil) - army := models.AffiliationARMY - armyMove := factory.BuildMove(suite.DB(), []factory.Customization{ - { - Model: models.Move{ - Status: models.MoveStatusSUBMITTED, - Show: &showMove, - }, - }, - { - Model: models.ServiceMember{ - Affiliation: &army, - }, - }, - }, nil) - factory.BuildMinimalPPMShipment(suite.DB(), []factory.Customization{ - { - Model: models.PPMShipment{ - Status: models.PPMShipmentStatusNeedsCloseout, - }, - }, - { - Model: armyMove, - LinkOnly: true, - }, - }, nil) + move := getSubmittedMove(suite, true, models.AffiliationCOASTGUARD) + buildPPMShipmentNeedsCloseout(suite, move) + + armyMove := getSubmittedMove(suite, true, models.AffiliationARMY) + buildPPMShipmentNeedsCloseout(suite, armyMove) + officeUserSC := factory.BuildOfficeUserWithRoles(suite.DB(), []factory.Customization{ { Model: models.TransportationOffice{ @@ -1049,32 +878,10 @@ func (suite *OrderServiceSuite) TestListOrdersPPMCloseoutForNavyCoastGuardAndMar }) suite.Run("Filters out moves with PPM shipments not in the status of NeedsApproval", func() { - cg := models.AffiliationCOASTGUARD - cgMoveInWrongStatus := factory.BuildMove(suite.DB(), []factory.Customization{ - { - Model: models.Move{ - Status: models.MoveStatusSUBMITTED, - Show: &showMove, - }, - }, - { - Model: models.ServiceMember{ - Affiliation: &cg, - }, - }, - }, nil) - factory.BuildMinimalPPMShipment(suite.DB(), []factory.Customization{ - { - Model: models.PPMShipment{ - Status: models.PPMShipmentStatusCloseoutComplete, - }, - }, - { - Model: cgMoveInWrongStatus, - LinkOnly: true, - }, - }, nil) + cgMoveInWrongStatus := getSubmittedMove(suite, true, models.AffiliationCOASTGUARD) + buildPPMShipmentCloseoutComplete(suite, cgMoveInWrongStatus) + officeUserSC := factory.BuildOfficeUserWithRoles(suite.DB(), []factory.Customization{ { Model: models.TransportationOffice{ @@ -1091,21 +898,8 @@ func (suite *OrderServiceSuite) TestListOrdersPPMCloseoutForNavyCoastGuardAndMar }) suite.Run("Filters out moves with no PPM shipment", func() { - cg := models.AffiliationCOASTGUARD - moveWithHHG := factory.BuildMove(suite.DB(), []factory.Customization{ - { - Model: models.Move{ - Status: models.MoveStatusSUBMITTED, - Show: &showMove, - }, - }, - { - Model: models.ServiceMember{ - Affiliation: &cg, - }, - }, - }, nil) + moveWithHHG := getSubmittedMove(suite, true, models.AffiliationCOASTGUARD) factory.BuildMTOShipment(suite.DB(), []factory.Customization{ { Model: models.MTOShipment{ @@ -1465,6 +1259,27 @@ func (suite *OrderServiceSuite) TestListOrdersWithSortOrder() { }) } +func getTransportationOffice(suite *OrderServiceSuite, name string) models.TransportationOffice { + trasportationOffice := factory.BuildTransportationOffice(suite.DB(), []factory.Customization{ + { + Model: models.TransportationOffice{ + Name: name, + }, + }}, nil) + return trasportationOffice +} + +func getPPMShipmentWithCloseoutOfficeNeedsCloseout(suite *OrderServiceSuite, closeoutOffice models.TransportationOffice) models.PPMShipment { + ppm := factory.BuildPPMShipmentThatNeedsCloseout(suite.DB(), nil, []factory.Customization{ + { + Model: closeoutOffice, + LinkOnly: true, + Type: &factory.TransportationOffices.CloseoutOffice, + }, + }) + return ppm +} + func (suite *OrderServiceSuite) TestListOrdersNeedingServicesCounselingWithPPMCloseoutColumnsSort() { defaultShipmentPickupPostalCode := "90210" setupTestData := func() models.OfficeUser { @@ -1549,32 +1364,11 @@ func (suite *OrderServiceSuite) TestListOrdersNeedingServicesCounselingWithPPMCl suite.Run("Sort by PPM closeout location", func() { officeUser := setupTestData() - locationA := factory.BuildTransportationOffice(suite.DB(), []factory.Customization{ - { - Model: models.TransportationOffice{ - Name: "A", - }, - }}, nil) - ppmShipmentA := factory.BuildPPMShipmentThatNeedsCloseout(suite.DB(), nil, []factory.Customization{ - { - Model: locationA, - LinkOnly: true, - Type: &factory.TransportationOffices.CloseoutOffice, - }, - }) - locationB := factory.BuildTransportationOffice(suite.DB(), []factory.Customization{ - { - Model: models.TransportationOffice{ - Name: "B", - }, - }}, nil) - ppmShipmentB := factory.BuildPPMShipmentThatNeedsCloseout(suite.DB(), nil, []factory.Customization{ - { - Model: locationB, - LinkOnly: true, - Type: &factory.TransportationOffices.CloseoutOffice, - }, - }) + locationA := getTransportationOffice(suite, "A") + ppmShipmentA := getPPMShipmentWithCloseoutOfficeNeedsCloseout(suite, locationA) + + locationB := getTransportationOffice(suite, "B") + ppmShipmentB := getPPMShipmentWithCloseoutOfficeNeedsCloseout(suite, locationB) // Sort by closeout location (ascending) moves, _, err := orderFetcher.ListOrders(suite.AppContextWithSessionForTest(&session), officeUser.ID, &services.ListOrderParams{ @@ -1737,13 +1531,7 @@ func (suite *OrderServiceSuite) TestListOrdersNeedingServicesCounselingWithPPMCl Model: models.TransportationOffice{Gbloc: "KKFA"}, }, }, nil) - ppmShipmentNeedsCloseout := factory.BuildPPMShipmentThatNeedsCloseout(suite.DB(), nil, []factory.Customization{ - { - Model: closeoutOffice, - LinkOnly: true, - Type: &factory.TransportationOffices.CloseoutOffice, - }, - }) + ppmShipmentNeedsCloseout := getPPMShipmentWithCloseoutOfficeNeedsCloseout(suite, closeoutOffice) ppmShipmentWaitingOnCustomer := factory.BuildPPMShipmentWaitingOnCustomer(suite.DB(), nil, []factory.Customization{ { Model: closeoutOffice, diff --git a/yarn.lock b/yarn.lock index 6d1e12f846e..a21c0c0ec0d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -15345,19 +15345,10 @@ sass-loader@^12.3.0: klona "^2.0.4" neo-async "^2.6.2" -sass@^1.63.6: - version "1.63.6" - resolved "https://registry.yarnpkg.com/sass/-/sass-1.63.6.tgz#481610e612902e0c31c46b46cf2dad66943283ea" - integrity sha512-MJuxGMHzaOW7ipp+1KdELtqKbfAWbH7OLIdoSMnVe3EXPMTmxTmlaZDCTsgIpPCs3w99lLo9/zDKkOrJuT5byw== - dependencies: - chokidar ">=3.0.0 <4.0.0" - immutable "^4.0.0" - source-map-js ">=0.6.2 <2.0.0" - -sass@^1.77.2: - version "1.77.4" - resolved "https://registry.yarnpkg.com/sass/-/sass-1.77.4.tgz#92059c7bfc56b827c56eb116778d157ec017a5cd" - integrity sha512-vcF3Ckow6g939GMA4PeU7b2K/9FALXk2KF9J87txdHzXbUF9XRQRwSxcAs/fGaTnJeBFd7UoV22j3lzMLdM0Pw== +sass@^1.77.2, sass@^1.77.6: + version "1.77.6" + resolved "https://registry.yarnpkg.com/sass/-/sass-1.77.6.tgz#898845c1348078c2e6d1b64f9ee06b3f8bd489e4" + integrity sha512-ByXE1oLD79GVq9Ht1PeHWCPMPB8XHpBuz1r85oByKHjZY6qV6rWnQovQzXJXuQ/XyE1Oj3iPk3lo28uzaRA2/Q== dependencies: chokidar ">=3.0.0 <4.0.0" immutable "^4.0.0"