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-20777 tio queue management #13899

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from
32 changes: 30 additions & 2 deletions pkg/gen/ghcapi/embedded_spec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 54 additions & 0 deletions pkg/gen/ghcmessages/queue_payment_request.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 26 additions & 2 deletions pkg/handlers/ghcapi/internal/payloads/model_to_payload.go
Original file line number Diff line number Diff line change
Expand Up @@ -2259,7 +2259,7 @@ func queuePaymentRequestStatus(paymentRequest models.PaymentRequest) string {
}

// QueuePaymentRequests payload
func QueuePaymentRequests(paymentRequests *models.PaymentRequests, officeUsers []models.OfficeUser) *ghcmessages.QueuePaymentRequests {
func QueuePaymentRequests(paymentRequests *models.PaymentRequests, officeUsers []models.OfficeUser, officeUser models.OfficeUser, isSupervisor bool) *ghcmessages.QueuePaymentRequests {
queuePaymentRequests := make(ghcmessages.QueuePaymentRequests, len(*paymentRequests))

for i, paymentRequest := range *paymentRequests {
Expand All @@ -2283,7 +2283,31 @@ func QueuePaymentRequests(paymentRequests *models.PaymentRequests, officeUsers [
OrderType: (*string)(orders.OrdersType.Pointer()),
LockedByOfficeUserID: handlers.FmtUUIDPtr(moveTaskOrder.LockedByOfficeUserID),
LockExpiresAt: handlers.FmtDateTimePtr(moveTaskOrder.LockExpiresAt),
AvailableOfficeUsers: *QueueAvailableOfficeUsers(officeUsers),
}

if paymentRequest.MoveTaskOrder.TIOAssignedUser != nil {
queuePaymentRequests[i].AssignedTo = AssignedOfficeUser(paymentRequest.MoveTaskOrder.TIOAssignedUser)
}

isAssignable := false
if queuePaymentRequests[i].AssignedTo == nil {
isAssignable = true
}

if isSupervisor {
isAssignable = true
}

queuePaymentRequests[i].Assignable = isAssignable

// only need to attach available office users if move is assignable
if queuePaymentRequests[i].Assignable {
availableOfficeUsers := officeUsers
if !isSupervisor {
availableOfficeUsers = models.OfficeUsers{officeUser}
}

queuePaymentRequests[i].AvailableOfficeUsers = *QueueAvailableOfficeUsers(availableOfficeUsers)
}

if orders.DepartmentIndicator != nil {
Expand Down
9 changes: 8 additions & 1 deletion pkg/handlers/ghcapi/queues.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ func (h GetPaymentRequestsQueueHandler) Handle(
Order: params.Order,
OriginDutyLocation: params.OriginDutyLocation,
OrderType: params.OrderType,
TIOAssignedUser: params.AssignedTo,
}

listPaymentRequestParams.Status = []string{string(models.QueuePaymentRequestPaymentRequested)}
Expand Down Expand Up @@ -319,7 +320,13 @@ func (h GetPaymentRequestsQueueHandler) Handle(
}
}

queuePaymentRequests := payloads.QueuePaymentRequests(paymentRequests, officeUsers)
privileges, err := models.FetchPrivilegesForUser(appCtx.DB(), appCtx.Session().UserID)
if err != nil {
appCtx.Logger().Error("Error retreiving user privileges", zap.Error(err))
}

isSupervisor := privileges.HasPrivilege(models.PrivilegeTypeSupervisor)
queuePaymentRequests := payloads.QueuePaymentRequests(paymentRequests, officeUsers, officeUser, isSupervisor)

result := &ghcmessages.QueuePaymentRequestsResult{
TotalCount: int64(count),
Expand Down
10 changes: 5 additions & 5 deletions pkg/services/order/order_fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,12 @@ func (f orderFetcher) ListOrders(appCtx appcontext.AppContext, officeUserID uuid
closeoutLocationQuery := closeoutLocationFilter(params.CloseoutLocation, ppmCloseoutGblocs)
ppmTypeQuery := ppmTypeFilter(params.PPMType)
ppmStatusQuery := ppmStatusFilter(params.PPMStatus)
SCAssignedUserQuery := SCAssignedUserFilter(params.SCAssignedUser)
TOOAssignedUserQuery := TOOAssignedUserFilter(params.TOOAssignedUser)
scAssignedUserQuery := scAssignedUserFilter(params.SCAssignedUser)
tooAssignedUserQuery := tooAssignedUserFilter(params.TOOAssignedUser)
sortOrderQuery := sortOrder(params.Sort, params.Order, ppmCloseoutGblocs)
counselingQuery := counselingOfficeFilter(params.CounselingOffice)
// Adding to an array so we can iterate over them and apply the filters after the query structure is set below
options := [20]QueryOption{branchQuery, locatorQuery, dodIDQuery, emplidQuery, lastNameQuery, originDutyLocationQuery, destinationDutyLocationQuery, moveStatusQuery, gblocQuery, submittedAtQuery, appearedInTOOAtQuery, requestedMoveDateQuery, ppmTypeQuery, closeoutInitiatedQuery, closeoutLocationQuery, ppmStatusQuery, sortOrderQuery, SCAssignedUserQuery, TOOAssignedUserQuery, counselingQuery}
options := [20]QueryOption{branchQuery, locatorQuery, dodIDQuery, emplidQuery, lastNameQuery, originDutyLocationQuery, destinationDutyLocationQuery, moveStatusQuery, gblocQuery, submittedAtQuery, appearedInTOOAtQuery, requestedMoveDateQuery, ppmTypeQuery, closeoutInitiatedQuery, closeoutLocationQuery, ppmStatusQuery, sortOrderQuery, scAssignedUserQuery, tooAssignedUserQuery, counselingQuery}

var query *pop.Query
if ppmCloseoutGblocs {
Expand Down Expand Up @@ -635,7 +635,7 @@ func ppmStatusFilter(ppmStatus *string) QueryOption {
}
}

func SCAssignedUserFilter(scAssigned *string) QueryOption {
func scAssignedUserFilter(scAssigned *string) QueryOption {
return func(query *pop.Query) {
if scAssigned != nil {
nameSearch := fmt.Sprintf("%s%%", *scAssigned)
Expand All @@ -644,7 +644,7 @@ func SCAssignedUserFilter(scAssigned *string) QueryOption {
}
}

func TOOAssignedUserFilter(tooAssigned *string) QueryOption {
func tooAssignedUserFilter(tooAssigned *string) QueryOption {
return func(query *pop.Query) {
if tooAssigned != nil {
nameSearch := fmt.Sprintf("%s%%", *tooAssigned)
Expand Down
1 change: 1 addition & 0 deletions pkg/services/payment_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ type FetchPaymentRequestListParams struct {
OriginDutyLocation *string
OrderType *string
ViewAsGBLOC *string
TIOAssignedUser *string
}

// ShipmentPaymentSITBalance is a public struct that's used to return current SIT balances to the TIO for a payment
Expand Down
Loading
Loading