Skip to content

Commit

Permalink
Merge pull request #14497 from transcom/B-22148-main
Browse files Browse the repository at this point in the history
B 22148 main - Assigned User Cleanup [BE] - PPM Closeout
  • Loading branch information
pambecker authored Jan 14, 2025
2 parents 345a61e + 7838746 commit c45a1d6
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 2 deletions.
1 change: 1 addition & 0 deletions pkg/services/ppmshipment/ppm_shipment_fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ func FindPPMShipment(appCtx appcontext.AppContext, id uuid.UUID) (*models.PPMShi
err := appCtx.DB().Scope(utilities.ExcludeDeletedScope()).
EagerPreload(
"Shipment",
"Shipment.MoveTaskOrder",
"WeightTickets",
"MovingExpenses",
"ProgearWeightTickets",
Expand Down
10 changes: 9 additions & 1 deletion pkg/services/ppmshipment/ppm_shipment_review_documents.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (p *ppmShipmentReviewDocuments) SubmitReviewedDocuments(appCtx appcontext.A
if err != nil {
return err
}

updatedPPMShipment.Shipment.MoveTaskOrder.SCAssignedID = nil
err = validatePPMShipment(appCtx, updatedPPMShipment, ppmShipment, &ppmShipment.Shipment, PPMShipmentUpdaterChecks...)

if err != nil {
Expand All @@ -74,6 +74,14 @@ func (p *ppmShipmentReviewDocuments) SubmitReviewedDocuments(appCtx appcontext.A
return apperror.NewQueryError("PPMShipment", err, "unable to update PPMShipment")
}

verrs, err = appCtx.DB().ValidateAndSave(&updatedPPMShipment.Shipment.MoveTaskOrder)
if verrs != nil && verrs.HasAny() {
return apperror.NewInvalidInputError(updatedPPMShipment.ID, nil, verrs, "")
}
if err != nil {
return err
}

err = p.signCertificationPPMCloseout(appCtx, updatedPPMShipment.Shipment.MoveTaskOrderID, updatedPPMShipment.ID)

if err != nil {
Expand Down
42 changes: 41 additions & 1 deletion pkg/services/ppmshipment/ppm_shipment_review_documents_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/transcom/mymove/pkg/auth"
"github.com/transcom/mymove/pkg/factory"
"github.com/transcom/mymove/pkg/models"
"github.com/transcom/mymove/pkg/models/roles"
"github.com/transcom/mymove/pkg/services"
"github.com/transcom/mymove/pkg/services/mocks"
signedcertification "github.com/transcom/mymove/pkg/services/signed_certification"
Expand Down Expand Up @@ -126,7 +127,6 @@ func (suite *PPMShipmentSuite) TestReviewDocuments() {

suite.Run("Can route the PPMShipment properly", func() {
existingPPMShipment := factory.BuildPPMShipmentThatNeedsCloseout(suite.DB(), nil, nil)

sm := factory.BuildServiceMember(suite.DB(), nil, nil)
session := suite.AppContextWithSessionForTest(&auth.Session{
ApplicationName: auth.OfficeApp,
Expand All @@ -135,6 +135,43 @@ func (suite *PPMShipmentSuite) TestReviewDocuments() {
FirstName: "Nelson",
LastName: "Muntz",
})
setupTestData := func() models.OfficeUser {

transportationOffice := factory.BuildTransportationOffice(suite.DB(), []factory.Customization{
{
Model: models.TransportationOffice{
ProvidesCloseout: true,
},
},
}, nil)

officeUser := factory.BuildOfficeUserWithRoles(suite.DB(), []factory.Customization{
{
Model: transportationOffice,
LinkOnly: true,
Type: &factory.TransportationOffices.CloseoutOffice,
},
}, []roles.RoleType{roles.RoleTypeServicesCounselor})

return officeUser
}

officeUser := setupTestData()
move := factory.BuildMoveWithShipment(suite.DB(), []factory.Customization{
{
Model: models.Move{
Status: models.MoveStatusNeedsServiceCounseling,
},
},
{
Model: officeUser,
LinkOnly: true,
Type: &factory.OfficeUsers.SCAssignedUser,
},
}, nil)

existingPPMShipment.Shipment.MoveTaskOrder = move
suite.NotNil(existingPPMShipment.Shipment.MoveTaskOrder.SCAssignedID)

router := setUpPPMShipperRouterMock(
func(_ appcontext.AppContext, ppmShipment *models.PPMShipment) error {
Expand All @@ -154,6 +191,9 @@ func (suite *PPMShipmentSuite) TestReviewDocuments() {
existingPPMShipment.ID,
)

//check removal of the SC Assigned User
suite.Nil(updatedPPMShipment.Shipment.MoveTaskOrder.SCAssignedID)

if suite.NoError(err) && suite.NotNil(updatedPPMShipment) {
suite.Equal(models.PPMShipmentStatusCloseoutComplete, updatedPPMShipment.Status)

Expand Down

0 comments on commit c45a1d6

Please sign in to comment.