Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

B-21359 - Backend: Assigned User Cleanup #14330

Merged
merged 48 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
5278ebb
Backend: Assigned User Cleanup
JonSpight Dec 4, 2024
f0a199f
Removed white space
JonSpight Dec 4, 2024
fd2351d
fixed placement
JonSpight Dec 6, 2024
35b2cdd
TIO/TOO assigned user removal
JonSpight Dec 10, 2024
4acfe7e
Payment Requset rejection - remove assigend user
JonSpight Dec 11, 2024
b1b8320
removed strings
JonSpight Dec 11, 2024
2af7532
added Test
JonSpight Dec 11, 2024
a30a370
Added test for test coverage
JonSpight Dec 12, 2024
09fa6b3
deeper test
JonSpight Dec 12, 2024
2614c41
Merge branch 'main' into B-21359-main
JonSpight Dec 12, 2024
4622222
Another backend test case
JonSpight Dec 12, 2024
def3c3e
Added Test cases
JonSpight Dec 13, 2024
27ed6a4
added test case
JonSpight Dec 13, 2024
14ac5b5
Merge branch 'main' into B-21359-main
JonSpight Dec 13, 2024
0f572e4
Added Test coverage
JonSpight Dec 13, 2024
b6620cf
:wq
JonSpight Dec 13, 2024
88a1376
Added Test Coverage
JonSpight Dec 13, 2024
04bf157
Added test Coverage
JonSpight Dec 13, 2024
b7896a9
Added TIO removal test case
JonSpight Dec 17, 2024
e1fa85d
cleaned up tests
JonSpight Dec 17, 2024
f6b2281
Merge branch 'main' into B-21359-main
JonSpight Dec 17, 2024
a841cbe
PR Fixes
JonSpight Dec 17, 2024
c8586ed
Merge branch 'B-21359-main' of https://github.com/transcom/mymove int…
JonSpight Dec 17, 2024
0bbc3c4
PR fix - name change
JonSpight Dec 17, 2024
a061005
PR fix - line removal
JonSpight Dec 17, 2024
90a455a
Validate&save
JonSpight Dec 18, 2024
9714cdf
Proper TOO service item removal
JonSpight Dec 18, 2024
06493d5
add factory stuff for SC and TOO
paulstonebraker Dec 18, 2024
f07c194
TOO assigned user tests
JonSpight Dec 18, 2024
e5d834d
Unfinished Handler -> service
JonSpight Dec 20, 2024
9b11c9d
trying something new with service
paulstonebraker Dec 20, 2024
bab025e
Updated Service
JonSpight Dec 20, 2024
87bbd7d
Merge branch 'main' into B-21359-main
JonSpight Dec 20, 2024
81aa903
updated mocks
JonSpight Dec 20, 2024
108e8de
Removed old code
JonSpight Dec 23, 2024
d9ca18c
fixed files
JonSpight Dec 23, 2024
416d9e8
Added SC and TOO test cases
JonSpight Dec 23, 2024
09ad1ed
PR changes
JonSpight Dec 24, 2024
6cf130b
Merge branch 'main' into B-21359-main
JonSpight Dec 31, 2024
67d3f7a
Merge branch 'main' into B-21359-main
JonSpight Jan 8, 2025
1155ac2
removed tests
JonSpight Jan 8, 2025
9713b2c
PR comments
JonSpight Jan 8, 2025
3782891
Merge branch 'main' into B-21359-main
JonSpight Jan 13, 2025
f1c6633
Merge branch 'main' into B-21359-main
JonSpight Jan 13, 2025
7dfef82
fixced merge conflicts
JonSpight Jan 13, 2025
28ce85b
PR Fixes
JonSpight Jan 13, 2025
a3eada6
moved SC to match INT placement
JonSpight Jan 13, 2025
eaeacf9
Merge branch 'main' into B-21359-main
paulstonebraker Jan 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 34 additions & 8 deletions pkg/factory/move_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,6 @@ func BuildMove(db *pop.Connection, customs []Customization, traits []Trait) mode
closeoutOffice = BuildTransportationOffice(db, tempCloseoutOfficeCustoms, nil)
}

var counselingOffice models.TransportationOffice
tempCounselingOfficeCustoms := customs
counselingOfficeResult := findValidCustomization(customs, TransportationOffices.CounselingOffice)
if counselingOfficeResult != nil {
tempCounselingOfficeCustoms = convertCustomizationInList(tempCounselingOfficeCustoms, TransportationOffices.CounselingOffice, TransportationOffice)
counselingOffice = BuildTransportationOffice(db, tempCounselingOfficeCustoms, nil)
}

var scAssignedUser models.OfficeUser
pambecker marked this conversation as resolved.
Show resolved Hide resolved
tempSCAssignedUserCustoms := customs
scAssignedUserResult := findValidCustomization(customs, OfficeUsers.SCAssignedUser)
Expand All @@ -51,6 +43,30 @@ func BuildMove(db *pop.Connection, customs []Customization, traits []Trait) mode
scAssignedUser = BuildOfficeUser(db, tempSCAssignedUserCustoms, nil)
}

var tooAssignedUser models.OfficeUser
pambecker marked this conversation as resolved.
Show resolved Hide resolved
tempTOOAssignedUserCustoms := customs
tooAssignedUserResult := findValidCustomization(customs, OfficeUsers.TOOAssignedUser)
if tooAssignedUserResult != nil {
tempTOOAssignedUserCustoms = convertCustomizationInList(tempTOOAssignedUserCustoms, OfficeUsers.TOOAssignedUser, OfficeUser)
tooAssignedUser = BuildOfficeUser(db, tempTOOAssignedUserCustoms, nil)
}

var tioAssignedUser models.OfficeUser
tempTIOAssignedUserCustoms := customs
tioAssignedUserResult := findValidCustomization(customs, OfficeUsers.TIOAssignedUser)
if tioAssignedUserResult != nil {
tempTIOAssignedUserCustoms = convertCustomizationInList(tempTIOAssignedUserCustoms, OfficeUsers.TIOAssignedUser, OfficeUser)
tioAssignedUser = BuildOfficeUser(db, tempTIOAssignedUserCustoms, nil)
}

pambecker marked this conversation as resolved.
Show resolved Hide resolved
var counselingOffice models.TransportationOffice
tempCounselingOfficeCustoms := customs
counselingOfficeResult := findValidCustomization(customs, TransportationOffices.CounselingOffice)
if counselingOfficeResult != nil {
tempCounselingOfficeCustoms = convertCustomizationInList(tempCounselingOfficeCustoms, TransportationOffices.CounselingOffice, TransportationOffice)
counselingOffice = BuildTransportationOffice(db, tempCounselingOfficeCustoms, nil)
}

var defaultReferenceID string
var err error
if db != nil {
Expand Down Expand Up @@ -89,6 +105,16 @@ func BuildMove(db *pop.Connection, customs []Customization, traits []Trait) mode
move.CloseoutOfficeID = &closeoutOffice.ID
}

if tooAssignedUserResult != nil {
pambecker marked this conversation as resolved.
Show resolved Hide resolved
move.TOOAssignedUser = &tooAssignedUser
move.TOOAssignedID = &tooAssignedUser.ID
}

if tioAssignedUserResult != nil {
move.TIOAssignedUser = &tioAssignedUser
move.TIOAssignedID = &tioAssignedUser.ID
}

if counselingOfficeResult != nil {
move.CounselingOffice = &counselingOffice
move.CounselingOfficeID = &counselingOffice.ID
Expand Down
53 changes: 53 additions & 0 deletions pkg/factory/move_factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,59 @@ func (suite *FactorySuite) TestBuildMove() {
suite.NotEmpty(move.MTOShipments)
suite.Equal(models.MTOShipmentStatusSubmitted, move.MTOShipments[0].Status)
})
suite.Run("Successful creation of a move with an assigned SC", func() {
officeUser := BuildOfficeUserWithRoles(suite.DB(), nil, []roles.RoleType{roles.RoleTypeServicesCounselor})

move := BuildMoveWithShipment(suite.DB(), []Customization{
{
Model: models.Move{
Status: models.MoveStatusAPPROVED,
},
},
{
Model: officeUser,
LinkOnly: true,
Type: &OfficeUsers.SCAssignedUser,
},
}, nil)
suite.Equal(officeUser.ID, *move.SCAssignedID)
})

suite.Run("Successful creation of a move with an assigned TOO", func() {
officeUser := BuildOfficeUserWithRoles(suite.DB(), nil, []roles.RoleType{roles.RoleTypeTOO})

move := BuildMoveWithShipment(suite.DB(), []Customization{
{
Model: models.Move{
Status: models.MoveStatusAPPROVED,
},
},
{
Model: officeUser,
LinkOnly: true,
Type: &OfficeUsers.TOOAssignedUser,
},
}, nil)
suite.Equal(officeUser.ID, *move.TOOAssignedID)
})

suite.Run("Successful creation of a move with an assigned TIO", func() {
officeUser := BuildOfficeUserWithRoles(suite.DB(), nil, []roles.RoleType{roles.RoleTypeTIO})

move := BuildMoveWithShipment(suite.DB(), []Customization{
{
Model: models.Move{
Status: models.MoveStatusAPPROVED,
},
},
{
Model: officeUser,
LinkOnly: true,
Type: &OfficeUsers.TIOAssignedUser,
},
}, nil)
suite.Equal(officeUser.ID, *move.TIOAssignedID)
})

suite.Run("Successful creation of customized move with shipment", func() {
// Under test: BuildMoveWithShipment
Expand Down
8 changes: 6 additions & 2 deletions pkg/factory/shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,11 +274,15 @@ var TransportationOffices = transportationOfficeGroup{
}

type officeUserGroup struct {
SCAssignedUser CustomType
SCAssignedUser CustomType
TIOAssignedUser CustomType
TOOAssignedUser CustomType
}

var OfficeUsers = officeUserGroup{
SCAssignedUser: "SCAssignedUser",
SCAssignedUser: "SCAssignedUser",
TIOAssignedUser: "TIOAssignedUser",
TOOAssignedUser: "TOOAssignedUser",
}

// uploadGroup is a grouping of all the upload related fields
Expand Down
162 changes: 161 additions & 1 deletion pkg/handlers/ghcapi/internal/payloads/model_to_payload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,98 @@ import (
"github.com/transcom/mymove/pkg/models"
"github.com/transcom/mymove/pkg/models/roles"
"github.com/transcom/mymove/pkg/storage/test"
"github.com/transcom/mymove/pkg/unit"
)

func TestOrder(_ *testing.T) {
order := &models.Order{}
Order(order)
}

func (suite *PayloadsSuite) TestOrderWithMove() {
move := factory.BuildMove(suite.DB(), nil, nil)
moves := models.Moves{}
moves = append(moves, move)
order := factory.BuildOrder(nil, []factory.Customization{
{
Model: models.Order{
ID: uuid.Must(uuid.NewV4()),
HasDependents: *models.BoolPointer(true),
Moves: moves,
},
},
}, nil)
Order(&order)
}

func (suite *PayloadsSuite) TestBoatShipment() {
boat := factory.BuildBoatShipment(suite.DB(), nil, nil)
boatShipment := BoatShipment(nil, &boat)
suite.NotNil(boatShipment)

}

func (suite *PayloadsSuite) TestMobileHomeShipment() {
mobileHome := factory.BuildMobileHomeShipment(suite.DB(), nil, nil)
mobileHomeShipment := MobileHomeShipment(nil, &mobileHome)
suite.NotNil(mobileHomeShipment)
}

func (suite *PayloadsSuite) TestMovingExpense() {
contractExpense := models.MovingExpenseReceiptTypeContractedExpense
weightStored := 2000
sitLocation := models.SITLocationTypeDestination
sitReimburseableAmount := 500

movingExpense := models.MovingExpense{
PPMShipmentID: uuid.Must(uuid.NewV4()),
DocumentID: uuid.Must(uuid.NewV4()),
MovingExpenseType: &contractExpense,
Reason: models.StringPointer("no good"),
SITStartDate: models.TimePointer(time.Now()),
SITEndDate: models.TimePointer(time.Now()),
WeightStored: (*unit.Pound)(&weightStored),
SITLocation: &sitLocation,
SITReimburseableAmount: (*unit.Cents)(&sitReimburseableAmount),
}
movingExpenseValues := MovingExpense(nil, &movingExpense)
suite.NotNil(movingExpenseValues)
}

func (suite *PayloadsSuite) TestMovingExpenses() {
contractExpense := models.MovingExpenseReceiptTypeContractedExpense
weightStored := 2000
sitLocation := models.SITLocationTypeDestination
sitReimburseableAmount := 500
movingExpenses := models.MovingExpenses{}

movingExpense := models.MovingExpense{
PPMShipmentID: uuid.Must(uuid.NewV4()),
DocumentID: uuid.Must(uuid.NewV4()),
MovingExpenseType: &contractExpense,
Reason: models.StringPointer("no good"),
SITStartDate: models.TimePointer(time.Now()),
SITEndDate: models.TimePointer(time.Now()),
WeightStored: (*unit.Pound)(&weightStored),
SITLocation: &sitLocation,
SITReimburseableAmount: (*unit.Cents)(&sitReimburseableAmount),
}
movingExpenseTwo := models.MovingExpense{
PPMShipmentID: uuid.Must(uuid.NewV4()),
DocumentID: uuid.Must(uuid.NewV4()),
MovingExpenseType: &contractExpense,
Reason: models.StringPointer("no good"),
SITStartDate: models.TimePointer(time.Now()),
SITEndDate: models.TimePointer(time.Now()),
WeightStored: (*unit.Pound)(&weightStored),
SITLocation: &sitLocation,
SITReimburseableAmount: (*unit.Cents)(&sitReimburseableAmount),
}
movingExpenses = append(movingExpenses, movingExpense, movingExpenseTwo)
movingExpensesValue := MovingExpenses(nil, movingExpenses)
suite.NotNil(movingExpensesValue)
}

// TestMove makes sure zero values/optional fields are handled
func TestMove(t *testing.T) {
_, err := Move(&models.Move{}, &test.FakeS3Storage{})
Expand Down Expand Up @@ -640,6 +725,81 @@ func (suite *PayloadsSuite) TestCreateCustomer() {
})
}

func (suite *PayloadsSuite) TestMoveTaskOrder() {
move := factory.BuildMove(suite.DB(), nil, nil)
moveTaskOrder := MoveTaskOrder(&move)
suite.NotNil(moveTaskOrder)
}

func (suite *PayloadsSuite) TestTransportationOffice() {
office := factory.BuildTransportationOffice(suite.DB(), []factory.Customization{
{
Model: models.TransportationOffice{
ID: uuid.Must(uuid.NewV4()),
},
}}, nil)
transportationOffice := TransportationOffice(&office)
suite.NotNil(transportationOffice)
}
func (suite *PayloadsSuite) TestTransportationOffices() {
office := factory.BuildTransportationOffice(suite.DB(), []factory.Customization{
{
Model: models.TransportationOffice{
ID: uuid.Must(uuid.NewV4()),
},
}}, nil)
officeTwo := factory.BuildTransportationOffice(suite.DB(), []factory.Customization{
{
Model: models.TransportationOffice{
ID: uuid.Must(uuid.NewV4()),
},
}}, nil)
transportationOfficeList := models.TransportationOffices{}
transportationOfficeList = append(transportationOfficeList, office, officeTwo)
value := TransportationOffices(transportationOfficeList)
suite.NotNil(value)
}
func (suite *PayloadsSuite) TestListMove() {

marines := models.AffiliationMARINES
listMove := ListMove(nil)

suite.Nil(listMove)
moveUSMC := factory.BuildMove(suite.DB(), []factory.Customization{
{
Model: models.ServiceMember{
Affiliation: &marines,
},
},
}, nil)

listMove = ListMove(&moveUSMC)
suite.NotNil(listMove)
}

func (suite *PayloadsSuite) TestListMoves() {
list := models.Moves{}

marines := models.AffiliationMARINES
spaceForce := models.AffiliationSPACEFORCE
moveUSMC := factory.BuildMove(suite.DB(), []factory.Customization{
{
Model: models.ServiceMember{
Affiliation: &marines,
},
},
}, nil)
moveSF := factory.BuildMove(suite.DB(), []factory.Customization{
{
Model: models.ServiceMember{
Affiliation: &spaceForce,
},
},
}, nil)
list = append(list, moveUSMC, moveSF)
value := ListMoves(&list)
suite.NotNil(value)
}
func (suite *PayloadsSuite) TestSearchMoves() {
appCtx := suite.AppContextForTest()

Expand All @@ -653,7 +813,7 @@ func (suite *PayloadsSuite) TestSearchMoves() {
}, nil)

moves := models.Moves{moveUSMC}
suite.Run("Success - Returns a ghcmessages Upload payload from Upload Struct", func() {
suite.Run("Success - Returns a ghcmessages Upload payload from Upload Struct Marine move with no shipments", func() {
payload := SearchMoves(appCtx, moves)

suite.IsType(payload, &ghcmessages.SearchMoves{})
Expand Down
25 changes: 16 additions & 9 deletions pkg/handlers/ghcapi/payment_request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,17 +228,25 @@ func (suite *HandlerSuite) TestGetPaymentRequestsForMoveHandler() {

func (suite *HandlerSuite) TestUpdatePaymentRequestStatusHandler() {
paymentRequestID, _ := uuid.FromString("00000000-0000-0000-0000-000000000001")
officeUserUUID, _ := uuid.NewV4()

setupTestData := func() models.OfficeUser {
officeUser := factory.BuildOfficeUser(nil, []factory.Customization{
{Model: models.OfficeUser{
ID: officeUserUUID,
}},

transportationOffice := factory.BuildTransportationOffice(suite.DB(), []factory.Customization{
{
Model: models.TransportationOffice{
ProvidesCloseout: true,
},
},
}, nil)
officeUser.User.Roles = append(officeUser.User.Roles, roles.Role{
RoleType: roles.RoleTypeTIO,
})

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

return officeUser
}
paymentRequest := models.PaymentRequest{
Expand All @@ -250,7 +258,6 @@ func (suite *HandlerSuite) TestUpdatePaymentRequestStatusHandler() {
}

statusUpdater := paymentrequest.NewPaymentRequestStatusUpdater(query.NewQueryBuilder())

suite.Run("successful status update of payment request", func() {
officeUser := setupTestData()
pendingPaymentRequest := factory.BuildPaymentRequest(suite.DB(), nil, nil)
Expand Down
Loading
Loading