From 132dec3ff75abeec5a2d6d36d8b70329b3ba0348 Mon Sep 17 00:00:00 2001 From: loganwc Date: Thu, 25 Jul 2024 16:51:25 +0000 Subject: [PATCH 01/37] added cancel move endpoint --- pkg/gen/ghcapi/configure_mymove.go | 5 + pkg/gen/ghcapi/embedded_spec.go | 122 +++++++ .../ghcoperations/move/move_cancellation.go | 58 +++ .../move/move_cancellation_parameters.go | 91 +++++ .../move/move_cancellation_responses.go | 329 ++++++++++++++++++ .../move/move_cancellation_urlbuilder.go | 101 ++++++ pkg/gen/ghcapi/ghcoperations/mymove_api.go | 12 + pkg/handlers/ghcapi/api.go | 5 + pkg/handlers/ghcapi/move.go | 33 ++ pkg/services/move.go | 4 + pkg/services/move/move_cancellation.go | 48 +++ pkg/services/move/move_cancellation_test.go | 20 ++ swagger-def/ghc.yaml | 36 ++ swagger/ghc.yaml | 36 ++ 14 files changed, 900 insertions(+) create mode 100644 pkg/gen/ghcapi/ghcoperations/move/move_cancellation.go create mode 100644 pkg/gen/ghcapi/ghcoperations/move/move_cancellation_parameters.go create mode 100644 pkg/gen/ghcapi/ghcoperations/move/move_cancellation_responses.go create mode 100644 pkg/gen/ghcapi/ghcoperations/move/move_cancellation_urlbuilder.go create mode 100644 pkg/services/move/move_cancellation.go create mode 100644 pkg/services/move/move_cancellation_test.go diff --git a/pkg/gen/ghcapi/configure_mymove.go b/pkg/gen/ghcapi/configure_mymove.go index 780c3432a1d..192fe39e8d5 100644 --- a/pkg/gen/ghcapi/configure_mymove.go +++ b/pkg/gen/ghcapi/configure_mymove.go @@ -354,6 +354,11 @@ func configureAPI(api *ghcoperations.MymoveAPI) http.Handler { return middleware.NotImplemented("operation queues.ListPrimeMoves has not yet been implemented") }) } + if api.MoveMoveCancellationHandler == nil { + api.MoveMoveCancellationHandler = move.MoveCancellationHandlerFunc(func(params move.MoveCancellationParams) middleware.Responder { + return middleware.NotImplemented("operation move.MoveCancellation has not yet been implemented") + }) + } if api.ShipmentRejectShipmentHandler == nil { api.ShipmentRejectShipmentHandler = shipment.RejectShipmentHandlerFunc(func(params shipment.RejectShipmentParams) middleware.Responder { return middleware.NotImplemented("operation shipment.RejectShipment has not yet been implemented") diff --git a/pkg/gen/ghcapi/embedded_spec.go b/pkg/gen/ghcapi/embedded_spec.go index c006ed91ce1..90622d9b44c 100644 --- a/pkg/gen/ghcapi/embedded_spec.go +++ b/pkg/gen/ghcapi/embedded_spec.go @@ -2225,6 +2225,58 @@ func init() { } ] }, + "/moves/{moveID}/cancel": { + "post": { + "description": "cancels a move", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "move" + ], + "summary": "Cancels a move", + "operationId": "moveCancellation", + "responses": { + "200": { + "description": "Successfully cancelled move", + "schema": { + "$ref": "#/definitions/Move" + } + }, + "403": { + "$ref": "#/responses/PermissionDenied" + }, + "404": { + "$ref": "#/responses/NotFound" + }, + "409": { + "$ref": "#/responses/Conflict" + }, + "412": { + "$ref": "#/responses/PreconditionFailed" + }, + "422": { + "$ref": "#/responses/UnprocessableEntity" + }, + "500": { + "$ref": "#/responses/ServerError" + } + } + }, + "parameters": [ + { + "type": "string", + "format": "uuid", + "description": "ID of the move", + "name": "moveID", + "in": "path", + "required": true + } + ] + }, "/moves/{moveID}/counseling-evaluation-reports-list": { "get": { "description": "Returns counseling evaluation reports for the specified move that are visible to the current office user", @@ -15897,6 +15949,76 @@ func init() { } ] }, + "/moves/{moveID}/cancel": { + "post": { + "description": "cancels a move", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "move" + ], + "summary": "Cancels a move", + "operationId": "moveCancellation", + "responses": { + "200": { + "description": "Successfully cancelled move", + "schema": { + "$ref": "#/definitions/Move" + } + }, + "403": { + "description": "The request was denied", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "404": { + "description": "The requested resource wasn't found", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "409": { + "description": "Conflict error", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "412": { + "description": "Precondition failed", + "schema": { + "$ref": "#/definitions/Error" + } + }, + "422": { + "description": "The payload was unprocessable.", + "schema": { + "$ref": "#/definitions/ValidationError" + } + }, + "500": { + "description": "A server error occurred", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + }, + "parameters": [ + { + "type": "string", + "format": "uuid", + "description": "ID of the move", + "name": "moveID", + "in": "path", + "required": true + } + ] + }, "/moves/{moveID}/counseling-evaluation-reports-list": { "get": { "description": "Returns counseling evaluation reports for the specified move that are visible to the current office user", diff --git a/pkg/gen/ghcapi/ghcoperations/move/move_cancellation.go b/pkg/gen/ghcapi/ghcoperations/move/move_cancellation.go new file mode 100644 index 00000000000..a2d9f8a9bf3 --- /dev/null +++ b/pkg/gen/ghcapi/ghcoperations/move/move_cancellation.go @@ -0,0 +1,58 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package move + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// MoveCancellationHandlerFunc turns a function with the right signature into a move cancellation handler +type MoveCancellationHandlerFunc func(MoveCancellationParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn MoveCancellationHandlerFunc) Handle(params MoveCancellationParams) middleware.Responder { + return fn(params) +} + +// MoveCancellationHandler interface for that can handle valid move cancellation params +type MoveCancellationHandler interface { + Handle(MoveCancellationParams) middleware.Responder +} + +// NewMoveCancellation creates a new http.Handler for the move cancellation operation +func NewMoveCancellation(ctx *middleware.Context, handler MoveCancellationHandler) *MoveCancellation { + return &MoveCancellation{Context: ctx, Handler: handler} +} + +/* + MoveCancellation swagger:route POST /moves/{moveID}/cancel move moveCancellation + +# Cancels a move + +cancels a move +*/ +type MoveCancellation struct { + Context *middleware.Context + Handler MoveCancellationHandler +} + +func (o *MoveCancellation) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewMoveCancellationParams() + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/pkg/gen/ghcapi/ghcoperations/move/move_cancellation_parameters.go b/pkg/gen/ghcapi/ghcoperations/move/move_cancellation_parameters.go new file mode 100644 index 00000000000..98a353a63ae --- /dev/null +++ b/pkg/gen/ghcapi/ghcoperations/move/move_cancellation_parameters.go @@ -0,0 +1,91 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package move + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/errors" + "github.com/go-openapi/runtime/middleware" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/validate" +) + +// NewMoveCancellationParams creates a new MoveCancellationParams object +// +// There are no default values defined in the spec. +func NewMoveCancellationParams() MoveCancellationParams { + + return MoveCancellationParams{} +} + +// MoveCancellationParams contains all the bound params for the move cancellation operation +// typically these are obtained from a http.Request +// +// swagger:parameters moveCancellation +type MoveCancellationParams struct { + + // HTTP Request Object + HTTPRequest *http.Request `json:"-"` + + /*ID of the move + Required: true + In: path + */ + MoveID strfmt.UUID +} + +// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface +// for simple values it will use straight method calls. +// +// To ensure default values, the struct must have been initialized with NewMoveCancellationParams() beforehand. +func (o *MoveCancellationParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { + var res []error + + o.HTTPRequest = r + + rMoveID, rhkMoveID, _ := route.Params.GetOK("moveID") + if err := o.bindMoveID(rMoveID, rhkMoveID, route.Formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +// bindMoveID binds and validates parameter MoveID from path. +func (o *MoveCancellationParams) bindMoveID(rawData []string, hasKey bool, formats strfmt.Registry) error { + var raw string + if len(rawData) > 0 { + raw = rawData[len(rawData)-1] + } + + // Required: true + // Parameter is provided by construction from the route + + // Format: uuid + value, err := formats.Parse("uuid", raw) + if err != nil { + return errors.InvalidType("moveID", "path", "strfmt.UUID", raw) + } + o.MoveID = *(value.(*strfmt.UUID)) + + if err := o.validateMoveID(formats); err != nil { + return err + } + + return nil +} + +// validateMoveID carries on validations for parameter MoveID +func (o *MoveCancellationParams) validateMoveID(formats strfmt.Registry) error { + + if err := validate.FormatOf("moveID", "path", "uuid", o.MoveID.String(), formats); err != nil { + return err + } + return nil +} diff --git a/pkg/gen/ghcapi/ghcoperations/move/move_cancellation_responses.go b/pkg/gen/ghcapi/ghcoperations/move/move_cancellation_responses.go new file mode 100644 index 00000000000..96d0e76f919 --- /dev/null +++ b/pkg/gen/ghcapi/ghcoperations/move/move_cancellation_responses.go @@ -0,0 +1,329 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package move + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/transcom/mymove/pkg/gen/ghcmessages" +) + +// MoveCancellationOKCode is the HTTP code returned for type MoveCancellationOK +const MoveCancellationOKCode int = 200 + +/* +MoveCancellationOK Successfully cancelled move + +swagger:response moveCancellationOK +*/ +type MoveCancellationOK struct { + + /* + In: Body + */ + Payload *ghcmessages.Move `json:"body,omitempty"` +} + +// NewMoveCancellationOK creates MoveCancellationOK with default headers values +func NewMoveCancellationOK() *MoveCancellationOK { + + return &MoveCancellationOK{} +} + +// WithPayload adds the payload to the move cancellation o k response +func (o *MoveCancellationOK) WithPayload(payload *ghcmessages.Move) *MoveCancellationOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the move cancellation o k response +func (o *MoveCancellationOK) SetPayload(payload *ghcmessages.Move) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *MoveCancellationOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// MoveCancellationForbiddenCode is the HTTP code returned for type MoveCancellationForbidden +const MoveCancellationForbiddenCode int = 403 + +/* +MoveCancellationForbidden The request was denied + +swagger:response moveCancellationForbidden +*/ +type MoveCancellationForbidden struct { + + /* + In: Body + */ + Payload *ghcmessages.Error `json:"body,omitempty"` +} + +// NewMoveCancellationForbidden creates MoveCancellationForbidden with default headers values +func NewMoveCancellationForbidden() *MoveCancellationForbidden { + + return &MoveCancellationForbidden{} +} + +// WithPayload adds the payload to the move cancellation forbidden response +func (o *MoveCancellationForbidden) WithPayload(payload *ghcmessages.Error) *MoveCancellationForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the move cancellation forbidden response +func (o *MoveCancellationForbidden) SetPayload(payload *ghcmessages.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *MoveCancellationForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// MoveCancellationNotFoundCode is the HTTP code returned for type MoveCancellationNotFound +const MoveCancellationNotFoundCode int = 404 + +/* +MoveCancellationNotFound The requested resource wasn't found + +swagger:response moveCancellationNotFound +*/ +type MoveCancellationNotFound struct { + + /* + In: Body + */ + Payload *ghcmessages.Error `json:"body,omitempty"` +} + +// NewMoveCancellationNotFound creates MoveCancellationNotFound with default headers values +func NewMoveCancellationNotFound() *MoveCancellationNotFound { + + return &MoveCancellationNotFound{} +} + +// WithPayload adds the payload to the move cancellation not found response +func (o *MoveCancellationNotFound) WithPayload(payload *ghcmessages.Error) *MoveCancellationNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the move cancellation not found response +func (o *MoveCancellationNotFound) SetPayload(payload *ghcmessages.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *MoveCancellationNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// MoveCancellationConflictCode is the HTTP code returned for type MoveCancellationConflict +const MoveCancellationConflictCode int = 409 + +/* +MoveCancellationConflict Conflict error + +swagger:response moveCancellationConflict +*/ +type MoveCancellationConflict struct { + + /* + In: Body + */ + Payload *ghcmessages.Error `json:"body,omitempty"` +} + +// NewMoveCancellationConflict creates MoveCancellationConflict with default headers values +func NewMoveCancellationConflict() *MoveCancellationConflict { + + return &MoveCancellationConflict{} +} + +// WithPayload adds the payload to the move cancellation conflict response +func (o *MoveCancellationConflict) WithPayload(payload *ghcmessages.Error) *MoveCancellationConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the move cancellation conflict response +func (o *MoveCancellationConflict) SetPayload(payload *ghcmessages.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *MoveCancellationConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// MoveCancellationPreconditionFailedCode is the HTTP code returned for type MoveCancellationPreconditionFailed +const MoveCancellationPreconditionFailedCode int = 412 + +/* +MoveCancellationPreconditionFailed Precondition failed + +swagger:response moveCancellationPreconditionFailed +*/ +type MoveCancellationPreconditionFailed struct { + + /* + In: Body + */ + Payload *ghcmessages.Error `json:"body,omitempty"` +} + +// NewMoveCancellationPreconditionFailed creates MoveCancellationPreconditionFailed with default headers values +func NewMoveCancellationPreconditionFailed() *MoveCancellationPreconditionFailed { + + return &MoveCancellationPreconditionFailed{} +} + +// WithPayload adds the payload to the move cancellation precondition failed response +func (o *MoveCancellationPreconditionFailed) WithPayload(payload *ghcmessages.Error) *MoveCancellationPreconditionFailed { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the move cancellation precondition failed response +func (o *MoveCancellationPreconditionFailed) SetPayload(payload *ghcmessages.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *MoveCancellationPreconditionFailed) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(412) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// MoveCancellationUnprocessableEntityCode is the HTTP code returned for type MoveCancellationUnprocessableEntity +const MoveCancellationUnprocessableEntityCode int = 422 + +/* +MoveCancellationUnprocessableEntity The payload was unprocessable. + +swagger:response moveCancellationUnprocessableEntity +*/ +type MoveCancellationUnprocessableEntity struct { + + /* + In: Body + */ + Payload *ghcmessages.ValidationError `json:"body,omitempty"` +} + +// NewMoveCancellationUnprocessableEntity creates MoveCancellationUnprocessableEntity with default headers values +func NewMoveCancellationUnprocessableEntity() *MoveCancellationUnprocessableEntity { + + return &MoveCancellationUnprocessableEntity{} +} + +// WithPayload adds the payload to the move cancellation unprocessable entity response +func (o *MoveCancellationUnprocessableEntity) WithPayload(payload *ghcmessages.ValidationError) *MoveCancellationUnprocessableEntity { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the move cancellation unprocessable entity response +func (o *MoveCancellationUnprocessableEntity) SetPayload(payload *ghcmessages.ValidationError) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *MoveCancellationUnprocessableEntity) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(422) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// MoveCancellationInternalServerErrorCode is the HTTP code returned for type MoveCancellationInternalServerError +const MoveCancellationInternalServerErrorCode int = 500 + +/* +MoveCancellationInternalServerError A server error occurred + +swagger:response moveCancellationInternalServerError +*/ +type MoveCancellationInternalServerError struct { + + /* + In: Body + */ + Payload *ghcmessages.Error `json:"body,omitempty"` +} + +// NewMoveCancellationInternalServerError creates MoveCancellationInternalServerError with default headers values +func NewMoveCancellationInternalServerError() *MoveCancellationInternalServerError { + + return &MoveCancellationInternalServerError{} +} + +// WithPayload adds the payload to the move cancellation internal server error response +func (o *MoveCancellationInternalServerError) WithPayload(payload *ghcmessages.Error) *MoveCancellationInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the move cancellation internal server error response +func (o *MoveCancellationInternalServerError) SetPayload(payload *ghcmessages.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *MoveCancellationInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/pkg/gen/ghcapi/ghcoperations/move/move_cancellation_urlbuilder.go b/pkg/gen/ghcapi/ghcoperations/move/move_cancellation_urlbuilder.go new file mode 100644 index 00000000000..fd91266aa01 --- /dev/null +++ b/pkg/gen/ghcapi/ghcoperations/move/move_cancellation_urlbuilder.go @@ -0,0 +1,101 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package move + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "errors" + "net/url" + golangswaggerpaths "path" + "strings" + + "github.com/go-openapi/strfmt" +) + +// MoveCancellationURL generates an URL for the move cancellation operation +type MoveCancellationURL struct { + MoveID strfmt.UUID + + _basePath string + // avoid unkeyed usage + _ struct{} +} + +// WithBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *MoveCancellationURL) WithBasePath(bp string) *MoveCancellationURL { + o.SetBasePath(bp) + return o +} + +// SetBasePath sets the base path for this url builder, only required when it's different from the +// base path specified in the swagger spec. +// When the value of the base path is an empty string +func (o *MoveCancellationURL) SetBasePath(bp string) { + o._basePath = bp +} + +// Build a url path and query string +func (o *MoveCancellationURL) Build() (*url.URL, error) { + var _result url.URL + + var _path = "/moves/{moveID}/cancel" + + moveID := o.MoveID.String() + if moveID != "" { + _path = strings.Replace(_path, "{moveID}", moveID, -1) + } else { + return nil, errors.New("moveId is required on MoveCancellationURL") + } + + _basePath := o._basePath + if _basePath == "" { + _basePath = "/ghc/v1" + } + _result.Path = golangswaggerpaths.Join(_basePath, _path) + + return &_result, nil +} + +// Must is a helper function to panic when the url builder returns an error +func (o *MoveCancellationURL) Must(u *url.URL, err error) *url.URL { + if err != nil { + panic(err) + } + if u == nil { + panic("url can't be nil") + } + return u +} + +// String returns the string representation of the path with query string +func (o *MoveCancellationURL) String() string { + return o.Must(o.Build()).String() +} + +// BuildFull builds a full url with scheme, host, path and query string +func (o *MoveCancellationURL) BuildFull(scheme, host string) (*url.URL, error) { + if scheme == "" { + return nil, errors.New("scheme is required for a full url on MoveCancellationURL") + } + if host == "" { + return nil, errors.New("host is required for a full url on MoveCancellationURL") + } + + base, err := o.Build() + if err != nil { + return nil, err + } + + base.Scheme = scheme + base.Host = host + return base, nil +} + +// StringFull returns the string representation of a complete url +func (o *MoveCancellationURL) StringFull(scheme, host string) string { + return o.Must(o.BuildFull(scheme, host)).String() +} diff --git a/pkg/gen/ghcapi/ghcoperations/mymove_api.go b/pkg/gen/ghcapi/ghcoperations/mymove_api.go index f5368032656..a9709ac70c6 100644 --- a/pkg/gen/ghcapi/ghcoperations/mymove_api.go +++ b/pkg/gen/ghcapi/ghcoperations/mymove_api.go @@ -239,6 +239,9 @@ func NewMymoveAPI(spec *loads.Document) *MymoveAPI { QueuesListPrimeMovesHandler: queues.ListPrimeMovesHandlerFunc(func(params queues.ListPrimeMovesParams) middleware.Responder { return middleware.NotImplemented("operation queues.ListPrimeMoves has not yet been implemented") }), + MoveMoveCancellationHandler: move.MoveCancellationHandlerFunc(func(params move.MoveCancellationParams) middleware.Responder { + return middleware.NotImplemented("operation move.MoveCancellation has not yet been implemented") + }), ShipmentRejectShipmentHandler: shipment.RejectShipmentHandlerFunc(func(params shipment.RejectShipmentParams) middleware.Responder { return middleware.NotImplemented("operation shipment.RejectShipment has not yet been implemented") }), @@ -510,6 +513,8 @@ type MymoveAPI struct { MtoShipmentListMTOShipmentsHandler mto_shipment.ListMTOShipmentsHandler // QueuesListPrimeMovesHandler sets the operation handler for the list prime moves operation QueuesListPrimeMovesHandler queues.ListPrimeMovesHandler + // MoveMoveCancellationHandler sets the operation handler for the move cancellation operation + MoveMoveCancellationHandler move.MoveCancellationHandler // ShipmentRejectShipmentHandler sets the operation handler for the reject shipment operation ShipmentRejectShipmentHandler shipment.RejectShipmentHandler // LinesOfAccountingRequestLineOfAccountingHandler sets the operation handler for the request line of accounting operation @@ -838,6 +843,9 @@ func (o *MymoveAPI) Validate() error { if o.QueuesListPrimeMovesHandler == nil { unregistered = append(unregistered, "queues.ListPrimeMovesHandler") } + if o.MoveMoveCancellationHandler == nil { + unregistered = append(unregistered, "move.MoveCancellationHandler") + } if o.ShipmentRejectShipmentHandler == nil { unregistered = append(unregistered, "shipment.RejectShipmentHandler") } @@ -1272,6 +1280,10 @@ func (o *MymoveAPI) initHandlerCache() { if o.handlers["POST"] == nil { o.handlers["POST"] = make(map[string]http.Handler) } + o.handlers["POST"]["/moves/{moveID}/cancel"] = move.NewMoveCancellation(o.context, o.MoveMoveCancellationHandler) + if o.handlers["POST"] == nil { + o.handlers["POST"] = make(map[string]http.Handler) + } o.handlers["POST"]["/shipments/{shipmentID}/reject"] = shipment.NewRejectShipment(o.context, o.ShipmentRejectShipmentHandler) if o.handlers["POST"] == nil { o.handlers["POST"] = make(map[string]http.Handler) diff --git a/pkg/handlers/ghcapi/api.go b/pkg/handlers/ghcapi/api.go index 32a53c4fca5..d7101aec4e1 100644 --- a/pkg/handlers/ghcapi/api.go +++ b/pkg/handlers/ghcapi/api.go @@ -656,5 +656,10 @@ func NewGhcAPIHandler(handlerConfig handlers.HandlerConfig) *ghcops.MymoveAPI { order.NewOrderUpdater(moveRouter), } + ghcAPI.MoveMoveCancellationHandler = MoveCancellationHandler{ + handlerConfig, + move.NewMoveCancellation(), + } + return ghcAPI } diff --git a/pkg/handlers/ghcapi/move.go b/pkg/handlers/ghcapi/move.go index c375d75a08e..0324cdcec50 100644 --- a/pkg/handlers/ghcapi/move.go +++ b/pkg/handlers/ghcapi/move.go @@ -279,6 +279,39 @@ func (h UploadAdditionalDocumentsHandler) Handle(params moveop.UploadAdditionalD }) } +type MoveCancellationHandler struct { + handlers.HandlerConfig + services.MoveCancellation +} + +func (h MoveCancellationHandler) Handle(params moveop.MoveCancellationParams) middleware.Responder { + return h.AuditableAppContextFromRequestWithErrors(params.HTTPRequest, + func(appCtx appcontext.AppContext) (middleware.Responder, error) { + moveID := uuid.FromStringOrNil(params.MoveID.String()) + + move, err := h.MoveCancellation.CancelMove(appCtx, moveID) + if err != nil { + appCtx.Logger().Error("MoveCancellationHandler error", zap.Error(err)) + switch err.(type) { + case apperror.NotFoundError: + return moveop.NewMoveCancellationNotFound(), err + case apperror.PreconditionFailedError: + return moveop.NewMoveCancellationPreconditionFailed(), err + case apperror.InvalidInputError: + return moveop.NewMoveCancellationUnprocessableEntity(), err + default: + return moveop.NewMoveCancellationInternalServerError(), err + } + } + + payload, err := payloads.Move(move, h.FileStorer()) + if err != nil { + return nil, err + } + return moveop.NewMoveCancellationOK().WithPayload(payload), nil + }) +} + func payloadForUploadModelFromAdditionalDocumentsUpload(storer storage.FileStorer, upload models.Upload, url string) (*ghcmessages.Upload, error) { uploadPayload := &ghcmessages.Upload{ ID: handlers.FmtUUIDValue(upload.ID), diff --git a/pkg/services/move.go b/pkg/services/move.go index a210171bff7..130669c0042 100644 --- a/pkg/services/move.go +++ b/pkg/services/move.go @@ -112,3 +112,7 @@ type SearchMovesParams struct { type MoveCloseoutOfficeUpdater interface { UpdateCloseoutOffice(appCtx appcontext.AppContext, moveLocator string, closeoutOfficeID uuid.UUID, eTag string) (*models.Move, error) } + +type MoveCancellation interface { + CancelMove(appCtx appcontext.AppContext, moveID uuid.UUID) (*models.Move, error) +} diff --git a/pkg/services/move/move_cancellation.go b/pkg/services/move/move_cancellation.go new file mode 100644 index 00000000000..977b398e78a --- /dev/null +++ b/pkg/services/move/move_cancellation.go @@ -0,0 +1,48 @@ +package move + +import ( + "github.com/gofrs/uuid" + + "github.com/transcom/mymove/pkg/appcontext" + "github.com/transcom/mymove/pkg/apperror" + "github.com/transcom/mymove/pkg/models" + "github.com/transcom/mymove/pkg/services" +) + +type moveCancellation struct{} + +func NewMoveCancellation() services.MoveCancellation { + return &moveCancellation{} +} + +func (f *moveCancellation) CancelMove(appCtx appcontext.AppContext, moveID uuid.UUID) (*models.Move, error) { + move := &models.Move{} + err := appCtx.DB().Find(move, moveID) + if err != nil { + return nil, apperror.NewNotFoundError(moveID, "while looking for a move") + } + + moveDelta := move + moveDelta.Status = models.MoveStatusCANCELED + + if verrs := validateMove(appCtx, *move, moveDelta); verrs != nil { + return move, verrs + } + + txnErr := appCtx.NewTransaction(func(txnAppCtx appcontext.AppContext) error { + verrs, err := txnAppCtx.DB().ValidateAndUpdate(moveDelta) + if verrs != nil && verrs.HasAny() { + return apperror.NewInvalidInputError( + move.ID, err, verrs, "Validation errors found while setting move status") + } else if err != nil { + return apperror.NewQueryError("Move", err, "Failed to update status for move") + } + + return nil + }) + if txnErr != nil { + return nil, txnErr + } + + return move, nil +} diff --git a/pkg/services/move/move_cancellation_test.go b/pkg/services/move/move_cancellation_test.go new file mode 100644 index 00000000000..f9d213060a8 --- /dev/null +++ b/pkg/services/move/move_cancellation_test.go @@ -0,0 +1,20 @@ +package move + +import ( + "github.com/transcom/mymove/pkg/factory" + "github.com/transcom/mymove/pkg/models" +) + +func (suite *MoveServiceSuite) TestCancelMove() { + moveCancellation := NewMoveCancellation() + + suite.Run("successfully cancels a move", func() { + move := factory.BuildMove(suite.DB(), nil, nil) + + suite.NotEqual(move.Status, models.MoveStatusCANCELED) + + m, err := moveCancellation.CancelMove(suite.AppContextForTest(), move.ID) + suite.NoError(err) + suite.Equal(m.Status, models.MoveStatusCANCELED) + }) +} diff --git a/swagger-def/ghc.yaml b/swagger-def/ghc.yaml index 1eee7b334e1..e343aacad4c 100644 --- a/swagger-def/ghc.yaml +++ b/swagger-def/ghc.yaml @@ -366,6 +366,42 @@ paths: description: Returns counseling evaluation reports for the specified move that are visible to the current office user summary: Returns counseling evaluation reports for the specified move that are visible to the current office user operationId: getMoveCounselingEvaluationReportsList + '/moves/{moveID}/cancel': + parameters: + - description: ID of the move + in: path + name: moveID + required: true + format: uuid + type: string + post: + consumes: + - application/json + produces: + - application/json + parameters: [] + responses: + '200': + description: Successfully cancelled move + schema: + $ref: '#/definitions/Move' + '403': + $ref: '#/responses/PermissionDenied' + '404': + $ref: '#/responses/NotFound' + '409': + $ref: '#/responses/Conflict' + '412': + $ref: '#/responses/PreconditionFailed' + '422': + $ref: '#/responses/UnprocessableEntity' + '500': + $ref: '#/responses/ServerError' + tags: + - move + description: cancels a move + operationId: moveCancellation + summary: Cancels a move '/counseling/orders/{orderID}': parameters: - description: ID of order to update diff --git a/swagger/ghc.yaml b/swagger/ghc.yaml index 02d50b79970..ab452acde0c 100644 --- a/swagger/ghc.yaml +++ b/swagger/ghc.yaml @@ -404,6 +404,42 @@ paths: Returns counseling evaluation reports for the specified move that are visible to the current office user operationId: getMoveCounselingEvaluationReportsList + /moves/{moveID}/cancel: + parameters: + - description: ID of the move + in: path + name: moveID + required: true + format: uuid + type: string + post: + consumes: + - application/json + produces: + - application/json + parameters: [] + responses: + '200': + description: Successfully cancelled move + schema: + $ref: '#/definitions/Move' + '403': + $ref: '#/responses/PermissionDenied' + '404': + $ref: '#/responses/NotFound' + '409': + $ref: '#/responses/Conflict' + '412': + $ref: '#/responses/PreconditionFailed' + '422': + $ref: '#/responses/UnprocessableEntity' + '500': + $ref: '#/responses/ServerError' + tags: + - move + description: cancels a move + operationId: moveCancellation + summary: Cancels a move /counseling/orders/{orderID}: parameters: - description: ID of order to update From 17df5945e07c0902737855f7418c5996033af898 Mon Sep 17 00:00:00 2001 From: loganwc Date: Mon, 29 Jul 2024 16:04:17 +0000 Subject: [PATCH 02/37] cancel move also cancels shipments now too --- pkg/services/move/move_cancellation.go | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/pkg/services/move/move_cancellation.go b/pkg/services/move/move_cancellation.go index 977b398e78a..45f89bdfcf0 100644 --- a/pkg/services/move/move_cancellation.go +++ b/pkg/services/move/move_cancellation.go @@ -25,11 +25,26 @@ func (f *moveCancellation) CancelMove(appCtx appcontext.AppContext, moveID uuid. moveDelta := move moveDelta.Status = models.MoveStatusCANCELED - if verrs := validateMove(appCtx, *move, moveDelta); verrs != nil { - return move, verrs + // get all shipments in move for cancellation + var shipments []models.MTOShipment + err = appCtx.DB().EagerPreload("Status").Where("mto_shipments.move_id = $1", move.ID).All(&shipments) + if err != nil { + return nil, apperror.NewNotFoundError(moveID, "while looking for shipments") } txnErr := appCtx.NewTransaction(func(txnAppCtx appcontext.AppContext) error { + for _, shipment := range shipments { + shipmentDelta := shipment + shipmentDelta.Status = models.MTOShipmentStatusCanceled + + verrs, err := txnAppCtx.DB().ValidateAndUpdate(&shipmentDelta) + if verrs != nil && verrs.HasAny() { + return apperror.NewInvalidInputError(shipment.ID, err, verrs, "Validation errors found while setting shipment status") + } else if err != nil { + return apperror.NewQueryError("Shipment", err, "Failed to update status for shipment") + } + } + verrs, err := txnAppCtx.DB().ValidateAndUpdate(moveDelta) if verrs != nil && verrs.HasAny() { return apperror.NewInvalidInputError( @@ -40,6 +55,7 @@ func (f *moveCancellation) CancelMove(appCtx appcontext.AppContext, moveID uuid. return nil }) + if txnErr != nil { return nil, txnErr } From 6d0a781dcfbd5160aeea5e065c47ffb855699e8d Mon Sep 17 00:00:00 2001 From: loganwc Date: Mon, 29 Jul 2024 18:55:59 +0000 Subject: [PATCH 03/37] you can now cancel a ppm shipment and canceler cancels ppm --- migrations/app/migrations_manifest.txt | 1 + ...85147_add_cancel_to_ppm_status_enum.up.sql | 1 + pkg/gen/ghcapi/embedded_spec.go | 6 ++++-- pkg/gen/ghcmessages/p_p_m_shipment_status.go | 5 ++++- pkg/gen/internalapi/embedded_spec.go | 6 ++++-- .../internalmessages/p_p_m_shipment_status.go | 5 ++++- pkg/gen/primeapi/embedded_spec.go | 6 ++++-- .../primemessages/p_p_m_shipment_status.go | 5 ++++- pkg/gen/primev2api/embedded_spec.go | 6 ++++-- .../primev2messages/p_p_m_shipment_status.go | 5 ++++- pkg/gen/primev3api/embedded_spec.go | 6 ++++-- .../primev3messages/p_p_m_shipment_status.go | 5 ++++- pkg/services/move/move_cancellation.go | 19 ++++++++++++++++++- .../definitions/PPMShipmentStatus.yaml | 1 + swagger/ghc.yaml | 1 + swagger/internal.yaml | 1 + swagger/prime.yaml | 1 + swagger/prime_v2.yaml | 1 + swagger/prime_v3.yaml | 1 + 19 files changed, 66 insertions(+), 16 deletions(-) create mode 100644 migrations/app/schema/20240729185147_add_cancel_to_ppm_status_enum.up.sql diff --git a/migrations/app/migrations_manifest.txt b/migrations/app/migrations_manifest.txt index 9a5d182acf4..7dad8b6ba4d 100644 --- a/migrations/app/migrations_manifest.txt +++ b/migrations/app/migrations_manifest.txt @@ -963,3 +963,4 @@ 20240624215947_add_sit_reimburseable_amount.up.sql 20240625144828_add_to_update_type_enum.up.sql 20240722134633_update_move_history_indexes.up.sql +20240729185147_add_cancel_to_ppm_status_enum.up.sql diff --git a/migrations/app/schema/20240729185147_add_cancel_to_ppm_status_enum.up.sql b/migrations/app/schema/20240729185147_add_cancel_to_ppm_status_enum.up.sql new file mode 100644 index 00000000000..07b306cdde3 --- /dev/null +++ b/migrations/app/schema/20240729185147_add_cancel_to_ppm_status_enum.up.sql @@ -0,0 +1 @@ +ALTER TYPE ppm_shipment_status ADD VALUE 'CANCELLED'; \ No newline at end of file diff --git a/pkg/gen/ghcapi/embedded_spec.go b/pkg/gen/ghcapi/embedded_spec.go index f6f987eb9e8..25793ac5784 100644 --- a/pkg/gen/ghcapi/embedded_spec.go +++ b/pkg/gen/ghcapi/embedded_spec.go @@ -10367,7 +10367,8 @@ func init() { "WAITING_ON_CUSTOMER", "NEEDS_ADVANCE_APPROVAL", "NEEDS_CLOSEOUT", - "CLOSEOUT_COMPLETE" + "CLOSEOUT_COMPLETE", + "CANCELLED" ], "readOnly": true }, @@ -24954,7 +24955,8 @@ func init() { "WAITING_ON_CUSTOMER", "NEEDS_ADVANCE_APPROVAL", "NEEDS_CLOSEOUT", - "CLOSEOUT_COMPLETE" + "CLOSEOUT_COMPLETE", + "CANCELLED" ], "readOnly": true }, diff --git a/pkg/gen/ghcmessages/p_p_m_shipment_status.go b/pkg/gen/ghcmessages/p_p_m_shipment_status.go index f976a0c7c5c..85295645793 100644 --- a/pkg/gen/ghcmessages/p_p_m_shipment_status.go +++ b/pkg/gen/ghcmessages/p_p_m_shipment_status.go @@ -53,6 +53,9 @@ const ( // PPMShipmentStatusCLOSEOUTCOMPLETE captures enum value "CLOSEOUT_COMPLETE" PPMShipmentStatusCLOSEOUTCOMPLETE PPMShipmentStatus = "CLOSEOUT_COMPLETE" + + // PPMShipmentStatusCANCELLED captures enum value "CANCELLED" + PPMShipmentStatusCANCELLED PPMShipmentStatus = "CANCELLED" ) // for schema @@ -60,7 +63,7 @@ var pPMShipmentStatusEnum []interface{} func init() { var res []PPMShipmentStatus - if err := json.Unmarshal([]byte(`["DRAFT","SUBMITTED","WAITING_ON_CUSTOMER","NEEDS_ADVANCE_APPROVAL","NEEDS_CLOSEOUT","CLOSEOUT_COMPLETE"]`), &res); err != nil { + if err := json.Unmarshal([]byte(`["DRAFT","SUBMITTED","WAITING_ON_CUSTOMER","NEEDS_ADVANCE_APPROVAL","NEEDS_CLOSEOUT","CLOSEOUT_COMPLETE","CANCELLED"]`), &res); err != nil { panic(err) } for _, v := range res { diff --git a/pkg/gen/internalapi/embedded_spec.go b/pkg/gen/internalapi/embedded_spec.go index 24f5a4fdd47..58b2403de6c 100644 --- a/pkg/gen/internalapi/embedded_spec.go +++ b/pkg/gen/internalapi/embedded_spec.go @@ -5934,7 +5934,8 @@ func init() { "WAITING_ON_CUSTOMER", "NEEDS_ADVANCE_APPROVAL", "NEEDS_CLOSEOUT", - "CLOSEOUT_COMPLETE" + "CLOSEOUT_COMPLETE", + "CANCELLED" ], "readOnly": true }, @@ -14029,7 +14030,8 @@ func init() { "WAITING_ON_CUSTOMER", "NEEDS_ADVANCE_APPROVAL", "NEEDS_CLOSEOUT", - "CLOSEOUT_COMPLETE" + "CLOSEOUT_COMPLETE", + "CANCELLED" ], "readOnly": true }, diff --git a/pkg/gen/internalmessages/p_p_m_shipment_status.go b/pkg/gen/internalmessages/p_p_m_shipment_status.go index f509efa3730..a3feb260493 100644 --- a/pkg/gen/internalmessages/p_p_m_shipment_status.go +++ b/pkg/gen/internalmessages/p_p_m_shipment_status.go @@ -53,6 +53,9 @@ const ( // PPMShipmentStatusCLOSEOUTCOMPLETE captures enum value "CLOSEOUT_COMPLETE" PPMShipmentStatusCLOSEOUTCOMPLETE PPMShipmentStatus = "CLOSEOUT_COMPLETE" + + // PPMShipmentStatusCANCELLED captures enum value "CANCELLED" + PPMShipmentStatusCANCELLED PPMShipmentStatus = "CANCELLED" ) // for schema @@ -60,7 +63,7 @@ var pPMShipmentStatusEnum []interface{} func init() { var res []PPMShipmentStatus - if err := json.Unmarshal([]byte(`["DRAFT","SUBMITTED","WAITING_ON_CUSTOMER","NEEDS_ADVANCE_APPROVAL","NEEDS_CLOSEOUT","CLOSEOUT_COMPLETE"]`), &res); err != nil { + if err := json.Unmarshal([]byte(`["DRAFT","SUBMITTED","WAITING_ON_CUSTOMER","NEEDS_ADVANCE_APPROVAL","NEEDS_CLOSEOUT","CLOSEOUT_COMPLETE","CANCELLED"]`), &res); err != nil { panic(err) } for _, v := range res { diff --git a/pkg/gen/primeapi/embedded_spec.go b/pkg/gen/primeapi/embedded_spec.go index fc782f0cadb..b145851ad48 100644 --- a/pkg/gen/primeapi/embedded_spec.go +++ b/pkg/gen/primeapi/embedded_spec.go @@ -3348,7 +3348,8 @@ func init() { "WAITING_ON_CUSTOMER", "NEEDS_ADVANCE_APPROVAL", "NEEDS_CLOSEOUT", - "CLOSEOUT_COMPLETE" + "CLOSEOUT_COMPLETE", + "CANCELLED" ], "readOnly": true }, @@ -8449,7 +8450,8 @@ func init() { "WAITING_ON_CUSTOMER", "NEEDS_ADVANCE_APPROVAL", "NEEDS_CLOSEOUT", - "CLOSEOUT_COMPLETE" + "CLOSEOUT_COMPLETE", + "CANCELLED" ], "readOnly": true }, diff --git a/pkg/gen/primemessages/p_p_m_shipment_status.go b/pkg/gen/primemessages/p_p_m_shipment_status.go index 371337b4482..30846737272 100644 --- a/pkg/gen/primemessages/p_p_m_shipment_status.go +++ b/pkg/gen/primemessages/p_p_m_shipment_status.go @@ -53,6 +53,9 @@ const ( // PPMShipmentStatusCLOSEOUTCOMPLETE captures enum value "CLOSEOUT_COMPLETE" PPMShipmentStatusCLOSEOUTCOMPLETE PPMShipmentStatus = "CLOSEOUT_COMPLETE" + + // PPMShipmentStatusCANCELLED captures enum value "CANCELLED" + PPMShipmentStatusCANCELLED PPMShipmentStatus = "CANCELLED" ) // for schema @@ -60,7 +63,7 @@ var pPMShipmentStatusEnum []interface{} func init() { var res []PPMShipmentStatus - if err := json.Unmarshal([]byte(`["DRAFT","SUBMITTED","WAITING_ON_CUSTOMER","NEEDS_ADVANCE_APPROVAL","NEEDS_CLOSEOUT","CLOSEOUT_COMPLETE"]`), &res); err != nil { + if err := json.Unmarshal([]byte(`["DRAFT","SUBMITTED","WAITING_ON_CUSTOMER","NEEDS_ADVANCE_APPROVAL","NEEDS_CLOSEOUT","CLOSEOUT_COMPLETE","CANCELLED"]`), &res); err != nil { panic(err) } for _, v := range res { diff --git a/pkg/gen/primev2api/embedded_spec.go b/pkg/gen/primev2api/embedded_spec.go index 704201b4e63..8254cd4ea8a 100644 --- a/pkg/gen/primev2api/embedded_spec.go +++ b/pkg/gen/primev2api/embedded_spec.go @@ -2118,7 +2118,8 @@ func init() { "WAITING_ON_CUSTOMER", "NEEDS_ADVANCE_APPROVAL", "NEEDS_CLOSEOUT", - "CLOSEOUT_COMPLETE" + "CLOSEOUT_COMPLETE", + "CANCELLED" ], "readOnly": true }, @@ -5545,7 +5546,8 @@ func init() { "WAITING_ON_CUSTOMER", "NEEDS_ADVANCE_APPROVAL", "NEEDS_CLOSEOUT", - "CLOSEOUT_COMPLETE" + "CLOSEOUT_COMPLETE", + "CANCELLED" ], "readOnly": true }, diff --git a/pkg/gen/primev2messages/p_p_m_shipment_status.go b/pkg/gen/primev2messages/p_p_m_shipment_status.go index 439086abcaa..1be442c8442 100644 --- a/pkg/gen/primev2messages/p_p_m_shipment_status.go +++ b/pkg/gen/primev2messages/p_p_m_shipment_status.go @@ -53,6 +53,9 @@ const ( // PPMShipmentStatusCLOSEOUTCOMPLETE captures enum value "CLOSEOUT_COMPLETE" PPMShipmentStatusCLOSEOUTCOMPLETE PPMShipmentStatus = "CLOSEOUT_COMPLETE" + + // PPMShipmentStatusCANCELLED captures enum value "CANCELLED" + PPMShipmentStatusCANCELLED PPMShipmentStatus = "CANCELLED" ) // for schema @@ -60,7 +63,7 @@ var pPMShipmentStatusEnum []interface{} func init() { var res []PPMShipmentStatus - if err := json.Unmarshal([]byte(`["DRAFT","SUBMITTED","WAITING_ON_CUSTOMER","NEEDS_ADVANCE_APPROVAL","NEEDS_CLOSEOUT","CLOSEOUT_COMPLETE"]`), &res); err != nil { + if err := json.Unmarshal([]byte(`["DRAFT","SUBMITTED","WAITING_ON_CUSTOMER","NEEDS_ADVANCE_APPROVAL","NEEDS_CLOSEOUT","CLOSEOUT_COMPLETE","CANCELLED"]`), &res); err != nil { panic(err) } for _, v := range res { diff --git a/pkg/gen/primev3api/embedded_spec.go b/pkg/gen/primev3api/embedded_spec.go index 527e9c2be8d..088c5c1fcde 100644 --- a/pkg/gen/primev3api/embedded_spec.go +++ b/pkg/gen/primev3api/embedded_spec.go @@ -2154,7 +2154,8 @@ func init() { "WAITING_ON_CUSTOMER", "NEEDS_ADVANCE_APPROVAL", "NEEDS_CLOSEOUT", - "CLOSEOUT_COMPLETE" + "CLOSEOUT_COMPLETE", + "CANCELLED" ], "readOnly": true }, @@ -5661,7 +5662,8 @@ func init() { "WAITING_ON_CUSTOMER", "NEEDS_ADVANCE_APPROVAL", "NEEDS_CLOSEOUT", - "CLOSEOUT_COMPLETE" + "CLOSEOUT_COMPLETE", + "CANCELLED" ], "readOnly": true }, diff --git a/pkg/gen/primev3messages/p_p_m_shipment_status.go b/pkg/gen/primev3messages/p_p_m_shipment_status.go index e594db1bc55..930aa98929f 100644 --- a/pkg/gen/primev3messages/p_p_m_shipment_status.go +++ b/pkg/gen/primev3messages/p_p_m_shipment_status.go @@ -53,6 +53,9 @@ const ( // PPMShipmentStatusCLOSEOUTCOMPLETE captures enum value "CLOSEOUT_COMPLETE" PPMShipmentStatusCLOSEOUTCOMPLETE PPMShipmentStatus = "CLOSEOUT_COMPLETE" + + // PPMShipmentStatusCANCELLED captures enum value "CANCELLED" + PPMShipmentStatusCANCELLED PPMShipmentStatus = "CANCELLED" ) // for schema @@ -60,7 +63,7 @@ var pPMShipmentStatusEnum []interface{} func init() { var res []PPMShipmentStatus - if err := json.Unmarshal([]byte(`["DRAFT","SUBMITTED","WAITING_ON_CUSTOMER","NEEDS_ADVANCE_APPROVAL","NEEDS_CLOSEOUT","CLOSEOUT_COMPLETE"]`), &res); err != nil { + if err := json.Unmarshal([]byte(`["DRAFT","SUBMITTED","WAITING_ON_CUSTOMER","NEEDS_ADVANCE_APPROVAL","NEEDS_CLOSEOUT","CLOSEOUT_COMPLETE","CANCELLED"]`), &res); err != nil { panic(err) } for _, v := range res { diff --git a/pkg/services/move/move_cancellation.go b/pkg/services/move/move_cancellation.go index 45f89bdfcf0..c1c27c9be65 100644 --- a/pkg/services/move/move_cancellation.go +++ b/pkg/services/move/move_cancellation.go @@ -27,7 +27,7 @@ func (f *moveCancellation) CancelMove(appCtx appcontext.AppContext, moveID uuid. // get all shipments in move for cancellation var shipments []models.MTOShipment - err = appCtx.DB().EagerPreload("Status").Where("mto_shipments.move_id = $1", move.ID).All(&shipments) + err = appCtx.DB().EagerPreload("Status", "PPMShipment", "PPMShipment.Status").Where("mto_shipments.move_id = $1", move.ID).All(&shipments) if err != nil { return nil, apperror.NewNotFoundError(moveID, "while looking for shipments") } @@ -37,6 +37,23 @@ func (f *moveCancellation) CancelMove(appCtx appcontext.AppContext, moveID uuid. shipmentDelta := shipment shipmentDelta.Status = models.MTOShipmentStatusCanceled + if shipment.PPMShipment != nil { + var ppmshipment models.PPMShipment + qerr := appCtx.DB().Where("id = ?", shipment.PPMShipment.ID).First(&ppmshipment) + if qerr != nil { + return apperror.NewNotFoundError(ppmshipment.ID, "while looking for ppm shipment") + } + + ppmshipment.Status = models.PPMShipmentStatusCancelled + + verrs, err := txnAppCtx.DB().ValidateAndUpdate(&ppmshipment) + if verrs != nil && verrs.HasAny() { + return apperror.NewInvalidInputError(shipment.ID, err, verrs, "Validation errors found while setting shipment status") + } else if err != nil { + return apperror.NewQueryError("PPM Shipment", err, "Failed to update status for ppm shipment") + } + } + verrs, err := txnAppCtx.DB().ValidateAndUpdate(&shipmentDelta) if verrs != nil && verrs.HasAny() { return apperror.NewInvalidInputError(shipment.ID, err, verrs, "Validation errors found while setting shipment status") diff --git a/swagger-def/definitions/PPMShipmentStatus.yaml b/swagger-def/definitions/PPMShipmentStatus.yaml index cd9a4aed306..aa935a9e982 100644 --- a/swagger-def/definitions/PPMShipmentStatus.yaml +++ b/swagger-def/definitions/PPMShipmentStatus.yaml @@ -15,3 +15,4 @@ enum: - NEEDS_ADVANCE_APPROVAL - NEEDS_CLOSEOUT - CLOSEOUT_COMPLETE + - CANCELLED \ No newline at end of file diff --git a/swagger/ghc.yaml b/swagger/ghc.yaml index 97c4c3b4aea..09339a37b9f 100644 --- a/swagger/ghc.yaml +++ b/swagger/ghc.yaml @@ -8066,6 +8066,7 @@ definitions: - NEEDS_ADVANCE_APPROVAL - NEEDS_CLOSEOUT - CLOSEOUT_COMPLETE + - CANCELLED PPMAdvanceStatus: type: string title: PPM Advance Status diff --git a/swagger/internal.yaml b/swagger/internal.yaml index a06ea2d0352..1da17375ffd 100644 --- a/swagger/internal.yaml +++ b/swagger/internal.yaml @@ -2667,6 +2667,7 @@ definitions: - NEEDS_ADVANCE_APPROVAL - NEEDS_CLOSEOUT - CLOSEOUT_COMPLETE + - CANCELLED PPMAdvanceStatus: type: string title: PPM Advance Status diff --git a/swagger/prime.yaml b/swagger/prime.yaml index 6c46854d776..f0def9f3c24 100644 --- a/swagger/prime.yaml +++ b/swagger/prime.yaml @@ -3822,6 +3822,7 @@ definitions: - NEEDS_ADVANCE_APPROVAL - NEEDS_CLOSEOUT - CLOSEOUT_COMPLETE + - CANCELLED SITLocationType: description: The list of SIT location types. type: string diff --git a/swagger/prime_v2.yaml b/swagger/prime_v2.yaml index 5075a3fd18e..f705cf6f850 100644 --- a/swagger/prime_v2.yaml +++ b/swagger/prime_v2.yaml @@ -2205,6 +2205,7 @@ definitions: - NEEDS_ADVANCE_APPROVAL - NEEDS_CLOSEOUT - CLOSEOUT_COMPLETE + - CANCELLED SITLocationType: description: The list of SIT location types. type: string diff --git a/swagger/prime_v3.yaml b/swagger/prime_v3.yaml index 65686023697..c5ab6e57755 100644 --- a/swagger/prime_v3.yaml +++ b/swagger/prime_v3.yaml @@ -2229,6 +2229,7 @@ definitions: - NEEDS_ADVANCE_APPROVAL - NEEDS_CLOSEOUT - CLOSEOUT_COMPLETE + - CANCELLED SITLocationType: description: The list of SIT location types. type: string From f154a8f027ded63229893c6b2c18d35b2c00019f Mon Sep 17 00:00:00 2001 From: loganwc Date: Thu, 1 Aug 2024 17:02:53 +0000 Subject: [PATCH 04/37] 1 L not 2 --- .../20240729185147_add_cancel_to_ppm_status_enum.up.sql | 2 +- pkg/gen/ghcapi/embedded_spec.go | 4 ++-- pkg/gen/ghcmessages/p_p_m_shipment_status.go | 6 +++--- pkg/gen/internalapi/embedded_spec.go | 4 ++-- pkg/gen/internalmessages/p_p_m_shipment_status.go | 6 +++--- pkg/gen/primeapi/embedded_spec.go | 4 ++-- pkg/gen/primemessages/p_p_m_shipment_status.go | 6 +++--- pkg/gen/primev2api/embedded_spec.go | 4 ++-- pkg/gen/primev2messages/p_p_m_shipment_status.go | 6 +++--- pkg/gen/primev3api/embedded_spec.go | 4 ++-- pkg/gen/primev3messages/p_p_m_shipment_status.go | 6 +++--- pkg/handlers/ghcapi/api.go | 2 +- pkg/handlers/ghcapi/move.go | 4 ++-- pkg/services/move.go | 2 +- .../move/{move_cancellation.go => move_cancelation.go} | 8 ++++---- ...move_cancellation_test.go => move_cancelation_test.go} | 2 +- swagger-def/definitions/PPMShipmentStatus.yaml | 2 +- swagger/ghc.yaml | 2 +- swagger/internal.yaml | 2 +- swagger/prime.yaml | 2 +- swagger/prime_v2.yaml | 2 +- swagger/prime_v3.yaml | 2 +- 22 files changed, 41 insertions(+), 41 deletions(-) rename pkg/services/move/{move_cancellation.go => move_cancelation.go} (91%) rename pkg/services/move/{move_cancellation_test.go => move_cancelation_test.go} (91%) diff --git a/migrations/app/schema/20240729185147_add_cancel_to_ppm_status_enum.up.sql b/migrations/app/schema/20240729185147_add_cancel_to_ppm_status_enum.up.sql index 07b306cdde3..966c7f400f3 100644 --- a/migrations/app/schema/20240729185147_add_cancel_to_ppm_status_enum.up.sql +++ b/migrations/app/schema/20240729185147_add_cancel_to_ppm_status_enum.up.sql @@ -1 +1 @@ -ALTER TYPE ppm_shipment_status ADD VALUE 'CANCELLED'; \ No newline at end of file +ALTER TYPE ppm_shipment_status ADD VALUE 'CANCELED'; \ No newline at end of file diff --git a/pkg/gen/ghcapi/embedded_spec.go b/pkg/gen/ghcapi/embedded_spec.go index 25793ac5784..84c90899ee6 100644 --- a/pkg/gen/ghcapi/embedded_spec.go +++ b/pkg/gen/ghcapi/embedded_spec.go @@ -10368,7 +10368,7 @@ func init() { "NEEDS_ADVANCE_APPROVAL", "NEEDS_CLOSEOUT", "CLOSEOUT_COMPLETE", - "CANCELLED" + "CANCELED" ], "readOnly": true }, @@ -24956,7 +24956,7 @@ func init() { "NEEDS_ADVANCE_APPROVAL", "NEEDS_CLOSEOUT", "CLOSEOUT_COMPLETE", - "CANCELLED" + "CANCELED" ], "readOnly": true }, diff --git a/pkg/gen/ghcmessages/p_p_m_shipment_status.go b/pkg/gen/ghcmessages/p_p_m_shipment_status.go index 85295645793..c0c00accade 100644 --- a/pkg/gen/ghcmessages/p_p_m_shipment_status.go +++ b/pkg/gen/ghcmessages/p_p_m_shipment_status.go @@ -54,8 +54,8 @@ const ( // PPMShipmentStatusCLOSEOUTCOMPLETE captures enum value "CLOSEOUT_COMPLETE" PPMShipmentStatusCLOSEOUTCOMPLETE PPMShipmentStatus = "CLOSEOUT_COMPLETE" - // PPMShipmentStatusCANCELLED captures enum value "CANCELLED" - PPMShipmentStatusCANCELLED PPMShipmentStatus = "CANCELLED" + // PPMShipmentStatusCANCELED captures enum value "CANCELED" + PPMShipmentStatusCANCELED PPMShipmentStatus = "CANCELED" ) // for schema @@ -63,7 +63,7 @@ var pPMShipmentStatusEnum []interface{} func init() { var res []PPMShipmentStatus - if err := json.Unmarshal([]byte(`["DRAFT","SUBMITTED","WAITING_ON_CUSTOMER","NEEDS_ADVANCE_APPROVAL","NEEDS_CLOSEOUT","CLOSEOUT_COMPLETE","CANCELLED"]`), &res); err != nil { + if err := json.Unmarshal([]byte(`["DRAFT","SUBMITTED","WAITING_ON_CUSTOMER","NEEDS_ADVANCE_APPROVAL","NEEDS_CLOSEOUT","CLOSEOUT_COMPLETE","CANCELED"]`), &res); err != nil { panic(err) } for _, v := range res { diff --git a/pkg/gen/internalapi/embedded_spec.go b/pkg/gen/internalapi/embedded_spec.go index 58b2403de6c..f64e988de2b 100644 --- a/pkg/gen/internalapi/embedded_spec.go +++ b/pkg/gen/internalapi/embedded_spec.go @@ -5935,7 +5935,7 @@ func init() { "NEEDS_ADVANCE_APPROVAL", "NEEDS_CLOSEOUT", "CLOSEOUT_COMPLETE", - "CANCELLED" + "CANCELED" ], "readOnly": true }, @@ -14031,7 +14031,7 @@ func init() { "NEEDS_ADVANCE_APPROVAL", "NEEDS_CLOSEOUT", "CLOSEOUT_COMPLETE", - "CANCELLED" + "CANCELED" ], "readOnly": true }, diff --git a/pkg/gen/internalmessages/p_p_m_shipment_status.go b/pkg/gen/internalmessages/p_p_m_shipment_status.go index a3feb260493..eade223927b 100644 --- a/pkg/gen/internalmessages/p_p_m_shipment_status.go +++ b/pkg/gen/internalmessages/p_p_m_shipment_status.go @@ -54,8 +54,8 @@ const ( // PPMShipmentStatusCLOSEOUTCOMPLETE captures enum value "CLOSEOUT_COMPLETE" PPMShipmentStatusCLOSEOUTCOMPLETE PPMShipmentStatus = "CLOSEOUT_COMPLETE" - // PPMShipmentStatusCANCELLED captures enum value "CANCELLED" - PPMShipmentStatusCANCELLED PPMShipmentStatus = "CANCELLED" + // PPMShipmentStatusCANCELED captures enum value "CANCELED" + PPMShipmentStatusCANCELED PPMShipmentStatus = "CANCELED" ) // for schema @@ -63,7 +63,7 @@ var pPMShipmentStatusEnum []interface{} func init() { var res []PPMShipmentStatus - if err := json.Unmarshal([]byte(`["DRAFT","SUBMITTED","WAITING_ON_CUSTOMER","NEEDS_ADVANCE_APPROVAL","NEEDS_CLOSEOUT","CLOSEOUT_COMPLETE","CANCELLED"]`), &res); err != nil { + if err := json.Unmarshal([]byte(`["DRAFT","SUBMITTED","WAITING_ON_CUSTOMER","NEEDS_ADVANCE_APPROVAL","NEEDS_CLOSEOUT","CLOSEOUT_COMPLETE","CANCELED"]`), &res); err != nil { panic(err) } for _, v := range res { diff --git a/pkg/gen/primeapi/embedded_spec.go b/pkg/gen/primeapi/embedded_spec.go index b145851ad48..131b3760b88 100644 --- a/pkg/gen/primeapi/embedded_spec.go +++ b/pkg/gen/primeapi/embedded_spec.go @@ -3349,7 +3349,7 @@ func init() { "NEEDS_ADVANCE_APPROVAL", "NEEDS_CLOSEOUT", "CLOSEOUT_COMPLETE", - "CANCELLED" + "CANCELED" ], "readOnly": true }, @@ -8451,7 +8451,7 @@ func init() { "NEEDS_ADVANCE_APPROVAL", "NEEDS_CLOSEOUT", "CLOSEOUT_COMPLETE", - "CANCELLED" + "CANCELED" ], "readOnly": true }, diff --git a/pkg/gen/primemessages/p_p_m_shipment_status.go b/pkg/gen/primemessages/p_p_m_shipment_status.go index 30846737272..8c3914c3f73 100644 --- a/pkg/gen/primemessages/p_p_m_shipment_status.go +++ b/pkg/gen/primemessages/p_p_m_shipment_status.go @@ -54,8 +54,8 @@ const ( // PPMShipmentStatusCLOSEOUTCOMPLETE captures enum value "CLOSEOUT_COMPLETE" PPMShipmentStatusCLOSEOUTCOMPLETE PPMShipmentStatus = "CLOSEOUT_COMPLETE" - // PPMShipmentStatusCANCELLED captures enum value "CANCELLED" - PPMShipmentStatusCANCELLED PPMShipmentStatus = "CANCELLED" + // PPMShipmentStatusCANCELED captures enum value "CANCELED" + PPMShipmentStatusCANCELED PPMShipmentStatus = "CANCELED" ) // for schema @@ -63,7 +63,7 @@ var pPMShipmentStatusEnum []interface{} func init() { var res []PPMShipmentStatus - if err := json.Unmarshal([]byte(`["DRAFT","SUBMITTED","WAITING_ON_CUSTOMER","NEEDS_ADVANCE_APPROVAL","NEEDS_CLOSEOUT","CLOSEOUT_COMPLETE","CANCELLED"]`), &res); err != nil { + if err := json.Unmarshal([]byte(`["DRAFT","SUBMITTED","WAITING_ON_CUSTOMER","NEEDS_ADVANCE_APPROVAL","NEEDS_CLOSEOUT","CLOSEOUT_COMPLETE","CANCELED"]`), &res); err != nil { panic(err) } for _, v := range res { diff --git a/pkg/gen/primev2api/embedded_spec.go b/pkg/gen/primev2api/embedded_spec.go index 8254cd4ea8a..55ed2f186b2 100644 --- a/pkg/gen/primev2api/embedded_spec.go +++ b/pkg/gen/primev2api/embedded_spec.go @@ -2119,7 +2119,7 @@ func init() { "NEEDS_ADVANCE_APPROVAL", "NEEDS_CLOSEOUT", "CLOSEOUT_COMPLETE", - "CANCELLED" + "CANCELED" ], "readOnly": true }, @@ -5547,7 +5547,7 @@ func init() { "NEEDS_ADVANCE_APPROVAL", "NEEDS_CLOSEOUT", "CLOSEOUT_COMPLETE", - "CANCELLED" + "CANCELED" ], "readOnly": true }, diff --git a/pkg/gen/primev2messages/p_p_m_shipment_status.go b/pkg/gen/primev2messages/p_p_m_shipment_status.go index 1be442c8442..ccbf00e05d1 100644 --- a/pkg/gen/primev2messages/p_p_m_shipment_status.go +++ b/pkg/gen/primev2messages/p_p_m_shipment_status.go @@ -54,8 +54,8 @@ const ( // PPMShipmentStatusCLOSEOUTCOMPLETE captures enum value "CLOSEOUT_COMPLETE" PPMShipmentStatusCLOSEOUTCOMPLETE PPMShipmentStatus = "CLOSEOUT_COMPLETE" - // PPMShipmentStatusCANCELLED captures enum value "CANCELLED" - PPMShipmentStatusCANCELLED PPMShipmentStatus = "CANCELLED" + // PPMShipmentStatusCANCELED captures enum value "CANCELED" + PPMShipmentStatusCANCELED PPMShipmentStatus = "CANCELED" ) // for schema @@ -63,7 +63,7 @@ var pPMShipmentStatusEnum []interface{} func init() { var res []PPMShipmentStatus - if err := json.Unmarshal([]byte(`["DRAFT","SUBMITTED","WAITING_ON_CUSTOMER","NEEDS_ADVANCE_APPROVAL","NEEDS_CLOSEOUT","CLOSEOUT_COMPLETE","CANCELLED"]`), &res); err != nil { + if err := json.Unmarshal([]byte(`["DRAFT","SUBMITTED","WAITING_ON_CUSTOMER","NEEDS_ADVANCE_APPROVAL","NEEDS_CLOSEOUT","CLOSEOUT_COMPLETE","CANCELED"]`), &res); err != nil { panic(err) } for _, v := range res { diff --git a/pkg/gen/primev3api/embedded_spec.go b/pkg/gen/primev3api/embedded_spec.go index 088c5c1fcde..3c864e81c07 100644 --- a/pkg/gen/primev3api/embedded_spec.go +++ b/pkg/gen/primev3api/embedded_spec.go @@ -2155,7 +2155,7 @@ func init() { "NEEDS_ADVANCE_APPROVAL", "NEEDS_CLOSEOUT", "CLOSEOUT_COMPLETE", - "CANCELLED" + "CANCELED" ], "readOnly": true }, @@ -5663,7 +5663,7 @@ func init() { "NEEDS_ADVANCE_APPROVAL", "NEEDS_CLOSEOUT", "CLOSEOUT_COMPLETE", - "CANCELLED" + "CANCELED" ], "readOnly": true }, diff --git a/pkg/gen/primev3messages/p_p_m_shipment_status.go b/pkg/gen/primev3messages/p_p_m_shipment_status.go index 930aa98929f..a2f5bd086cd 100644 --- a/pkg/gen/primev3messages/p_p_m_shipment_status.go +++ b/pkg/gen/primev3messages/p_p_m_shipment_status.go @@ -54,8 +54,8 @@ const ( // PPMShipmentStatusCLOSEOUTCOMPLETE captures enum value "CLOSEOUT_COMPLETE" PPMShipmentStatusCLOSEOUTCOMPLETE PPMShipmentStatus = "CLOSEOUT_COMPLETE" - // PPMShipmentStatusCANCELLED captures enum value "CANCELLED" - PPMShipmentStatusCANCELLED PPMShipmentStatus = "CANCELLED" + // PPMShipmentStatusCANCELED captures enum value "CANCELED" + PPMShipmentStatusCANCELED PPMShipmentStatus = "CANCELED" ) // for schema @@ -63,7 +63,7 @@ var pPMShipmentStatusEnum []interface{} func init() { var res []PPMShipmentStatus - if err := json.Unmarshal([]byte(`["DRAFT","SUBMITTED","WAITING_ON_CUSTOMER","NEEDS_ADVANCE_APPROVAL","NEEDS_CLOSEOUT","CLOSEOUT_COMPLETE","CANCELLED"]`), &res); err != nil { + if err := json.Unmarshal([]byte(`["DRAFT","SUBMITTED","WAITING_ON_CUSTOMER","NEEDS_ADVANCE_APPROVAL","NEEDS_CLOSEOUT","CLOSEOUT_COMPLETE","CANCELED"]`), &res); err != nil { panic(err) } for _, v := range res { diff --git a/pkg/handlers/ghcapi/api.go b/pkg/handlers/ghcapi/api.go index d7101aec4e1..9f94baaad89 100644 --- a/pkg/handlers/ghcapi/api.go +++ b/pkg/handlers/ghcapi/api.go @@ -658,7 +658,7 @@ func NewGhcAPIHandler(handlerConfig handlers.HandlerConfig) *ghcops.MymoveAPI { ghcAPI.MoveMoveCancellationHandler = MoveCancellationHandler{ handlerConfig, - move.NewMoveCancellation(), + move.NewMoveCancelation(), } return ghcAPI diff --git a/pkg/handlers/ghcapi/move.go b/pkg/handlers/ghcapi/move.go index 0324cdcec50..c2d1ee9fdcd 100644 --- a/pkg/handlers/ghcapi/move.go +++ b/pkg/handlers/ghcapi/move.go @@ -281,7 +281,7 @@ func (h UploadAdditionalDocumentsHandler) Handle(params moveop.UploadAdditionalD type MoveCancellationHandler struct { handlers.HandlerConfig - services.MoveCancellation + services.MoveCancelation } func (h MoveCancellationHandler) Handle(params moveop.MoveCancellationParams) middleware.Responder { @@ -289,7 +289,7 @@ func (h MoveCancellationHandler) Handle(params moveop.MoveCancellationParams) mi func(appCtx appcontext.AppContext) (middleware.Responder, error) { moveID := uuid.FromStringOrNil(params.MoveID.String()) - move, err := h.MoveCancellation.CancelMove(appCtx, moveID) + move, err := h.MoveCancelation.CancelMove(appCtx, moveID) if err != nil { appCtx.Logger().Error("MoveCancellationHandler error", zap.Error(err)) switch err.(type) { diff --git a/pkg/services/move.go b/pkg/services/move.go index 130669c0042..8997c1fe3d6 100644 --- a/pkg/services/move.go +++ b/pkg/services/move.go @@ -113,6 +113,6 @@ type MoveCloseoutOfficeUpdater interface { UpdateCloseoutOffice(appCtx appcontext.AppContext, moveLocator string, closeoutOfficeID uuid.UUID, eTag string) (*models.Move, error) } -type MoveCancellation interface { +type MoveCancelation interface { CancelMove(appCtx appcontext.AppContext, moveID uuid.UUID) (*models.Move, error) } diff --git a/pkg/services/move/move_cancellation.go b/pkg/services/move/move_cancelation.go similarity index 91% rename from pkg/services/move/move_cancellation.go rename to pkg/services/move/move_cancelation.go index c1c27c9be65..c2c9229f435 100644 --- a/pkg/services/move/move_cancellation.go +++ b/pkg/services/move/move_cancelation.go @@ -9,13 +9,13 @@ import ( "github.com/transcom/mymove/pkg/services" ) -type moveCancellation struct{} +type moveCancelation struct{} -func NewMoveCancellation() services.MoveCancellation { - return &moveCancellation{} +func NewMoveCancelation() services.MoveCancelation { + return &moveCancelation{} } -func (f *moveCancellation) CancelMove(appCtx appcontext.AppContext, moveID uuid.UUID) (*models.Move, error) { +func (f *moveCancelation) CancelMove(appCtx appcontext.AppContext, moveID uuid.UUID) (*models.Move, error) { move := &models.Move{} err := appCtx.DB().Find(move, moveID) if err != nil { diff --git a/pkg/services/move/move_cancellation_test.go b/pkg/services/move/move_cancelation_test.go similarity index 91% rename from pkg/services/move/move_cancellation_test.go rename to pkg/services/move/move_cancelation_test.go index f9d213060a8..3c8c02d2bd3 100644 --- a/pkg/services/move/move_cancellation_test.go +++ b/pkg/services/move/move_cancelation_test.go @@ -6,7 +6,7 @@ import ( ) func (suite *MoveServiceSuite) TestCancelMove() { - moveCancellation := NewMoveCancellation() + moveCancellation := NewMoveCancelation() suite.Run("successfully cancels a move", func() { move := factory.BuildMove(suite.DB(), nil, nil) diff --git a/swagger-def/definitions/PPMShipmentStatus.yaml b/swagger-def/definitions/PPMShipmentStatus.yaml index aa935a9e982..c4bff9288f0 100644 --- a/swagger-def/definitions/PPMShipmentStatus.yaml +++ b/swagger-def/definitions/PPMShipmentStatus.yaml @@ -15,4 +15,4 @@ enum: - NEEDS_ADVANCE_APPROVAL - NEEDS_CLOSEOUT - CLOSEOUT_COMPLETE - - CANCELLED \ No newline at end of file + - CANCELED \ No newline at end of file diff --git a/swagger/ghc.yaml b/swagger/ghc.yaml index 09339a37b9f..c2af626e302 100644 --- a/swagger/ghc.yaml +++ b/swagger/ghc.yaml @@ -8066,7 +8066,7 @@ definitions: - NEEDS_ADVANCE_APPROVAL - NEEDS_CLOSEOUT - CLOSEOUT_COMPLETE - - CANCELLED + - CANCELED PPMAdvanceStatus: type: string title: PPM Advance Status diff --git a/swagger/internal.yaml b/swagger/internal.yaml index 1da17375ffd..4027d22d7f6 100644 --- a/swagger/internal.yaml +++ b/swagger/internal.yaml @@ -2667,7 +2667,7 @@ definitions: - NEEDS_ADVANCE_APPROVAL - NEEDS_CLOSEOUT - CLOSEOUT_COMPLETE - - CANCELLED + - CANCELED PPMAdvanceStatus: type: string title: PPM Advance Status diff --git a/swagger/prime.yaml b/swagger/prime.yaml index f0def9f3c24..eb914b772bd 100644 --- a/swagger/prime.yaml +++ b/swagger/prime.yaml @@ -3822,7 +3822,7 @@ definitions: - NEEDS_ADVANCE_APPROVAL - NEEDS_CLOSEOUT - CLOSEOUT_COMPLETE - - CANCELLED + - CANCELED SITLocationType: description: The list of SIT location types. type: string diff --git a/swagger/prime_v2.yaml b/swagger/prime_v2.yaml index f705cf6f850..b26f035fd1c 100644 --- a/swagger/prime_v2.yaml +++ b/swagger/prime_v2.yaml @@ -2205,7 +2205,7 @@ definitions: - NEEDS_ADVANCE_APPROVAL - NEEDS_CLOSEOUT - CLOSEOUT_COMPLETE - - CANCELLED + - CANCELED SITLocationType: description: The list of SIT location types. type: string diff --git a/swagger/prime_v3.yaml b/swagger/prime_v3.yaml index c5ab6e57755..4a35a12f8b3 100644 --- a/swagger/prime_v3.yaml +++ b/swagger/prime_v3.yaml @@ -2229,7 +2229,7 @@ definitions: - NEEDS_ADVANCE_APPROVAL - NEEDS_CLOSEOUT - CLOSEOUT_COMPLETE - - CANCELLED + - CANCELED SITLocationType: description: The list of SIT location types. type: string From b81474629936e644a025157b2a87aad923db6674 Mon Sep 17 00:00:00 2001 From: loganwc Date: Thu, 1 Aug 2024 17:24:53 +0000 Subject: [PATCH 05/37] 1 l not 2 part2 --- pkg/gen/ghcapi/configure_mymove.go | 6 +- pkg/gen/ghcapi/embedded_spec.go | 4 +- .../ghcoperations/move/move_cancelation.go | 58 +++ ...ters.go => move_cancelation_parameters.go} | 20 +- .../move/move_cancelation_responses.go | 329 ++++++++++++++++++ ...lder.go => move_cancelation_urlbuilder.go} | 24 +- .../ghcoperations/move/move_cancellation.go | 58 --- .../move/move_cancellation_responses.go | 329 ------------------ pkg/gen/ghcapi/ghcoperations/mymove_api.go | 14 +- pkg/handlers/ghcapi/api.go | 2 +- pkg/handlers/ghcapi/move.go | 12 +- swagger-def/ghc.yaml | 2 +- swagger/ghc.yaml | 2 +- 13 files changed, 430 insertions(+), 430 deletions(-) create mode 100644 pkg/gen/ghcapi/ghcoperations/move/move_cancelation.go rename pkg/gen/ghcapi/ghcoperations/move/{move_cancellation_parameters.go => move_cancelation_parameters.go} (73%) create mode 100644 pkg/gen/ghcapi/ghcoperations/move/move_cancelation_responses.go rename pkg/gen/ghcapi/ghcoperations/move/{move_cancellation_urlbuilder.go => move_cancelation_urlbuilder.go} (74%) delete mode 100644 pkg/gen/ghcapi/ghcoperations/move/move_cancellation.go delete mode 100644 pkg/gen/ghcapi/ghcoperations/move/move_cancellation_responses.go diff --git a/pkg/gen/ghcapi/configure_mymove.go b/pkg/gen/ghcapi/configure_mymove.go index 192fe39e8d5..01c94b74da7 100644 --- a/pkg/gen/ghcapi/configure_mymove.go +++ b/pkg/gen/ghcapi/configure_mymove.go @@ -354,9 +354,9 @@ func configureAPI(api *ghcoperations.MymoveAPI) http.Handler { return middleware.NotImplemented("operation queues.ListPrimeMoves has not yet been implemented") }) } - if api.MoveMoveCancellationHandler == nil { - api.MoveMoveCancellationHandler = move.MoveCancellationHandlerFunc(func(params move.MoveCancellationParams) middleware.Responder { - return middleware.NotImplemented("operation move.MoveCancellation has not yet been implemented") + if api.MoveMoveCancelationHandler == nil { + api.MoveMoveCancelationHandler = move.MoveCancelationHandlerFunc(func(params move.MoveCancelationParams) middleware.Responder { + return middleware.NotImplemented("operation move.MoveCancelation has not yet been implemented") }) } if api.ShipmentRejectShipmentHandler == nil { diff --git a/pkg/gen/ghcapi/embedded_spec.go b/pkg/gen/ghcapi/embedded_spec.go index 84c90899ee6..1a6c5ff98b3 100644 --- a/pkg/gen/ghcapi/embedded_spec.go +++ b/pkg/gen/ghcapi/embedded_spec.go @@ -2238,7 +2238,7 @@ func init() { "move" ], "summary": "Cancels a move", - "operationId": "moveCancellation", + "operationId": "moveCancelation", "responses": { "200": { "description": "Successfully cancelled move", @@ -15969,7 +15969,7 @@ func init() { "move" ], "summary": "Cancels a move", - "operationId": "moveCancellation", + "operationId": "moveCancelation", "responses": { "200": { "description": "Successfully cancelled move", diff --git a/pkg/gen/ghcapi/ghcoperations/move/move_cancelation.go b/pkg/gen/ghcapi/ghcoperations/move/move_cancelation.go new file mode 100644 index 00000000000..0ef81e57167 --- /dev/null +++ b/pkg/gen/ghcapi/ghcoperations/move/move_cancelation.go @@ -0,0 +1,58 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package move + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// MoveCancelationHandlerFunc turns a function with the right signature into a move cancelation handler +type MoveCancelationHandlerFunc func(MoveCancelationParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn MoveCancelationHandlerFunc) Handle(params MoveCancelationParams) middleware.Responder { + return fn(params) +} + +// MoveCancelationHandler interface for that can handle valid move cancelation params +type MoveCancelationHandler interface { + Handle(MoveCancelationParams) middleware.Responder +} + +// NewMoveCancelation creates a new http.Handler for the move cancelation operation +func NewMoveCancelation(ctx *middleware.Context, handler MoveCancelationHandler) *MoveCancelation { + return &MoveCancelation{Context: ctx, Handler: handler} +} + +/* + MoveCancelation swagger:route POST /moves/{moveID}/cancel move moveCancelation + +# Cancels a move + +cancels a move +*/ +type MoveCancelation struct { + Context *middleware.Context + Handler MoveCancelationHandler +} + +func (o *MoveCancelation) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewMoveCancelationParams() + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/pkg/gen/ghcapi/ghcoperations/move/move_cancellation_parameters.go b/pkg/gen/ghcapi/ghcoperations/move/move_cancelation_parameters.go similarity index 73% rename from pkg/gen/ghcapi/ghcoperations/move/move_cancellation_parameters.go rename to pkg/gen/ghcapi/ghcoperations/move/move_cancelation_parameters.go index 98a353a63ae..423bf6eca75 100644 --- a/pkg/gen/ghcapi/ghcoperations/move/move_cancellation_parameters.go +++ b/pkg/gen/ghcapi/ghcoperations/move/move_cancelation_parameters.go @@ -14,19 +14,19 @@ import ( "github.com/go-openapi/validate" ) -// NewMoveCancellationParams creates a new MoveCancellationParams object +// NewMoveCancelationParams creates a new MoveCancelationParams object // // There are no default values defined in the spec. -func NewMoveCancellationParams() MoveCancellationParams { +func NewMoveCancelationParams() MoveCancelationParams { - return MoveCancellationParams{} + return MoveCancelationParams{} } -// MoveCancellationParams contains all the bound params for the move cancellation operation +// MoveCancelationParams contains all the bound params for the move cancelation operation // typically these are obtained from a http.Request // -// swagger:parameters moveCancellation -type MoveCancellationParams struct { +// swagger:parameters moveCancelation +type MoveCancelationParams struct { // HTTP Request Object HTTPRequest *http.Request `json:"-"` @@ -41,8 +41,8 @@ type MoveCancellationParams struct { // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface // for simple values it will use straight method calls. // -// To ensure default values, the struct must have been initialized with NewMoveCancellationParams() beforehand. -func (o *MoveCancellationParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { +// To ensure default values, the struct must have been initialized with NewMoveCancelationParams() beforehand. +func (o *MoveCancelationParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { var res []error o.HTTPRequest = r @@ -58,7 +58,7 @@ func (o *MoveCancellationParams) BindRequest(r *http.Request, route *middleware. } // bindMoveID binds and validates parameter MoveID from path. -func (o *MoveCancellationParams) bindMoveID(rawData []string, hasKey bool, formats strfmt.Registry) error { +func (o *MoveCancelationParams) bindMoveID(rawData []string, hasKey bool, formats strfmt.Registry) error { var raw string if len(rawData) > 0 { raw = rawData[len(rawData)-1] @@ -82,7 +82,7 @@ func (o *MoveCancellationParams) bindMoveID(rawData []string, hasKey bool, forma } // validateMoveID carries on validations for parameter MoveID -func (o *MoveCancellationParams) validateMoveID(formats strfmt.Registry) error { +func (o *MoveCancelationParams) validateMoveID(formats strfmt.Registry) error { if err := validate.FormatOf("moveID", "path", "uuid", o.MoveID.String(), formats); err != nil { return err diff --git a/pkg/gen/ghcapi/ghcoperations/move/move_cancelation_responses.go b/pkg/gen/ghcapi/ghcoperations/move/move_cancelation_responses.go new file mode 100644 index 00000000000..4fa392a314a --- /dev/null +++ b/pkg/gen/ghcapi/ghcoperations/move/move_cancelation_responses.go @@ -0,0 +1,329 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package move + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/transcom/mymove/pkg/gen/ghcmessages" +) + +// MoveCancelationOKCode is the HTTP code returned for type MoveCancelationOK +const MoveCancelationOKCode int = 200 + +/* +MoveCancelationOK Successfully cancelled move + +swagger:response moveCancelationOK +*/ +type MoveCancelationOK struct { + + /* + In: Body + */ + Payload *ghcmessages.Move `json:"body,omitempty"` +} + +// NewMoveCancelationOK creates MoveCancelationOK with default headers values +func NewMoveCancelationOK() *MoveCancelationOK { + + return &MoveCancelationOK{} +} + +// WithPayload adds the payload to the move cancelation o k response +func (o *MoveCancelationOK) WithPayload(payload *ghcmessages.Move) *MoveCancelationOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the move cancelation o k response +func (o *MoveCancelationOK) SetPayload(payload *ghcmessages.Move) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *MoveCancelationOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// MoveCancelationForbiddenCode is the HTTP code returned for type MoveCancelationForbidden +const MoveCancelationForbiddenCode int = 403 + +/* +MoveCancelationForbidden The request was denied + +swagger:response moveCancelationForbidden +*/ +type MoveCancelationForbidden struct { + + /* + In: Body + */ + Payload *ghcmessages.Error `json:"body,omitempty"` +} + +// NewMoveCancelationForbidden creates MoveCancelationForbidden with default headers values +func NewMoveCancelationForbidden() *MoveCancelationForbidden { + + return &MoveCancelationForbidden{} +} + +// WithPayload adds the payload to the move cancelation forbidden response +func (o *MoveCancelationForbidden) WithPayload(payload *ghcmessages.Error) *MoveCancelationForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the move cancelation forbidden response +func (o *MoveCancelationForbidden) SetPayload(payload *ghcmessages.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *MoveCancelationForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// MoveCancelationNotFoundCode is the HTTP code returned for type MoveCancelationNotFound +const MoveCancelationNotFoundCode int = 404 + +/* +MoveCancelationNotFound The requested resource wasn't found + +swagger:response moveCancelationNotFound +*/ +type MoveCancelationNotFound struct { + + /* + In: Body + */ + Payload *ghcmessages.Error `json:"body,omitempty"` +} + +// NewMoveCancelationNotFound creates MoveCancelationNotFound with default headers values +func NewMoveCancelationNotFound() *MoveCancelationNotFound { + + return &MoveCancelationNotFound{} +} + +// WithPayload adds the payload to the move cancelation not found response +func (o *MoveCancelationNotFound) WithPayload(payload *ghcmessages.Error) *MoveCancelationNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the move cancelation not found response +func (o *MoveCancelationNotFound) SetPayload(payload *ghcmessages.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *MoveCancelationNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// MoveCancelationConflictCode is the HTTP code returned for type MoveCancelationConflict +const MoveCancelationConflictCode int = 409 + +/* +MoveCancelationConflict Conflict error + +swagger:response moveCancelationConflict +*/ +type MoveCancelationConflict struct { + + /* + In: Body + */ + Payload *ghcmessages.Error `json:"body,omitempty"` +} + +// NewMoveCancelationConflict creates MoveCancelationConflict with default headers values +func NewMoveCancelationConflict() *MoveCancelationConflict { + + return &MoveCancelationConflict{} +} + +// WithPayload adds the payload to the move cancelation conflict response +func (o *MoveCancelationConflict) WithPayload(payload *ghcmessages.Error) *MoveCancelationConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the move cancelation conflict response +func (o *MoveCancelationConflict) SetPayload(payload *ghcmessages.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *MoveCancelationConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// MoveCancelationPreconditionFailedCode is the HTTP code returned for type MoveCancelationPreconditionFailed +const MoveCancelationPreconditionFailedCode int = 412 + +/* +MoveCancelationPreconditionFailed Precondition failed + +swagger:response moveCancelationPreconditionFailed +*/ +type MoveCancelationPreconditionFailed struct { + + /* + In: Body + */ + Payload *ghcmessages.Error `json:"body,omitempty"` +} + +// NewMoveCancelationPreconditionFailed creates MoveCancelationPreconditionFailed with default headers values +func NewMoveCancelationPreconditionFailed() *MoveCancelationPreconditionFailed { + + return &MoveCancelationPreconditionFailed{} +} + +// WithPayload adds the payload to the move cancelation precondition failed response +func (o *MoveCancelationPreconditionFailed) WithPayload(payload *ghcmessages.Error) *MoveCancelationPreconditionFailed { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the move cancelation precondition failed response +func (o *MoveCancelationPreconditionFailed) SetPayload(payload *ghcmessages.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *MoveCancelationPreconditionFailed) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(412) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// MoveCancelationUnprocessableEntityCode is the HTTP code returned for type MoveCancelationUnprocessableEntity +const MoveCancelationUnprocessableEntityCode int = 422 + +/* +MoveCancelationUnprocessableEntity The payload was unprocessable. + +swagger:response moveCancelationUnprocessableEntity +*/ +type MoveCancelationUnprocessableEntity struct { + + /* + In: Body + */ + Payload *ghcmessages.ValidationError `json:"body,omitempty"` +} + +// NewMoveCancelationUnprocessableEntity creates MoveCancelationUnprocessableEntity with default headers values +func NewMoveCancelationUnprocessableEntity() *MoveCancelationUnprocessableEntity { + + return &MoveCancelationUnprocessableEntity{} +} + +// WithPayload adds the payload to the move cancelation unprocessable entity response +func (o *MoveCancelationUnprocessableEntity) WithPayload(payload *ghcmessages.ValidationError) *MoveCancelationUnprocessableEntity { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the move cancelation unprocessable entity response +func (o *MoveCancelationUnprocessableEntity) SetPayload(payload *ghcmessages.ValidationError) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *MoveCancelationUnprocessableEntity) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(422) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// MoveCancelationInternalServerErrorCode is the HTTP code returned for type MoveCancelationInternalServerError +const MoveCancelationInternalServerErrorCode int = 500 + +/* +MoveCancelationInternalServerError A server error occurred + +swagger:response moveCancelationInternalServerError +*/ +type MoveCancelationInternalServerError struct { + + /* + In: Body + */ + Payload *ghcmessages.Error `json:"body,omitempty"` +} + +// NewMoveCancelationInternalServerError creates MoveCancelationInternalServerError with default headers values +func NewMoveCancelationInternalServerError() *MoveCancelationInternalServerError { + + return &MoveCancelationInternalServerError{} +} + +// WithPayload adds the payload to the move cancelation internal server error response +func (o *MoveCancelationInternalServerError) WithPayload(payload *ghcmessages.Error) *MoveCancelationInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the move cancelation internal server error response +func (o *MoveCancelationInternalServerError) SetPayload(payload *ghcmessages.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *MoveCancelationInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/pkg/gen/ghcapi/ghcoperations/move/move_cancellation_urlbuilder.go b/pkg/gen/ghcapi/ghcoperations/move/move_cancelation_urlbuilder.go similarity index 74% rename from pkg/gen/ghcapi/ghcoperations/move/move_cancellation_urlbuilder.go rename to pkg/gen/ghcapi/ghcoperations/move/move_cancelation_urlbuilder.go index fd91266aa01..62afc20dc03 100644 --- a/pkg/gen/ghcapi/ghcoperations/move/move_cancellation_urlbuilder.go +++ b/pkg/gen/ghcapi/ghcoperations/move/move_cancelation_urlbuilder.go @@ -14,8 +14,8 @@ import ( "github.com/go-openapi/strfmt" ) -// MoveCancellationURL generates an URL for the move cancellation operation -type MoveCancellationURL struct { +// MoveCancelationURL generates an URL for the move cancelation operation +type MoveCancelationURL struct { MoveID strfmt.UUID _basePath string @@ -26,7 +26,7 @@ type MoveCancellationURL struct { // WithBasePath sets the base path for this url builder, only required when it's different from the // base path specified in the swagger spec. // When the value of the base path is an empty string -func (o *MoveCancellationURL) WithBasePath(bp string) *MoveCancellationURL { +func (o *MoveCancelationURL) WithBasePath(bp string) *MoveCancelationURL { o.SetBasePath(bp) return o } @@ -34,12 +34,12 @@ func (o *MoveCancellationURL) WithBasePath(bp string) *MoveCancellationURL { // SetBasePath sets the base path for this url builder, only required when it's different from the // base path specified in the swagger spec. // When the value of the base path is an empty string -func (o *MoveCancellationURL) SetBasePath(bp string) { +func (o *MoveCancelationURL) SetBasePath(bp string) { o._basePath = bp } // Build a url path and query string -func (o *MoveCancellationURL) Build() (*url.URL, error) { +func (o *MoveCancelationURL) Build() (*url.URL, error) { var _result url.URL var _path = "/moves/{moveID}/cancel" @@ -48,7 +48,7 @@ func (o *MoveCancellationURL) Build() (*url.URL, error) { if moveID != "" { _path = strings.Replace(_path, "{moveID}", moveID, -1) } else { - return nil, errors.New("moveId is required on MoveCancellationURL") + return nil, errors.New("moveId is required on MoveCancelationURL") } _basePath := o._basePath @@ -61,7 +61,7 @@ func (o *MoveCancellationURL) Build() (*url.URL, error) { } // Must is a helper function to panic when the url builder returns an error -func (o *MoveCancellationURL) Must(u *url.URL, err error) *url.URL { +func (o *MoveCancelationURL) Must(u *url.URL, err error) *url.URL { if err != nil { panic(err) } @@ -72,17 +72,17 @@ func (o *MoveCancellationURL) Must(u *url.URL, err error) *url.URL { } // String returns the string representation of the path with query string -func (o *MoveCancellationURL) String() string { +func (o *MoveCancelationURL) String() string { return o.Must(o.Build()).String() } // BuildFull builds a full url with scheme, host, path and query string -func (o *MoveCancellationURL) BuildFull(scheme, host string) (*url.URL, error) { +func (o *MoveCancelationURL) BuildFull(scheme, host string) (*url.URL, error) { if scheme == "" { - return nil, errors.New("scheme is required for a full url on MoveCancellationURL") + return nil, errors.New("scheme is required for a full url on MoveCancelationURL") } if host == "" { - return nil, errors.New("host is required for a full url on MoveCancellationURL") + return nil, errors.New("host is required for a full url on MoveCancelationURL") } base, err := o.Build() @@ -96,6 +96,6 @@ func (o *MoveCancellationURL) BuildFull(scheme, host string) (*url.URL, error) { } // StringFull returns the string representation of a complete url -func (o *MoveCancellationURL) StringFull(scheme, host string) string { +func (o *MoveCancelationURL) StringFull(scheme, host string) string { return o.Must(o.BuildFull(scheme, host)).String() } diff --git a/pkg/gen/ghcapi/ghcoperations/move/move_cancellation.go b/pkg/gen/ghcapi/ghcoperations/move/move_cancellation.go deleted file mode 100644 index a2d9f8a9bf3..00000000000 --- a/pkg/gen/ghcapi/ghcoperations/move/move_cancellation.go +++ /dev/null @@ -1,58 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package move - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "net/http" - - "github.com/go-openapi/runtime/middleware" -) - -// MoveCancellationHandlerFunc turns a function with the right signature into a move cancellation handler -type MoveCancellationHandlerFunc func(MoveCancellationParams) middleware.Responder - -// Handle executing the request and returning a response -func (fn MoveCancellationHandlerFunc) Handle(params MoveCancellationParams) middleware.Responder { - return fn(params) -} - -// MoveCancellationHandler interface for that can handle valid move cancellation params -type MoveCancellationHandler interface { - Handle(MoveCancellationParams) middleware.Responder -} - -// NewMoveCancellation creates a new http.Handler for the move cancellation operation -func NewMoveCancellation(ctx *middleware.Context, handler MoveCancellationHandler) *MoveCancellation { - return &MoveCancellation{Context: ctx, Handler: handler} -} - -/* - MoveCancellation swagger:route POST /moves/{moveID}/cancel move moveCancellation - -# Cancels a move - -cancels a move -*/ -type MoveCancellation struct { - Context *middleware.Context - Handler MoveCancellationHandler -} - -func (o *MoveCancellation) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - route, rCtx, _ := o.Context.RouteInfo(r) - if rCtx != nil { - *r = *rCtx - } - var Params = NewMoveCancellationParams() - if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - - res := o.Handler.Handle(Params) // actually handle the request - o.Context.Respond(rw, r, route.Produces, route, res) - -} diff --git a/pkg/gen/ghcapi/ghcoperations/move/move_cancellation_responses.go b/pkg/gen/ghcapi/ghcoperations/move/move_cancellation_responses.go deleted file mode 100644 index 96d0e76f919..00000000000 --- a/pkg/gen/ghcapi/ghcoperations/move/move_cancellation_responses.go +++ /dev/null @@ -1,329 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package move - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/runtime" - - "github.com/transcom/mymove/pkg/gen/ghcmessages" -) - -// MoveCancellationOKCode is the HTTP code returned for type MoveCancellationOK -const MoveCancellationOKCode int = 200 - -/* -MoveCancellationOK Successfully cancelled move - -swagger:response moveCancellationOK -*/ -type MoveCancellationOK struct { - - /* - In: Body - */ - Payload *ghcmessages.Move `json:"body,omitempty"` -} - -// NewMoveCancellationOK creates MoveCancellationOK with default headers values -func NewMoveCancellationOK() *MoveCancellationOK { - - return &MoveCancellationOK{} -} - -// WithPayload adds the payload to the move cancellation o k response -func (o *MoveCancellationOK) WithPayload(payload *ghcmessages.Move) *MoveCancellationOK { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the move cancellation o k response -func (o *MoveCancellationOK) SetPayload(payload *ghcmessages.Move) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *MoveCancellationOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.WriteHeader(200) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// MoveCancellationForbiddenCode is the HTTP code returned for type MoveCancellationForbidden -const MoveCancellationForbiddenCode int = 403 - -/* -MoveCancellationForbidden The request was denied - -swagger:response moveCancellationForbidden -*/ -type MoveCancellationForbidden struct { - - /* - In: Body - */ - Payload *ghcmessages.Error `json:"body,omitempty"` -} - -// NewMoveCancellationForbidden creates MoveCancellationForbidden with default headers values -func NewMoveCancellationForbidden() *MoveCancellationForbidden { - - return &MoveCancellationForbidden{} -} - -// WithPayload adds the payload to the move cancellation forbidden response -func (o *MoveCancellationForbidden) WithPayload(payload *ghcmessages.Error) *MoveCancellationForbidden { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the move cancellation forbidden response -func (o *MoveCancellationForbidden) SetPayload(payload *ghcmessages.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *MoveCancellationForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.WriteHeader(403) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// MoveCancellationNotFoundCode is the HTTP code returned for type MoveCancellationNotFound -const MoveCancellationNotFoundCode int = 404 - -/* -MoveCancellationNotFound The requested resource wasn't found - -swagger:response moveCancellationNotFound -*/ -type MoveCancellationNotFound struct { - - /* - In: Body - */ - Payload *ghcmessages.Error `json:"body,omitempty"` -} - -// NewMoveCancellationNotFound creates MoveCancellationNotFound with default headers values -func NewMoveCancellationNotFound() *MoveCancellationNotFound { - - return &MoveCancellationNotFound{} -} - -// WithPayload adds the payload to the move cancellation not found response -func (o *MoveCancellationNotFound) WithPayload(payload *ghcmessages.Error) *MoveCancellationNotFound { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the move cancellation not found response -func (o *MoveCancellationNotFound) SetPayload(payload *ghcmessages.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *MoveCancellationNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.WriteHeader(404) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// MoveCancellationConflictCode is the HTTP code returned for type MoveCancellationConflict -const MoveCancellationConflictCode int = 409 - -/* -MoveCancellationConflict Conflict error - -swagger:response moveCancellationConflict -*/ -type MoveCancellationConflict struct { - - /* - In: Body - */ - Payload *ghcmessages.Error `json:"body,omitempty"` -} - -// NewMoveCancellationConflict creates MoveCancellationConflict with default headers values -func NewMoveCancellationConflict() *MoveCancellationConflict { - - return &MoveCancellationConflict{} -} - -// WithPayload adds the payload to the move cancellation conflict response -func (o *MoveCancellationConflict) WithPayload(payload *ghcmessages.Error) *MoveCancellationConflict { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the move cancellation conflict response -func (o *MoveCancellationConflict) SetPayload(payload *ghcmessages.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *MoveCancellationConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.WriteHeader(409) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// MoveCancellationPreconditionFailedCode is the HTTP code returned for type MoveCancellationPreconditionFailed -const MoveCancellationPreconditionFailedCode int = 412 - -/* -MoveCancellationPreconditionFailed Precondition failed - -swagger:response moveCancellationPreconditionFailed -*/ -type MoveCancellationPreconditionFailed struct { - - /* - In: Body - */ - Payload *ghcmessages.Error `json:"body,omitempty"` -} - -// NewMoveCancellationPreconditionFailed creates MoveCancellationPreconditionFailed with default headers values -func NewMoveCancellationPreconditionFailed() *MoveCancellationPreconditionFailed { - - return &MoveCancellationPreconditionFailed{} -} - -// WithPayload adds the payload to the move cancellation precondition failed response -func (o *MoveCancellationPreconditionFailed) WithPayload(payload *ghcmessages.Error) *MoveCancellationPreconditionFailed { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the move cancellation precondition failed response -func (o *MoveCancellationPreconditionFailed) SetPayload(payload *ghcmessages.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *MoveCancellationPreconditionFailed) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.WriteHeader(412) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// MoveCancellationUnprocessableEntityCode is the HTTP code returned for type MoveCancellationUnprocessableEntity -const MoveCancellationUnprocessableEntityCode int = 422 - -/* -MoveCancellationUnprocessableEntity The payload was unprocessable. - -swagger:response moveCancellationUnprocessableEntity -*/ -type MoveCancellationUnprocessableEntity struct { - - /* - In: Body - */ - Payload *ghcmessages.ValidationError `json:"body,omitempty"` -} - -// NewMoveCancellationUnprocessableEntity creates MoveCancellationUnprocessableEntity with default headers values -func NewMoveCancellationUnprocessableEntity() *MoveCancellationUnprocessableEntity { - - return &MoveCancellationUnprocessableEntity{} -} - -// WithPayload adds the payload to the move cancellation unprocessable entity response -func (o *MoveCancellationUnprocessableEntity) WithPayload(payload *ghcmessages.ValidationError) *MoveCancellationUnprocessableEntity { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the move cancellation unprocessable entity response -func (o *MoveCancellationUnprocessableEntity) SetPayload(payload *ghcmessages.ValidationError) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *MoveCancellationUnprocessableEntity) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.WriteHeader(422) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// MoveCancellationInternalServerErrorCode is the HTTP code returned for type MoveCancellationInternalServerError -const MoveCancellationInternalServerErrorCode int = 500 - -/* -MoveCancellationInternalServerError A server error occurred - -swagger:response moveCancellationInternalServerError -*/ -type MoveCancellationInternalServerError struct { - - /* - In: Body - */ - Payload *ghcmessages.Error `json:"body,omitempty"` -} - -// NewMoveCancellationInternalServerError creates MoveCancellationInternalServerError with default headers values -func NewMoveCancellationInternalServerError() *MoveCancellationInternalServerError { - - return &MoveCancellationInternalServerError{} -} - -// WithPayload adds the payload to the move cancellation internal server error response -func (o *MoveCancellationInternalServerError) WithPayload(payload *ghcmessages.Error) *MoveCancellationInternalServerError { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the move cancellation internal server error response -func (o *MoveCancellationInternalServerError) SetPayload(payload *ghcmessages.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *MoveCancellationInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.WriteHeader(500) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} diff --git a/pkg/gen/ghcapi/ghcoperations/mymove_api.go b/pkg/gen/ghcapi/ghcoperations/mymove_api.go index a9709ac70c6..5c182dd1144 100644 --- a/pkg/gen/ghcapi/ghcoperations/mymove_api.go +++ b/pkg/gen/ghcapi/ghcoperations/mymove_api.go @@ -239,8 +239,8 @@ func NewMymoveAPI(spec *loads.Document) *MymoveAPI { QueuesListPrimeMovesHandler: queues.ListPrimeMovesHandlerFunc(func(params queues.ListPrimeMovesParams) middleware.Responder { return middleware.NotImplemented("operation queues.ListPrimeMoves has not yet been implemented") }), - MoveMoveCancellationHandler: move.MoveCancellationHandlerFunc(func(params move.MoveCancellationParams) middleware.Responder { - return middleware.NotImplemented("operation move.MoveCancellation has not yet been implemented") + MoveMoveCancelationHandler: move.MoveCancelationHandlerFunc(func(params move.MoveCancelationParams) middleware.Responder { + return middleware.NotImplemented("operation move.MoveCancelation has not yet been implemented") }), ShipmentRejectShipmentHandler: shipment.RejectShipmentHandlerFunc(func(params shipment.RejectShipmentParams) middleware.Responder { return middleware.NotImplemented("operation shipment.RejectShipment has not yet been implemented") @@ -513,8 +513,8 @@ type MymoveAPI struct { MtoShipmentListMTOShipmentsHandler mto_shipment.ListMTOShipmentsHandler // QueuesListPrimeMovesHandler sets the operation handler for the list prime moves operation QueuesListPrimeMovesHandler queues.ListPrimeMovesHandler - // MoveMoveCancellationHandler sets the operation handler for the move cancellation operation - MoveMoveCancellationHandler move.MoveCancellationHandler + // MoveMoveCancelationHandler sets the operation handler for the move cancelation operation + MoveMoveCancelationHandler move.MoveCancelationHandler // ShipmentRejectShipmentHandler sets the operation handler for the reject shipment operation ShipmentRejectShipmentHandler shipment.RejectShipmentHandler // LinesOfAccountingRequestLineOfAccountingHandler sets the operation handler for the request line of accounting operation @@ -843,8 +843,8 @@ func (o *MymoveAPI) Validate() error { if o.QueuesListPrimeMovesHandler == nil { unregistered = append(unregistered, "queues.ListPrimeMovesHandler") } - if o.MoveMoveCancellationHandler == nil { - unregistered = append(unregistered, "move.MoveCancellationHandler") + if o.MoveMoveCancelationHandler == nil { + unregistered = append(unregistered, "move.MoveCancelationHandler") } if o.ShipmentRejectShipmentHandler == nil { unregistered = append(unregistered, "shipment.RejectShipmentHandler") @@ -1280,7 +1280,7 @@ func (o *MymoveAPI) initHandlerCache() { if o.handlers["POST"] == nil { o.handlers["POST"] = make(map[string]http.Handler) } - o.handlers["POST"]["/moves/{moveID}/cancel"] = move.NewMoveCancellation(o.context, o.MoveMoveCancellationHandler) + o.handlers["POST"]["/moves/{moveID}/cancel"] = move.NewMoveCancelation(o.context, o.MoveMoveCancelationHandler) if o.handlers["POST"] == nil { o.handlers["POST"] = make(map[string]http.Handler) } diff --git a/pkg/handlers/ghcapi/api.go b/pkg/handlers/ghcapi/api.go index 9f94baaad89..4f71e7f9555 100644 --- a/pkg/handlers/ghcapi/api.go +++ b/pkg/handlers/ghcapi/api.go @@ -656,7 +656,7 @@ func NewGhcAPIHandler(handlerConfig handlers.HandlerConfig) *ghcops.MymoveAPI { order.NewOrderUpdater(moveRouter), } - ghcAPI.MoveMoveCancellationHandler = MoveCancellationHandler{ + ghcAPI.MoveMoveCancelationHandler = MoveCancellationHandler{ handlerConfig, move.NewMoveCancelation(), } diff --git a/pkg/handlers/ghcapi/move.go b/pkg/handlers/ghcapi/move.go index c2d1ee9fdcd..23e3b0a96f6 100644 --- a/pkg/handlers/ghcapi/move.go +++ b/pkg/handlers/ghcapi/move.go @@ -284,7 +284,7 @@ type MoveCancellationHandler struct { services.MoveCancelation } -func (h MoveCancellationHandler) Handle(params moveop.MoveCancellationParams) middleware.Responder { +func (h MoveCancellationHandler) Handle(params moveop.MoveCancelationParams) middleware.Responder { return h.AuditableAppContextFromRequestWithErrors(params.HTTPRequest, func(appCtx appcontext.AppContext) (middleware.Responder, error) { moveID := uuid.FromStringOrNil(params.MoveID.String()) @@ -294,13 +294,13 @@ func (h MoveCancellationHandler) Handle(params moveop.MoveCancellationParams) mi appCtx.Logger().Error("MoveCancellationHandler error", zap.Error(err)) switch err.(type) { case apperror.NotFoundError: - return moveop.NewMoveCancellationNotFound(), err + return moveop.NewMoveCancelationNotFound(), err case apperror.PreconditionFailedError: - return moveop.NewMoveCancellationPreconditionFailed(), err + return moveop.NewMoveCancelationPreconditionFailed(), err case apperror.InvalidInputError: - return moveop.NewMoveCancellationUnprocessableEntity(), err + return moveop.NewMoveCancelationUnprocessableEntity(), err default: - return moveop.NewMoveCancellationInternalServerError(), err + return moveop.NewMoveCancelationInternalServerError(), err } } @@ -308,7 +308,7 @@ func (h MoveCancellationHandler) Handle(params moveop.MoveCancellationParams) mi if err != nil { return nil, err } - return moveop.NewMoveCancellationOK().WithPayload(payload), nil + return moveop.NewMoveCancelationOK().WithPayload(payload), nil }) } diff --git a/swagger-def/ghc.yaml b/swagger-def/ghc.yaml index 3127005c38d..8fcd66ccf46 100644 --- a/swagger-def/ghc.yaml +++ b/swagger-def/ghc.yaml @@ -400,7 +400,7 @@ paths: tags: - move description: cancels a move - operationId: moveCancellation + operationId: moveCancelation summary: Cancels a move '/counseling/orders/{orderID}': parameters: diff --git a/swagger/ghc.yaml b/swagger/ghc.yaml index c2af626e302..a174bf3c409 100644 --- a/swagger/ghc.yaml +++ b/swagger/ghc.yaml @@ -438,7 +438,7 @@ paths: tags: - move description: cancels a move - operationId: moveCancellation + operationId: moveCancelation summary: Cancels a move /counseling/orders/{orderID}: parameters: From adcd79af2d463a19f5b19233d80867107bf90540 Mon Sep 17 00:00:00 2001 From: loganwc Date: Thu, 1 Aug 2024 17:35:40 +0000 Subject: [PATCH 06/37] resolve handler not having same name as service object --- pkg/handlers/ghcapi/api.go | 2 +- pkg/handlers/ghcapi/move.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/handlers/ghcapi/api.go b/pkg/handlers/ghcapi/api.go index 4f71e7f9555..3a399147c34 100644 --- a/pkg/handlers/ghcapi/api.go +++ b/pkg/handlers/ghcapi/api.go @@ -656,7 +656,7 @@ func NewGhcAPIHandler(handlerConfig handlers.HandlerConfig) *ghcops.MymoveAPI { order.NewOrderUpdater(moveRouter), } - ghcAPI.MoveMoveCancelationHandler = MoveCancellationHandler{ + ghcAPI.MoveMoveCancelationHandler = MoveCancelationHandler{ handlerConfig, move.NewMoveCancelation(), } diff --git a/pkg/handlers/ghcapi/move.go b/pkg/handlers/ghcapi/move.go index 23e3b0a96f6..744afce9bb2 100644 --- a/pkg/handlers/ghcapi/move.go +++ b/pkg/handlers/ghcapi/move.go @@ -279,19 +279,19 @@ func (h UploadAdditionalDocumentsHandler) Handle(params moveop.UploadAdditionalD }) } -type MoveCancellationHandler struct { +type MoveCancelationHandler struct { handlers.HandlerConfig services.MoveCancelation } -func (h MoveCancellationHandler) Handle(params moveop.MoveCancelationParams) middleware.Responder { +func (h MoveCancelationHandler) Handle(params moveop.MoveCancelationParams) middleware.Responder { return h.AuditableAppContextFromRequestWithErrors(params.HTTPRequest, func(appCtx appcontext.AppContext) (middleware.Responder, error) { moveID := uuid.FromStringOrNil(params.MoveID.String()) move, err := h.MoveCancelation.CancelMove(appCtx, moveID) if err != nil { - appCtx.Logger().Error("MoveCancellationHandler error", zap.Error(err)) + appCtx.Logger().Error("MoveCancelationHandler error", zap.Error(err)) switch err.(type) { case apperror.NotFoundError: return moveop.NewMoveCancelationNotFound(), err From 82debbd0702f11c128ddde625678f8606846b987 Mon Sep 17 00:00:00 2001 From: loganwc Date: Mon, 5 Aug 2024 15:36:47 +0000 Subject: [PATCH 07/37] ok sometimes two L's... --- pkg/gen/ghcapi/configure_mymove.go | 6 +- pkg/gen/ghcapi/embedded_spec.go | 4 +- .../ghcoperations/move/move_cancelation.go | 58 --- .../move/move_cancelation_responses.go | 329 ------------------ .../ghcoperations/move/move_cancellation.go | 58 +++ ...ers.go => move_cancellation_parameters.go} | 20 +- .../move/move_cancellation_responses.go | 329 ++++++++++++++++++ ...der.go => move_cancellation_urlbuilder.go} | 24 +- pkg/gen/ghcapi/ghcoperations/mymove_api.go | 14 +- pkg/handlers/ghcapi/api.go | 4 +- pkg/handlers/ghcapi/move.go | 20 +- pkg/services/move.go | 2 +- pkg/services/move/move_cancelation.go | 8 +- pkg/services/move/move_cancelation_test.go | 2 +- swagger-def/ghc.yaml | 2 +- swagger/ghc.yaml | 2 +- 16 files changed, 441 insertions(+), 441 deletions(-) delete mode 100644 pkg/gen/ghcapi/ghcoperations/move/move_cancelation.go delete mode 100644 pkg/gen/ghcapi/ghcoperations/move/move_cancelation_responses.go create mode 100644 pkg/gen/ghcapi/ghcoperations/move/move_cancellation.go rename pkg/gen/ghcapi/ghcoperations/move/{move_cancelation_parameters.go => move_cancellation_parameters.go} (73%) create mode 100644 pkg/gen/ghcapi/ghcoperations/move/move_cancellation_responses.go rename pkg/gen/ghcapi/ghcoperations/move/{move_cancelation_urlbuilder.go => move_cancellation_urlbuilder.go} (74%) diff --git a/pkg/gen/ghcapi/configure_mymove.go b/pkg/gen/ghcapi/configure_mymove.go index 01c94b74da7..192fe39e8d5 100644 --- a/pkg/gen/ghcapi/configure_mymove.go +++ b/pkg/gen/ghcapi/configure_mymove.go @@ -354,9 +354,9 @@ func configureAPI(api *ghcoperations.MymoveAPI) http.Handler { return middleware.NotImplemented("operation queues.ListPrimeMoves has not yet been implemented") }) } - if api.MoveMoveCancelationHandler == nil { - api.MoveMoveCancelationHandler = move.MoveCancelationHandlerFunc(func(params move.MoveCancelationParams) middleware.Responder { - return middleware.NotImplemented("operation move.MoveCancelation has not yet been implemented") + if api.MoveMoveCancellationHandler == nil { + api.MoveMoveCancellationHandler = move.MoveCancellationHandlerFunc(func(params move.MoveCancellationParams) middleware.Responder { + return middleware.NotImplemented("operation move.MoveCancellation has not yet been implemented") }) } if api.ShipmentRejectShipmentHandler == nil { diff --git a/pkg/gen/ghcapi/embedded_spec.go b/pkg/gen/ghcapi/embedded_spec.go index 1a6c5ff98b3..84c90899ee6 100644 --- a/pkg/gen/ghcapi/embedded_spec.go +++ b/pkg/gen/ghcapi/embedded_spec.go @@ -2238,7 +2238,7 @@ func init() { "move" ], "summary": "Cancels a move", - "operationId": "moveCancelation", + "operationId": "moveCancellation", "responses": { "200": { "description": "Successfully cancelled move", @@ -15969,7 +15969,7 @@ func init() { "move" ], "summary": "Cancels a move", - "operationId": "moveCancelation", + "operationId": "moveCancellation", "responses": { "200": { "description": "Successfully cancelled move", diff --git a/pkg/gen/ghcapi/ghcoperations/move/move_cancelation.go b/pkg/gen/ghcapi/ghcoperations/move/move_cancelation.go deleted file mode 100644 index 0ef81e57167..00000000000 --- a/pkg/gen/ghcapi/ghcoperations/move/move_cancelation.go +++ /dev/null @@ -1,58 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package move - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "net/http" - - "github.com/go-openapi/runtime/middleware" -) - -// MoveCancelationHandlerFunc turns a function with the right signature into a move cancelation handler -type MoveCancelationHandlerFunc func(MoveCancelationParams) middleware.Responder - -// Handle executing the request and returning a response -func (fn MoveCancelationHandlerFunc) Handle(params MoveCancelationParams) middleware.Responder { - return fn(params) -} - -// MoveCancelationHandler interface for that can handle valid move cancelation params -type MoveCancelationHandler interface { - Handle(MoveCancelationParams) middleware.Responder -} - -// NewMoveCancelation creates a new http.Handler for the move cancelation operation -func NewMoveCancelation(ctx *middleware.Context, handler MoveCancelationHandler) *MoveCancelation { - return &MoveCancelation{Context: ctx, Handler: handler} -} - -/* - MoveCancelation swagger:route POST /moves/{moveID}/cancel move moveCancelation - -# Cancels a move - -cancels a move -*/ -type MoveCancelation struct { - Context *middleware.Context - Handler MoveCancelationHandler -} - -func (o *MoveCancelation) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - route, rCtx, _ := o.Context.RouteInfo(r) - if rCtx != nil { - *r = *rCtx - } - var Params = NewMoveCancelationParams() - if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - - res := o.Handler.Handle(Params) // actually handle the request - o.Context.Respond(rw, r, route.Produces, route, res) - -} diff --git a/pkg/gen/ghcapi/ghcoperations/move/move_cancelation_responses.go b/pkg/gen/ghcapi/ghcoperations/move/move_cancelation_responses.go deleted file mode 100644 index 4fa392a314a..00000000000 --- a/pkg/gen/ghcapi/ghcoperations/move/move_cancelation_responses.go +++ /dev/null @@ -1,329 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package move - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/runtime" - - "github.com/transcom/mymove/pkg/gen/ghcmessages" -) - -// MoveCancelationOKCode is the HTTP code returned for type MoveCancelationOK -const MoveCancelationOKCode int = 200 - -/* -MoveCancelationOK Successfully cancelled move - -swagger:response moveCancelationOK -*/ -type MoveCancelationOK struct { - - /* - In: Body - */ - Payload *ghcmessages.Move `json:"body,omitempty"` -} - -// NewMoveCancelationOK creates MoveCancelationOK with default headers values -func NewMoveCancelationOK() *MoveCancelationOK { - - return &MoveCancelationOK{} -} - -// WithPayload adds the payload to the move cancelation o k response -func (o *MoveCancelationOK) WithPayload(payload *ghcmessages.Move) *MoveCancelationOK { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the move cancelation o k response -func (o *MoveCancelationOK) SetPayload(payload *ghcmessages.Move) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *MoveCancelationOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.WriteHeader(200) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// MoveCancelationForbiddenCode is the HTTP code returned for type MoveCancelationForbidden -const MoveCancelationForbiddenCode int = 403 - -/* -MoveCancelationForbidden The request was denied - -swagger:response moveCancelationForbidden -*/ -type MoveCancelationForbidden struct { - - /* - In: Body - */ - Payload *ghcmessages.Error `json:"body,omitempty"` -} - -// NewMoveCancelationForbidden creates MoveCancelationForbidden with default headers values -func NewMoveCancelationForbidden() *MoveCancelationForbidden { - - return &MoveCancelationForbidden{} -} - -// WithPayload adds the payload to the move cancelation forbidden response -func (o *MoveCancelationForbidden) WithPayload(payload *ghcmessages.Error) *MoveCancelationForbidden { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the move cancelation forbidden response -func (o *MoveCancelationForbidden) SetPayload(payload *ghcmessages.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *MoveCancelationForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.WriteHeader(403) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// MoveCancelationNotFoundCode is the HTTP code returned for type MoveCancelationNotFound -const MoveCancelationNotFoundCode int = 404 - -/* -MoveCancelationNotFound The requested resource wasn't found - -swagger:response moveCancelationNotFound -*/ -type MoveCancelationNotFound struct { - - /* - In: Body - */ - Payload *ghcmessages.Error `json:"body,omitempty"` -} - -// NewMoveCancelationNotFound creates MoveCancelationNotFound with default headers values -func NewMoveCancelationNotFound() *MoveCancelationNotFound { - - return &MoveCancelationNotFound{} -} - -// WithPayload adds the payload to the move cancelation not found response -func (o *MoveCancelationNotFound) WithPayload(payload *ghcmessages.Error) *MoveCancelationNotFound { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the move cancelation not found response -func (o *MoveCancelationNotFound) SetPayload(payload *ghcmessages.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *MoveCancelationNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.WriteHeader(404) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// MoveCancelationConflictCode is the HTTP code returned for type MoveCancelationConflict -const MoveCancelationConflictCode int = 409 - -/* -MoveCancelationConflict Conflict error - -swagger:response moveCancelationConflict -*/ -type MoveCancelationConflict struct { - - /* - In: Body - */ - Payload *ghcmessages.Error `json:"body,omitempty"` -} - -// NewMoveCancelationConflict creates MoveCancelationConflict with default headers values -func NewMoveCancelationConflict() *MoveCancelationConflict { - - return &MoveCancelationConflict{} -} - -// WithPayload adds the payload to the move cancelation conflict response -func (o *MoveCancelationConflict) WithPayload(payload *ghcmessages.Error) *MoveCancelationConflict { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the move cancelation conflict response -func (o *MoveCancelationConflict) SetPayload(payload *ghcmessages.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *MoveCancelationConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.WriteHeader(409) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// MoveCancelationPreconditionFailedCode is the HTTP code returned for type MoveCancelationPreconditionFailed -const MoveCancelationPreconditionFailedCode int = 412 - -/* -MoveCancelationPreconditionFailed Precondition failed - -swagger:response moveCancelationPreconditionFailed -*/ -type MoveCancelationPreconditionFailed struct { - - /* - In: Body - */ - Payload *ghcmessages.Error `json:"body,omitempty"` -} - -// NewMoveCancelationPreconditionFailed creates MoveCancelationPreconditionFailed with default headers values -func NewMoveCancelationPreconditionFailed() *MoveCancelationPreconditionFailed { - - return &MoveCancelationPreconditionFailed{} -} - -// WithPayload adds the payload to the move cancelation precondition failed response -func (o *MoveCancelationPreconditionFailed) WithPayload(payload *ghcmessages.Error) *MoveCancelationPreconditionFailed { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the move cancelation precondition failed response -func (o *MoveCancelationPreconditionFailed) SetPayload(payload *ghcmessages.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *MoveCancelationPreconditionFailed) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.WriteHeader(412) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// MoveCancelationUnprocessableEntityCode is the HTTP code returned for type MoveCancelationUnprocessableEntity -const MoveCancelationUnprocessableEntityCode int = 422 - -/* -MoveCancelationUnprocessableEntity The payload was unprocessable. - -swagger:response moveCancelationUnprocessableEntity -*/ -type MoveCancelationUnprocessableEntity struct { - - /* - In: Body - */ - Payload *ghcmessages.ValidationError `json:"body,omitempty"` -} - -// NewMoveCancelationUnprocessableEntity creates MoveCancelationUnprocessableEntity with default headers values -func NewMoveCancelationUnprocessableEntity() *MoveCancelationUnprocessableEntity { - - return &MoveCancelationUnprocessableEntity{} -} - -// WithPayload adds the payload to the move cancelation unprocessable entity response -func (o *MoveCancelationUnprocessableEntity) WithPayload(payload *ghcmessages.ValidationError) *MoveCancelationUnprocessableEntity { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the move cancelation unprocessable entity response -func (o *MoveCancelationUnprocessableEntity) SetPayload(payload *ghcmessages.ValidationError) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *MoveCancelationUnprocessableEntity) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.WriteHeader(422) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// MoveCancelationInternalServerErrorCode is the HTTP code returned for type MoveCancelationInternalServerError -const MoveCancelationInternalServerErrorCode int = 500 - -/* -MoveCancelationInternalServerError A server error occurred - -swagger:response moveCancelationInternalServerError -*/ -type MoveCancelationInternalServerError struct { - - /* - In: Body - */ - Payload *ghcmessages.Error `json:"body,omitempty"` -} - -// NewMoveCancelationInternalServerError creates MoveCancelationInternalServerError with default headers values -func NewMoveCancelationInternalServerError() *MoveCancelationInternalServerError { - - return &MoveCancelationInternalServerError{} -} - -// WithPayload adds the payload to the move cancelation internal server error response -func (o *MoveCancelationInternalServerError) WithPayload(payload *ghcmessages.Error) *MoveCancelationInternalServerError { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the move cancelation internal server error response -func (o *MoveCancelationInternalServerError) SetPayload(payload *ghcmessages.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *MoveCancelationInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.WriteHeader(500) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} diff --git a/pkg/gen/ghcapi/ghcoperations/move/move_cancellation.go b/pkg/gen/ghcapi/ghcoperations/move/move_cancellation.go new file mode 100644 index 00000000000..a2d9f8a9bf3 --- /dev/null +++ b/pkg/gen/ghcapi/ghcoperations/move/move_cancellation.go @@ -0,0 +1,58 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package move + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// MoveCancellationHandlerFunc turns a function with the right signature into a move cancellation handler +type MoveCancellationHandlerFunc func(MoveCancellationParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn MoveCancellationHandlerFunc) Handle(params MoveCancellationParams) middleware.Responder { + return fn(params) +} + +// MoveCancellationHandler interface for that can handle valid move cancellation params +type MoveCancellationHandler interface { + Handle(MoveCancellationParams) middleware.Responder +} + +// NewMoveCancellation creates a new http.Handler for the move cancellation operation +func NewMoveCancellation(ctx *middleware.Context, handler MoveCancellationHandler) *MoveCancellation { + return &MoveCancellation{Context: ctx, Handler: handler} +} + +/* + MoveCancellation swagger:route POST /moves/{moveID}/cancel move moveCancellation + +# Cancels a move + +cancels a move +*/ +type MoveCancellation struct { + Context *middleware.Context + Handler MoveCancellationHandler +} + +func (o *MoveCancellation) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewMoveCancellationParams() + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/pkg/gen/ghcapi/ghcoperations/move/move_cancelation_parameters.go b/pkg/gen/ghcapi/ghcoperations/move/move_cancellation_parameters.go similarity index 73% rename from pkg/gen/ghcapi/ghcoperations/move/move_cancelation_parameters.go rename to pkg/gen/ghcapi/ghcoperations/move/move_cancellation_parameters.go index 423bf6eca75..98a353a63ae 100644 --- a/pkg/gen/ghcapi/ghcoperations/move/move_cancelation_parameters.go +++ b/pkg/gen/ghcapi/ghcoperations/move/move_cancellation_parameters.go @@ -14,19 +14,19 @@ import ( "github.com/go-openapi/validate" ) -// NewMoveCancelationParams creates a new MoveCancelationParams object +// NewMoveCancellationParams creates a new MoveCancellationParams object // // There are no default values defined in the spec. -func NewMoveCancelationParams() MoveCancelationParams { +func NewMoveCancellationParams() MoveCancellationParams { - return MoveCancelationParams{} + return MoveCancellationParams{} } -// MoveCancelationParams contains all the bound params for the move cancelation operation +// MoveCancellationParams contains all the bound params for the move cancellation operation // typically these are obtained from a http.Request // -// swagger:parameters moveCancelation -type MoveCancelationParams struct { +// swagger:parameters moveCancellation +type MoveCancellationParams struct { // HTTP Request Object HTTPRequest *http.Request `json:"-"` @@ -41,8 +41,8 @@ type MoveCancelationParams struct { // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface // for simple values it will use straight method calls. // -// To ensure default values, the struct must have been initialized with NewMoveCancelationParams() beforehand. -func (o *MoveCancelationParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { +// To ensure default values, the struct must have been initialized with NewMoveCancellationParams() beforehand. +func (o *MoveCancellationParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { var res []error o.HTTPRequest = r @@ -58,7 +58,7 @@ func (o *MoveCancelationParams) BindRequest(r *http.Request, route *middleware.M } // bindMoveID binds and validates parameter MoveID from path. -func (o *MoveCancelationParams) bindMoveID(rawData []string, hasKey bool, formats strfmt.Registry) error { +func (o *MoveCancellationParams) bindMoveID(rawData []string, hasKey bool, formats strfmt.Registry) error { var raw string if len(rawData) > 0 { raw = rawData[len(rawData)-1] @@ -82,7 +82,7 @@ func (o *MoveCancelationParams) bindMoveID(rawData []string, hasKey bool, format } // validateMoveID carries on validations for parameter MoveID -func (o *MoveCancelationParams) validateMoveID(formats strfmt.Registry) error { +func (o *MoveCancellationParams) validateMoveID(formats strfmt.Registry) error { if err := validate.FormatOf("moveID", "path", "uuid", o.MoveID.String(), formats); err != nil { return err diff --git a/pkg/gen/ghcapi/ghcoperations/move/move_cancellation_responses.go b/pkg/gen/ghcapi/ghcoperations/move/move_cancellation_responses.go new file mode 100644 index 00000000000..96d0e76f919 --- /dev/null +++ b/pkg/gen/ghcapi/ghcoperations/move/move_cancellation_responses.go @@ -0,0 +1,329 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package move + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/transcom/mymove/pkg/gen/ghcmessages" +) + +// MoveCancellationOKCode is the HTTP code returned for type MoveCancellationOK +const MoveCancellationOKCode int = 200 + +/* +MoveCancellationOK Successfully cancelled move + +swagger:response moveCancellationOK +*/ +type MoveCancellationOK struct { + + /* + In: Body + */ + Payload *ghcmessages.Move `json:"body,omitempty"` +} + +// NewMoveCancellationOK creates MoveCancellationOK with default headers values +func NewMoveCancellationOK() *MoveCancellationOK { + + return &MoveCancellationOK{} +} + +// WithPayload adds the payload to the move cancellation o k response +func (o *MoveCancellationOK) WithPayload(payload *ghcmessages.Move) *MoveCancellationOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the move cancellation o k response +func (o *MoveCancellationOK) SetPayload(payload *ghcmessages.Move) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *MoveCancellationOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// MoveCancellationForbiddenCode is the HTTP code returned for type MoveCancellationForbidden +const MoveCancellationForbiddenCode int = 403 + +/* +MoveCancellationForbidden The request was denied + +swagger:response moveCancellationForbidden +*/ +type MoveCancellationForbidden struct { + + /* + In: Body + */ + Payload *ghcmessages.Error `json:"body,omitempty"` +} + +// NewMoveCancellationForbidden creates MoveCancellationForbidden with default headers values +func NewMoveCancellationForbidden() *MoveCancellationForbidden { + + return &MoveCancellationForbidden{} +} + +// WithPayload adds the payload to the move cancellation forbidden response +func (o *MoveCancellationForbidden) WithPayload(payload *ghcmessages.Error) *MoveCancellationForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the move cancellation forbidden response +func (o *MoveCancellationForbidden) SetPayload(payload *ghcmessages.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *MoveCancellationForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// MoveCancellationNotFoundCode is the HTTP code returned for type MoveCancellationNotFound +const MoveCancellationNotFoundCode int = 404 + +/* +MoveCancellationNotFound The requested resource wasn't found + +swagger:response moveCancellationNotFound +*/ +type MoveCancellationNotFound struct { + + /* + In: Body + */ + Payload *ghcmessages.Error `json:"body,omitempty"` +} + +// NewMoveCancellationNotFound creates MoveCancellationNotFound with default headers values +func NewMoveCancellationNotFound() *MoveCancellationNotFound { + + return &MoveCancellationNotFound{} +} + +// WithPayload adds the payload to the move cancellation not found response +func (o *MoveCancellationNotFound) WithPayload(payload *ghcmessages.Error) *MoveCancellationNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the move cancellation not found response +func (o *MoveCancellationNotFound) SetPayload(payload *ghcmessages.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *MoveCancellationNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// MoveCancellationConflictCode is the HTTP code returned for type MoveCancellationConflict +const MoveCancellationConflictCode int = 409 + +/* +MoveCancellationConflict Conflict error + +swagger:response moveCancellationConflict +*/ +type MoveCancellationConflict struct { + + /* + In: Body + */ + Payload *ghcmessages.Error `json:"body,omitempty"` +} + +// NewMoveCancellationConflict creates MoveCancellationConflict with default headers values +func NewMoveCancellationConflict() *MoveCancellationConflict { + + return &MoveCancellationConflict{} +} + +// WithPayload adds the payload to the move cancellation conflict response +func (o *MoveCancellationConflict) WithPayload(payload *ghcmessages.Error) *MoveCancellationConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the move cancellation conflict response +func (o *MoveCancellationConflict) SetPayload(payload *ghcmessages.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *MoveCancellationConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// MoveCancellationPreconditionFailedCode is the HTTP code returned for type MoveCancellationPreconditionFailed +const MoveCancellationPreconditionFailedCode int = 412 + +/* +MoveCancellationPreconditionFailed Precondition failed + +swagger:response moveCancellationPreconditionFailed +*/ +type MoveCancellationPreconditionFailed struct { + + /* + In: Body + */ + Payload *ghcmessages.Error `json:"body,omitempty"` +} + +// NewMoveCancellationPreconditionFailed creates MoveCancellationPreconditionFailed with default headers values +func NewMoveCancellationPreconditionFailed() *MoveCancellationPreconditionFailed { + + return &MoveCancellationPreconditionFailed{} +} + +// WithPayload adds the payload to the move cancellation precondition failed response +func (o *MoveCancellationPreconditionFailed) WithPayload(payload *ghcmessages.Error) *MoveCancellationPreconditionFailed { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the move cancellation precondition failed response +func (o *MoveCancellationPreconditionFailed) SetPayload(payload *ghcmessages.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *MoveCancellationPreconditionFailed) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(412) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// MoveCancellationUnprocessableEntityCode is the HTTP code returned for type MoveCancellationUnprocessableEntity +const MoveCancellationUnprocessableEntityCode int = 422 + +/* +MoveCancellationUnprocessableEntity The payload was unprocessable. + +swagger:response moveCancellationUnprocessableEntity +*/ +type MoveCancellationUnprocessableEntity struct { + + /* + In: Body + */ + Payload *ghcmessages.ValidationError `json:"body,omitempty"` +} + +// NewMoveCancellationUnprocessableEntity creates MoveCancellationUnprocessableEntity with default headers values +func NewMoveCancellationUnprocessableEntity() *MoveCancellationUnprocessableEntity { + + return &MoveCancellationUnprocessableEntity{} +} + +// WithPayload adds the payload to the move cancellation unprocessable entity response +func (o *MoveCancellationUnprocessableEntity) WithPayload(payload *ghcmessages.ValidationError) *MoveCancellationUnprocessableEntity { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the move cancellation unprocessable entity response +func (o *MoveCancellationUnprocessableEntity) SetPayload(payload *ghcmessages.ValidationError) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *MoveCancellationUnprocessableEntity) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(422) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// MoveCancellationInternalServerErrorCode is the HTTP code returned for type MoveCancellationInternalServerError +const MoveCancellationInternalServerErrorCode int = 500 + +/* +MoveCancellationInternalServerError A server error occurred + +swagger:response moveCancellationInternalServerError +*/ +type MoveCancellationInternalServerError struct { + + /* + In: Body + */ + Payload *ghcmessages.Error `json:"body,omitempty"` +} + +// NewMoveCancellationInternalServerError creates MoveCancellationInternalServerError with default headers values +func NewMoveCancellationInternalServerError() *MoveCancellationInternalServerError { + + return &MoveCancellationInternalServerError{} +} + +// WithPayload adds the payload to the move cancellation internal server error response +func (o *MoveCancellationInternalServerError) WithPayload(payload *ghcmessages.Error) *MoveCancellationInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the move cancellation internal server error response +func (o *MoveCancellationInternalServerError) SetPayload(payload *ghcmessages.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *MoveCancellationInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/pkg/gen/ghcapi/ghcoperations/move/move_cancelation_urlbuilder.go b/pkg/gen/ghcapi/ghcoperations/move/move_cancellation_urlbuilder.go similarity index 74% rename from pkg/gen/ghcapi/ghcoperations/move/move_cancelation_urlbuilder.go rename to pkg/gen/ghcapi/ghcoperations/move/move_cancellation_urlbuilder.go index 62afc20dc03..fd91266aa01 100644 --- a/pkg/gen/ghcapi/ghcoperations/move/move_cancelation_urlbuilder.go +++ b/pkg/gen/ghcapi/ghcoperations/move/move_cancellation_urlbuilder.go @@ -14,8 +14,8 @@ import ( "github.com/go-openapi/strfmt" ) -// MoveCancelationURL generates an URL for the move cancelation operation -type MoveCancelationURL struct { +// MoveCancellationURL generates an URL for the move cancellation operation +type MoveCancellationURL struct { MoveID strfmt.UUID _basePath string @@ -26,7 +26,7 @@ type MoveCancelationURL struct { // WithBasePath sets the base path for this url builder, only required when it's different from the // base path specified in the swagger spec. // When the value of the base path is an empty string -func (o *MoveCancelationURL) WithBasePath(bp string) *MoveCancelationURL { +func (o *MoveCancellationURL) WithBasePath(bp string) *MoveCancellationURL { o.SetBasePath(bp) return o } @@ -34,12 +34,12 @@ func (o *MoveCancelationURL) WithBasePath(bp string) *MoveCancelationURL { // SetBasePath sets the base path for this url builder, only required when it's different from the // base path specified in the swagger spec. // When the value of the base path is an empty string -func (o *MoveCancelationURL) SetBasePath(bp string) { +func (o *MoveCancellationURL) SetBasePath(bp string) { o._basePath = bp } // Build a url path and query string -func (o *MoveCancelationURL) Build() (*url.URL, error) { +func (o *MoveCancellationURL) Build() (*url.URL, error) { var _result url.URL var _path = "/moves/{moveID}/cancel" @@ -48,7 +48,7 @@ func (o *MoveCancelationURL) Build() (*url.URL, error) { if moveID != "" { _path = strings.Replace(_path, "{moveID}", moveID, -1) } else { - return nil, errors.New("moveId is required on MoveCancelationURL") + return nil, errors.New("moveId is required on MoveCancellationURL") } _basePath := o._basePath @@ -61,7 +61,7 @@ func (o *MoveCancelationURL) Build() (*url.URL, error) { } // Must is a helper function to panic when the url builder returns an error -func (o *MoveCancelationURL) Must(u *url.URL, err error) *url.URL { +func (o *MoveCancellationURL) Must(u *url.URL, err error) *url.URL { if err != nil { panic(err) } @@ -72,17 +72,17 @@ func (o *MoveCancelationURL) Must(u *url.URL, err error) *url.URL { } // String returns the string representation of the path with query string -func (o *MoveCancelationURL) String() string { +func (o *MoveCancellationURL) String() string { return o.Must(o.Build()).String() } // BuildFull builds a full url with scheme, host, path and query string -func (o *MoveCancelationURL) BuildFull(scheme, host string) (*url.URL, error) { +func (o *MoveCancellationURL) BuildFull(scheme, host string) (*url.URL, error) { if scheme == "" { - return nil, errors.New("scheme is required for a full url on MoveCancelationURL") + return nil, errors.New("scheme is required for a full url on MoveCancellationURL") } if host == "" { - return nil, errors.New("host is required for a full url on MoveCancelationURL") + return nil, errors.New("host is required for a full url on MoveCancellationURL") } base, err := o.Build() @@ -96,6 +96,6 @@ func (o *MoveCancelationURL) BuildFull(scheme, host string) (*url.URL, error) { } // StringFull returns the string representation of a complete url -func (o *MoveCancelationURL) StringFull(scheme, host string) string { +func (o *MoveCancellationURL) StringFull(scheme, host string) string { return o.Must(o.BuildFull(scheme, host)).String() } diff --git a/pkg/gen/ghcapi/ghcoperations/mymove_api.go b/pkg/gen/ghcapi/ghcoperations/mymove_api.go index 5c182dd1144..a9709ac70c6 100644 --- a/pkg/gen/ghcapi/ghcoperations/mymove_api.go +++ b/pkg/gen/ghcapi/ghcoperations/mymove_api.go @@ -239,8 +239,8 @@ func NewMymoveAPI(spec *loads.Document) *MymoveAPI { QueuesListPrimeMovesHandler: queues.ListPrimeMovesHandlerFunc(func(params queues.ListPrimeMovesParams) middleware.Responder { return middleware.NotImplemented("operation queues.ListPrimeMoves has not yet been implemented") }), - MoveMoveCancelationHandler: move.MoveCancelationHandlerFunc(func(params move.MoveCancelationParams) middleware.Responder { - return middleware.NotImplemented("operation move.MoveCancelation has not yet been implemented") + MoveMoveCancellationHandler: move.MoveCancellationHandlerFunc(func(params move.MoveCancellationParams) middleware.Responder { + return middleware.NotImplemented("operation move.MoveCancellation has not yet been implemented") }), ShipmentRejectShipmentHandler: shipment.RejectShipmentHandlerFunc(func(params shipment.RejectShipmentParams) middleware.Responder { return middleware.NotImplemented("operation shipment.RejectShipment has not yet been implemented") @@ -513,8 +513,8 @@ type MymoveAPI struct { MtoShipmentListMTOShipmentsHandler mto_shipment.ListMTOShipmentsHandler // QueuesListPrimeMovesHandler sets the operation handler for the list prime moves operation QueuesListPrimeMovesHandler queues.ListPrimeMovesHandler - // MoveMoveCancelationHandler sets the operation handler for the move cancelation operation - MoveMoveCancelationHandler move.MoveCancelationHandler + // MoveMoveCancellationHandler sets the operation handler for the move cancellation operation + MoveMoveCancellationHandler move.MoveCancellationHandler // ShipmentRejectShipmentHandler sets the operation handler for the reject shipment operation ShipmentRejectShipmentHandler shipment.RejectShipmentHandler // LinesOfAccountingRequestLineOfAccountingHandler sets the operation handler for the request line of accounting operation @@ -843,8 +843,8 @@ func (o *MymoveAPI) Validate() error { if o.QueuesListPrimeMovesHandler == nil { unregistered = append(unregistered, "queues.ListPrimeMovesHandler") } - if o.MoveMoveCancelationHandler == nil { - unregistered = append(unregistered, "move.MoveCancelationHandler") + if o.MoveMoveCancellationHandler == nil { + unregistered = append(unregistered, "move.MoveCancellationHandler") } if o.ShipmentRejectShipmentHandler == nil { unregistered = append(unregistered, "shipment.RejectShipmentHandler") @@ -1280,7 +1280,7 @@ func (o *MymoveAPI) initHandlerCache() { if o.handlers["POST"] == nil { o.handlers["POST"] = make(map[string]http.Handler) } - o.handlers["POST"]["/moves/{moveID}/cancel"] = move.NewMoveCancelation(o.context, o.MoveMoveCancelationHandler) + o.handlers["POST"]["/moves/{moveID}/cancel"] = move.NewMoveCancellation(o.context, o.MoveMoveCancellationHandler) if o.handlers["POST"] == nil { o.handlers["POST"] = make(map[string]http.Handler) } diff --git a/pkg/handlers/ghcapi/api.go b/pkg/handlers/ghcapi/api.go index 3a399147c34..d7101aec4e1 100644 --- a/pkg/handlers/ghcapi/api.go +++ b/pkg/handlers/ghcapi/api.go @@ -656,9 +656,9 @@ func NewGhcAPIHandler(handlerConfig handlers.HandlerConfig) *ghcops.MymoveAPI { order.NewOrderUpdater(moveRouter), } - ghcAPI.MoveMoveCancelationHandler = MoveCancelationHandler{ + ghcAPI.MoveMoveCancellationHandler = MoveCancellationHandler{ handlerConfig, - move.NewMoveCancelation(), + move.NewMoveCancellation(), } return ghcAPI diff --git a/pkg/handlers/ghcapi/move.go b/pkg/handlers/ghcapi/move.go index 744afce9bb2..0324cdcec50 100644 --- a/pkg/handlers/ghcapi/move.go +++ b/pkg/handlers/ghcapi/move.go @@ -279,28 +279,28 @@ func (h UploadAdditionalDocumentsHandler) Handle(params moveop.UploadAdditionalD }) } -type MoveCancelationHandler struct { +type MoveCancellationHandler struct { handlers.HandlerConfig - services.MoveCancelation + services.MoveCancellation } -func (h MoveCancelationHandler) Handle(params moveop.MoveCancelationParams) middleware.Responder { +func (h MoveCancellationHandler) Handle(params moveop.MoveCancellationParams) middleware.Responder { return h.AuditableAppContextFromRequestWithErrors(params.HTTPRequest, func(appCtx appcontext.AppContext) (middleware.Responder, error) { moveID := uuid.FromStringOrNil(params.MoveID.String()) - move, err := h.MoveCancelation.CancelMove(appCtx, moveID) + move, err := h.MoveCancellation.CancelMove(appCtx, moveID) if err != nil { - appCtx.Logger().Error("MoveCancelationHandler error", zap.Error(err)) + appCtx.Logger().Error("MoveCancellationHandler error", zap.Error(err)) switch err.(type) { case apperror.NotFoundError: - return moveop.NewMoveCancelationNotFound(), err + return moveop.NewMoveCancellationNotFound(), err case apperror.PreconditionFailedError: - return moveop.NewMoveCancelationPreconditionFailed(), err + return moveop.NewMoveCancellationPreconditionFailed(), err case apperror.InvalidInputError: - return moveop.NewMoveCancelationUnprocessableEntity(), err + return moveop.NewMoveCancellationUnprocessableEntity(), err default: - return moveop.NewMoveCancelationInternalServerError(), err + return moveop.NewMoveCancellationInternalServerError(), err } } @@ -308,7 +308,7 @@ func (h MoveCancelationHandler) Handle(params moveop.MoveCancelationParams) midd if err != nil { return nil, err } - return moveop.NewMoveCancelationOK().WithPayload(payload), nil + return moveop.NewMoveCancellationOK().WithPayload(payload), nil }) } diff --git a/pkg/services/move.go b/pkg/services/move.go index 8997c1fe3d6..130669c0042 100644 --- a/pkg/services/move.go +++ b/pkg/services/move.go @@ -113,6 +113,6 @@ type MoveCloseoutOfficeUpdater interface { UpdateCloseoutOffice(appCtx appcontext.AppContext, moveLocator string, closeoutOfficeID uuid.UUID, eTag string) (*models.Move, error) } -type MoveCancelation interface { +type MoveCancellation interface { CancelMove(appCtx appcontext.AppContext, moveID uuid.UUID) (*models.Move, error) } diff --git a/pkg/services/move/move_cancelation.go b/pkg/services/move/move_cancelation.go index c2c9229f435..c1c27c9be65 100644 --- a/pkg/services/move/move_cancelation.go +++ b/pkg/services/move/move_cancelation.go @@ -9,13 +9,13 @@ import ( "github.com/transcom/mymove/pkg/services" ) -type moveCancelation struct{} +type moveCancellation struct{} -func NewMoveCancelation() services.MoveCancelation { - return &moveCancelation{} +func NewMoveCancellation() services.MoveCancellation { + return &moveCancellation{} } -func (f *moveCancelation) CancelMove(appCtx appcontext.AppContext, moveID uuid.UUID) (*models.Move, error) { +func (f *moveCancellation) CancelMove(appCtx appcontext.AppContext, moveID uuid.UUID) (*models.Move, error) { move := &models.Move{} err := appCtx.DB().Find(move, moveID) if err != nil { diff --git a/pkg/services/move/move_cancelation_test.go b/pkg/services/move/move_cancelation_test.go index 3c8c02d2bd3..f9d213060a8 100644 --- a/pkg/services/move/move_cancelation_test.go +++ b/pkg/services/move/move_cancelation_test.go @@ -6,7 +6,7 @@ import ( ) func (suite *MoveServiceSuite) TestCancelMove() { - moveCancellation := NewMoveCancelation() + moveCancellation := NewMoveCancellation() suite.Run("successfully cancels a move", func() { move := factory.BuildMove(suite.DB(), nil, nil) diff --git a/swagger-def/ghc.yaml b/swagger-def/ghc.yaml index 8fcd66ccf46..3127005c38d 100644 --- a/swagger-def/ghc.yaml +++ b/swagger-def/ghc.yaml @@ -400,7 +400,7 @@ paths: tags: - move description: cancels a move - operationId: moveCancelation + operationId: moveCancellation summary: Cancels a move '/counseling/orders/{orderID}': parameters: diff --git a/swagger/ghc.yaml b/swagger/ghc.yaml index a174bf3c409..c2af626e302 100644 --- a/swagger/ghc.yaml +++ b/swagger/ghc.yaml @@ -438,7 +438,7 @@ paths: tags: - move description: cancels a move - operationId: moveCancelation + operationId: moveCancellation summary: Cancels a move /counseling/orders/{orderID}: parameters: From 97050af6a7f73e94d366e6b23bdbb92c94b4004d Mon Sep 17 00:00:00 2001 From: loganwc Date: Fri, 9 Aug 2024 03:36:39 +0000 Subject: [PATCH 08/37] canceler instead of cancellation --- pkg/gen/ghcapi/configure_mymove.go | 6 +- pkg/gen/ghcapi/embedded_spec.go | 4 +- .../ghcoperations/move/move_canceler.go | 58 +++ ...ameters.go => move_canceler_parameters.go} | 20 +- .../move/move_canceler_responses.go | 329 ++++++++++++++++++ ...builder.go => move_canceler_urlbuilder.go} | 24 +- .../ghcoperations/move/move_cancellation.go | 58 --- .../move/move_cancellation_responses.go | 329 ------------------ pkg/gen/ghcapi/ghcoperations/mymove_api.go | 14 +- pkg/handlers/ghcapi/api.go | 4 +- pkg/handlers/ghcapi/move.go | 20 +- pkg/services/move.go | 2 +- .../{move_cancelation.go => move_canceler.go} | 8 +- ...celation_test.go => move_canceler_test.go} | 6 +- swagger-def/ghc.yaml | 2 +- swagger/ghc.yaml | 2 +- 16 files changed, 443 insertions(+), 443 deletions(-) create mode 100644 pkg/gen/ghcapi/ghcoperations/move/move_canceler.go rename pkg/gen/ghcapi/ghcoperations/move/{move_cancellation_parameters.go => move_canceler_parameters.go} (73%) create mode 100644 pkg/gen/ghcapi/ghcoperations/move/move_canceler_responses.go rename pkg/gen/ghcapi/ghcoperations/move/{move_cancellation_urlbuilder.go => move_canceler_urlbuilder.go} (74%) delete mode 100644 pkg/gen/ghcapi/ghcoperations/move/move_cancellation.go delete mode 100644 pkg/gen/ghcapi/ghcoperations/move/move_cancellation_responses.go rename pkg/services/move/{move_cancelation.go => move_canceler.go} (91%) rename pkg/services/move/{move_cancelation_test.go => move_canceler_test.go} (67%) diff --git a/pkg/gen/ghcapi/configure_mymove.go b/pkg/gen/ghcapi/configure_mymove.go index 192fe39e8d5..342536899da 100644 --- a/pkg/gen/ghcapi/configure_mymove.go +++ b/pkg/gen/ghcapi/configure_mymove.go @@ -354,9 +354,9 @@ func configureAPI(api *ghcoperations.MymoveAPI) http.Handler { return middleware.NotImplemented("operation queues.ListPrimeMoves has not yet been implemented") }) } - if api.MoveMoveCancellationHandler == nil { - api.MoveMoveCancellationHandler = move.MoveCancellationHandlerFunc(func(params move.MoveCancellationParams) middleware.Responder { - return middleware.NotImplemented("operation move.MoveCancellation has not yet been implemented") + if api.MoveMoveCancelerHandler == nil { + api.MoveMoveCancelerHandler = move.MoveCancelerHandlerFunc(func(params move.MoveCancelerParams) middleware.Responder { + return middleware.NotImplemented("operation move.MoveCanceler has not yet been implemented") }) } if api.ShipmentRejectShipmentHandler == nil { diff --git a/pkg/gen/ghcapi/embedded_spec.go b/pkg/gen/ghcapi/embedded_spec.go index 84c90899ee6..da62cd66377 100644 --- a/pkg/gen/ghcapi/embedded_spec.go +++ b/pkg/gen/ghcapi/embedded_spec.go @@ -2238,7 +2238,7 @@ func init() { "move" ], "summary": "Cancels a move", - "operationId": "moveCancellation", + "operationId": "moveCanceler", "responses": { "200": { "description": "Successfully cancelled move", @@ -15969,7 +15969,7 @@ func init() { "move" ], "summary": "Cancels a move", - "operationId": "moveCancellation", + "operationId": "moveCanceler", "responses": { "200": { "description": "Successfully cancelled move", diff --git a/pkg/gen/ghcapi/ghcoperations/move/move_canceler.go b/pkg/gen/ghcapi/ghcoperations/move/move_canceler.go new file mode 100644 index 00000000000..5036a38e3a0 --- /dev/null +++ b/pkg/gen/ghcapi/ghcoperations/move/move_canceler.go @@ -0,0 +1,58 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package move + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime/middleware" +) + +// MoveCancelerHandlerFunc turns a function with the right signature into a move canceler handler +type MoveCancelerHandlerFunc func(MoveCancelerParams) middleware.Responder + +// Handle executing the request and returning a response +func (fn MoveCancelerHandlerFunc) Handle(params MoveCancelerParams) middleware.Responder { + return fn(params) +} + +// MoveCancelerHandler interface for that can handle valid move canceler params +type MoveCancelerHandler interface { + Handle(MoveCancelerParams) middleware.Responder +} + +// NewMoveCanceler creates a new http.Handler for the move canceler operation +func NewMoveCanceler(ctx *middleware.Context, handler MoveCancelerHandler) *MoveCanceler { + return &MoveCanceler{Context: ctx, Handler: handler} +} + +/* + MoveCanceler swagger:route POST /moves/{moveID}/cancel move moveCanceler + +# Cancels a move + +cancels a move +*/ +type MoveCanceler struct { + Context *middleware.Context + Handler MoveCancelerHandler +} + +func (o *MoveCanceler) ServeHTTP(rw http.ResponseWriter, r *http.Request) { + route, rCtx, _ := o.Context.RouteInfo(r) + if rCtx != nil { + *r = *rCtx + } + var Params = NewMoveCancelerParams() + if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params + o.Context.Respond(rw, r, route.Produces, route, err) + return + } + + res := o.Handler.Handle(Params) // actually handle the request + o.Context.Respond(rw, r, route.Produces, route, res) + +} diff --git a/pkg/gen/ghcapi/ghcoperations/move/move_cancellation_parameters.go b/pkg/gen/ghcapi/ghcoperations/move/move_canceler_parameters.go similarity index 73% rename from pkg/gen/ghcapi/ghcoperations/move/move_cancellation_parameters.go rename to pkg/gen/ghcapi/ghcoperations/move/move_canceler_parameters.go index 98a353a63ae..e997f36bc19 100644 --- a/pkg/gen/ghcapi/ghcoperations/move/move_cancellation_parameters.go +++ b/pkg/gen/ghcapi/ghcoperations/move/move_canceler_parameters.go @@ -14,19 +14,19 @@ import ( "github.com/go-openapi/validate" ) -// NewMoveCancellationParams creates a new MoveCancellationParams object +// NewMoveCancelerParams creates a new MoveCancelerParams object // // There are no default values defined in the spec. -func NewMoveCancellationParams() MoveCancellationParams { +func NewMoveCancelerParams() MoveCancelerParams { - return MoveCancellationParams{} + return MoveCancelerParams{} } -// MoveCancellationParams contains all the bound params for the move cancellation operation +// MoveCancelerParams contains all the bound params for the move canceler operation // typically these are obtained from a http.Request // -// swagger:parameters moveCancellation -type MoveCancellationParams struct { +// swagger:parameters moveCanceler +type MoveCancelerParams struct { // HTTP Request Object HTTPRequest *http.Request `json:"-"` @@ -41,8 +41,8 @@ type MoveCancellationParams struct { // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface // for simple values it will use straight method calls. // -// To ensure default values, the struct must have been initialized with NewMoveCancellationParams() beforehand. -func (o *MoveCancellationParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { +// To ensure default values, the struct must have been initialized with NewMoveCancelerParams() beforehand. +func (o *MoveCancelerParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error { var res []error o.HTTPRequest = r @@ -58,7 +58,7 @@ func (o *MoveCancellationParams) BindRequest(r *http.Request, route *middleware. } // bindMoveID binds and validates parameter MoveID from path. -func (o *MoveCancellationParams) bindMoveID(rawData []string, hasKey bool, formats strfmt.Registry) error { +func (o *MoveCancelerParams) bindMoveID(rawData []string, hasKey bool, formats strfmt.Registry) error { var raw string if len(rawData) > 0 { raw = rawData[len(rawData)-1] @@ -82,7 +82,7 @@ func (o *MoveCancellationParams) bindMoveID(rawData []string, hasKey bool, forma } // validateMoveID carries on validations for parameter MoveID -func (o *MoveCancellationParams) validateMoveID(formats strfmt.Registry) error { +func (o *MoveCancelerParams) validateMoveID(formats strfmt.Registry) error { if err := validate.FormatOf("moveID", "path", "uuid", o.MoveID.String(), formats); err != nil { return err diff --git a/pkg/gen/ghcapi/ghcoperations/move/move_canceler_responses.go b/pkg/gen/ghcapi/ghcoperations/move/move_canceler_responses.go new file mode 100644 index 00000000000..828a8086069 --- /dev/null +++ b/pkg/gen/ghcapi/ghcoperations/move/move_canceler_responses.go @@ -0,0 +1,329 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package move + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "net/http" + + "github.com/go-openapi/runtime" + + "github.com/transcom/mymove/pkg/gen/ghcmessages" +) + +// MoveCancelerOKCode is the HTTP code returned for type MoveCancelerOK +const MoveCancelerOKCode int = 200 + +/* +MoveCancelerOK Successfully cancelled move + +swagger:response moveCancelerOK +*/ +type MoveCancelerOK struct { + + /* + In: Body + */ + Payload *ghcmessages.Move `json:"body,omitempty"` +} + +// NewMoveCancelerOK creates MoveCancelerOK with default headers values +func NewMoveCancelerOK() *MoveCancelerOK { + + return &MoveCancelerOK{} +} + +// WithPayload adds the payload to the move canceler o k response +func (o *MoveCancelerOK) WithPayload(payload *ghcmessages.Move) *MoveCancelerOK { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the move canceler o k response +func (o *MoveCancelerOK) SetPayload(payload *ghcmessages.Move) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *MoveCancelerOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(200) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// MoveCancelerForbiddenCode is the HTTP code returned for type MoveCancelerForbidden +const MoveCancelerForbiddenCode int = 403 + +/* +MoveCancelerForbidden The request was denied + +swagger:response moveCancelerForbidden +*/ +type MoveCancelerForbidden struct { + + /* + In: Body + */ + Payload *ghcmessages.Error `json:"body,omitempty"` +} + +// NewMoveCancelerForbidden creates MoveCancelerForbidden with default headers values +func NewMoveCancelerForbidden() *MoveCancelerForbidden { + + return &MoveCancelerForbidden{} +} + +// WithPayload adds the payload to the move canceler forbidden response +func (o *MoveCancelerForbidden) WithPayload(payload *ghcmessages.Error) *MoveCancelerForbidden { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the move canceler forbidden response +func (o *MoveCancelerForbidden) SetPayload(payload *ghcmessages.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *MoveCancelerForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(403) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// MoveCancelerNotFoundCode is the HTTP code returned for type MoveCancelerNotFound +const MoveCancelerNotFoundCode int = 404 + +/* +MoveCancelerNotFound The requested resource wasn't found + +swagger:response moveCancelerNotFound +*/ +type MoveCancelerNotFound struct { + + /* + In: Body + */ + Payload *ghcmessages.Error `json:"body,omitempty"` +} + +// NewMoveCancelerNotFound creates MoveCancelerNotFound with default headers values +func NewMoveCancelerNotFound() *MoveCancelerNotFound { + + return &MoveCancelerNotFound{} +} + +// WithPayload adds the payload to the move canceler not found response +func (o *MoveCancelerNotFound) WithPayload(payload *ghcmessages.Error) *MoveCancelerNotFound { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the move canceler not found response +func (o *MoveCancelerNotFound) SetPayload(payload *ghcmessages.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *MoveCancelerNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(404) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// MoveCancelerConflictCode is the HTTP code returned for type MoveCancelerConflict +const MoveCancelerConflictCode int = 409 + +/* +MoveCancelerConflict Conflict error + +swagger:response moveCancelerConflict +*/ +type MoveCancelerConflict struct { + + /* + In: Body + */ + Payload *ghcmessages.Error `json:"body,omitempty"` +} + +// NewMoveCancelerConflict creates MoveCancelerConflict with default headers values +func NewMoveCancelerConflict() *MoveCancelerConflict { + + return &MoveCancelerConflict{} +} + +// WithPayload adds the payload to the move canceler conflict response +func (o *MoveCancelerConflict) WithPayload(payload *ghcmessages.Error) *MoveCancelerConflict { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the move canceler conflict response +func (o *MoveCancelerConflict) SetPayload(payload *ghcmessages.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *MoveCancelerConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(409) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// MoveCancelerPreconditionFailedCode is the HTTP code returned for type MoveCancelerPreconditionFailed +const MoveCancelerPreconditionFailedCode int = 412 + +/* +MoveCancelerPreconditionFailed Precondition failed + +swagger:response moveCancelerPreconditionFailed +*/ +type MoveCancelerPreconditionFailed struct { + + /* + In: Body + */ + Payload *ghcmessages.Error `json:"body,omitempty"` +} + +// NewMoveCancelerPreconditionFailed creates MoveCancelerPreconditionFailed with default headers values +func NewMoveCancelerPreconditionFailed() *MoveCancelerPreconditionFailed { + + return &MoveCancelerPreconditionFailed{} +} + +// WithPayload adds the payload to the move canceler precondition failed response +func (o *MoveCancelerPreconditionFailed) WithPayload(payload *ghcmessages.Error) *MoveCancelerPreconditionFailed { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the move canceler precondition failed response +func (o *MoveCancelerPreconditionFailed) SetPayload(payload *ghcmessages.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *MoveCancelerPreconditionFailed) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(412) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// MoveCancelerUnprocessableEntityCode is the HTTP code returned for type MoveCancelerUnprocessableEntity +const MoveCancelerUnprocessableEntityCode int = 422 + +/* +MoveCancelerUnprocessableEntity The payload was unprocessable. + +swagger:response moveCancelerUnprocessableEntity +*/ +type MoveCancelerUnprocessableEntity struct { + + /* + In: Body + */ + Payload *ghcmessages.ValidationError `json:"body,omitempty"` +} + +// NewMoveCancelerUnprocessableEntity creates MoveCancelerUnprocessableEntity with default headers values +func NewMoveCancelerUnprocessableEntity() *MoveCancelerUnprocessableEntity { + + return &MoveCancelerUnprocessableEntity{} +} + +// WithPayload adds the payload to the move canceler unprocessable entity response +func (o *MoveCancelerUnprocessableEntity) WithPayload(payload *ghcmessages.ValidationError) *MoveCancelerUnprocessableEntity { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the move canceler unprocessable entity response +func (o *MoveCancelerUnprocessableEntity) SetPayload(payload *ghcmessages.ValidationError) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *MoveCancelerUnprocessableEntity) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(422) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} + +// MoveCancelerInternalServerErrorCode is the HTTP code returned for type MoveCancelerInternalServerError +const MoveCancelerInternalServerErrorCode int = 500 + +/* +MoveCancelerInternalServerError A server error occurred + +swagger:response moveCancelerInternalServerError +*/ +type MoveCancelerInternalServerError struct { + + /* + In: Body + */ + Payload *ghcmessages.Error `json:"body,omitempty"` +} + +// NewMoveCancelerInternalServerError creates MoveCancelerInternalServerError with default headers values +func NewMoveCancelerInternalServerError() *MoveCancelerInternalServerError { + + return &MoveCancelerInternalServerError{} +} + +// WithPayload adds the payload to the move canceler internal server error response +func (o *MoveCancelerInternalServerError) WithPayload(payload *ghcmessages.Error) *MoveCancelerInternalServerError { + o.Payload = payload + return o +} + +// SetPayload sets the payload to the move canceler internal server error response +func (o *MoveCancelerInternalServerError) SetPayload(payload *ghcmessages.Error) { + o.Payload = payload +} + +// WriteResponse to the client +func (o *MoveCancelerInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { + + rw.WriteHeader(500) + if o.Payload != nil { + payload := o.Payload + if err := producer.Produce(rw, payload); err != nil { + panic(err) // let the recovery middleware deal with this + } + } +} diff --git a/pkg/gen/ghcapi/ghcoperations/move/move_cancellation_urlbuilder.go b/pkg/gen/ghcapi/ghcoperations/move/move_canceler_urlbuilder.go similarity index 74% rename from pkg/gen/ghcapi/ghcoperations/move/move_cancellation_urlbuilder.go rename to pkg/gen/ghcapi/ghcoperations/move/move_canceler_urlbuilder.go index fd91266aa01..f3f6ebb25eb 100644 --- a/pkg/gen/ghcapi/ghcoperations/move/move_cancellation_urlbuilder.go +++ b/pkg/gen/ghcapi/ghcoperations/move/move_canceler_urlbuilder.go @@ -14,8 +14,8 @@ import ( "github.com/go-openapi/strfmt" ) -// MoveCancellationURL generates an URL for the move cancellation operation -type MoveCancellationURL struct { +// MoveCancelerURL generates an URL for the move canceler operation +type MoveCancelerURL struct { MoveID strfmt.UUID _basePath string @@ -26,7 +26,7 @@ type MoveCancellationURL struct { // WithBasePath sets the base path for this url builder, only required when it's different from the // base path specified in the swagger spec. // When the value of the base path is an empty string -func (o *MoveCancellationURL) WithBasePath(bp string) *MoveCancellationURL { +func (o *MoveCancelerURL) WithBasePath(bp string) *MoveCancelerURL { o.SetBasePath(bp) return o } @@ -34,12 +34,12 @@ func (o *MoveCancellationURL) WithBasePath(bp string) *MoveCancellationURL { // SetBasePath sets the base path for this url builder, only required when it's different from the // base path specified in the swagger spec. // When the value of the base path is an empty string -func (o *MoveCancellationURL) SetBasePath(bp string) { +func (o *MoveCancelerURL) SetBasePath(bp string) { o._basePath = bp } // Build a url path and query string -func (o *MoveCancellationURL) Build() (*url.URL, error) { +func (o *MoveCancelerURL) Build() (*url.URL, error) { var _result url.URL var _path = "/moves/{moveID}/cancel" @@ -48,7 +48,7 @@ func (o *MoveCancellationURL) Build() (*url.URL, error) { if moveID != "" { _path = strings.Replace(_path, "{moveID}", moveID, -1) } else { - return nil, errors.New("moveId is required on MoveCancellationURL") + return nil, errors.New("moveId is required on MoveCancelerURL") } _basePath := o._basePath @@ -61,7 +61,7 @@ func (o *MoveCancellationURL) Build() (*url.URL, error) { } // Must is a helper function to panic when the url builder returns an error -func (o *MoveCancellationURL) Must(u *url.URL, err error) *url.URL { +func (o *MoveCancelerURL) Must(u *url.URL, err error) *url.URL { if err != nil { panic(err) } @@ -72,17 +72,17 @@ func (o *MoveCancellationURL) Must(u *url.URL, err error) *url.URL { } // String returns the string representation of the path with query string -func (o *MoveCancellationURL) String() string { +func (o *MoveCancelerURL) String() string { return o.Must(o.Build()).String() } // BuildFull builds a full url with scheme, host, path and query string -func (o *MoveCancellationURL) BuildFull(scheme, host string) (*url.URL, error) { +func (o *MoveCancelerURL) BuildFull(scheme, host string) (*url.URL, error) { if scheme == "" { - return nil, errors.New("scheme is required for a full url on MoveCancellationURL") + return nil, errors.New("scheme is required for a full url on MoveCancelerURL") } if host == "" { - return nil, errors.New("host is required for a full url on MoveCancellationURL") + return nil, errors.New("host is required for a full url on MoveCancelerURL") } base, err := o.Build() @@ -96,6 +96,6 @@ func (o *MoveCancellationURL) BuildFull(scheme, host string) (*url.URL, error) { } // StringFull returns the string representation of a complete url -func (o *MoveCancellationURL) StringFull(scheme, host string) string { +func (o *MoveCancelerURL) StringFull(scheme, host string) string { return o.Must(o.BuildFull(scheme, host)).String() } diff --git a/pkg/gen/ghcapi/ghcoperations/move/move_cancellation.go b/pkg/gen/ghcapi/ghcoperations/move/move_cancellation.go deleted file mode 100644 index a2d9f8a9bf3..00000000000 --- a/pkg/gen/ghcapi/ghcoperations/move/move_cancellation.go +++ /dev/null @@ -1,58 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package move - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the generate command - -import ( - "net/http" - - "github.com/go-openapi/runtime/middleware" -) - -// MoveCancellationHandlerFunc turns a function with the right signature into a move cancellation handler -type MoveCancellationHandlerFunc func(MoveCancellationParams) middleware.Responder - -// Handle executing the request and returning a response -func (fn MoveCancellationHandlerFunc) Handle(params MoveCancellationParams) middleware.Responder { - return fn(params) -} - -// MoveCancellationHandler interface for that can handle valid move cancellation params -type MoveCancellationHandler interface { - Handle(MoveCancellationParams) middleware.Responder -} - -// NewMoveCancellation creates a new http.Handler for the move cancellation operation -func NewMoveCancellation(ctx *middleware.Context, handler MoveCancellationHandler) *MoveCancellation { - return &MoveCancellation{Context: ctx, Handler: handler} -} - -/* - MoveCancellation swagger:route POST /moves/{moveID}/cancel move moveCancellation - -# Cancels a move - -cancels a move -*/ -type MoveCancellation struct { - Context *middleware.Context - Handler MoveCancellationHandler -} - -func (o *MoveCancellation) ServeHTTP(rw http.ResponseWriter, r *http.Request) { - route, rCtx, _ := o.Context.RouteInfo(r) - if rCtx != nil { - *r = *rCtx - } - var Params = NewMoveCancellationParams() - if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params - o.Context.Respond(rw, r, route.Produces, route, err) - return - } - - res := o.Handler.Handle(Params) // actually handle the request - o.Context.Respond(rw, r, route.Produces, route, res) - -} diff --git a/pkg/gen/ghcapi/ghcoperations/move/move_cancellation_responses.go b/pkg/gen/ghcapi/ghcoperations/move/move_cancellation_responses.go deleted file mode 100644 index 96d0e76f919..00000000000 --- a/pkg/gen/ghcapi/ghcoperations/move/move_cancellation_responses.go +++ /dev/null @@ -1,329 +0,0 @@ -// Code generated by go-swagger; DO NOT EDIT. - -package move - -// This file was generated by the swagger tool. -// Editing this file might prove futile when you re-run the swagger generate command - -import ( - "net/http" - - "github.com/go-openapi/runtime" - - "github.com/transcom/mymove/pkg/gen/ghcmessages" -) - -// MoveCancellationOKCode is the HTTP code returned for type MoveCancellationOK -const MoveCancellationOKCode int = 200 - -/* -MoveCancellationOK Successfully cancelled move - -swagger:response moveCancellationOK -*/ -type MoveCancellationOK struct { - - /* - In: Body - */ - Payload *ghcmessages.Move `json:"body,omitempty"` -} - -// NewMoveCancellationOK creates MoveCancellationOK with default headers values -func NewMoveCancellationOK() *MoveCancellationOK { - - return &MoveCancellationOK{} -} - -// WithPayload adds the payload to the move cancellation o k response -func (o *MoveCancellationOK) WithPayload(payload *ghcmessages.Move) *MoveCancellationOK { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the move cancellation o k response -func (o *MoveCancellationOK) SetPayload(payload *ghcmessages.Move) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *MoveCancellationOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.WriteHeader(200) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// MoveCancellationForbiddenCode is the HTTP code returned for type MoveCancellationForbidden -const MoveCancellationForbiddenCode int = 403 - -/* -MoveCancellationForbidden The request was denied - -swagger:response moveCancellationForbidden -*/ -type MoveCancellationForbidden struct { - - /* - In: Body - */ - Payload *ghcmessages.Error `json:"body,omitempty"` -} - -// NewMoveCancellationForbidden creates MoveCancellationForbidden with default headers values -func NewMoveCancellationForbidden() *MoveCancellationForbidden { - - return &MoveCancellationForbidden{} -} - -// WithPayload adds the payload to the move cancellation forbidden response -func (o *MoveCancellationForbidden) WithPayload(payload *ghcmessages.Error) *MoveCancellationForbidden { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the move cancellation forbidden response -func (o *MoveCancellationForbidden) SetPayload(payload *ghcmessages.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *MoveCancellationForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.WriteHeader(403) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// MoveCancellationNotFoundCode is the HTTP code returned for type MoveCancellationNotFound -const MoveCancellationNotFoundCode int = 404 - -/* -MoveCancellationNotFound The requested resource wasn't found - -swagger:response moveCancellationNotFound -*/ -type MoveCancellationNotFound struct { - - /* - In: Body - */ - Payload *ghcmessages.Error `json:"body,omitempty"` -} - -// NewMoveCancellationNotFound creates MoveCancellationNotFound with default headers values -func NewMoveCancellationNotFound() *MoveCancellationNotFound { - - return &MoveCancellationNotFound{} -} - -// WithPayload adds the payload to the move cancellation not found response -func (o *MoveCancellationNotFound) WithPayload(payload *ghcmessages.Error) *MoveCancellationNotFound { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the move cancellation not found response -func (o *MoveCancellationNotFound) SetPayload(payload *ghcmessages.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *MoveCancellationNotFound) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.WriteHeader(404) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// MoveCancellationConflictCode is the HTTP code returned for type MoveCancellationConflict -const MoveCancellationConflictCode int = 409 - -/* -MoveCancellationConflict Conflict error - -swagger:response moveCancellationConflict -*/ -type MoveCancellationConflict struct { - - /* - In: Body - */ - Payload *ghcmessages.Error `json:"body,omitempty"` -} - -// NewMoveCancellationConflict creates MoveCancellationConflict with default headers values -func NewMoveCancellationConflict() *MoveCancellationConflict { - - return &MoveCancellationConflict{} -} - -// WithPayload adds the payload to the move cancellation conflict response -func (o *MoveCancellationConflict) WithPayload(payload *ghcmessages.Error) *MoveCancellationConflict { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the move cancellation conflict response -func (o *MoveCancellationConflict) SetPayload(payload *ghcmessages.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *MoveCancellationConflict) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.WriteHeader(409) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// MoveCancellationPreconditionFailedCode is the HTTP code returned for type MoveCancellationPreconditionFailed -const MoveCancellationPreconditionFailedCode int = 412 - -/* -MoveCancellationPreconditionFailed Precondition failed - -swagger:response moveCancellationPreconditionFailed -*/ -type MoveCancellationPreconditionFailed struct { - - /* - In: Body - */ - Payload *ghcmessages.Error `json:"body,omitempty"` -} - -// NewMoveCancellationPreconditionFailed creates MoveCancellationPreconditionFailed with default headers values -func NewMoveCancellationPreconditionFailed() *MoveCancellationPreconditionFailed { - - return &MoveCancellationPreconditionFailed{} -} - -// WithPayload adds the payload to the move cancellation precondition failed response -func (o *MoveCancellationPreconditionFailed) WithPayload(payload *ghcmessages.Error) *MoveCancellationPreconditionFailed { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the move cancellation precondition failed response -func (o *MoveCancellationPreconditionFailed) SetPayload(payload *ghcmessages.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *MoveCancellationPreconditionFailed) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.WriteHeader(412) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// MoveCancellationUnprocessableEntityCode is the HTTP code returned for type MoveCancellationUnprocessableEntity -const MoveCancellationUnprocessableEntityCode int = 422 - -/* -MoveCancellationUnprocessableEntity The payload was unprocessable. - -swagger:response moveCancellationUnprocessableEntity -*/ -type MoveCancellationUnprocessableEntity struct { - - /* - In: Body - */ - Payload *ghcmessages.ValidationError `json:"body,omitempty"` -} - -// NewMoveCancellationUnprocessableEntity creates MoveCancellationUnprocessableEntity with default headers values -func NewMoveCancellationUnprocessableEntity() *MoveCancellationUnprocessableEntity { - - return &MoveCancellationUnprocessableEntity{} -} - -// WithPayload adds the payload to the move cancellation unprocessable entity response -func (o *MoveCancellationUnprocessableEntity) WithPayload(payload *ghcmessages.ValidationError) *MoveCancellationUnprocessableEntity { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the move cancellation unprocessable entity response -func (o *MoveCancellationUnprocessableEntity) SetPayload(payload *ghcmessages.ValidationError) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *MoveCancellationUnprocessableEntity) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.WriteHeader(422) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} - -// MoveCancellationInternalServerErrorCode is the HTTP code returned for type MoveCancellationInternalServerError -const MoveCancellationInternalServerErrorCode int = 500 - -/* -MoveCancellationInternalServerError A server error occurred - -swagger:response moveCancellationInternalServerError -*/ -type MoveCancellationInternalServerError struct { - - /* - In: Body - */ - Payload *ghcmessages.Error `json:"body,omitempty"` -} - -// NewMoveCancellationInternalServerError creates MoveCancellationInternalServerError with default headers values -func NewMoveCancellationInternalServerError() *MoveCancellationInternalServerError { - - return &MoveCancellationInternalServerError{} -} - -// WithPayload adds the payload to the move cancellation internal server error response -func (o *MoveCancellationInternalServerError) WithPayload(payload *ghcmessages.Error) *MoveCancellationInternalServerError { - o.Payload = payload - return o -} - -// SetPayload sets the payload to the move cancellation internal server error response -func (o *MoveCancellationInternalServerError) SetPayload(payload *ghcmessages.Error) { - o.Payload = payload -} - -// WriteResponse to the client -func (o *MoveCancellationInternalServerError) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) { - - rw.WriteHeader(500) - if o.Payload != nil { - payload := o.Payload - if err := producer.Produce(rw, payload); err != nil { - panic(err) // let the recovery middleware deal with this - } - } -} diff --git a/pkg/gen/ghcapi/ghcoperations/mymove_api.go b/pkg/gen/ghcapi/ghcoperations/mymove_api.go index a9709ac70c6..b3695bcb833 100644 --- a/pkg/gen/ghcapi/ghcoperations/mymove_api.go +++ b/pkg/gen/ghcapi/ghcoperations/mymove_api.go @@ -239,8 +239,8 @@ func NewMymoveAPI(spec *loads.Document) *MymoveAPI { QueuesListPrimeMovesHandler: queues.ListPrimeMovesHandlerFunc(func(params queues.ListPrimeMovesParams) middleware.Responder { return middleware.NotImplemented("operation queues.ListPrimeMoves has not yet been implemented") }), - MoveMoveCancellationHandler: move.MoveCancellationHandlerFunc(func(params move.MoveCancellationParams) middleware.Responder { - return middleware.NotImplemented("operation move.MoveCancellation has not yet been implemented") + MoveMoveCancelerHandler: move.MoveCancelerHandlerFunc(func(params move.MoveCancelerParams) middleware.Responder { + return middleware.NotImplemented("operation move.MoveCanceler has not yet been implemented") }), ShipmentRejectShipmentHandler: shipment.RejectShipmentHandlerFunc(func(params shipment.RejectShipmentParams) middleware.Responder { return middleware.NotImplemented("operation shipment.RejectShipment has not yet been implemented") @@ -513,8 +513,8 @@ type MymoveAPI struct { MtoShipmentListMTOShipmentsHandler mto_shipment.ListMTOShipmentsHandler // QueuesListPrimeMovesHandler sets the operation handler for the list prime moves operation QueuesListPrimeMovesHandler queues.ListPrimeMovesHandler - // MoveMoveCancellationHandler sets the operation handler for the move cancellation operation - MoveMoveCancellationHandler move.MoveCancellationHandler + // MoveMoveCancelerHandler sets the operation handler for the move canceler operation + MoveMoveCancelerHandler move.MoveCancelerHandler // ShipmentRejectShipmentHandler sets the operation handler for the reject shipment operation ShipmentRejectShipmentHandler shipment.RejectShipmentHandler // LinesOfAccountingRequestLineOfAccountingHandler sets the operation handler for the request line of accounting operation @@ -843,8 +843,8 @@ func (o *MymoveAPI) Validate() error { if o.QueuesListPrimeMovesHandler == nil { unregistered = append(unregistered, "queues.ListPrimeMovesHandler") } - if o.MoveMoveCancellationHandler == nil { - unregistered = append(unregistered, "move.MoveCancellationHandler") + if o.MoveMoveCancelerHandler == nil { + unregistered = append(unregistered, "move.MoveCancelerHandler") } if o.ShipmentRejectShipmentHandler == nil { unregistered = append(unregistered, "shipment.RejectShipmentHandler") @@ -1280,7 +1280,7 @@ func (o *MymoveAPI) initHandlerCache() { if o.handlers["POST"] == nil { o.handlers["POST"] = make(map[string]http.Handler) } - o.handlers["POST"]["/moves/{moveID}/cancel"] = move.NewMoveCancellation(o.context, o.MoveMoveCancellationHandler) + o.handlers["POST"]["/moves/{moveID}/cancel"] = move.NewMoveCanceler(o.context, o.MoveMoveCancelerHandler) if o.handlers["POST"] == nil { o.handlers["POST"] = make(map[string]http.Handler) } diff --git a/pkg/handlers/ghcapi/api.go b/pkg/handlers/ghcapi/api.go index d7101aec4e1..323ba0b3293 100644 --- a/pkg/handlers/ghcapi/api.go +++ b/pkg/handlers/ghcapi/api.go @@ -656,9 +656,9 @@ func NewGhcAPIHandler(handlerConfig handlers.HandlerConfig) *ghcops.MymoveAPI { order.NewOrderUpdater(moveRouter), } - ghcAPI.MoveMoveCancellationHandler = MoveCancellationHandler{ + ghcAPI.MoveMoveCancelerHandler = MoveCancelerHandler{ handlerConfig, - move.NewMoveCancellation(), + move.NewMoveCanceler(), } return ghcAPI diff --git a/pkg/handlers/ghcapi/move.go b/pkg/handlers/ghcapi/move.go index 0324cdcec50..b39675f9a42 100644 --- a/pkg/handlers/ghcapi/move.go +++ b/pkg/handlers/ghcapi/move.go @@ -279,28 +279,28 @@ func (h UploadAdditionalDocumentsHandler) Handle(params moveop.UploadAdditionalD }) } -type MoveCancellationHandler struct { +type MoveCancelerHandler struct { handlers.HandlerConfig - services.MoveCancellation + services.MoveCanceler } -func (h MoveCancellationHandler) Handle(params moveop.MoveCancellationParams) middleware.Responder { +func (h MoveCancelerHandler) Handle(params moveop.MoveCancelerParams) middleware.Responder { return h.AuditableAppContextFromRequestWithErrors(params.HTTPRequest, func(appCtx appcontext.AppContext) (middleware.Responder, error) { moveID := uuid.FromStringOrNil(params.MoveID.String()) - move, err := h.MoveCancellation.CancelMove(appCtx, moveID) + move, err := h.MoveCanceler.CancelMove(appCtx, moveID) if err != nil { - appCtx.Logger().Error("MoveCancellationHandler error", zap.Error(err)) + appCtx.Logger().Error("MoveCancelerHandler error", zap.Error(err)) switch err.(type) { case apperror.NotFoundError: - return moveop.NewMoveCancellationNotFound(), err + return moveop.NewMoveCancelerNotFound(), err case apperror.PreconditionFailedError: - return moveop.NewMoveCancellationPreconditionFailed(), err + return moveop.NewMoveCancelerPreconditionFailed(), err case apperror.InvalidInputError: - return moveop.NewMoveCancellationUnprocessableEntity(), err + return moveop.NewMoveCancelerUnprocessableEntity(), err default: - return moveop.NewMoveCancellationInternalServerError(), err + return moveop.NewMoveCancelerInternalServerError(), err } } @@ -308,7 +308,7 @@ func (h MoveCancellationHandler) Handle(params moveop.MoveCancellationParams) mi if err != nil { return nil, err } - return moveop.NewMoveCancellationOK().WithPayload(payload), nil + return moveop.NewMoveCancelerOK().WithPayload(payload), nil }) } diff --git a/pkg/services/move.go b/pkg/services/move.go index 130669c0042..f6c91fb8f74 100644 --- a/pkg/services/move.go +++ b/pkg/services/move.go @@ -113,6 +113,6 @@ type MoveCloseoutOfficeUpdater interface { UpdateCloseoutOffice(appCtx appcontext.AppContext, moveLocator string, closeoutOfficeID uuid.UUID, eTag string) (*models.Move, error) } -type MoveCancellation interface { +type MoveCanceler interface { CancelMove(appCtx appcontext.AppContext, moveID uuid.UUID) (*models.Move, error) } diff --git a/pkg/services/move/move_cancelation.go b/pkg/services/move/move_canceler.go similarity index 91% rename from pkg/services/move/move_cancelation.go rename to pkg/services/move/move_canceler.go index c1c27c9be65..8dda26ad898 100644 --- a/pkg/services/move/move_cancelation.go +++ b/pkg/services/move/move_canceler.go @@ -9,13 +9,13 @@ import ( "github.com/transcom/mymove/pkg/services" ) -type moveCancellation struct{} +type moveCanceler struct{} -func NewMoveCancellation() services.MoveCancellation { - return &moveCancellation{} +func NewMoveCanceler() services.MoveCanceler { + return &moveCanceler{} } -func (f *moveCancellation) CancelMove(appCtx appcontext.AppContext, moveID uuid.UUID) (*models.Move, error) { +func (f *moveCanceler) CancelMove(appCtx appcontext.AppContext, moveID uuid.UUID) (*models.Move, error) { move := &models.Move{} err := appCtx.DB().Find(move, moveID) if err != nil { diff --git a/pkg/services/move/move_cancelation_test.go b/pkg/services/move/move_canceler_test.go similarity index 67% rename from pkg/services/move/move_cancelation_test.go rename to pkg/services/move/move_canceler_test.go index f9d213060a8..132054fe852 100644 --- a/pkg/services/move/move_cancelation_test.go +++ b/pkg/services/move/move_canceler_test.go @@ -5,15 +5,15 @@ import ( "github.com/transcom/mymove/pkg/models" ) -func (suite *MoveServiceSuite) TestCancelMove() { - moveCancellation := NewMoveCancellation() +func (suite *MoveServiceSuite) TestMoveCanceler() { + moveCanceler := NewMoveCanceler() suite.Run("successfully cancels a move", func() { move := factory.BuildMove(suite.DB(), nil, nil) suite.NotEqual(move.Status, models.MoveStatusCANCELED) - m, err := moveCancellation.CancelMove(suite.AppContextForTest(), move.ID) + m, err := moveCanceler.CancelMove(suite.AppContextForTest(), move.ID) suite.NoError(err) suite.Equal(m.Status, models.MoveStatusCANCELED) }) diff --git a/swagger-def/ghc.yaml b/swagger-def/ghc.yaml index 3127005c38d..698daa0259b 100644 --- a/swagger-def/ghc.yaml +++ b/swagger-def/ghc.yaml @@ -400,7 +400,7 @@ paths: tags: - move description: cancels a move - operationId: moveCancellation + operationId: moveCanceler summary: Cancels a move '/counseling/orders/{orderID}': parameters: diff --git a/swagger/ghc.yaml b/swagger/ghc.yaml index c2af626e302..d1f60f50d6b 100644 --- a/swagger/ghc.yaml +++ b/swagger/ghc.yaml @@ -438,7 +438,7 @@ paths: tags: - move description: cancels a move - operationId: moveCancellation + operationId: moveCanceler summary: Cancels a move /counseling/orders/{orderID}: parameters: From 74b5d32f6943f8819a7b8b1fb6c3287a534d59c6 Mon Sep 17 00:00:00 2001 From: loganwc Date: Fri, 9 Aug 2024 10:07:01 -0500 Subject: [PATCH 09/37] adding status check before cancellation and additional test --- migrations/app/migrations_manifest.txt | 2 +- pkg/services/move/move_canceler.go | 17 ++++++++++++----- pkg/services/move/move_canceler_test.go | 13 +++++++++++++ 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/migrations/app/migrations_manifest.txt b/migrations/app/migrations_manifest.txt index bf8be32e668..5c9293fa5e8 100644 --- a/migrations/app/migrations_manifest.txt +++ b/migrations/app/migrations_manifest.txt @@ -967,10 +967,10 @@ 20240719192106_add_destination_gbloc_to_orders.up.sql 20240719222007_add_state_to_us_post_region_cities.up.sql 20240722134633_update_move_history_indexes.up.sql -20240729185147_add_cancel_to_ppm_status_enum.up.sql 20240725190050_update_payment_request_status_tpps_received.up.sql 20240729162353_joseph_doye_cn_cac.up.sql 20240729164930_mai_do_cac.up.sql +20240729185147_add_cancel_to_ppm_status_enum.up.sql 20240730161630_remove-boat-shipments-index.up.sql 20240801135811_create_mobile_home.up.sql 20240801135833_alter_mto_shipment_type_motorhome.up.sql diff --git a/pkg/services/move/move_canceler.go b/pkg/services/move/move_canceler.go index 8dda26ad898..397630a1c0e 100644 --- a/pkg/services/move/move_canceler.go +++ b/pkg/services/move/move_canceler.go @@ -38,6 +38,9 @@ func (f *moveCanceler) CancelMove(appCtx appcontext.AppContext, moveID uuid.UUID shipmentDelta.Status = models.MTOShipmentStatusCanceled if shipment.PPMShipment != nil { + if shipment.PPMShipment.Status == models.PPMShipmentStatusCloseoutComplete { + return apperror.NewConflictError(move.ID, " cannot cancel move with approved shipment.") + } var ppmshipment models.PPMShipment qerr := appCtx.DB().Where("id = ?", shipment.PPMShipment.ID).First(&ppmshipment) if qerr != nil { @@ -54,11 +57,15 @@ func (f *moveCanceler) CancelMove(appCtx appcontext.AppContext, moveID uuid.UUID } } - verrs, err := txnAppCtx.DB().ValidateAndUpdate(&shipmentDelta) - if verrs != nil && verrs.HasAny() { - return apperror.NewInvalidInputError(shipment.ID, err, verrs, "Validation errors found while setting shipment status") - } else if err != nil { - return apperror.NewQueryError("Shipment", err, "Failed to update status for shipment") + if shipment.Status != models.MTOShipmentStatusApproved { + verrs, err := txnAppCtx.DB().ValidateAndUpdate(&shipmentDelta) + if verrs != nil && verrs.HasAny() { + return apperror.NewInvalidInputError(shipment.ID, err, verrs, "Validation errors found while setting shipment status") + } else if err != nil { + return apperror.NewQueryError("Shipment", err, "Failed to update status for shipment") + } + } else { + return apperror.NewConflictError(move.ID, " cannot cancel move with approved shipment.") } } diff --git a/pkg/services/move/move_canceler_test.go b/pkg/services/move/move_canceler_test.go index 132054fe852..314b0719075 100644 --- a/pkg/services/move/move_canceler_test.go +++ b/pkg/services/move/move_canceler_test.go @@ -17,4 +17,17 @@ func (suite *MoveServiceSuite) TestMoveCanceler() { suite.NoError(err) suite.Equal(m.Status, models.MoveStatusCANCELED) }) + + suite.Run("fails to cancel move with approved hhg shipment", func() { + move := factory.BuildMoveWithShipment(suite.DB(), []factory.Customization{ + { + Model: models.MTOShipment{ + Status: models.MTOShipmentStatusApproved, + }, + }, + }, nil) + + _, err := moveCanceler.CancelMove(suite.AppContextForTest(), move.ID) + suite.Error(err) + }) } From 8e986215d1225bd157aecdf4c1e24e14ceb4130a Mon Sep 17 00:00:00 2001 From: loganwc Date: Fri, 9 Aug 2024 13:55:03 -0500 Subject: [PATCH 10/37] added if not exists to query --- .../schema/20240729185147_add_cancel_to_ppm_status_enum.up.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/migrations/app/schema/20240729185147_add_cancel_to_ppm_status_enum.up.sql b/migrations/app/schema/20240729185147_add_cancel_to_ppm_status_enum.up.sql index 966c7f400f3..90e2dde0ad7 100644 --- a/migrations/app/schema/20240729185147_add_cancel_to_ppm_status_enum.up.sql +++ b/migrations/app/schema/20240729185147_add_cancel_to_ppm_status_enum.up.sql @@ -1 +1 @@ -ALTER TYPE ppm_shipment_status ADD VALUE 'CANCELED'; \ No newline at end of file +ALTER TYPE ppm_shipment_status ADD VALUE IF NOT EXISTS 'CANCELED'; \ No newline at end of file From 5623acf19b4d65f0e0d6a4ed2e3fce7170d9be56 Mon Sep 17 00:00:00 2001 From: loganwc Date: Thu, 15 Aug 2024 14:53:44 +0000 Subject: [PATCH 11/37] added 409 return for conflicting move status --- pkg/handlers/ghcapi/move.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/handlers/ghcapi/move.go b/pkg/handlers/ghcapi/move.go index b39675f9a42..9cab8f9f385 100644 --- a/pkg/handlers/ghcapi/move.go +++ b/pkg/handlers/ghcapi/move.go @@ -299,6 +299,8 @@ func (h MoveCancelerHandler) Handle(params moveop.MoveCancelerParams) middleware return moveop.NewMoveCancelerPreconditionFailed(), err case apperror.InvalidInputError: return moveop.NewMoveCancelerUnprocessableEntity(), err + case apperror.ConflictError: + return moveop.NewMoveCancelerConflict(), err default: return moveop.NewMoveCancelerInternalServerError(), err } From 5d9dcf03db77ae4c6f389d12c33caa33964c2269 Mon Sep 17 00:00:00 2001 From: loganwc Date: Fri, 23 Aug 2024 14:50:48 +0000 Subject: [PATCH 12/37] fixed spelling --- pkg/models/ppm_shipment.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/models/ppm_shipment.go b/pkg/models/ppm_shipment.go index 629dab0f0fb..eda1eefc5ce 100644 --- a/pkg/models/ppm_shipment.go +++ b/pkg/models/ppm_shipment.go @@ -73,7 +73,7 @@ type PPMShipmentStatus string const ( // PPMShipmentStatusCancelled captures enum value "DRAFT" - PPMShipmentStatusCancelled PPMShipmentStatus = "CANCELLED" + PPMShipmentStatusCancelled PPMShipmentStatus = "CANCELED" // PPMShipmentStatusDraft captures enum value "DRAFT" PPMShipmentStatusDraft PPMShipmentStatus = "DRAFT" // PPMShipmentStatusSubmitted captures enum value "SUBMITTED" From 75eed29fd6d5369100babb6a3b25c70f3dfa8a50 Mon Sep 17 00:00:00 2001 From: loganwc Date: Mon, 26 Aug 2024 13:58:40 +0000 Subject: [PATCH 13/37] updated comment --- pkg/models/ppm_shipment.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/models/ppm_shipment.go b/pkg/models/ppm_shipment.go index eda1eefc5ce..8f225abce07 100644 --- a/pkg/models/ppm_shipment.go +++ b/pkg/models/ppm_shipment.go @@ -72,7 +72,7 @@ type PPMSITEstimatedCostInfo struct { type PPMShipmentStatus string const ( - // PPMShipmentStatusCancelled captures enum value "DRAFT" + // PPMShipmentStatusCanceled captures enum value "DRAFT" PPMShipmentStatusCancelled PPMShipmentStatus = "CANCELED" // PPMShipmentStatusDraft captures enum value "DRAFT" PPMShipmentStatusDraft PPMShipmentStatus = "DRAFT" From 018cc026ecac654b22498d6905278a3b6658ec18 Mon Sep 17 00:00:00 2001 From: loganwc Date: Mon, 26 Aug 2024 16:54:04 +0000 Subject: [PATCH 14/37] renamed symbol --- pkg/models/ppm_shipment.go | 6 +++--- pkg/services/move/move_canceler.go | 2 +- pkg/services/move/move_router_test.go | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/models/ppm_shipment.go b/pkg/models/ppm_shipment.go index 8f225abce07..d00fe1510c8 100644 --- a/pkg/models/ppm_shipment.go +++ b/pkg/models/ppm_shipment.go @@ -73,7 +73,7 @@ type PPMShipmentStatus string const ( // PPMShipmentStatusCanceled captures enum value "DRAFT" - PPMShipmentStatusCancelled PPMShipmentStatus = "CANCELED" + PPMShipmentStatusCanceled PPMShipmentStatus = "CANCELED" // PPMShipmentStatusDraft captures enum value "DRAFT" PPMShipmentStatusDraft PPMShipmentStatus = "DRAFT" // PPMShipmentStatusSubmitted captures enum value "SUBMITTED" @@ -93,7 +93,7 @@ const ( // AllowedPPMShipmentStatuses is a list of all the allowed values for the Status of a PPMShipment as strings. Needed for // validation. var AllowedPPMShipmentStatuses = []string{ - string(PPMShipmentStatusCancelled), + string(PPMShipmentStatusCanceled), string(PPMShipmentStatusDraft), string(PPMShipmentStatusSubmitted), string(PPMShipmentStatusWaitingOnCustomer), @@ -244,7 +244,7 @@ func (p PPMShipment) TableName() string { // Cancel marks the PPM as Canceled func (p *PPMShipment) CancelShipment() error { - p.Status = PPMShipmentStatusCancelled + p.Status = PPMShipmentStatusCanceled return nil } diff --git a/pkg/services/move/move_canceler.go b/pkg/services/move/move_canceler.go index 397630a1c0e..26a0c2e04bb 100644 --- a/pkg/services/move/move_canceler.go +++ b/pkg/services/move/move_canceler.go @@ -47,7 +47,7 @@ func (f *moveCanceler) CancelMove(appCtx appcontext.AppContext, moveID uuid.UUID return apperror.NewNotFoundError(ppmshipment.ID, "while looking for ppm shipment") } - ppmshipment.Status = models.PPMShipmentStatusCancelled + ppmshipment.Status = models.PPMShipmentStatusCanceled verrs, err := txnAppCtx.DB().ValidateAndUpdate(&ppmshipment) if verrs != nil && verrs.HasAny() { diff --git a/pkg/services/move/move_router_test.go b/pkg/services/move/move_router_test.go index dfa830bef13..cd6b9f6623e 100644 --- a/pkg/services/move/move_router_test.go +++ b/pkg/services/move/move_router_test.go @@ -433,7 +433,7 @@ func (suite *MoveServiceSuite) TestMoveCancellation() { suite.NoError(err) suite.Equal(models.MoveStatusCANCELED, move.Status, "expected Canceled") - suite.Equal(models.PPMShipmentStatusCancelled, move.MTOShipments[0].PPMShipment.Status, "expected Canceled") + suite.Equal(models.PPMShipmentStatusCanceled, move.MTOShipments[0].PPMShipment.Status, "expected Canceled") suite.Equal(models.OrderStatusCANCELED, move.Orders.Status, "expected Canceled") }) From 5677e0e6a360ccaa0f1c93acaa6ab188434432e9 Mon Sep 17 00:00:00 2001 From: loganwc Date: Mon, 26 Aug 2024 17:01:44 +0000 Subject: [PATCH 15/37] CANCELED --- pkg/models/ppm_shipment.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/models/ppm_shipment.go b/pkg/models/ppm_shipment.go index d00fe1510c8..6c2cc9272d9 100644 --- a/pkg/models/ppm_shipment.go +++ b/pkg/models/ppm_shipment.go @@ -72,7 +72,7 @@ type PPMSITEstimatedCostInfo struct { type PPMShipmentStatus string const ( - // PPMShipmentStatusCanceled captures enum value "DRAFT" + // PPMShipmentStatusCanceled captures enum value "CANCELED" PPMShipmentStatusCanceled PPMShipmentStatus = "CANCELED" // PPMShipmentStatusDraft captures enum value "DRAFT" PPMShipmentStatusDraft PPMShipmentStatus = "DRAFT" From 27eb069415b07d2217c0f0cba01fb42f1805670d Mon Sep 17 00:00:00 2001 From: Jon Spight Date: Thu, 5 Sep 2024 16:08:48 +0000 Subject: [PATCH 16/37] added return for error --- pkg/handlers/ghcapi/orders.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/handlers/ghcapi/orders.go b/pkg/handlers/ghcapi/orders.go index ec024d8c55f..925c0cf2084 100644 --- a/pkg/handlers/ghcapi/orders.go +++ b/pkg/handlers/ghcapi/orders.go @@ -318,6 +318,7 @@ func (h CreateOrderHandler) Handle(params orderop.CreateOrderParams) middleware. if err != nil { err = apperror.NewBadDataError("Unable to fetch office user.") appCtx.Logger().Error(err.Error()) + return orderop.NewCreateOrderUnprocessableEntity(), err } else { moveOptions.CounselingOfficeID = &officeUser.TransportationOfficeID } From ad8f936b6bf9b22382369226f41e97a745f1c6c5 Mon Sep 17 00:00:00 2001 From: Brooklyn Welsh Date: Fri, 6 Sep 2024 11:35:57 -0400 Subject: [PATCH 17/37] Added feature flags for Boat and Mobile Home in SC/TIO/TOO views, was misssing one for the "Add a new shipment" dropdown. --- src/pages/Office/MoveDetails/MoveDetails.jsx | 37 +++++++++++++---- .../ServicesCounselingMoveDetails.jsx | 41 +++++++++++++------ 2 files changed, 56 insertions(+), 22 deletions(-) diff --git a/src/pages/Office/MoveDetails/MoveDetails.jsx b/src/pages/Office/MoveDetails/MoveDetails.jsx index 1c448c575a7..5eb9805131d 100644 --- a/src/pages/Office/MoveDetails/MoveDetails.jsx +++ b/src/pages/Office/MoveDetails/MoveDetails.jsx @@ -29,11 +29,12 @@ import LeftNavTag from 'components/LeftNavTag/LeftNavTag'; import Restricted from 'components/Restricted/Restricted'; import LoadingPlaceholder from 'shared/LoadingPlaceholder'; import SomethingWentWrong from 'shared/SomethingWentWrong'; -import { SHIPMENT_OPTIONS_URL } from 'shared/constants'; +import { SHIPMENT_OPTIONS_URL, FEATURE_FLAG_KEYS } from 'shared/constants'; import { SIT_EXTENSION_STATUS } from 'constants/sitExtensions'; import { ORDERS_TYPE } from 'constants/orders'; import { permissionTypes } from 'constants/permissions'; import { objectIsMissingFieldWithCondition } from 'utils/displayFlags'; +import { isBooleanFlagEnabled } from 'utils/featureFlags'; import formattedCustomerName from 'utils/formattedCustomerName'; import { calculateEstimatedWeight } from 'hooks/custom'; @@ -64,6 +65,8 @@ const MoveDetails = ({ const [shipmentMissingRequiredInformation, setShipmentMissingRequiredInformation] = useState(false); const [alertMessage, setAlertMessage] = useState(null); const [alertType, setAlertType] = useState('success'); + const [enableBoat, setEnableBoat] = useState(false); + const [enableMobileHome, setEnableMobileHome] = useState(false); const navigate = useNavigate(); @@ -168,6 +171,14 @@ const MoveDetails = ({ navigate(addShipmentPath); }; + useEffect(() => { + const fetchData = async () => { + setEnableBoat(await isBooleanFlagEnabled(FEATURE_FLAG_KEYS.BOAT)); + setEnableMobileHome(await isBooleanFlagEnabled(FEATURE_FLAG_KEYS.MOBILE_HOME)); + }; + fetchData(); + }, []); + useEffect(() => { const shipmentCount = shipmentWithDestinationAddressChangeRequest?.length || 0; if (setShipmentsWithDeliveryAddressUpdateRequestedCount) @@ -306,6 +317,21 @@ const MoveDetails = ({ const hasDestinationAddressUpdate = shipmentWithDestinationAddressChangeRequest && shipmentWithDestinationAddressChangeRequest.length > 0; + const allowedShipmentOptions = () => { + return ( + <> + + + + + {enableBoat && } + {enableMobileHome && } + + ); + }; + return (
@@ -389,14 +415,7 @@ const MoveDetails = ({ - - - - - - + {allowedShipmentOptions()} )} diff --git a/src/pages/Office/ServicesCounselingMoveDetails/ServicesCounselingMoveDetails.jsx b/src/pages/Office/ServicesCounselingMoveDetails/ServicesCounselingMoveDetails.jsx index b630bd71b68..a11571275f7 100644 --- a/src/pages/Office/ServicesCounselingMoveDetails/ServicesCounselingMoveDetails.jsx +++ b/src/pages/Office/ServicesCounselingMoveDetails/ServicesCounselingMoveDetails.jsx @@ -24,7 +24,7 @@ import ShipmentDisplay from 'components/Office/ShipmentDisplay/ShipmentDisplay'; import { SubmitMoveConfirmationModal } from 'components/Office/SubmitMoveConfirmationModal/SubmitMoveConfirmationModal'; import { useMoveDetailsQueries, useOrdersDocumentQueries } from 'hooks/queries'; import { updateMoveStatusServiceCounselingCompleted, updateFinancialFlag } from 'services/ghcApi'; -import { MOVE_STATUSES, SHIPMENT_OPTIONS_URL, SHIPMENT_OPTIONS } from 'shared/constants'; +import { MOVE_STATUSES, SHIPMENT_OPTIONS_URL, SHIPMENT_OPTIONS, FEATURE_FLAG_KEYS } from 'shared/constants'; import { ppmShipmentStatuses } from 'constants/shipments'; import shipmentCardsStyles from 'styles/shipmentCards.module.scss'; import LeftNav from 'components/LeftNav/LeftNav'; @@ -41,6 +41,7 @@ import NotificationScrollToTop from 'components/NotificationScrollToTop'; import { objectIsMissingFieldWithCondition } from 'utils/displayFlags'; import { ReviewButton } from 'components/form/IconButtons'; import { calculateWeightRequested } from 'hooks/custom'; +import { isBooleanFlagEnabled } from 'utils/featureFlags'; const ServicesCounselingMoveDetails = ({ infoSavedAlert, setUnapprovedShipmentCount, isMoveLocked }) => { const { moveCode } = useParams(); @@ -51,6 +52,8 @@ const ServicesCounselingMoveDetails = ({ infoSavedAlert, setUnapprovedShipmentCo const [isSubmitModalVisible, setIsSubmitModalVisible] = useState(false); const [isFinancialModalVisible, setIsFinancialModalVisible] = useState(false); const [shipmentConcernCount, setShipmentConcernCount] = useState(0); + const [enableBoat, setEnableBoat] = useState(false); + const [enableMobileHome, setEnableMobileHome] = useState(false); const { upload, amendedUpload } = useOrdersDocumentQueries(moveCode); const documentsForViewer = Object.values(upload || {}) .concat(Object.values(amendedUpload || {})) @@ -135,6 +138,14 @@ const ServicesCounselingMoveDetails = ({ infoSavedAlert, setUnapprovedShipmentCo checkProGearAllowances(); }); + useEffect(() => { + const fetchData = async () => { + setEnableBoat(await isBooleanFlagEnabled(FEATURE_FLAG_KEYS.BOAT)); + setEnableMobileHome(await isBooleanFlagEnabled(FEATURE_FLAG_KEYS.MOBILE_HOME)); + }; + fetchData(); + }, []); + // for now we are only showing dest type on retiree and separatee orders const isRetirementOrSeparation = order.order_type === ORDERS_TYPE.RETIREMENT || order.order_type === ORDERS_TYPE.SEPARATION; @@ -465,6 +476,21 @@ const ServicesCounselingMoveDetails = ({ infoSavedAlert, setUnapprovedShipmentCo const hasMissingOrdersRequiredInfo = Object.values(requiredOrdersInfo).some((value) => !value || value === ''); const hasAmendedOrders = ordersInfo.uploadedAmendedOrderID && !ordersInfo.amendedOrdersAcknowledgedAt; + const allowedShipmentOptions = () => { + return ( + <> + + + + + {enableBoat && } + {enableMobileHome && } + + ); + }; + return (
@@ -574,18 +600,7 @@ const ServicesCounselingMoveDetails = ({ infoSavedAlert, setUnapprovedShipmentCo - - - - - - + {allowedShipmentOptions()} ) } From c6b9130bab4914ae2e4f2d0137a89a43d77e2cad Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 9 Sep 2024 11:42:33 +0000 Subject: [PATCH 18/37] Bump alpine from 3.20.2 to 3.20.3 Bumps alpine from 3.20.2 to 3.20.3. --- updated-dependencies: - dependency-name: alpine dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Dockerfile.e2e | 2 +- Dockerfile.migrations | 2 +- Dockerfile.migrations_local | 2 +- Dockerfile.reviewapp | 2 +- Dockerfile.tools | 2 +- Dockerfile.tools_local | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Dockerfile.e2e b/Dockerfile.e2e index d161f38e33d..c88d243eb48 100644 --- a/Dockerfile.e2e +++ b/Dockerfile.e2e @@ -1,4 +1,4 @@ -FROM alpine:3.20.2 +FROM alpine:3.20.3 # hadolint ignore=DL3017 RUN apk upgrade --no-cache busybox diff --git a/Dockerfile.migrations b/Dockerfile.migrations index c3852e777b4..b4187431cd2 100644 --- a/Dockerfile.migrations +++ b/Dockerfile.migrations @@ -1,4 +1,4 @@ -FROM alpine:3.20.2 +FROM alpine:3.20.3 # hadolint ignore=DL3017 RUN apk upgrade --no-cache busybox diff --git a/Dockerfile.migrations_local b/Dockerfile.migrations_local index de2cbbb3481..3b2d11e7444 100644 --- a/Dockerfile.migrations_local +++ b/Dockerfile.migrations_local @@ -18,7 +18,7 @@ RUN rm -f bin/milmove && make bin/milmove # FINAL # ######### -FROM alpine:3.20.2 +FROM alpine:3.20.3 # hadolint ignore=DL3017 RUN apk upgrade --no-cache busybox diff --git a/Dockerfile.reviewapp b/Dockerfile.reviewapp index c27b975a8c9..cd35976410f 100644 --- a/Dockerfile.reviewapp +++ b/Dockerfile.reviewapp @@ -45,7 +45,7 @@ RUN set -x \ && make bin/generate-test-data # define migrations before client build since it doesn't need client -FROM alpine:3.20.2 as migrate +FROM alpine:3.20.3 as migrate COPY --from=server_builder /build/bin/rds-ca-2019-root.pem /bin/rds-ca-2019-root.pem COPY --from=server_builder /build/bin/milmove /bin/milmove diff --git a/Dockerfile.tools b/Dockerfile.tools index c3fd78134b6..97fe065b9d3 100644 --- a/Dockerfile.tools +++ b/Dockerfile.tools @@ -1,4 +1,4 @@ -FROM alpine:3.20.2 +FROM alpine:3.20.3 # hadolint ignore=DL3017 RUN apk upgrade --no-cache busybox diff --git a/Dockerfile.tools_local b/Dockerfile.tools_local index a68970c839d..fa2f95af5f7 100644 --- a/Dockerfile.tools_local +++ b/Dockerfile.tools_local @@ -18,7 +18,7 @@ RUN rm -f bin/prime-api-client && make bin/prime-api-client # FINAL # ######### -FROM alpine:3.20.2 +FROM alpine:3.20.3 # hadolint ignore=DL3017 RUN apk upgrade --no-cache busybox From 210b8c07eca946758f575020c359c5119849c244 Mon Sep 17 00:00:00 2001 From: Logan Cunningham <148146808+loganwc@users.noreply.github.com> Date: Mon, 9 Sep 2024 09:42:02 -0500 Subject: [PATCH 19/37] Update api.go --- pkg/handlers/ghcapi/api.go | 1 - 1 file changed, 1 deletion(-) diff --git a/pkg/handlers/ghcapi/api.go b/pkg/handlers/ghcapi/api.go index bcf6a5e7f16..716e0756bfc 100644 --- a/pkg/handlers/ghcapi/api.go +++ b/pkg/handlers/ghcapi/api.go @@ -676,6 +676,5 @@ func NewGhcAPIHandler(handlerConfig handlers.HandlerConfig) *ghcops.MymoveAPI { dateSelectionChecker := dateservice.NewDateSelectionChecker() ghcAPI.CalendarIsDateWeekendHolidayHandler = IsDateWeekendHolidayHandler{handlerConfig, dateSelectionChecker} - return ghcAPI } From e43a5c317da75f5c8c1fb439b3df9dc49090c48e Mon Sep 17 00:00:00 2001 From: Daniel Jordan Date: Tue, 10 Sep 2024 16:19:57 +0000 Subject: [PATCH 20/37] initial commit, should all be good, tests added --- .../ServicesCounselingTabNav.jsx | 12 +- .../ServicesCounselingTabNav.test.jsx | 6 +- src/components/Office/TXOTabNav/TXOTabNav.jsx | 4 + .../Office/TXOTabNav/TXOTabNav.test.jsx | 3 +- src/pages/Office/MoveDetails/MoveDetails.jsx | 37 +++++-- .../Office/MoveDetails/MoveDetails.test.jsx | 26 +++++ .../ServicesCounselingMoveDetails.jsx | 44 ++++++-- .../ServicesCounselingMoveDetails.test.jsx | 104 +++++++++++++++++- .../ServicesCounselingMoveInfo.jsx | 4 + src/pages/Office/TXOMoveInfo/TXOMoveInfo.jsx | 4 + 10 files changed, 213 insertions(+), 31 deletions(-) diff --git a/src/components/Office/ServicesCounselingTabNav/ServicesCounselingTabNav.jsx b/src/components/Office/ServicesCounselingTabNav/ServicesCounselingTabNav.jsx index 3dc4c9dadab..2d557e2c874 100644 --- a/src/components/Office/ServicesCounselingTabNav/ServicesCounselingTabNav.jsx +++ b/src/components/Office/ServicesCounselingTabNav/ServicesCounselingTabNav.jsx @@ -10,7 +10,7 @@ import 'styles/office.scss'; import TabNav from 'components/TabNav'; import { isBooleanFlagEnabled } from 'utils/featureFlags'; -const ServicesCounselingTabNav = ({ unapprovedShipmentCount = 0, moveCode }) => { +const ServicesCounselingTabNav = ({ unapprovedShipmentCount = 0, missingOrdersInfoCount, moveCode }) => { const [supportingDocsFF, setSupportingDocsFF] = React.useState(false); React.useEffect(() => { const fetchData = async () => { @@ -19,6 +19,14 @@ const ServicesCounselingTabNav = ({ unapprovedShipmentCount = 0, moveCode }) => fetchData(); }, []); + let moveDetailsTagCount = 0; + if (unapprovedShipmentCount > 0) { + moveDetailsTagCount += unapprovedShipmentCount; + } + if (missingOrdersInfoCount > 0) { + moveDetailsTagCount += missingOrdersInfoCount; + } + const items = [ data-testid="MoveDetails-Tab" > Move details - {unapprovedShipmentCount > 0 && {unapprovedShipmentCount}} + {moveDetailsTagCount > 0 && {moveDetailsTagCount}} , { expect(within(moveDetailsTab).queryByTestId('tag')).not.toBeInTheDocument(); }); - it('should render the move details tab container with a tag that shows the count of unapproved shipments', () => { + it('should render the move details tab container with a tag that shows the count of action items', () => { const moveDetailsShipmentAndAmendedOrders = { ...basicNavProps, unapprovedShipmentCount: 6, + missingOrdersInfoCount: 4, }; render(, { wrapper: MemoryRouter }); const moveDetailsTab = screen.getByTestId('MoveDetails-Tab'); - expect(within(moveDetailsTab).getByTestId('tag')).toHaveTextContent('6'); + expect(within(moveDetailsTab).getByTestId('tag')).toHaveTextContent('10'); }); }); diff --git a/src/components/Office/TXOTabNav/TXOTabNav.jsx b/src/components/Office/TXOTabNav/TXOTabNav.jsx index 9732c46407e..d3db9fbd1b9 100644 --- a/src/components/Office/TXOTabNav/TXOTabNav.jsx +++ b/src/components/Office/TXOTabNav/TXOTabNav.jsx @@ -17,6 +17,7 @@ const TXOTabNav = ({ excessWeightRiskCount, pendingPaymentRequestCount, unapprovedSITExtensionCount, + missingOrdersInfoCount, shipmentsWithDeliveryAddressUpdateRequestedCount, order, moveCode, @@ -39,6 +40,9 @@ const TXOTabNav = ({ if (shipmentsWithDeliveryAddressUpdateRequestedCount) { moveDetailsTagCount += shipmentsWithDeliveryAddressUpdateRequestedCount; } + if (missingOrdersInfoCount > 0) { + moveDetailsTagCount += missingOrdersInfoCount; + } let moveTaskOrderTagCount = 0; if (unapprovedServiceItemCount > 0) { diff --git a/src/components/Office/TXOTabNav/TXOTabNav.test.jsx b/src/components/Office/TXOTabNav/TXOTabNav.test.jsx index 7298a9d4d08..2779c53b11e 100644 --- a/src/components/Office/TXOTabNav/TXOTabNav.test.jsx +++ b/src/components/Office/TXOTabNav/TXOTabNav.test.jsx @@ -41,11 +41,12 @@ describe('Move details tag rendering', () => { const moveDetailsOneShipment = { ...basicNavProps, unapprovedShipmentCount: 1, + missingOrdersInfoCount: 4, }; render(, { wrapper: MemoryRouter }); const moveDetailsTab = screen.getByTestId('MoveDetails-Tab'); - expect(within(moveDetailsTab).getByTestId('tag')).toHaveTextContent('1'); + expect(within(moveDetailsTab).getByTestId('tag')).toHaveTextContent('5'); }); it('should render the move details tab container with a tag that shows the count of items that need attention when there are approved shipments with a destination address update requiring TXO review', () => { diff --git a/src/pages/Office/MoveDetails/MoveDetails.jsx b/src/pages/Office/MoveDetails/MoveDetails.jsx index 8d6a4c359ac..f6397c94061 100644 --- a/src/pages/Office/MoveDetails/MoveDetails.jsx +++ b/src/pages/Office/MoveDetails/MoveDetails.jsx @@ -57,6 +57,8 @@ const MoveDetails = ({ setExcessWeightRiskCount, setUnapprovedSITExtensionCount, setShipmentsWithDeliveryAddressUpdateRequestedCount, + missingOrdersInfoCount, + setMissingOrdersInfoCount, isMoveLocked, }) => { const { moveCode } = useParams(); @@ -238,6 +240,28 @@ const MoveDetails = ({ setShipmentMissingRequiredInformation(shipmentIsMissingInformation); }, [mtoShipments]); + // using useMemo here due to this being used in a useEffect + // using useMemo prevents the useEffect from being rendered on ever render by memoizing the object + // so that it only recognizes the change when the orders object changes + const requiredOrdersInfo = useMemo( + () => ({ + ordersNumber: order?.order_number || '', + ordersType: order?.order_type || '', + ordersTypeDetail: order?.order_type_detail || '', + tacMDC: order?.tac || '', + departmentIndicator: order?.department_indicator || '', + }), + [order], + ); + + // Keep num of missing orders info synced up + useEffect(() => { + const ordersInfoCount = Object.values(requiredOrdersInfo).reduce((count, value) => { + return !value ? count + 1 : count; + }, 0); + setMissingOrdersInfoCount(ordersInfoCount); + }, [order, requiredOrdersInfo, setMissingOrdersInfoCount]); + if (isLoading) return ; if (isError) return ; @@ -294,13 +318,6 @@ const MoveDetails = ({ backupContact: customer.backup_contact, }; - const requiredOrdersInfo = { - ordersNumber: order.order_number, - ordersType: order.order_type, - ordersTypeDetail: order.order_type_detail, - tacMDC: order.tac, - }; - const hasMissingOrdersRequiredInfo = Object.values(requiredOrdersInfo).some((value) => !value || value === ''); const hasAmendedOrders = ordersInfo.uploadedAmendedOrderID && !ordersInfo.amendedOrdersAcknowledgedAt; const hasDestinationAddressUpdate = @@ -311,12 +328,12 @@ const MoveDetails = ({
- + {missingOrdersInfoCount} ({ ...jest.requireActual('react-router-dom'), @@ -360,6 +361,7 @@ const requestedMoveDetailsAmendedOrdersQuery = { }, order: { id: '1', + department_indicator: 'ARMY', originDutyLocation: { address: { streetAddress1: '', @@ -783,6 +785,8 @@ describe('MoveDetails page', () => { setUnapprovedServiceItemCount={setUnapprovedServiceItemCount} setExcessWeightRiskCount={setExcessWeightRiskCount} setUnapprovedSITExtensionCount={setUnapprovedSITExtensionCount} + missingOrdersInfoCount={0} + setMissingOrdersInfoCount={setMissingOrdersInfoCount} /> , ); @@ -801,6 +805,8 @@ describe('MoveDetails page', () => { setUnapprovedServiceItemCount={setUnapprovedServiceItemCount} setExcessWeightRiskCount={setExcessWeightRiskCount} setUnapprovedSITExtensionCount={setUnapprovedSITExtensionCount} + missingOrdersInfoCount={0} + setMissingOrdersInfoCount={setMissingOrdersInfoCount} /> , ); @@ -819,6 +825,8 @@ describe('MoveDetails page', () => { setUnapprovedServiceItemCount={setUnapprovedServiceItemCount} setExcessWeightRiskCount={setExcessWeightRiskCount} setUnapprovedSITExtensionCount={setUnapprovedSITExtensionCount} + missingOrdersInfoCount={0} + setMissingOrdersInfoCount={setMissingOrdersInfoCount} /> , ); @@ -885,6 +893,8 @@ describe('MoveDetails page', () => { setUnapprovedServiceItemCount={setUnapprovedServiceItemCount} setExcessWeightRiskCount={setExcessWeightRiskCount} setUnapprovedSITExtensionCount={setUnapprovedSITExtensionCount} + missingOrdersInfoCount={0} + setMissingOrdersInfoCount={setMissingOrdersInfoCount} /> , ); @@ -905,6 +915,8 @@ describe('MoveDetails page', () => { setUnapprovedServiceItemCount={setUnapprovedServiceItemCount} setExcessWeightRiskCount={setExcessWeightRiskCount} setUnapprovedSITExtensionCount={setUnapprovedSITExtensionCount} + missingOrdersInfoCount={0} + setMissingOrdersInfoCount={setMissingOrdersInfoCount} /> , ); @@ -928,6 +940,8 @@ describe('MoveDetails page', () => { setUnapprovedServiceItemCount={setUnapprovedServiceItemCount} setExcessWeightRiskCount={setExcessWeightRiskCount} setUnapprovedSITExtensionCount={setUnapprovedSITExtensionCount} + missingOrdersInfoCount={0} + setMissingOrdersInfoCount={setMissingOrdersInfoCount} /> , ); @@ -967,6 +981,8 @@ describe('MoveDetails page', () => { setUnapprovedServiceItemCount={setUnapprovedServiceItemCount} setExcessWeightRiskCount={setExcessWeightRiskCount} setUnapprovedSITExtensionCount={setUnapprovedServiceItemCount} + missingOrdersInfoCount={0} + setMissingOrdersInfoCount={setMissingOrdersInfoCount} /> , ); @@ -986,12 +1002,15 @@ describe('MoveDetails page', () => { setUnapprovedServiceItemCount={setUnapprovedServiceItemCount} setExcessWeightRiskCount={setExcessWeightRiskCount} setUnapprovedSITExtensionCount={setUnapprovedSITExtensionCount} + missingOrdersInfoCount={2} + setMissingOrdersInfoCount={setMissingOrdersInfoCount} /> , ); it('renders an error indicator in the sidebar', () => { expect(wrapper.find('a[href="#orders"] span[data-testid="tag"]').exists()).toBe(true); + expect(wrapper.find('a[href="#orders"] span[data-testid="tag"]').text()).toBe('2'); }); }); @@ -1006,6 +1025,8 @@ describe('MoveDetails page', () => { setUnapprovedServiceItemCount={setUnapprovedServiceItemCount} setExcessWeightRiskCount={setExcessWeightRiskCount} setUnapprovedSITExtensionCount={setUnapprovedSITExtensionCount} + missingOrdersInfoCount={0} + setMissingOrdersInfoCount={setMissingOrdersInfoCount} /> , ); @@ -1025,6 +1046,8 @@ describe('MoveDetails page', () => { setUnapprovedServiceItemCount={setUnapprovedServiceItemCount} setExcessWeightRiskCount={setExcessWeightRiskCount} setUnapprovedSITExtensionCount={setUnapprovedSITExtensionCount} + missingOrdersInfoCount={0} + setMissingOrdersInfoCount={setMissingOrdersInfoCount} /> , ); @@ -1039,6 +1062,7 @@ describe('MoveDetails page', () => { setUnapprovedServiceItemCount, setExcessWeightRiskCount, setUnapprovedSITExtensionCount, + setMissingOrdersInfoCount, }; it('renders the financial review flag button when user has permission', async () => { @@ -1150,6 +1174,8 @@ describe('MoveDetails page', () => { setUnapprovedServiceItemCount={setUnapprovedServiceItemCount} setExcessWeightRiskCount={setExcessWeightRiskCount} setUnapprovedSITExtensionCount={setUnapprovedSITExtensionCount} + missingOrdersInfoCount={0} + setMissingOrdersInfoCount={setMissingOrdersInfoCount} /> , ); diff --git a/src/pages/Office/ServicesCounselingMoveDetails/ServicesCounselingMoveDetails.jsx b/src/pages/Office/ServicesCounselingMoveDetails/ServicesCounselingMoveDetails.jsx index 6c065a37083..dd5e25bab4c 100644 --- a/src/pages/Office/ServicesCounselingMoveDetails/ServicesCounselingMoveDetails.jsx +++ b/src/pages/Office/ServicesCounselingMoveDetails/ServicesCounselingMoveDetails.jsx @@ -1,7 +1,6 @@ import React, { useState, useEffect, useMemo } from 'react'; import { Link, useParams, useNavigate, generatePath } from 'react-router-dom'; import { useQueryClient, useMutation } from '@tanstack/react-query'; -import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { func } from 'prop-types'; import classnames from 'classnames'; import 'styles/office.scss'; @@ -42,7 +41,13 @@ import { objectIsMissingFieldWithCondition } from 'utils/displayFlags'; import { ReviewButton } from 'components/form/IconButtons'; import { calculateWeightRequested } from 'hooks/custom'; -const ServicesCounselingMoveDetails = ({ infoSavedAlert, setUnapprovedShipmentCount, isMoveLocked }) => { +const ServicesCounselingMoveDetails = ({ + infoSavedAlert, + setUnapprovedShipmentCount, + isMoveLocked, + missingOrdersInfoCount, + setMissingOrdersInfoCount, +}) => { const { moveCode } = useParams(); const navigate = useNavigate(); const [alertMessage, setAlertMessage] = useState(null); @@ -345,6 +350,20 @@ const ServicesCounselingMoveDetails = ({ infoSavedAlert, setUnapprovedShipmentCo ntsSac: order.ntsSac, }; + // using useMemo here due to this being used in a useEffect + // using useMemo prevents the useEffect from being rendered on ever render by memoizing the object + // so that it only recognizes the change when the orders object changes + const requiredOrdersInfo = useMemo( + () => ({ + ordersNumber: order?.order_number || '', + ordersType: order?.order_type || '', + ordersTypeDetail: order?.order_type_detail || '', + tacMDC: order?.tac || '', + departmentIndicator: order?.department_indicator || '', + }), + [order], + ); + const handleButtonDropdownChange = (e) => { const selectedOption = e.target.value; @@ -412,6 +431,14 @@ const ServicesCounselingMoveDetails = ({ infoSavedAlert, setUnapprovedShipmentCo setUnapprovedShipmentCount, ]); + // Keep num of missing orders info synced up + useEffect(() => { + const ordersInfoCount = Object.values(requiredOrdersInfo).reduce((count, value) => { + return !value ? count + 1 : count; + }, 0); + setMissingOrdersInfoCount(ordersInfoCount); + }, [order, requiredOrdersInfo, setMissingOrdersInfoCount]); + if (isLoading) return ; if (isError) return ; @@ -454,13 +481,6 @@ const ServicesCounselingMoveDetails = ({ infoSavedAlert, setUnapprovedShipmentCo return false; }; - const requiredOrdersInfo = { - ordersNumber: order.order_number, - ordersType: order.order_type, - ordersTypeDetail: order.order_type_detail, - tacMDC: order.tac, - }; - const allShipmentsDeleted = mtoShipments.every((shipment) => !!shipment.deletedAt); const hasMissingOrdersRequiredInfo = Object.values(requiredOrdersInfo).some((value) => !value || value === ''); const hasAmendedOrders = ordersInfo.uploadedAmendedOrderID && !ordersInfo.amendedOrdersAcknowledgedAt; @@ -477,12 +497,12 @@ const ServicesCounselingMoveDetails = ({ infoSavedAlert, setUnapprovedShipmentCo {shipmentConcernCount} - + {missingOrdersInfoCount} { return render( - + , ); }; @@ -570,6 +638,23 @@ describe('MoveDetails page', () => { expect(mockSetUpapprovedShipmentCount).toHaveBeenCalledWith(3); }); + it('shares the number of missing orders information', () => { + const moveDetailsQuery = { + ...newMoveDetailsQuery, + order: orderMissingRequiredInfo, + }; + + useMoveDetailsQueries.mockReturnValue(moveDetailsQuery); + useOrdersDocumentQueries.mockReturnValue(moveDetailsQuery); + + const mockSetMissingOrdersInfoCount = jest.fn(); + renderComponent({ setMissingOrdersInfoCount: mockSetMissingOrdersInfoCount }); + + // Should have called `setMissingOrdersInfoCount` with 4 missing fields + expect(mockSetMissingOrdersInfoCount).toHaveBeenCalledTimes(1); + expect(mockSetMissingOrdersInfoCount).toHaveBeenCalledWith(4); + }); + /* eslint-disable camelcase */ it('renders shipments info', async () => { useMoveDetailsQueries.mockReturnValue(newMoveDetailsQuery); @@ -836,7 +921,11 @@ describe('MoveDetails page', () => { permissions={[permissionTypes.updateShipment, permissionTypes.updateCustomer]} {...mockRoutingOptions} > - + , ); @@ -933,7 +1022,11 @@ describe('MoveDetails page', () => { path={servicesCounselingRoutes.BASE_SHIPMENT_ADD_PATH} params={{ moveCode: mockRequestedMoveCode, shipmentType }} > - , + + , , ); @@ -1031,7 +1124,10 @@ describe('MoveDetails page', () => { it('renders the financial review flag button when user has permission', async () => { render( - + , ); diff --git a/src/pages/Office/ServicesCounselingMoveInfo/ServicesCounselingMoveInfo.jsx b/src/pages/Office/ServicesCounselingMoveInfo/ServicesCounselingMoveInfo.jsx index 8646b252640..eaedf6eca8a 100644 --- a/src/pages/Office/ServicesCounselingMoveInfo/ServicesCounselingMoveInfo.jsx +++ b/src/pages/Office/ServicesCounselingMoveInfo/ServicesCounselingMoveInfo.jsx @@ -42,6 +42,7 @@ const ServicesCounselingMoveInfo = () => { const [unapprovedServiceItemCount, setUnapprovedServiceItemCount] = React.useState(0); const [excessWeightRiskCount, setExcessWeightRiskCount] = React.useState(0); const [unapprovedSITExtensionCount, setUnApprovedSITExtensionCount] = React.useState(0); + const [missingOrdersInfoCount, setMissingOrdersInfoCount] = useState(0); const [infoSavedAlert, setInfoSavedAlert] = useState(null); const { hasRecentError, traceId } = useSelector((state) => state.interceptor); const [moveLockFlag, setMoveLockFlag] = useState(false); @@ -195,6 +196,7 @@ const ServicesCounselingMoveInfo = () => { unapprovedServiceItemCount={unapprovedServiceItemCount} excessWeightRiskCount={excessWeightRiskCount} unapprovedSITExtensionCount={unapprovedSITExtensionCount} + missingOrdersInfoCount={missingOrdersInfoCount} /> )} @@ -214,6 +216,8 @@ const ServicesCounselingMoveInfo = () => { } diff --git a/src/pages/Office/TXOMoveInfo/TXOMoveInfo.jsx b/src/pages/Office/TXOMoveInfo/TXOMoveInfo.jsx index a931a110286..bbe6c9c4f09 100644 --- a/src/pages/Office/TXOMoveInfo/TXOMoveInfo.jsx +++ b/src/pages/Office/TXOMoveInfo/TXOMoveInfo.jsx @@ -39,6 +39,7 @@ const TXOMoveInfo = () => { const [excessWeightRiskCount, setExcessWeightRiskCount] = React.useState(0); const [pendingPaymentRequestCount, setPendingPaymentRequestCount] = React.useState(0); const [unapprovedSITExtensionCount, setUnApprovedSITExtensionCount] = React.useState(0); + const [missingOrdersInfoCount, setMissingOrdersInfoCount] = useState(0); const [moveLockFlag, setMoveLockFlag] = useState(false); const [isMoveLocked, setIsMoveLocked] = useState(false); @@ -150,6 +151,7 @@ const TXOMoveInfo = () => { excessWeightRiskCount={excessWeightRiskCount} pendingPaymentRequestCount={pendingPaymentRequestCount} unapprovedSITExtensionCount={unapprovedSITExtensionCount} + missingOrdersInfoCount={missingOrdersInfoCount} moveCode={moveCode} reportId={reportId} order={order} @@ -177,6 +179,8 @@ const TXOMoveInfo = () => { } setExcessWeightRiskCount={setExcessWeightRiskCount} setUnapprovedSITExtensionCount={setUnApprovedSITExtensionCount} + missingOrdersInfoCount={missingOrdersInfoCount} + setMissingOrdersInfoCount={setMissingOrdersInfoCount} isMoveLocked={isMoveLocked} /> } From 1d9d1de6225d2bddeab5c784f52902d0511830a6 Mon Sep 17 00:00:00 2001 From: Daniel Jordan Date: Wed, 4 Sep 2024 16:23:58 +0000 Subject: [PATCH 21/37] initial changes --- .../CustomerOnboarding/CreateCustomerForm.jsx | 26 +++++++++++++++++-- src/utils/customer.js | 25 ++++++++++++++++++ 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/src/pages/Office/CustomerOnboarding/CreateCustomerForm.jsx b/src/pages/Office/CustomerOnboarding/CreateCustomerForm.jsx index b8a6ed6a6fa..94266ee376a 100644 --- a/src/pages/Office/CustomerOnboarding/CreateCustomerForm.jsx +++ b/src/pages/Office/CustomerOnboarding/CreateCustomerForm.jsx @@ -27,11 +27,14 @@ import { setFlashMessage as setFlashMessageAction } from 'store/flash/actions'; import { elevatedPrivilegeTypes } from 'constants/userPrivileges'; import { isBooleanFlagEnabled } from 'utils/featureFlags'; import departmentIndicators from 'constants/departmentIndicators'; +import { generateUniqueDodid, generateUniqueEmplid } from 'utils/customer'; +import Hint from 'components/Hint'; export const CreateCustomerForm = ({ userPrivileges, setFlashMessage }) => { const [serverError, setServerError] = useState(null); const [showEmplid, setShowEmplid] = useState(false); const [isSafetyMove, setIsSafetyMove] = useState(false); + const [showSafetyMoveHint, setShowSafetyMoveHint] = useState(false); const navigate = useNavigate(); const branchOptions = dropdownInputOptions(SERVICE_MEMBER_AGENCY_LABELS); @@ -42,6 +45,9 @@ export const CreateCustomerForm = ({ userPrivileges, setFlashMessage }) => { const [isSafetyMoveFF, setSafetyMoveFF] = useState(false); + const uniqueDodid = generateUniqueDodid(); + const uniqueEmplid = generateUniqueEmplid(); + useEffect(() => { isBooleanFlagEnabled('safety_move')?.then((enabled) => { setSafetyMoveFF(enabled); @@ -55,6 +61,7 @@ export const CreateCustomerForm = ({ userPrivileges, setFlashMessage }) => { const initialValues = { affiliation: '', edipi: '', + emplid: '', first_name: '', middle_name: '', last_name: '', @@ -193,11 +200,10 @@ export const CreateCustomerForm = ({ userPrivileges, setFlashMessage }) => { const { value } = e.target; if (value === 'true') { setIsSafetyMove(true); + setShowSafetyMoveHint(true); // clear out DoDID, emplid, and OKTA fields setValues({ ...values, - edipi: '', - emplid: '', create_okta_account: '', cac_user: 'true', is_safety_move: 'true', @@ -211,10 +217,23 @@ export const CreateCustomerForm = ({ userPrivileges, setFlashMessage }) => { } }; const handleBranchChange = (e) => { + setShowSafetyMoveHint(false); if (e.target.value === departmentIndicators.COAST_GUARD) { setShowEmplid(true); + setValues({ + ...values, + affiliation: e.target.value, + edipi: '', + emplid: uniqueEmplid, + }); } else { setShowEmplid(false); + setValues({ + ...values, + affiliation: e.target.value, + edipi: uniqueDodid, + emplid: '', + }); } }; return ( @@ -266,6 +285,9 @@ export const CreateCustomerForm = ({ userPrivileges, setFlashMessage }) => { maxLength="10" isDisabled={isSafetyMove} /> + {isSafetyMove && showSafetyMoveHint && ( + Once a branch is selected, this will generate a random safety move identifier + )} {showEmplid && ( { return generalRoutes.HOME_PATH; } }; + +export const generateUniqueDodid = () => { + const prefix = 'SM'; + + // Custom epoch start date (e.g., 2024-01-01), generates something like 1704067200000 + const customEpoch = new Date('2024-01-01').getTime(); + const now = Date.now(); + + // Calculate milliseconds since custom epoch, then convert to an 8-digit integer + const uniqueNumber = Math.floor((now - customEpoch) / 1000); // Dividing by 1000 to reduce to seconds + + // Convert the unique number to a string, ensuring it has 8 digits + const uniqueStr = uniqueNumber.toString().slice(0, 8).padStart(8, '0'); + + return prefix + uniqueStr; +}; + +export const generateUniqueEmplid = () => { + const prefix = 'SM'; + const customEpoch = new Date('2024-01-01').getTime(); + const now = Date.now(); + const uniqueNumber = Math.floor((now - customEpoch) / 1000) % 100000; // Modulo 100000 ensures it's 5 digits + const uniqueStr = uniqueNumber.toString().padStart(5, '0'); + return prefix + uniqueStr; +}; From df6d5e4ace4f37557a31952008d6192cbb9c1ab4 Mon Sep 17 00:00:00 2001 From: Daniel Jordan Date: Thu, 5 Sep 2024 19:26:16 +0000 Subject: [PATCH 22/37] initial commit, tests added, working as intended --- pkg/gen/ghcapi/embedded_spec.go | 8 +-- pkg/gen/ghcmessages/customer.go | 6 +- pkg/handlers/ghcapi/customer_test.go | 2 +- .../internal/payloads/model_to_payload.go | 2 +- pkg/handlers/ghcapi/orders.go | 14 +--- pkg/handlers/ghcapi/queues_test.go | 4 +- .../CustomerHeader/CustomerHeader.test.jsx | 8 +-- src/components/CustomerHeader/index.jsx | 4 +- .../DefinitionLists/CustomerInfoList.jsx | 4 +- .../DefinitionLists/CustomerInfoList.test.jsx | 2 +- .../CustomerOnboarding/CreateCustomerForm.jsx | 49 ++++++++++---- .../CreateCustomerForm.test.jsx | 67 ++++++++++++++++++- src/pages/Office/MoveDetails/MoveDetails.jsx | 2 +- swagger-def/ghc.yaml | 2 +- swagger/ghc.yaml | 2 +- 15 files changed, 125 insertions(+), 51 deletions(-) diff --git a/pkg/gen/ghcapi/embedded_spec.go b/pkg/gen/ghcapi/embedded_spec.go index 7388e1b61d5..03e37ade392 100644 --- a/pkg/gen/ghcapi/embedded_spec.go +++ b/pkg/gen/ghcapi/embedded_spec.go @@ -7174,10 +7174,10 @@ func init() { "current_address": { "$ref": "#/definitions/Address" }, - "dodID": { + "eTag": { "type": "string" }, - "eTag": { + "edipi": { "type": "string" }, "email": { @@ -22542,10 +22542,10 @@ func init() { "current_address": { "$ref": "#/definitions/Address" }, - "dodID": { + "eTag": { "type": "string" }, - "eTag": { + "edipi": { "type": "string" }, "email": { diff --git a/pkg/gen/ghcmessages/customer.go b/pkg/gen/ghcmessages/customer.go index 2bac3e7d0b3..c4034e3cfe2 100644 --- a/pkg/gen/ghcmessages/customer.go +++ b/pkg/gen/ghcmessages/customer.go @@ -34,12 +34,12 @@ type Customer struct { // current address CurrentAddress *Address `json:"current_address,omitempty"` - // dod ID - DodID string `json:"dodID,omitempty"` - // e tag ETag string `json:"eTag,omitempty"` + // edipi + Edipi string `json:"edipi,omitempty"` + // email // Pattern: ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$ Email *string `json:"email,omitempty"` diff --git a/pkg/handlers/ghcapi/customer_test.go b/pkg/handlers/ghcapi/customer_test.go index ca46f85b2a5..4e8564af27c 100644 --- a/pkg/handlers/ghcapi/customer_test.go +++ b/pkg/handlers/ghcapi/customer_test.go @@ -53,7 +53,7 @@ func (suite *HandlerSuite) TestGetCustomerHandlerIntegration() { suite.NoError(getCustomerPayload.Validate(strfmt.Default)) suite.Equal(strfmt.UUID(customer.ID.String()), getCustomerPayload.ID) - suite.Equal(*customer.Edipi, getCustomerPayload.DodID) + suite.Equal(*customer.Edipi, getCustomerPayload.Edipi) suite.Equal(strfmt.UUID(customer.UserID.String()), getCustomerPayload.UserID) suite.Equal(customer.Affiliation.String(), getCustomerPayload.Agency) suite.Equal(customer.PersonalEmail, getCustomerPayload.Email) diff --git a/pkg/handlers/ghcapi/internal/payloads/model_to_payload.go b/pkg/handlers/ghcapi/internal/payloads/model_to_payload.go index f024da83510..9d6fc33e81c 100644 --- a/pkg/handlers/ghcapi/internal/payloads/model_to_payload.go +++ b/pkg/handlers/ghcapi/internal/payloads/model_to_payload.go @@ -490,7 +490,7 @@ func Customer(customer *models.ServiceMember) *ghcmessages.Customer { payload := ghcmessages.Customer{ Agency: swag.StringValue((*string)(customer.Affiliation)), CurrentAddress: Address(customer.ResidentialAddress), - DodID: swag.StringValue(customer.Edipi), + Edipi: swag.StringValue(customer.Edipi), Email: customer.PersonalEmail, FirstName: swag.StringValue(customer.FirstName), ID: strfmt.UUID(customer.ID.String()), diff --git a/pkg/handlers/ghcapi/orders.go b/pkg/handlers/ghcapi/orders.go index fb6d627c2dd..c8ea763b501 100644 --- a/pkg/handlers/ghcapi/orders.go +++ b/pkg/handlers/ghcapi/orders.go @@ -315,24 +315,12 @@ func (h CreateOrderHandler) Handle(params orderop.CreateOrderParams) middleware. } if newOrder.OrdersType == "SAFETY" { - // if creating a Safety move, clear out the DoDID and OktaID for the customer + // if creating a Safety move, clear out the OktaID for the customer since they won't log into MilMove err = models.UpdateUserOktaID(appCtx.DB(), &newOrder.ServiceMember.User, "") if err != nil { appCtx.Logger().Error("Authorization error updating user", zap.Error(err)) return orderop.NewUpdateOrderInternalServerError(), err } - - err = models.UpdateServiceMemberDoDID(appCtx.DB(), &newOrder.ServiceMember, nil) - if err != nil { - appCtx.Logger().Error("Authorization error updating service member", zap.Error(err)) - return orderop.NewUpdateOrderInternalServerError(), err - } - - err = models.UpdateServiceMemberEMPLID(appCtx.DB(), &newOrder.ServiceMember, nil) - if err != nil { - appCtx.Logger().Error("Authorization error updating service member", zap.Error(err)) - return orderop.NewUpdateOrderInternalServerError(), err - } } newMove, verrs, err := newOrder.CreateNewMove(appCtx.DB(), moveOptions) diff --git a/pkg/handlers/ghcapi/queues_test.go b/pkg/handlers/ghcapi/queues_test.go index f1efe5028fe..4cc6aaaa1da 100644 --- a/pkg/handlers/ghcapi/queues_test.go +++ b/pkg/handlers/ghcapi/queues_test.go @@ -833,7 +833,7 @@ func (suite *HandlerSuite) TestGetMoveQueuesHandlerCustomerInfoFilters() { result := payload.QueueMoves[0] suite.Len(payload.QueueMoves, 1) - suite.Equal("11111", result.Customer.DodID) + suite.Equal("11111", result.Customer.Edipi) }) suite.Run("returns results matching Move ID search term", func() { @@ -1525,7 +1525,7 @@ func (suite *HandlerSuite) TestGetServicesCounselingQueueHandler() { suite.Len(payload.QueueMoves, 2) suite.Equal(order.ServiceMember.ID.String(), result1.Customer.ID.String()) - suite.Equal(*order.ServiceMember.Edipi, result1.Customer.DodID) + suite.Equal(*order.ServiceMember.Edipi, result1.Customer.Edipi) suite.Equal(subtestData.needsCounselingMove.Locator, result1.Locator) suite.EqualValues(subtestData.needsCounselingMove.Status, result1.Status) suite.Equal(subtestData.needsCounselingEarliestShipment.RequestedPickupDate.Format(time.RFC3339Nano), (time.Time)(*result1.RequestedMoveDate).Format(time.RFC3339Nano)) diff --git a/src/components/CustomerHeader/CustomerHeader.test.jsx b/src/components/CustomerHeader/CustomerHeader.test.jsx index 1668afb9f29..fec1c7c7b73 100644 --- a/src/components/CustomerHeader/CustomerHeader.test.jsx +++ b/src/components/CustomerHeader/CustomerHeader.test.jsx @@ -5,7 +5,7 @@ import { mount } from 'enzyme'; import CustomerHeader from './index'; const props = { - customer: { last_name: 'Kerry', first_name: 'Smith', dodID: '999999999', emplid: '7777777', agency: 'COAST_GUARD' }, + customer: { last_name: 'Kerry', first_name: 'Smith', edipi: '999999999', emplid: '7777777', agency: 'COAST_GUARD' }, order: { agency: 'COAST_GUARD', grade: 'E_6', @@ -25,7 +25,7 @@ const props = { }; const propsRetiree = { - customer: { last_name: 'Kerry', first_name: 'Smith', dodID: '999999999' }, + customer: { last_name: 'Kerry', first_name: 'Smith', edipi: '999999999' }, order: { agency: 'NAVY', grade: 'E_6', @@ -45,7 +45,7 @@ const propsRetiree = { }; const propsUSMC = { - customer: { last_name: 'Kerry', first_name: 'Smith', dodID: '999999999' }, + customer: { last_name: 'Kerry', first_name: 'Smith', edipi: '999999999' }, order: { agency: 'MARINES', grade: 'E_6', @@ -77,7 +77,7 @@ describe('CustomerHeader component', () => { expect(wrapper.find('[data-testid="nameBlock"]').text()).toContain('Kerry, Smith'); expect(wrapper.find('[data-testid="nameBlock"]').text()).toContain('FKLCTR'); expect(wrapper.find('[data-testid="deptPayGrade"]').text()).toContain('Coast Guard E-6'); - expect(wrapper.find('[data-testid="dodId"]').text()).toContain('DoD ID 999999999'); + expect(wrapper.find('[data-testid="edipi"]').text()).toContain('DoD ID 999999999'); expect(wrapper.find('[data-testid="emplid"]').text()).toContain('EMPLID 7777777'); expect(wrapper.find('[data-testid="infoBlock"]').text()).toContain('JBSA Lackland'); expect(wrapper.find('[data-testid="infoBlock"]').text()).toContain('JB Lewis-McChord'); diff --git a/src/components/CustomerHeader/index.jsx b/src/components/CustomerHeader/index.jsx index 36d8ebc037a..857e2469997 100644 --- a/src/components/CustomerHeader/index.jsx +++ b/src/components/CustomerHeader/index.jsx @@ -55,8 +55,8 @@ const CustomerHeader = ({ customer, order, moveCode, move, userRole }) => { {ORDERS_BRANCH_OPTIONS[`${order.agency}`]} {ORDERS_PAY_GRADE_OPTIONS[`${order.grade}`]} | - - DoD ID {customer.dodID} + + DoD ID {customer.edipi} {isCoastGuard && ( <> diff --git a/src/components/Office/DefinitionLists/CustomerInfoList.jsx b/src/components/Office/DefinitionLists/CustomerInfoList.jsx index b1b79d9ac01..16a698529f4 100644 --- a/src/components/Office/DefinitionLists/CustomerInfoList.jsx +++ b/src/components/Office/DefinitionLists/CustomerInfoList.jsx @@ -19,7 +19,7 @@ const CustomerInfoList = ({ customerInfo }) => {
DoD ID
-
{customerInfo.dodId}
+
{customerInfo.edipi}
{customerInfo.agency === departmentIndicators.COAST_GUARD && (
@@ -81,7 +81,7 @@ const CustomerInfoList = ({ customerInfo }) => { CustomerInfoList.propTypes = { customerInfo: PropTypes.shape({ name: PropTypes.string, - dodId: PropTypes.string, + edipi: PropTypes.string, phone: PropTypes.string, email: PropTypes.string, currentAddress: AddressShape, diff --git a/src/components/Office/DefinitionLists/CustomerInfoList.test.jsx b/src/components/Office/DefinitionLists/CustomerInfoList.test.jsx index 18682850c78..d957be52b4f 100644 --- a/src/components/Office/DefinitionLists/CustomerInfoList.test.jsx +++ b/src/components/Office/DefinitionLists/CustomerInfoList.test.jsx @@ -6,7 +6,7 @@ import CustomerInfoList from './CustomerInfoList'; const info = { name: 'Smith, Kerry', agency: 'COAST_GUARD', - dodId: '9999999999', + edipi: '9999999999', emplid: '7777777', phone: '999-999-9999', altPhone: '888-888-8888', diff --git a/src/pages/Office/CustomerOnboarding/CreateCustomerForm.jsx b/src/pages/Office/CustomerOnboarding/CreateCustomerForm.jsx index 94266ee376a..72f27a84ca5 100644 --- a/src/pages/Office/CustomerOnboarding/CreateCustomerForm.jsx +++ b/src/pages/Office/CustomerOnboarding/CreateCustomerForm.jsx @@ -94,7 +94,7 @@ export const CreateCustomerForm = ({ userPrivileges, setFlashMessage }) => { }, create_okta_account: '', cac_user: '', - is_safety_move: false, + is_safety_move: 'false', }; const handleBack = () => { @@ -151,10 +151,8 @@ export const CreateCustomerForm = ({ userPrivileges, setFlashMessage }) => { const validationSchema = Yup.object().shape({ affiliation: Yup.mixed().oneOf(Object.keys(SERVICE_MEMBER_AGENCY_LABELS)).required('Required'), - edipi: Yup.string().matches(/[0-9]{10}/, 'Enter a 10-digit DOD ID number'), - emplid: Yup.string() - .notRequired() - .matches(/[0-9]{7}/, 'Enter a 7-digit EMPLID number'), + edipi: Yup.string().matches(/^(SM[0-9]{8}|[0-9]{10})$/, 'Enter a 10-digit DOD ID number'), + emplid: Yup.string().matches(/^(SM[0-9]{5}|[0-9]{7})$/, 'Enter a 7-digit EMPLID number'), first_name: Yup.string().required('Required'), middle_name: Yup.string(), last_name: Yup.string().required('Required'), @@ -201,9 +199,9 @@ export const CreateCustomerForm = ({ userPrivileges, setFlashMessage }) => { if (value === 'true') { setIsSafetyMove(true); setShowSafetyMoveHint(true); - // clear out DoDID, emplid, and OKTA fields setValues({ ...values, + affiliation: '', create_okta_account: '', cac_user: 'true', is_safety_move: 'true', @@ -212,21 +210,32 @@ export const CreateCustomerForm = ({ userPrivileges, setFlashMessage }) => { setIsSafetyMove(false); setValues({ ...values, + affiliation: '', + edipi: '', + emplid: '', is_safety_move: 'false', }); } }; const handleBranchChange = (e) => { setShowSafetyMoveHint(false); - if (e.target.value === departmentIndicators.COAST_GUARD) { + if (e.target.value === departmentIndicators.COAST_GUARD && isSafetyMove) { setShowEmplid(true); setValues({ ...values, affiliation: e.target.value, - edipi: '', + edipi: uniqueDodid, emplid: uniqueEmplid, }); - } else { + } else if (e.target.value === departmentIndicators.COAST_GUARD && !isSafetyMove) { + setShowEmplid(true); + setValues({ + ...values, + affiliation: e.target.value, + edipi: '', + emplid: '', + }); + } else if (e.target.value !== departmentIndicators.COAST_GUARD && isSafetyMove) { setShowEmplid(false); setValues({ ...values, @@ -234,6 +243,14 @@ export const CreateCustomerForm = ({ userPrivileges, setFlashMessage }) => { edipi: uniqueDodid, emplid: '', }); + } else { + setShowEmplid(false); + setValues({ + ...values, + affiliation: e.target.value, + edipi: '', + emplid: '', + }); } }; return ( @@ -253,6 +270,7 @@ export const CreateCustomerForm = ({ userPrivileges, setFlashMessage }) => { value="true" data-testid="is-safety-move-yes" onChange={handleIsSafetyMove} + checked={values.is_safety_move === 'true'} /> { value="false" data-testid="is-safety-move-no" onChange={handleIsSafetyMove} + checked={values.is_safety_move === 'false'} />
@@ -281,25 +300,27 @@ export const CreateCustomerForm = ({ userPrivileges, setFlashMessage }) => { label="DoD ID number" name="edipi" id="edipi" - labelHint="Optional" maxLength="10" isDisabled={isSafetyMove} + data-testid="edipiInput" /> - {isSafetyMove && showSafetyMoveHint && ( - Once a branch is selected, this will generate a random safety move identifier - )} {showEmplid && ( )} + {isSafetyMove && showSafetyMoveHint && ( + + Once a branch is selected, this will generate a random safety move identifier + + )}

Customer Name

diff --git a/src/pages/Office/CustomerOnboarding/CreateCustomerForm.test.jsx b/src/pages/Office/CustomerOnboarding/CreateCustomerForm.test.jsx index 7167c40da84..c98c254b36e 100644 --- a/src/pages/Office/CustomerOnboarding/CreateCustomerForm.test.jsx +++ b/src/pages/Office/CustomerOnboarding/CreateCustomerForm.test.jsx @@ -69,7 +69,7 @@ const fakePayload = { }, create_okta_account: 'true', cac_user: 'false', - is_safety_move: 'false', + is_safety_move: false, }; const fakeResponse = { @@ -335,6 +335,71 @@ describe('CreateCustomerForm', () => { }); }, 10000); + it('disables and populates DODID and EMPLID inputs when safety move is selected', async () => { + createCustomerWithOktaOption.mockImplementation(() => Promise.resolve(fakeResponse)); + isBooleanFlagEnabled.mockImplementation(() => Promise.resolve(true)); + + const { getByLabelText, getByTestId, getByRole } = render( + + + , + ); + + const user = userEvent.setup(); + + const safetyMove = await screen.findByTestId('is-safety-move-no'); + expect(safetyMove).toBeChecked(); + + // check the safety move box + await userEvent.type(getByTestId('is-safety-move-yes'), safetyPayload.is_safety_move); + + expect(await screen.findByTestId('safetyMoveHint')).toBeInTheDocument(); + + await user.selectOptions(getByLabelText('Branch of service'), ['COAST_GUARD']); + + // the input boxes should now be disabled + expect(await screen.findByTestId('edipiInput')).toBeDisabled(); + expect(await screen.findByTestId('emplidInput')).toBeDisabled(); + + // should be able to submit the form + await user.type(getByLabelText('First name'), safetyPayload.first_name); + await user.type(getByLabelText('Last name'), safetyPayload.last_name); + + await user.type(getByLabelText('Best contact phone'), safetyPayload.telephone); + await user.type(getByLabelText('Personal email'), safetyPayload.personal_email); + + await userEvent.type(getByTestId('res-add-street1'), safetyPayload.residential_address.streetAddress1); + await userEvent.type(getByTestId('res-add-city'), safetyPayload.residential_address.city); + await userEvent.selectOptions(getByTestId('res-add-state'), [safetyPayload.residential_address.state]); + await userEvent.type(getByTestId('res-add-zip'), safetyPayload.residential_address.postalCode); + + await userEvent.type(getByTestId('backup-add-street1'), safetyPayload.backup_mailing_address.streetAddress1); + await userEvent.type(getByTestId('backup-add-city'), safetyPayload.backup_mailing_address.city); + await userEvent.selectOptions(getByTestId('backup-add-state'), [safetyPayload.backup_mailing_address.state]); + await userEvent.type(getByTestId('backup-add-zip'), safetyPayload.backup_mailing_address.postalCode); + + await userEvent.type(getByLabelText('Name'), safetyPayload.backup_contact.name); + await userEvent.type(getByRole('textbox', { name: 'Email' }), safetyPayload.backup_contact.email); + await userEvent.type(getByRole('textbox', { name: 'Phone' }), safetyPayload.backup_contact.telephone); + + const saveBtn = await screen.findByRole('button', { name: 'Save' }); + expect(saveBtn).toBeInTheDocument(); + + await waitFor(() => { + expect(saveBtn).toBeEnabled(); + }); + await userEvent.click(saveBtn); + + await waitFor(() => { + expect(createCustomerWithOktaOption).toHaveBeenCalled(); + expect(mockNavigate).toHaveBeenCalledWith(ordersPath, { + state: { + isSafetyMoveSelected: true, + }, + }); + }); + }, 10000); + it('submits the form and tests for unsupported state validation', async () => { createCustomerWithOktaOption.mockImplementation(() => Promise.resolve(fakeResponse)); diff --git a/src/pages/Office/MoveDetails/MoveDetails.jsx b/src/pages/Office/MoveDetails/MoveDetails.jsx index 8d6a4c359ac..06422417bc2 100644 --- a/src/pages/Office/MoveDetails/MoveDetails.jsx +++ b/src/pages/Office/MoveDetails/MoveDetails.jsx @@ -284,7 +284,7 @@ const MoveDetails = ({ const customerInfo = { name: formattedCustomerName(customer.last_name, customer.first_name, customer.suffix, customer.middle_name), agency: customer.agency, - dodId: customer.dodID, + edipi: customer.edipi, emplid: customer.emplid, phone: customer.phone, altPhone: customer.secondaryTelephone, diff --git a/swagger-def/ghc.yaml b/swagger-def/ghc.yaml index 0bb252d0846..5d48eaff405 100644 --- a/swagger-def/ghc.yaml +++ b/swagger-def/ghc.yaml @@ -4336,7 +4336,7 @@ definitions: type: string format: uuid example: c56a4180-65aa-42ec-a945-5fd21dec0538 - dodID: + edipi: type: string userID: type: string diff --git a/swagger/ghc.yaml b/swagger/ghc.yaml index 62feecb4062..77d9993c7c9 100644 --- a/swagger/ghc.yaml +++ b/swagger/ghc.yaml @@ -4527,7 +4527,7 @@ definitions: type: string format: uuid example: c56a4180-65aa-42ec-a945-5fd21dec0538 - dodID: + edipi: type: string userID: type: string From 6fc809481b5790b0ce5a3f20c366710eeb21b4d0 Mon Sep 17 00:00:00 2001 From: Logan Cunningham <148146808+loganwc@users.noreply.github.com> Date: Wed, 11 Sep 2024 12:06:33 -0500 Subject: [PATCH 23/37] Update api.go --- pkg/handlers/ghcapi/api.go | 1 - 1 file changed, 1 deletion(-) diff --git a/pkg/handlers/ghcapi/api.go b/pkg/handlers/ghcapi/api.go index 716e0756bfc..a25624164dd 100644 --- a/pkg/handlers/ghcapi/api.go +++ b/pkg/handlers/ghcapi/api.go @@ -667,7 +667,6 @@ func NewGhcAPIHandler(handlerConfig handlers.HandlerConfig) *ghcops.MymoveAPI { order.NewOrderUpdater(moveRouter), } - ghcAPI.MoveMoveCancelerHandler = MoveCancelerHandler{ handlerConfig, move.NewMoveCanceler(), From 62281970304eb081c643d757ba536cfcae7c012d Mon Sep 17 00:00:00 2001 From: Brooklyn Welsh Date: Thu, 12 Sep 2024 18:23:09 -0400 Subject: [PATCH 24/37] Initial additions to Playwright tests for Mobile Home shipments. --- pkg/testdatagen/scenario/shared.go | 213 ++++++++++++++++- pkg/testdatagen/testharness/dispatch.go | 3 + pkg/testdatagen/testharness/make_move.go | 43 ++++ .../servicesCounselingMobileHome.spec.js | 225 +++++++++++++++++- .../tests/utils/office/waitForOfficePage.js | 8 + playwright/tests/utils/testharness.js | 8 + 6 files changed, 493 insertions(+), 7 deletions(-) diff --git a/pkg/testdatagen/scenario/shared.go b/pkg/testdatagen/scenario/shared.go index e794ccb104e..abea790b36c 100644 --- a/pkg/testdatagen/scenario/shared.go +++ b/pkg/testdatagen/scenario/shared.go @@ -1,6 +1,7 @@ package scenario import ( + "errors" "fmt" "log" "sort" @@ -10169,6 +10170,167 @@ func createMoveWithUniqueDestinationAddress(appCtx appcontext.AppContext) { }, nil) } +/* +Generic helper function that lets you create a move with any staus and with any shipment type +*/ +func CreateMoveWithMTOShipment(appCtx appcontext.AppContext, ordersType internalmessages.OrdersType, shipmentType models.MTOShipmentType, destinationType *models.DestinationType, locator string, moveStatus models.MoveStatus) models.Move { + if shipmentType == models.MTOShipmentTypeBoatHaulAway || shipmentType == models.MTOShipmentTypeBoatTowAway { // Add boat specific fields in relevant PR + log.Panic(fmt.Errorf("Unable to generate random integer for submitted move date"), zap.Error(errors.New("Not yet implemented"))) + } + + db := appCtx.DB() + submittedAt := time.Now() + hhgPermitted := internalmessages.OrdersTypeDetailHHGPERMITTED + ordersNumber := "8675309" + departmentIndicator := "ARMY" + tac := "E19A" + newDutyLocation := factory.FetchOrBuildCurrentDutyLocation(db) + newDutyLocation.Address.PostalCode = "52549" + orders := factory.BuildOrderWithoutDefaults(db, []factory.Customization{ + { + Model: models.DutyLocation{ + ProvidesServicesCounseling: true, + }, + Type: &factory.DutyLocations.OriginDutyLocation, + }, + { + Model: newDutyLocation, + LinkOnly: true, + Type: &factory.DutyLocations.NewDutyLocation, + }, + { + Model: models.Order{ + OrdersType: ordersType, + OrdersTypeDetail: &hhgPermitted, + OrdersNumber: &ordersNumber, + DepartmentIndicator: &departmentIndicator, + TAC: &tac, + }, + }, + }, nil) + move := factory.BuildMove(db, []factory.Customization{ + { + Model: orders, + LinkOnly: true, + }, + { + Model: models.Move{ + Locator: locator, + Status: moveStatus, + SubmittedAt: &submittedAt, + }, + }, + }, nil) + requestedPickupDate := submittedAt.Add(60 * 24 * time.Hour) + requestedDeliveryDate := requestedPickupDate.Add(7 * 24 * time.Hour) + destinationAddress := factory.BuildAddress(db, nil, nil) + + if destinationType != nil { // Destination type is only used for retirement moves + retirementMTOShipment := factory.BuildMTOShipment(db, []factory.Customization{ + { + Model: move, + LinkOnly: true, + }, + { + Model: models.MTOShipment{ + ShipmentType: shipmentType, + Status: models.MTOShipmentStatusSubmitted, + RequestedPickupDate: &requestedPickupDate, + RequestedDeliveryDate: &requestedDeliveryDate, + DestinationType: destinationType, + }, + }, + { + Model: destinationAddress, + LinkOnly: true, + Type: &factory.Addresses.DeliveryAddress, + }, + }, nil) + + if shipmentType == models.MTOShipmentTypeMobileHome { + factory.BuildMobileHomeShipment(appCtx.DB(), []factory.Customization{ + { + Model: models.MobileHome{ + Year: models.IntPointer(2000), + Make: models.StringPointer("Boat Make"), + Model: models.StringPointer("Boat Model"), + LengthInInches: models.IntPointer(300), + WidthInInches: models.IntPointer(108), + HeightInInches: models.IntPointer(72), + }, + }, + { + Model: move, + LinkOnly: true, + }, + { + Model: retirementMTOShipment, + LinkOnly: true, + }, + }, nil) + } + } + + requestedPickupDate = submittedAt.Add(30 * 24 * time.Hour) + requestedDeliveryDate = requestedPickupDate.Add(7 * 24 * time.Hour) + regularMTOShipment := factory.BuildMTOShipment(db, []factory.Customization{ + { + Model: move, + LinkOnly: true, + }, + { + Model: models.MTOShipment{ + ShipmentType: shipmentType, + Status: models.MTOShipmentStatusSubmitted, + RequestedPickupDate: &requestedPickupDate, + RequestedDeliveryDate: &requestedDeliveryDate, + }, + }, + }, nil) + + if shipmentType == models.MTOShipmentTypeMobileHome { + factory.BuildMobileHomeShipment(appCtx.DB(), []factory.Customization{ + { + Model: models.MobileHome{ + Year: models.IntPointer(2000), + Make: models.StringPointer("Boat Make"), + Model: models.StringPointer("Boat Model"), + LengthInInches: models.IntPointer(300), + WidthInInches: models.IntPointer(108), + HeightInInches: models.IntPointer(72), + }, + }, + { + Model: move, + LinkOnly: true, + }, + { + Model: regularMTOShipment, + LinkOnly: true, + }, + }, nil) + } + + officeUser := factory.BuildOfficeUserWithRoles(db, nil, []roles.RoleType{roles.RoleTypeTOO}) + factory.BuildCustomerSupportRemark(db, []factory.Customization{ + { + Model: move, + LinkOnly: true, + }, + { + Model: officeUser, + LinkOnly: true, + }, + { + Model: models.CustomerSupportRemark{ + Content: "The customer mentioned that they need to provide some more complex instructions for pickup and drop off.", + }, + }, + }, nil) + + return move +} + /* Create Needs Service Counseling - pass in orders with all required information, shipment type, destination type, locator */ @@ -10219,7 +10381,7 @@ func CreateNeedsServicesCounseling(appCtx appcontext.AppContext, ordersType inte requestedPickupDate := submittedAt.Add(60 * 24 * time.Hour) requestedDeliveryDate := requestedPickupDate.Add(7 * 24 * time.Hour) destinationAddress := factory.BuildAddress(db, nil, nil) - factory.BuildMTOShipment(db, []factory.Customization{ + retirementMTOShipment := factory.BuildMTOShipment(db, []factory.Customization{ { Model: move, LinkOnly: true, @@ -10240,9 +10402,32 @@ func CreateNeedsServicesCounseling(appCtx appcontext.AppContext, ordersType inte }, }, nil) + if shipmentType == models.MTOShipmentTypeMobileHome { + factory.BuildMobileHomeShipment(appCtx.DB(), []factory.Customization{ + { + Model: models.MobileHome{ + Year: models.IntPointer(2000), + Make: models.StringPointer("Boat Make"), + Model: models.StringPointer("Boat Model"), + LengthInInches: models.IntPointer(300), + WidthInInches: models.IntPointer(108), + HeightInInches: models.IntPointer(72), + }, + }, + { + Model: move, + LinkOnly: true, + }, + { + Model: retirementMTOShipment, + LinkOnly: true, + }, + }, nil) + } + requestedPickupDate = submittedAt.Add(30 * 24 * time.Hour) requestedDeliveryDate = requestedPickupDate.Add(7 * 24 * time.Hour) - factory.BuildMTOShipment(db, []factory.Customization{ + regularMTOShipment := factory.BuildMTOShipment(db, []factory.Customization{ { Model: move, LinkOnly: true, @@ -10256,6 +10441,30 @@ func CreateNeedsServicesCounseling(appCtx appcontext.AppContext, ordersType inte }, }, }, nil) + + if shipmentType == models.MTOShipmentTypeMobileHome { + factory.BuildMobileHomeShipment(appCtx.DB(), []factory.Customization{ + { + Model: models.MobileHome{ + Year: models.IntPointer(2000), + Make: models.StringPointer("Boat Make"), + Model: models.StringPointer("Boat Model"), + LengthInInches: models.IntPointer(300), + WidthInInches: models.IntPointer(108), + HeightInInches: models.IntPointer(72), + }, + }, + { + Model: move, + LinkOnly: true, + }, + { + Model: regularMTOShipment, + LinkOnly: true, + }, + }, nil) + } + officeUser := factory.BuildOfficeUserWithRoles(db, nil, []roles.RoleType{roles.RoleTypeTOO}) factory.BuildCustomerSupportRemark(db, []factory.Customization{ { diff --git a/pkg/testdatagen/testharness/dispatch.go b/pkg/testdatagen/testharness/dispatch.go index 8033ca02825..99d21b4240c 100644 --- a/pkg/testdatagen/testharness/dispatch.go +++ b/pkg/testdatagen/testharness/dispatch.go @@ -35,6 +35,9 @@ var actionDispatcher = map[string]actionFunc{ "HHGMoveWithNTSAndNeedsSC": func(appCtx appcontext.AppContext) testHarnessResponse { return MakeHHGMoveWithNTSAndNeedsSC(appCtx) }, + "MobileHomeMoveNeedsSC": func(appCtx appcontext.AppContext) testHarnessResponse { + return MakeMobileHomeMoveNeedsSC(appCtx) + }, "GoodTACAndLoaCombination": func(appCtx appcontext.AppContext) testHarnessResponse { return MakeGoodTACAndLoaCombination(appCtx) }, diff --git a/pkg/testdatagen/testharness/make_move.go b/pkg/testdatagen/testharness/make_move.go index 23e8665a889..7354f74fe4b 100644 --- a/pkg/testdatagen/testharness/make_move.go +++ b/pkg/testdatagen/testharness/make_move.go @@ -3792,6 +3792,49 @@ func MakeHHGMoveNeedsSC(appCtx appcontext.AppContext) models.Move { return *newmove } +// MakeHHGMoveNeedsSC creates an fully ready move needing SC approval +func MakeMobileHomeMoveNeedsSC(appCtx appcontext.AppContext) models.Move { + locator := models.GenerateLocator() + move := scenario.CreateMoveWithMTOShipment(appCtx, internalmessages.OrdersTypePERMANENTCHANGEOFSTATION, models.MTOShipmentTypeMobileHome, nil, locator, models.MoveStatusNeedsServiceCounseling) + + // re-fetch the move so that we ensure we have exactly what is in + // the db + newmove, err := models.FetchMove(appCtx.DB(), &auth.Session{}, move.ID) + if err != nil { + log.Panic(fmt.Errorf("failed to fetch move: %w", err)) + } + return *newmove +} + +func MakeMobileHomeMoveForTOO(appCtx appcontext.AppContext) models.Move { + hhg := models.MTOShipmentTypeHHG + hor := models.DestinationTypeHomeOfRecord + originDutyLocation := factory.FetchOrBuildCurrentDutyLocation(appCtx.DB()) + move := scenario.CreateMoveWithOptions(appCtx, testdatagen.Assertions{ + Order: models.Order{ + OriginDutyLocation: &originDutyLocation, + }, + MTOShipment: models.MTOShipment{ + ShipmentType: hhg, + DestinationType: &hor, + }, + Move: models.Move{ + Status: models.MoveStatusSUBMITTED, + }, + DutyLocation: models.DutyLocation{ + ProvidesServicesCounseling: false, + }, + }) + + // re-fetch the move so that we ensure we have exactly what is in + // the db + newmove, err := models.FetchMove(appCtx.DB(), &auth.Session{}, move.ID) + if err != nil { + log.Panic(fmt.Errorf("failed to fetch move: %w", err)) + } + return *newmove +} + // MakeHHGMoveNeedsServicesCounselingUSMC creates an fully ready move as USMC needing SC approval func MakeHHGMoveNeedsServicesCounselingUSMC(appCtx appcontext.AppContext) models.Move { userUploader := newUserUploader(appCtx) diff --git a/playwright/tests/office/servicescounseling/servicesCounselingMobileHome.spec.js b/playwright/tests/office/servicescounseling/servicesCounselingMobileHome.spec.js index 0588fe6cd0d..b0d603d29e8 100644 --- a/playwright/tests/office/servicescounseling/servicesCounselingMobileHome.spec.js +++ b/playwright/tests/office/servicescounseling/servicesCounselingMobileHome.spec.js @@ -1,16 +1,90 @@ // @ts-check import { test, expect } from './servicesCounselingTestFixture'; +const today = new Date(); +const pickupDate = today; +const pickupDateString = pickupDate.toLocaleDateString('en-US'); +const deliveryDate = new Date(new Date().setDate(today.getDate() + 14)); +const deliveryDateString = deliveryDate.toLocaleDateString('en-US'); + +const pickupAddress = { + Address1: '7 Q St', + City: 'Atco', + State: 'NJ', + ZIP: '08004', +}; + +const secondaryPickupAddress = { + ...pickupAddress, +}; +secondaryPickupAddress.Address1 = '8 Q St'; + +const addressToString = (address) => { + return `${address.Address1}, ${address.Address2 ? `${address.Address2}, ` : ''}${ + address.Address3 ? `${address.Address3}, ` : '' + }${address.City}, ${address.State} ${address.ZIP}`; +}; + +const deliveryAddress = { + Address1: '9 W 2nd Ave', + Address2: 'P.O. Box 456', + City: 'Hollywood', + State: 'MD', + ZIP: '20636', +}; + +const secondaryDeliveryAddress = { + Address1: '9 Q St', + City: 'Atco', + State: 'NJ', + ZIP: '08004', +}; + +const releasingAgent = { + firstName: 'Grace', + lastName: 'Griffin', + phone: '2025551234', + email: 'grace.griffin@example.com', +}; + +const receivingAgent = { + firstName: 'Leo', + lastName: 'Spacemen', + phone: '2025552345', + email: 'leo.spaceman@example.com', +}; + +const formatPhone = (phone) => { + return `${phone.slice(0, 3)}-${phone.slice(3, 6)}-${phone.slice(6)}`; +}; + +const agentToString = (agent) => { + return `${agent.firstName} ${agent.lastName}${formatPhone(agent.phone)}${agent.email}`; +}; + +const formatDate = (date) => { + const formattedDay = date.toLocaleDateString(undefined, { day: '2-digit' }); + const formattedMonth = date.toLocaleDateString(undefined, { + month: 'short', + }); + const formattedYear = date.toLocaleDateString(undefined, { + year: 'numeric', + }); + + return `${formattedDay} ${formattedMonth} ${formattedYear}`; +}; + test.describe('Services counselor user', () => { test.beforeEach(async ({ scPage }) => { - const move = await scPage.testHarness.buildHHGMoveWithNTSAndNeedsSC(); + const move = await scPage.testHarness.buildMobileHomeMoveNeedsSC(); await scPage.navigateToMove(move.locator); }); test('Services Counselor can create a mobile home shipment and view shipment card info', async ({ page, scPage }) => { - const deliveryDate = new Date().toLocaleDateString('en-US'); await page.getByTestId('dropdown').selectOption({ label: 'Mobile Home' }); + await expect(page.getByText('Mobile Home Information')).toBeVisible(); + await expect(page.getByRole('heading', { level: 1 })).toHaveText('Add shipment details'); await expect(page.getByTestId('tag')).toHaveText('Mobile Home'); @@ -18,17 +92,21 @@ test.describe('Services counselor user', () => { await page.getByLabel('Make').fill('make'); await page.getByLabel('Model').fill('model'); await page.getByTestId('lengthFeet').fill('22'); + await page.getByTestId('lengthInches').fill('0'); await page.getByTestId('widthFeet').fill('22'); + await page.getByTestId('widthInches').fill('0'); await page.getByTestId('heightFeet').fill('22'); + await page.getByTestId('heightInches').fill('0'); - await page.locator('#requestedPickupDate').fill(deliveryDate); + await page.locator('#requestedPickupDate').fill(pickupDateString); await page.locator('#requestedPickupDate').blur(); await page.getByText('Use current address').click(); - await page.locator('#requestedDeliveryDate').fill('16 Mar 2022'); - await page.locator('#requestedDeliveryDate').blur(); await page.getByLabel('Counselor remarks').fill('Sample counselor remarks'); + await page.locator('#requestedDeliveryDate').fill(deliveryDateString); + await page.locator('#requestedDeliveryDate').blur(); + // Save the shipment await page.getByRole('button', { name: 'Save' }).click(); await scPage.waitForPage.moveDetails(); @@ -44,4 +122,141 @@ test.describe('Services counselor user', () => { await expect(page.getByText('Dimensions')).toBeVisible(); await expect(page.getByTestId('dimensions')).toHaveText("22' L x 22' W x 22' H"); }); + + test('Services Counselor can delete an existing Mobile Home shipment', async ({ page, scPage }) => { + // Testdata fixture creates 2 shipments, one with the "Destination Type" field populated, which is used only for retirement moves + await expect(page.getByText('Edit Shipment')).toHaveCount(1); + // Choose a shipment and store it's shipment ID + const editShipmentButton = await page.getByRole('button', { name: 'Edit Shipment' }); + process.stdout.write(await editShipmentButton.evaluate((el) => el.outerHTML)); + + const shipmentButtonTestID = await editShipmentButton.evaluate((e) => e.dataset.testid); + await editShipmentButton.click(); + await scPage.waitForLoading(); + await scPage.waitForPage.editMobileHomeShipment(); + + // Delete that shipment + await page.getByRole('button', { name: 'Delete shipment' }).click(); + await expect(page.getByTestId('modalCloseButton')).toBeVisible(); + await page.getByTestId('modal').getByRole('button', { name: 'Delete shipment' }).click(); + await scPage.waitForPage.moveDetails(); + + // Verify that there's only 1 shipment displayed now + await expect(page.getByTestId('ShipmentContainer')).toHaveCount(1); + + // Verify that the deleted shipment is not on the page + await expect(page.getByTestId(shipmentButtonTestID)).toHaveCount(0); + }); + + test('Services Counselor can edit an existing Mobile Home shipment', async ({ page, scPage }) => { + // Testdata fixture creates 2 shipments, one with the "Destination Type" field populated, which is used only for retirement moves + await expect(page.getByText('Edit Shipment')).toHaveCount(1); + + // Choose a shipment, store it's container, and click the edit button + const shipmentContainer = await page.getByTestId('ShipmentContainer'); + await shipmentContainer.getByRole('button').click(); + await scPage.waitForLoading(); + await scPage.waitForPage.editMobileHomeShipment(); + + // Fill in all of the form fields with new data + await page.getByLabel('Year').fill('2024'); + await page.getByLabel('Make').fill('Test Make'); + await page.getByLabel('Model').fill('Test Model'); + + await page.getByTestId('lengthFeet').fill('20'); + await page.getByTestId('lengthInches').fill('6'); + + await page.getByTestId('widthFeet').fill('15'); + await page.getByTestId('widthInches').fill('1'); + + await page.getByTestId('heightFeet').fill('10'); + await page.getByTestId('heightInches').fill('0'); + + await page.locator('#requestedPickupDate').fill(pickupDateString); + await page.locator('#requestedPickupDate').blur(); + await page.locator('#requestedDeliveryDate').fill(deliveryDateString); + await page.locator('#requestedDeliveryDate').blur(); + + // Update form (adding pickup and delivery address) + const pickupAddressGroup = await page.getByRole('group', { name: 'Pickup location' }); + await pickupAddressGroup.getByText('Yes').click(); + await pickupAddressGroup.getByLabel('Address 1').nth(0).fill(pickupAddress.Address1); + await pickupAddressGroup.getByLabel('Address 2').nth(0).clear(); + await pickupAddressGroup.getByLabel('Address 3').nth(0).clear(); + await pickupAddressGroup.getByLabel('City').nth(0).fill(pickupAddress.City); + await pickupAddressGroup.getByLabel('State').nth(0).selectOption({ label: pickupAddress.State }); + await pickupAddressGroup.getByLabel('ZIP').nth(0).fill(pickupAddress.ZIP); + + // Secondary pickup address + await pickupAddressGroup.getByText('Yes').click(); + await pickupAddressGroup.getByLabel('Address 1').nth(1).fill(secondaryPickupAddress.Address1); + await pickupAddressGroup.getByLabel('Address 2').nth(1).clear(); + await pickupAddressGroup.getByLabel('Address 3').nth(1).clear(); + await pickupAddressGroup.getByLabel('City').nth(1).fill(secondaryPickupAddress.City); + await pickupAddressGroup.getByLabel('State').nth(1).selectOption({ label: secondaryPickupAddress.State }); + await pickupAddressGroup.getByLabel('ZIP').nth(1).fill(secondaryPickupAddress.ZIP); + + // Releasing agent + await page.locator(`[name='pickup.agent.firstName']`).fill(releasingAgent.firstName); + await page.locator(`[name='pickup.agent.lastName']`).fill(releasingAgent.lastName); + await page.locator(`[name='pickup.agent.phone']`).fill(releasingAgent.phone); + await page.locator(`[name='pickup.agent.email']`).fill(releasingAgent.email); + + const deliveryAddressGroup = await page.getByRole('group', { name: 'Delivery location' }); + await deliveryAddressGroup.getByText('Yes').nth(0).click(); + await deliveryAddressGroup.getByLabel('Address 1').nth(0).fill(deliveryAddress.Address1); + await deliveryAddressGroup.getByLabel('Address 2').nth(0).fill(deliveryAddress.Address2); + await deliveryAddressGroup.getByLabel('Address 3').nth(0).clear(); + await deliveryAddressGroup.getByLabel('City').nth(0).fill(deliveryAddress.City); + await deliveryAddressGroup.getByLabel('State').nth(0).selectOption({ label: deliveryAddress.State }); + await deliveryAddressGroup.getByLabel('ZIP').nth(0).fill(deliveryAddress.ZIP); + + // Secondary delivery address + await deliveryAddressGroup.getByText('Yes').nth(1).click(); + await deliveryAddressGroup.getByLabel('Address 1').nth(1).fill(secondaryDeliveryAddress.Address1); + await deliveryAddressGroup.getByLabel('Address 2').nth(1).clear(); + await deliveryAddressGroup.getByLabel('Address 3').nth(1).clear(); + await deliveryAddressGroup.getByLabel('City').nth(1).fill(secondaryDeliveryAddress.City); + await deliveryAddressGroup.getByLabel('State').nth(1).selectOption({ label: secondaryDeliveryAddress.State }); + await deliveryAddressGroup.getByLabel('ZIP').nth(1).fill(secondaryDeliveryAddress.ZIP); + + // Receiving agent + await page.locator(`[name='delivery.agent.firstName']`).fill(receivingAgent.firstName); + await page.locator(`[name='delivery.agent.lastName']`).fill(receivingAgent.lastName); + await page.locator(`[name='delivery.agent.phone']`).fill(receivingAgent.phone); + await page.locator(`[name='delivery.agent.email']`).fill(receivingAgent.email); + + await page.getByLabel('Counselor remarks').fill('Sample counselor remarks'); + + // Submit edits + await page.getByTestId('submitForm').click(); + await scPage.waitForLoading(); + await expect(page.locator('.usa-alert__text')).toContainText('Your changes were saved.'); + + // Check that the data in the shipment card now matches what we just submitted + await shipmentContainer.locator('[data-prefix="fas"][data-icon="chevron-down"]').click(); + await expect(shipmentContainer.getByTestId('requestedPickupDate')).toHaveText(formatDate(pickupDate)); + await expect(shipmentContainer.getByTestId('pickupAddress')).toHaveText(addressToString(pickupAddress)); + await expect(shipmentContainer.getByTestId('secondaryPickupAddress')).toHaveText( + addressToString(secondaryPickupAddress), + ); + + await expect(shipmentContainer.getByTestId('RELEASING_AGENT')).toHaveText(agentToString(releasingAgent)); + + await expect(shipmentContainer.getByTestId('requestedDeliveryDate')).toHaveText(formatDate(deliveryDate)); + await expect(shipmentContainer.getByTestId('destinationAddress')).toHaveText(addressToString(deliveryAddress)); + await expect(shipmentContainer.getByTestId('secondaryDeliveryAddress')).toHaveText( + addressToString(secondaryDeliveryAddress), + ); + + await expect(shipmentContainer.getByTestId('RECEIVING_AGENT')).toHaveText(agentToString(receivingAgent)); + + await expect(shipmentContainer.getByTestId('year')).toHaveText('2024'); + await expect(shipmentContainer.getByTestId('make')).toHaveText('Test Make'); + await expect(shipmentContainer.getByTestId('model')).toHaveText('Test Model'); + + await expect(shipmentContainer.getByTestId('dimensions')).toHaveText(`20' 6" L x 15' 1" W x 10' H`); + + await expect(shipmentContainer.getByTestId('counselorRemarks')).toHaveText('Sample counselor remarks'); + }); }); diff --git a/playwright/tests/utils/office/waitForOfficePage.js b/playwright/tests/utils/office/waitForOfficePage.js index e3bf4b82f80..7a785949cdf 100644 --- a/playwright/tests/utils/office/waitForOfficePage.js +++ b/playwright/tests/utils/office/waitForOfficePage.js @@ -68,6 +68,14 @@ export class WaitForOfficePage extends WaitForPage { await base.expect(this.page.getByTestId('tag')).toHaveText('NTS-release'); } + /** + * @returns {Promise} + */ + async editMobileHomeShipment() { + await base.expect(this.page.getByRole('heading', { level: 1 })).toHaveText('Edit shipment details'); + await base.expect(this.page.getByTestId('tag')).toHaveText('Mobile Home'); + } + /** * @returns {Promise} */ diff --git a/playwright/tests/utils/testharness.js b/playwright/tests/utils/testharness.js index 1faf82f5ee5..1ece5698f7d 100644 --- a/playwright/tests/utils/testharness.js +++ b/playwright/tests/utils/testharness.js @@ -411,6 +411,14 @@ export class TestHarness { return this.buildDefault('HHGMoveWithNTSAndNeedsSC'); } + /** + * Use testharness to build Mobile move + * @returns {Promise} + */ + async buildMobileHomeMoveNeedsSC() { + return this.buildDefault('MobileHomeMoveNeedsSC'); + } + /** * Use testharness to build a good TAC and LOA combination, return the TAC * so that office users can input the TAC, and preview the LOA (If the From ecd1b33df8482b3a658faecafb43c54243250cbe Mon Sep 17 00:00:00 2001 From: Maria Traskowsky Date: Fri, 13 Sep 2024 15:40:12 +0000 Subject: [PATCH 25/37] update red color to meet 508 compliance --- src/pages/Office/MoveDetails/MoveDetails.jsx | 2 +- .../ServicesCounselingMoveDetails.jsx | 2 +- src/shared/styles/colors.scss | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/pages/Office/MoveDetails/MoveDetails.jsx b/src/pages/Office/MoveDetails/MoveDetails.jsx index f6397c94061..cf28e9a42ef 100644 --- a/src/pages/Office/MoveDetails/MoveDetails.jsx +++ b/src/pages/Office/MoveDetails/MoveDetails.jsx @@ -328,7 +328,7 @@ const MoveDetails = ({
Date: Fri, 13 Sep 2024 15:26:01 -0400 Subject: [PATCH 26/37] Fixed typo in factory and added unit tests for boat/mobile home shipment types. --- pkg/factory/boat_shipment_factory.go | 8 ++-- pkg/services/move/move_router_test.go | 66 ++++++++++++++++++++++++++- 2 files changed, 69 insertions(+), 5 deletions(-) diff --git a/pkg/factory/boat_shipment_factory.go b/pkg/factory/boat_shipment_factory.go index dacbd3f26a8..d08cfd0f8de 100644 --- a/pkg/factory/boat_shipment_factory.go +++ b/pkg/factory/boat_shipment_factory.go @@ -14,7 +14,7 @@ type boatBuildType byte const ( boatBuildStandard boatBuildType = iota boatBuildStandardTowAway - boatBuildStandardHualAway + boatBuildStandardhaulaway ) // buildBoatShipmentWithBuildType does the actual work @@ -56,7 +56,7 @@ func buildBoatShipmentWithBuildType(db *pop.Connection, customs []Customization, shipment.ShipmentType = models.MTOShipmentTypeBoatTowAway } - if buildType == boatBuildStandardHualAway { + if buildType == boatBuildStandardhaulaway { shipment.ShipmentType = models.MTOShipmentTypeBoatHaulAway } @@ -80,7 +80,7 @@ func buildBoatShipmentWithBuildType(db *pop.Connection, customs []Customization, boatShipment.IsRoadworthy = models.BoolPointer(true) } - if buildType == boatBuildStandardHualAway { + if buildType == boatBuildStandardhaulaway { boatShipment.Type = models.BoatShipmentTypeHaulAway boatShipment.HasTrailer = models.BoolPointer(false) boatShipment.IsRoadworthy = models.BoolPointer(false) @@ -106,7 +106,7 @@ func BuildBoatShipmentTowAway(db *pop.Connection, customs []Customization, trait return buildBoatShipmentWithBuildType(db, customs, traits, boatBuildStandardTowAway) } func BuildBoatShipmentHaulAway(db *pop.Connection, customs []Customization, traits []Trait) models.BoatShipment { - return buildBoatShipmentWithBuildType(db, customs, traits, boatBuildStandardHualAway) + return buildBoatShipmentWithBuildType(db, customs, traits, boatBuildStandardhaulaway) } // ------------------------ diff --git a/pkg/services/move/move_router_test.go b/pkg/services/move/move_router_test.go index cd6b9f6623e..945a65d6033 100644 --- a/pkg/services/move/move_router_test.go +++ b/pkg/services/move/move_router_test.go @@ -296,6 +296,32 @@ func (suite *MoveServiceSuite) TestMoveSubmission() { }, }, nil) + boatMTOSHipment := factory.BuildMTOShipmentMinimal(suite.DB(), []factory.Customization{ + { + Model: models.MTOShipment{ + Status: models.MTOShipmentStatusDraft, + ShipmentType: models.MTOShipmentTypeBoatHaulAway, + }, + }, + { + Model: move, + LinkOnly: true, + }, + }, nil) + + mobileHomeMTOShipment := factory.BuildMTOShipmentMinimal(suite.DB(), []factory.Customization{ + { + Model: models.MTOShipment{ + Status: models.MTOShipmentStatusDraft, + ShipmentType: models.MTOShipmentTypeMobileHome, + }, + }, + { + Model: move, + LinkOnly: true, + }, + }, nil) + ppmShipment := factory.BuildPPMShipment(suite.DB(), []factory.Customization{ { Model: models.PPMShipment{ @@ -303,8 +329,23 @@ func (suite *MoveServiceSuite) TestMoveSubmission() { }, }, }, nil) - move.MTOShipments = models.MTOShipments{shipment} + + boatShipment := factory.BuildBoatShipmentHaulAway(suite.DB(), []factory.Customization{ + { + Model: models.BoatShipment{}, + }, + }, nil) + + mobileHomeShipment := factory.BuildMobileHomeShipment(suite.DB(), []factory.Customization{ + { + Model: models.MobileHome{}, + }, + }, nil) + + move.MTOShipments = models.MTOShipments{shipment, boatMTOSHipment, mobileHomeMTOShipment} move.MTOShipments[0].PPMShipment = &ppmShipment + move.MTOShipments[0].BoatShipment = &boatShipment + move.MTOShipments[0].MobileHome = &mobileHomeShipment newSignedCertification := factory.BuildSignedCertification(nil, []factory.Customization{ { @@ -397,6 +438,7 @@ func (suite *MoveServiceSuite) TestMoveSubmission() { suite.Equal(models.MTOShipmentStatusSubmitted, move.MTOShipments[0].Status, "expected Submitted") suite.Equal(models.PPMShipmentStatusSubmitted, move.MTOShipments[0].PPMShipment.Status, "expected Submitted") }) + } func (suite *MoveServiceSuite) TestMoveCancellation() { @@ -745,6 +787,28 @@ func (suite *MoveServiceSuite) TestCompleteServiceCounseling() { suite.IsType(apperror.ConflictError{}, err) suite.Contains(err.Error(), "NTS-release shipment must include facility info") }) + + suite.Run("Boat Shipment - status changed to 'SERVICE_COUNSELING_COMPLETED'", func() { + move := factory.BuildStubbedMoveWithStatus(models.MoveStatusNeedsServiceCounseling) + boatShipment := factory.BuildBoatShipment(nil, nil, nil) + move.MTOShipments = models.MTOShipments{boatShipment.Shipment} + + err := moveRouter.CompleteServiceCounseling(suite.AppContextForTest(), &move) + + suite.NoError(err) + suite.Equal(models.MoveStatusServiceCounselingCompleted, move.Status) + }) + + suite.Run("Mobile Home Shipment - status changed to 'SERVICE_COUNSELING_COMPLETED'", func() { + move := factory.BuildStubbedMoveWithStatus(models.MoveStatusNeedsServiceCounseling) + mobileHomeShipment := factory.BuildMobileHomeShipment(nil, nil, nil) + move.MTOShipments = models.MTOShipments{mobileHomeShipment.Shipment} + + err := moveRouter.CompleteServiceCounseling(suite.AppContextForTest(), &move) + + suite.NoError(err) + suite.Equal(models.MoveStatusServiceCounselingCompleted, move.Status) + }) } func (suite *MoveServiceSuite) createServiceItem() (models.MTOServiceItem, models.Move) { From 5bb7d4fea81e5fa47151d6c3d3923b85061e1c9a Mon Sep 17 00:00:00 2001 From: Brooklyn Welsh Date: Fri, 13 Sep 2024 20:38:32 +0000 Subject: [PATCH 27/37] Fixed typo again to have correct camelCase naming --- pkg/factory/boat_shipment_factory.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/factory/boat_shipment_factory.go b/pkg/factory/boat_shipment_factory.go index d08cfd0f8de..bf6fae5a275 100644 --- a/pkg/factory/boat_shipment_factory.go +++ b/pkg/factory/boat_shipment_factory.go @@ -14,7 +14,7 @@ type boatBuildType byte const ( boatBuildStandard boatBuildType = iota boatBuildStandardTowAway - boatBuildStandardhaulaway + boatBuildStandardHaulAway ) // buildBoatShipmentWithBuildType does the actual work @@ -56,7 +56,7 @@ func buildBoatShipmentWithBuildType(db *pop.Connection, customs []Customization, shipment.ShipmentType = models.MTOShipmentTypeBoatTowAway } - if buildType == boatBuildStandardhaulaway { + if buildType == boatBuildStandardHaulAway { shipment.ShipmentType = models.MTOShipmentTypeBoatHaulAway } @@ -80,7 +80,7 @@ func buildBoatShipmentWithBuildType(db *pop.Connection, customs []Customization, boatShipment.IsRoadworthy = models.BoolPointer(true) } - if buildType == boatBuildStandardhaulaway { + if buildType == boatBuildStandardHaulAway { boatShipment.Type = models.BoatShipmentTypeHaulAway boatShipment.HasTrailer = models.BoolPointer(false) boatShipment.IsRoadworthy = models.BoolPointer(false) @@ -106,7 +106,7 @@ func BuildBoatShipmentTowAway(db *pop.Connection, customs []Customization, trait return buildBoatShipmentWithBuildType(db, customs, traits, boatBuildStandardTowAway) } func BuildBoatShipmentHaulAway(db *pop.Connection, customs []Customization, traits []Trait) models.BoatShipment { - return buildBoatShipmentWithBuildType(db, customs, traits, boatBuildStandardhaulaway) + return buildBoatShipmentWithBuildType(db, customs, traits, boatBuildStandardHaulAway) } // ------------------------ From 710e5a2b22254078242214f189dcb67ced71cc22 Mon Sep 17 00:00:00 2001 From: AaronW Date: Fri, 13 Sep 2024 22:13:11 +0000 Subject: [PATCH 28/37] Commits from PR 13578 --- pkg/gen/internalapi/embedded_spec.go | 12 ++-- .../create_service_member_payload.go | 4 +- .../patch_service_member_payload.go | 4 +- .../service_member_payload.go | 4 +- pkg/handlers/internalapi/service_members.go | 5 +- src/pages/MyMove/Profile/EditContactInfo.jsx | 4 +- .../CustomerOnboarding/CreateCustomerForm.jsx | 14 ++++- .../CreateCustomerForm.test.jsx | 60 +++++++++++++++++++ swagger-def/internal.yaml | 6 +- swagger/internal.yaml | 6 +- 10 files changed, 94 insertions(+), 25 deletions(-) diff --git a/pkg/gen/internalapi/embedded_spec.go b/pkg/gen/internalapi/embedded_spec.go index 794f7f59f10..3ba15e834fa 100644 --- a/pkg/gen/internalapi/embedded_spec.go +++ b/pkg/gen/internalapi/embedded_spec.go @@ -3987,7 +3987,7 @@ func init() { "type": "string", "format": "telephone", "title": "Alternate phone", - "pattern": "^[2-9]\\d{2}-\\d{3}-\\d{4}$", + "pattern": "^([2-9]\\d{2}-\\d{3}-\\d{4})?$", "x-nullable": true, "example": "212-555-5555" }, @@ -6429,7 +6429,7 @@ func init() { "type": "string", "format": "telephone", "title": "Alternate Phone", - "pattern": "^[2-9]\\d{2}-\\d{3}-\\d{4}$", + "pattern": "^([2-9]\\d{2}-\\d{3}-\\d{4})?$", "x-nullable": true, "example": "212-555-5555" }, @@ -6905,7 +6905,7 @@ func init() { "type": "string", "format": "telephone", "title": "Secondary Phone", - "pattern": "^[2-9]\\d{2}-\\d{3}-\\d{4}$", + "pattern": "^([2-9]\\d{2}-\\d{3}-\\d{4})?$", "x-nullable": true, "example": "212-555-5555" }, @@ -12588,7 +12588,7 @@ func init() { "type": "string", "format": "telephone", "title": "Alternate phone", - "pattern": "^[2-9]\\d{2}-\\d{3}-\\d{4}$", + "pattern": "^([2-9]\\d{2}-\\d{3}-\\d{4})?$", "x-nullable": true, "example": "212-555-5555" }, @@ -15034,7 +15034,7 @@ func init() { "type": "string", "format": "telephone", "title": "Alternate Phone", - "pattern": "^[2-9]\\d{2}-\\d{3}-\\d{4}$", + "pattern": "^([2-9]\\d{2}-\\d{3}-\\d{4})?$", "x-nullable": true, "example": "212-555-5555" }, @@ -15512,7 +15512,7 @@ func init() { "type": "string", "format": "telephone", "title": "Secondary Phone", - "pattern": "^[2-9]\\d{2}-\\d{3}-\\d{4}$", + "pattern": "^([2-9]\\d{2}-\\d{3}-\\d{4})?$", "x-nullable": true, "example": "212-555-5555" }, diff --git a/pkg/gen/internalmessages/create_service_member_payload.go b/pkg/gen/internalmessages/create_service_member_payload.go index a2b48dce311..737d5a0a897 100644 --- a/pkg/gen/internalmessages/create_service_member_payload.go +++ b/pkg/gen/internalmessages/create_service_member_payload.go @@ -68,7 +68,7 @@ type CreateServiceMemberPayload struct { // Alternate phone // Example: 212-555-5555 - // Pattern: ^[2-9]\d{2}-\d{3}-\d{4}$ + // Pattern: ^([2-9]\d{2}-\d{3}-\d{4})?$ SecondaryTelephone *string `json:"secondary_telephone,omitempty"` // Suffix @@ -261,7 +261,7 @@ func (m *CreateServiceMemberPayload) validateSecondaryTelephone(formats strfmt.R return nil } - if err := validate.Pattern("secondary_telephone", "body", *m.SecondaryTelephone, `^[2-9]\d{2}-\d{3}-\d{4}$`); err != nil { + if err := validate.Pattern("secondary_telephone", "body", *m.SecondaryTelephone, `^([2-9]\d{2}-\d{3}-\d{4})?$`); err != nil { return err } diff --git a/pkg/gen/internalmessages/patch_service_member_payload.go b/pkg/gen/internalmessages/patch_service_member_payload.go index ec9b127dcda..a85374ad1eb 100644 --- a/pkg/gen/internalmessages/patch_service_member_payload.go +++ b/pkg/gen/internalmessages/patch_service_member_payload.go @@ -72,7 +72,7 @@ type PatchServiceMemberPayload struct { // Alternate Phone // Example: 212-555-5555 - // Pattern: ^[2-9]\d{2}-\d{3}-\d{4}$ + // Pattern: ^([2-9]\d{2}-\d{3}-\d{4})?$ SecondaryTelephone *string `json:"secondary_telephone,omitempty"` // Suffix @@ -266,7 +266,7 @@ func (m *PatchServiceMemberPayload) validateSecondaryTelephone(formats strfmt.Re return nil } - if err := validate.Pattern("secondary_telephone", "body", *m.SecondaryTelephone, `^[2-9]\d{2}-\d{3}-\d{4}$`); err != nil { + if err := validate.Pattern("secondary_telephone", "body", *m.SecondaryTelephone, `^([2-9]\d{2}-\d{3}-\d{4})?$`); err != nil { return err } diff --git a/pkg/gen/internalmessages/service_member_payload.go b/pkg/gen/internalmessages/service_member_payload.go index 463243292ff..a288cfba291 100644 --- a/pkg/gen/internalmessages/service_member_payload.go +++ b/pkg/gen/internalmessages/service_member_payload.go @@ -95,7 +95,7 @@ type ServiceMemberPayload struct { // Secondary Phone // Example: 212-555-5555 - // Pattern: ^[2-9]\d{2}-\d{3}-\d{4}$ + // Pattern: ^([2-9]\d{2}-\d{3}-\d{4})?$ SecondaryTelephone *string `json:"secondary_telephone,omitempty"` // Suffix @@ -411,7 +411,7 @@ func (m *ServiceMemberPayload) validateSecondaryTelephone(formats strfmt.Registr return nil } - if err := validate.Pattern("secondary_telephone", "body", *m.SecondaryTelephone, `^[2-9]\d{2}-\d{3}-\d{4}$`); err != nil { + if err := validate.Pattern("secondary_telephone", "body", *m.SecondaryTelephone, `^([2-9]\d{2}-\d{3}-\d{4})?$`); err != nil { return err } diff --git a/pkg/handlers/internalapi/service_members.go b/pkg/handlers/internalapi/service_members.go index cd257025cef..bd91b21f4fc 100644 --- a/pkg/handlers/internalapi/service_members.go +++ b/pkg/handlers/internalapi/service_members.go @@ -235,9 +235,8 @@ func (h PatchServiceMemberHandler) patchServiceMemberWithPayload(serviceMember * if payload.Telephone != nil { serviceMember.Telephone = payload.Telephone } - if payload.SecondaryTelephone != nil { - serviceMember.SecondaryTelephone = payload.SecondaryTelephone - } + // Need to be able to accept a nil value for this optional field + serviceMember.SecondaryTelephone = payload.SecondaryTelephone if payload.PersonalEmail != nil { serviceMember.PersonalEmail = payload.PersonalEmail } diff --git a/src/pages/MyMove/Profile/EditContactInfo.jsx b/src/pages/MyMove/Profile/EditContactInfo.jsx index aa27b30eae0..898031e46b8 100644 --- a/src/pages/MyMove/Profile/EditContactInfo.jsx +++ b/src/pages/MyMove/Profile/EditContactInfo.jsx @@ -73,9 +73,7 @@ export const EditContactInfo = ({ backup_mailing_address: values[backupAddressName.toString()], }; - if (values?.secondary_telephone) { - serviceMemberPayload.secondary_telephone = values?.secondary_telephone; - } + serviceMemberPayload.secondary_telephone = values?.secondary_telephone; const backupContactPayload = { id: currentBackupContacts[0].id, diff --git a/src/pages/Office/CustomerOnboarding/CreateCustomerForm.jsx b/src/pages/Office/CustomerOnboarding/CreateCustomerForm.jsx index b8a6ed6a6fa..0bb4255d3e6 100644 --- a/src/pages/Office/CustomerOnboarding/CreateCustomerForm.jsx +++ b/src/pages/Office/CustomerOnboarding/CreateCustomerForm.jsx @@ -41,6 +41,7 @@ export const CreateCustomerForm = ({ userPrivileges, setFlashMessage }) => { const backupContactName = 'backup_contact'; const [isSafetyMoveFF, setSafetyMoveFF] = useState(false); + const [secondaryTelephoneNum, setSecondaryTelephoneNum] = useState(''); useEffect(() => { isBooleanFlagEnabled('safety_move')?.then((enabled) => { @@ -189,6 +190,16 @@ export const CreateCustomerForm = ({ userPrivileges, setFlashMessage }) => { {({ isValid, handleSubmit, setValues, values, handleChange }) => { + const handleSubmitNext = () => { + setValues({ + ...values, + secondary_telephone: secondaryTelephoneNum, + }); + handleSubmit(); + }; + const handlePhoneNumChange = (value) => { + setSecondaryTelephoneNum(value); + }; const handleIsSafetyMove = (e) => { const { value } = e.target; if (value === 'true') { @@ -305,6 +316,7 @@ export const CreateCustomerForm = ({ userPrivileges, setFlashMessage }) => { type="tel" minimum="12" mask="000{-}000{-}0000" + onChange={handlePhoneNumChange} /> @@ -479,7 +491,7 @@ export const CreateCustomerForm = ({ userPrivileges, setFlashMessage }) => { editMode onCancelClick={handleBack} disableNext={!isValid} - onNextClick={handleSubmit} + onNextClick={handleSubmitNext} />
diff --git a/src/pages/Office/CustomerOnboarding/CreateCustomerForm.test.jsx b/src/pages/Office/CustomerOnboarding/CreateCustomerForm.test.jsx index 7167c40da84..cf97cda4d5d 100644 --- a/src/pages/Office/CustomerOnboarding/CreateCustomerForm.test.jsx +++ b/src/pages/Office/CustomerOnboarding/CreateCustomerForm.test.jsx @@ -215,6 +215,66 @@ describe('CreateCustomerForm', () => { expect(screen.getByText('EMPLID')).toBeInTheDocument(); }); + it('payload can have an empty secondary phone number', async () => { + createCustomerWithOktaOption.mockImplementation(() => Promise.resolve(fakeResponse)); + + const { getByLabelText, getByTestId, getByRole } = render( + + + , + ); + + const user = userEvent.setup(); + + const saveBtn = await screen.findByRole('button', { name: 'Save' }); + expect(saveBtn).toBeInTheDocument(); + + await user.selectOptions(getByLabelText('Branch of service'), [fakePayload.affiliation]); + + await user.type(getByLabelText('First name'), fakePayload.first_name); + await user.type(getByLabelText('Last name'), fakePayload.last_name); + + await user.type(getByLabelText('Best contact phone'), fakePayload.telephone); + await user.type(getByLabelText('Personal email'), fakePayload.personal_email); + + await user.type(getByTestId('res-add-street1'), fakePayload.residential_address.streetAddress1); + await user.type(getByTestId('res-add-city'), fakePayload.residential_address.city); + await user.selectOptions(getByTestId('res-add-state'), [fakePayload.residential_address.state]); + await user.type(getByTestId('res-add-zip'), fakePayload.residential_address.postalCode); + + await user.type(getByTestId('backup-add-street1'), fakePayload.backup_mailing_address.streetAddress1); + await user.type(getByTestId('backup-add-city'), fakePayload.backup_mailing_address.city); + await user.selectOptions(getByTestId('backup-add-state'), [fakePayload.backup_mailing_address.state]); + await user.type(getByTestId('backup-add-zip'), fakePayload.backup_mailing_address.postalCode); + + await user.type(getByLabelText('Name'), fakePayload.backup_contact.name); + await user.type(getByRole('textbox', { name: 'Email' }), fakePayload.backup_contact.email); + await user.type(getByRole('textbox', { name: 'Phone' }), fakePayload.backup_contact.telephone); + + await userEvent.type(getByTestId('create-okta-account-yes'), fakePayload.create_okta_account); + + await userEvent.type(getByTestId('cac-user-no'), fakePayload.cac_user); + + await waitFor(() => { + expect(saveBtn).toBeEnabled(); + }); + + const waiter = waitFor(() => { + expect(createCustomerWithOktaOption).toHaveBeenCalled(); + expect(mockNavigate).toHaveBeenCalledWith(ordersPath, { + state: { + isSafetyMoveSelected: false, + }, + }); + }); + + await user.click(saveBtn); + await waiter; + expect(mockNavigate).toHaveBeenCalled(); + + expect(createCustomerWithOktaOption.mock.calls[0][0]).not.toHaveProperty('secondary_number'); + }, 10000); + it('navigates the user on cancel click', async () => { const { getByText } = render( diff --git a/swagger-def/internal.yaml b/swagger-def/internal.yaml index 679236a358b..134d05f587a 100644 --- a/swagger-def/internal.yaml +++ b/swagger-def/internal.yaml @@ -705,7 +705,7 @@ definitions: secondary_telephone: type: string format: telephone - pattern: '^[2-9]\d{2}-\d{3}-\d{4}$' + pattern: '^([2-9]\d{2}-\d{3}-\d{4})?$' example: 212-555-5555 x-nullable: true title: Secondary Phone @@ -799,7 +799,7 @@ definitions: secondary_telephone: type: string format: telephone - pattern: '^[2-9]\d{2}-\d{3}-\d{4}$' + pattern: '^([2-9]\d{2}-\d{3}-\d{4})?$' example: 212-555-5555 x-nullable: true title: Alternate phone @@ -883,7 +883,7 @@ definitions: secondary_telephone: type: string format: telephone - pattern: '^[2-9]\d{2}-\d{3}-\d{4}$' + pattern: '^([2-9]\d{2}-\d{3}-\d{4})?$' example: 212-555-5555 x-nullable: true title: Alternate Phone diff --git a/swagger/internal.yaml b/swagger/internal.yaml index 2ddb5861003..ca80ccc7816 100644 --- a/swagger/internal.yaml +++ b/swagger/internal.yaml @@ -726,7 +726,7 @@ definitions: secondary_telephone: type: string format: telephone - pattern: ^[2-9]\d{2}-\d{3}-\d{4}$ + pattern: ^([2-9]\d{2}-\d{3}-\d{4})?$ example: 212-555-5555 x-nullable: true title: Secondary Phone @@ -820,7 +820,7 @@ definitions: secondary_telephone: type: string format: telephone - pattern: ^[2-9]\d{2}-\d{3}-\d{4}$ + pattern: ^([2-9]\d{2}-\d{3}-\d{4})?$ example: 212-555-5555 x-nullable: true title: Alternate phone @@ -904,7 +904,7 @@ definitions: secondary_telephone: type: string format: telephone - pattern: ^[2-9]\d{2}-\d{3}-\d{4}$ + pattern: ^([2-9]\d{2}-\d{3}-\d{4})?$ example: 212-555-5555 x-nullable: true title: Alternate Phone From 0ceb94d02d9bbaf497e8047552aec616ba36b702 Mon Sep 17 00:00:00 2001 From: AaronW Date: Fri, 13 Sep 2024 22:16:12 +0000 Subject: [PATCH 29/37] Commits from PR 13616 --- pkg/handlers/internalapi/service_members.go | 5 +++-- src/pages/MyMove/Profile/ContactInfo.jsx | 6 +++--- .../CustomerOnboarding/CreateCustomerForm.jsx | 14 +------------- 3 files changed, 7 insertions(+), 18 deletions(-) diff --git a/pkg/handlers/internalapi/service_members.go b/pkg/handlers/internalapi/service_members.go index bd91b21f4fc..cd257025cef 100644 --- a/pkg/handlers/internalapi/service_members.go +++ b/pkg/handlers/internalapi/service_members.go @@ -235,8 +235,9 @@ func (h PatchServiceMemberHandler) patchServiceMemberWithPayload(serviceMember * if payload.Telephone != nil { serviceMember.Telephone = payload.Telephone } - // Need to be able to accept a nil value for this optional field - serviceMember.SecondaryTelephone = payload.SecondaryTelephone + if payload.SecondaryTelephone != nil { + serviceMember.SecondaryTelephone = payload.SecondaryTelephone + } if payload.PersonalEmail != nil { serviceMember.PersonalEmail = payload.PersonalEmail } diff --git a/src/pages/MyMove/Profile/ContactInfo.jsx b/src/pages/MyMove/Profile/ContactInfo.jsx index 2b25f520797..298789034a0 100644 --- a/src/pages/MyMove/Profile/ContactInfo.jsx +++ b/src/pages/MyMove/Profile/ContactInfo.jsx @@ -37,13 +37,13 @@ export const ContactInfo = ({ serviceMember, updateServiceMember, userEmail }) = const payload = { id: serviceMember.id, telephone: values?.telephone, - secondary_telephone: values?.secondary_telephone, + secondary_telephone: values?.secondary_telephone || '', personal_email: values?.personal_email, phone_is_preferred: values?.phone_is_preferred, email_is_preferred: values?.email_is_preferred, }; - if (!payload.secondary_telephone) { - delete payload.secondary_telephone; + if (!payload.secondary_telephone || payload.secondary_telephone === '') { + payload.secondary_telephone = ''; } return patchServiceMember(payload) diff --git a/src/pages/Office/CustomerOnboarding/CreateCustomerForm.jsx b/src/pages/Office/CustomerOnboarding/CreateCustomerForm.jsx index 0bb4255d3e6..b8a6ed6a6fa 100644 --- a/src/pages/Office/CustomerOnboarding/CreateCustomerForm.jsx +++ b/src/pages/Office/CustomerOnboarding/CreateCustomerForm.jsx @@ -41,7 +41,6 @@ export const CreateCustomerForm = ({ userPrivileges, setFlashMessage }) => { const backupContactName = 'backup_contact'; const [isSafetyMoveFF, setSafetyMoveFF] = useState(false); - const [secondaryTelephoneNum, setSecondaryTelephoneNum] = useState(''); useEffect(() => { isBooleanFlagEnabled('safety_move')?.then((enabled) => { @@ -190,16 +189,6 @@ export const CreateCustomerForm = ({ userPrivileges, setFlashMessage }) => { {({ isValid, handleSubmit, setValues, values, handleChange }) => { - const handleSubmitNext = () => { - setValues({ - ...values, - secondary_telephone: secondaryTelephoneNum, - }); - handleSubmit(); - }; - const handlePhoneNumChange = (value) => { - setSecondaryTelephoneNum(value); - }; const handleIsSafetyMove = (e) => { const { value } = e.target; if (value === 'true') { @@ -316,7 +305,6 @@ export const CreateCustomerForm = ({ userPrivileges, setFlashMessage }) => { type="tel" minimum="12" mask="000{-}000{-}0000" - onChange={handlePhoneNumChange} /> @@ -491,7 +479,7 @@ export const CreateCustomerForm = ({ userPrivileges, setFlashMessage }) => { editMode onCancelClick={handleBack} disableNext={!isValid} - onNextClick={handleSubmitNext} + onNextClick={handleSubmit} />
From 78eb5df3b5ce5bf01ae877f03fb6c528ef49c64f Mon Sep 17 00:00:00 2001 From: Brooklyn Welsh Date: Mon, 16 Sep 2024 14:30:02 +0000 Subject: [PATCH 30/37] Fixed duplicate instance of "Requested delivery" field that was present in Mobile Home Card component --- .../Office/DefinitionLists/MobileHomeShipmentInfoList.jsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/Office/DefinitionLists/MobileHomeShipmentInfoList.jsx b/src/components/Office/DefinitionLists/MobileHomeShipmentInfoList.jsx index 8854c983d75..b8630805eeb 100644 --- a/src/components/Office/DefinitionLists/MobileHomeShipmentInfoList.jsx +++ b/src/components/Office/DefinitionLists/MobileHomeShipmentInfoList.jsx @@ -315,7 +315,6 @@ const ShipmentInfoList = ({ {secondaryPickupAddressElement} {isTertiaryAddressEnabled ? tertiaryPickupAddressElement : null} {showElement(agentsElementFlags) && releasingAgentElement} - {showElement(requestedDeliveryDateElementFlags) && requestedDeliveryDateElement} {requestedDeliveryDateElement} {destinationAddressElement} {showElement(destinationTypeFlags) && displayDestinationType && destinationTypeElement} From 474950f61112ca867330c8abb455f60d99bad6a5 Mon Sep 17 00:00:00 2001 From: Brooklyn Welsh Date: Tue, 17 Sep 2024 19:00:00 +0000 Subject: [PATCH 31/37] Fix for mobile home creation playwright test. --- .../servicesCounselingMobileHome.spec.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/playwright/tests/office/servicescounseling/servicesCounselingMobileHome.spec.js b/playwright/tests/office/servicescounseling/servicesCounselingMobileHome.spec.js index b0d603d29e8..8160a7c35fc 100644 --- a/playwright/tests/office/servicescounseling/servicesCounselingMobileHome.spec.js +++ b/playwright/tests/office/servicescounseling/servicesCounselingMobileHome.spec.js @@ -113,14 +113,14 @@ test.describe('Services counselor user', () => { await expect(page.getByTestId('ShipmentContainer')).toHaveCount(2); - await expect(page.getByText('Mobile home year')).toBeVisible(); - await expect(page.getByTestId('year')).toHaveText('2022'); - await expect(page.getByText('Mobile home make')).toBeVisible(); - await expect(page.getByTestId('make')).toHaveText('make'); - await expect(page.getByText('Mobile home model')).toBeVisible(); - await expect(page.getByTestId('model')).toHaveText('model'); - await expect(page.getByText('Dimensions')).toBeVisible(); - await expect(page.getByTestId('dimensions')).toHaveText("22' L x 22' W x 22' H"); + await expect(page.getByText('Mobile home year').last()).toBeVisible(); + await expect(page.getByTestId('year').last()).toHaveText('2022'); + await expect(page.getByText('Mobile home make').last()).toBeVisible(); + await expect(page.getByTestId('make').last()).toHaveText('make'); + await expect(page.getByText('Mobile home model').last()).toBeVisible(); + await expect(page.getByTestId('model').last()).toHaveText('model'); + await expect(page.getByText('Dimensions').last()).toBeVisible(); + await expect(page.getByTestId('dimensions').last()).toHaveText("22' L x 22' W x 22' H"); }); test('Services Counselor can delete an existing Mobile Home shipment', async ({ page, scPage }) => { From 1f96840fc69ea084ad98f8257be879eb3c8f9349 Mon Sep 17 00:00:00 2001 From: Jon Spight Date: Tue, 17 Sep 2024 20:10:19 +0000 Subject: [PATCH 32/37] missing file --- pkg/handlers/ghcapi/orders_test.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/pkg/handlers/ghcapi/orders_test.go b/pkg/handlers/ghcapi/orders_test.go index 351c09087d5..35e92e4611e 100644 --- a/pkg/handlers/ghcapi/orders_test.go +++ b/pkg/handlers/ghcapi/orders_test.go @@ -37,21 +37,22 @@ import ( ) func (suite *HandlerSuite) TestCreateOrder() { - sm := factory.BuildExtendedServiceMember(suite.DB(), nil, nil) + sm := factory.BuildExtendedServiceMember(suite.AppContextForTest().DB(), nil, nil) + officeUser := factory.BuildOfficeUserWithRoles(suite.AppContextForTest().DB(), nil, []roles.RoleType{roles.RoleTypeTOO}) - originDutyLocation := factory.BuildDutyLocation(suite.DB(), []factory.Customization{ + originDutyLocation := factory.BuildDutyLocation(suite.AppContextForTest().DB(), []factory.Customization{ { Model: models.DutyLocation{ Name: "Not Yuma AFB", }, }, }, nil) - dutyLocation := factory.FetchOrBuildCurrentDutyLocation(suite.DB()) - factory.FetchOrBuildPostalCodeToGBLOC(suite.DB(), dutyLocation.Address.PostalCode, "KKFA") - factory.FetchOrBuildDefaultContractor(suite.DB(), nil, nil) + dutyLocation := factory.FetchOrBuildCurrentDutyLocation(suite.AppContextForTest().DB()) + factory.FetchOrBuildPostalCodeToGBLOC(suite.AppContextForTest().DB(), dutyLocation.Address.PostalCode, "KKFA") + factory.FetchOrBuildDefaultContractor(suite.AppContextForTest().DB(), nil, nil) req := httptest.NewRequest("POST", "/orders", nil) - req = suite.AuthenticateRequest(req, sm) + req = suite.AuthenticateOfficeRequest(req, officeUser) hasDependents := true spouseHasProGear := true From e47b241f6ee6eb79ed4c6ad4ce88b168199f2790 Mon Sep 17 00:00:00 2001 From: Brooklyn Welsh Date: Tue, 17 Sep 2024 20:12:14 +0000 Subject: [PATCH 33/37] Changed unneeded selector in playwright test --- .../servicesCounselingMobileHome.spec.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/playwright/tests/office/servicescounseling/servicesCounselingMobileHome.spec.js b/playwright/tests/office/servicescounseling/servicesCounselingMobileHome.spec.js index 8160a7c35fc..0f7a6d1d695 100644 --- a/playwright/tests/office/servicescounseling/servicesCounselingMobileHome.spec.js +++ b/playwright/tests/office/servicescounseling/servicesCounselingMobileHome.spec.js @@ -124,13 +124,11 @@ test.describe('Services counselor user', () => { }); test('Services Counselor can delete an existing Mobile Home shipment', async ({ page, scPage }) => { - // Testdata fixture creates 2 shipments, one with the "Destination Type" field populated, which is used only for retirement moves await expect(page.getByText('Edit Shipment')).toHaveCount(1); // Choose a shipment and store it's shipment ID const editShipmentButton = await page.getByRole('button', { name: 'Edit Shipment' }); process.stdout.write(await editShipmentButton.evaluate((el) => el.outerHTML)); - const shipmentButtonTestID = await editShipmentButton.evaluate((e) => e.dataset.testid); await editShipmentButton.click(); await scPage.waitForLoading(); await scPage.waitForPage.editMobileHomeShipment(); @@ -141,11 +139,8 @@ test.describe('Services counselor user', () => { await page.getByTestId('modal').getByRole('button', { name: 'Delete shipment' }).click(); await scPage.waitForPage.moveDetails(); - // Verify that there's only 1 shipment displayed now - await expect(page.getByTestId('ShipmentContainer')).toHaveCount(1); - - // Verify that the deleted shipment is not on the page - await expect(page.getByTestId(shipmentButtonTestID)).toHaveCount(0); + // Verify that the shipment has been deleted + await expect(page.getByTestId('ShipmentContainer')).toHaveCount(0); }); test('Services Counselor can edit an existing Mobile Home shipment', async ({ page, scPage }) => { From 469ce49dc999954f3c934e14595de04d56853b0d Mon Sep 17 00:00:00 2001 From: Brooklyn Welsh Date: Tue, 17 Sep 2024 20:12:55 +0000 Subject: [PATCH 34/37] Removed outdated comment. --- .../servicescounseling/servicesCounselingMobileHome.spec.js | 1 - 1 file changed, 1 deletion(-) diff --git a/playwright/tests/office/servicescounseling/servicesCounselingMobileHome.spec.js b/playwright/tests/office/servicescounseling/servicesCounselingMobileHome.spec.js index 0f7a6d1d695..be161ca0594 100644 --- a/playwright/tests/office/servicescounseling/servicesCounselingMobileHome.spec.js +++ b/playwright/tests/office/servicescounseling/servicesCounselingMobileHome.spec.js @@ -144,7 +144,6 @@ test.describe('Services counselor user', () => { }); test('Services Counselor can edit an existing Mobile Home shipment', async ({ page, scPage }) => { - // Testdata fixture creates 2 shipments, one with the "Destination Type" field populated, which is used only for retirement moves await expect(page.getByText('Edit Shipment')).toHaveCount(1); // Choose a shipment, store it's container, and click the edit button From 7bd9ac646579b37a7153f243961b55d70b1ad7e4 Mon Sep 17 00:00:00 2001 From: AaronW Date: Fri, 20 Sep 2024 14:07:26 +0000 Subject: [PATCH 35/37] commits from PR 13591 --- src/components/Table/SearchResultsTable.jsx | 9 +- src/constants/queues.js | 9 - src/pages/Office/MoveQueue/MoveQueue.jsx | 2 +- src/pages/Office/MoveQueue/MoveQueue.test.jsx | 220 ++++++++++++------ ...icesCounselingEditShipmentDetails.test.jsx | 2 +- .../ServicesCounselingQueue.jsx | 6 +- 6 files changed, 157 insertions(+), 91 deletions(-) diff --git a/src/components/Table/SearchResultsTable.jsx b/src/components/Table/SearchResultsTable.jsx index 78a0daf5180..f36fc385faa 100644 --- a/src/components/Table/SearchResultsTable.jsx +++ b/src/components/Table/SearchResultsTable.jsx @@ -13,12 +13,7 @@ import DateSelectFilter from 'components/Table/Filters/DateSelectFilter'; import LoadingPlaceholder from 'shared/LoadingPlaceholder'; import SomethingWentWrong from 'shared/SomethingWentWrong'; import TextBoxFilter from 'components/Table/Filters/TextBoxFilter'; -import { - BRANCH_OPTIONS_WITH_MARINE_CORPS, - MOVE_STATUS_LABELS, - SEARCH_QUEUE_STATUS_FILTER_OPTIONS, - SortShape, -} from 'constants/queues'; +import { BRANCH_OPTIONS, MOVE_STATUS_LABELS, SEARCH_QUEUE_STATUS_FILTER_OPTIONS, SortShape } from 'constants/queues'; import { DATE_FORMAT_STRING } from 'shared/constants'; import { formatDateFromIso, serviceMemberAgencyLabel } from 'utils/formatters'; import MultiSelectCheckBoxFilter from 'components/Table/Filters/MultiSelectCheckBoxFilter'; @@ -107,7 +102,7 @@ const moveSearchColumns = (moveLockFlag, handleEditProfileClick) => [ isFilterable: true, Filter: (props) => ( // eslint-disable-next-line react/jsx-props-no-spreading - + ), }, ), diff --git a/src/constants/queues.js b/src/constants/queues.js index 87d23e1ed04..17a6e9d4066 100644 --- a/src/constants/queues.js +++ b/src/constants/queues.js @@ -52,15 +52,6 @@ export const BRANCH_OPTIONS = [ { value: 'AIR_FORCE', label: 'Air Force' }, { value: 'COAST_GUARD', label: 'Coast Guard' }, { value: 'SPACE_FORCE', label: 'Space Force' }, -]; - -export const BRANCH_OPTIONS_WITH_MARINE_CORPS = [ - { value: '', label: 'All' }, - { value: 'ARMY', label: 'Army' }, - { value: 'NAVY', label: 'Navy' }, - { value: 'AIR_FORCE', label: 'Air Force' }, - { value: 'COAST_GUARD', label: 'Coast Guard' }, - { value: 'SPACE_FORCE', label: 'Space Force' }, { value: 'MARINES', label: 'Marine Corps' }, ]; diff --git a/src/pages/Office/MoveQueue/MoveQueue.jsx b/src/pages/Office/MoveQueue/MoveQueue.jsx index d485648b3fe..acfceb62439 100644 --- a/src/pages/Office/MoveQueue/MoveQueue.jsx +++ b/src/pages/Office/MoveQueue/MoveQueue.jsx @@ -10,7 +10,7 @@ import { getMovesQueue } from 'services/ghcApi'; import { formatDateFromIso, serviceMemberAgencyLabel } from 'utils/formatters'; import MultiSelectCheckBoxFilter from 'components/Table/Filters/MultiSelectCheckBoxFilter'; import SelectFilter from 'components/Table/Filters/SelectFilter'; -import { BRANCH_OPTIONS, MOVE_STATUS_OPTIONS, GBLOC, MOVE_STATUS_LABELS } from 'constants/queues'; +import { MOVE_STATUS_OPTIONS, GBLOC, MOVE_STATUS_LABELS, BRANCH_OPTIONS } from 'constants/queues'; import TableQueue from 'components/Table/TableQueue'; import LoadingPlaceholder from 'shared/LoadingPlaceholder'; import SomethingWentWrong from 'shared/SomethingWentWrong'; diff --git a/src/pages/Office/MoveQueue/MoveQueue.test.jsx b/src/pages/Office/MoveQueue/MoveQueue.test.jsx index f62a6b75c05..b8017b59fdb 100644 --- a/src/pages/Office/MoveQueue/MoveQueue.test.jsx +++ b/src/pages/Office/MoveQueue/MoveQueue.test.jsx @@ -7,7 +7,7 @@ import { render, screen, waitFor } from '@testing-library/react'; import MoveQueue from './MoveQueue'; import { MockProviders } from 'testUtils'; -import { MOVE_STATUS_OPTIONS } from 'constants/queues'; +import { MOVE_STATUS_OPTIONS, BRANCH_OPTIONS } from 'constants/queues'; import { generalRoutes, tooRoutes } from 'constants/routes'; import { isBooleanFlagEnabled } from 'utils/featureFlags'; @@ -23,6 +23,71 @@ jest.mock('utils/featureFlags', () => ({ isBooleanFlagEnabled: jest.fn().mockImplementation(() => Promise.resolve()), })); +const moveData = [ + { + id: 'move1', + customer: { + agency: 'AIR_FORCE', + first_name: 'test first', + last_name: 'test last', + dodID: '555555555', + }, + locator: 'AB5P', + departmentIndicator: 'ARMY', + shipmentsCount: 2, + status: 'SUBMITTED', + originDutyLocation: { + name: 'Area 51', + }, + originGBLOC: 'EEEE', + requestedMoveDate: '2023-02-10', + appearedInTooAt: '2023-02-10T00:00:00.000Z', + lockExpiresAt: '2099-02-10T00:00:00.000Z', + lockedByOfficeUserID: '2744435d-7ba8-4cc5-bae5-f302c72c966e', + }, + { + id: 'move2', + customer: { + agency: 'COAST_GUARD', + first_name: 'test another first', + last_name: 'test another last', + dodID: '4444444444', + emplid: '4589652', + }, + locator: 'T12A', + departmentIndicator: 'COAST_GUARD', + shipmentsCount: 1, + status: 'APPROVED', + originDutyLocation: { + name: 'Los Alamos', + }, + originGBLOC: 'EEEE', + requestedMoveDate: '2023-02-12', + appearedInTooAt: '2023-02-12T00:00:00.000Z', + }, + { + id: 'move3', + customer: { + agency: 'Marine Corps', + first_name: 'will', + last_name: 'robinson', + dodID: '6666666666', + }, + locator: 'PREP', + departmentIndicator: 'MARINES', + shipmentsCount: 1, + status: 'SUBMITTED', + originDutyLocation: { + name: 'Area 52', + }, + originGBLOC: 'EEEE', + requestedMoveDate: '2023-03-12', + appearedInTooAt: '2023-03-12T00:00:00.000Z', + lockExpiresAt: '2099-03-12T00:00:00.000Z', + lockedByOfficeUserID: '2744435d-7ba8-4cc5-bae5-f302c72c966e', + }, +]; + jest.mock('hooks/queries', () => ({ useUserQueries: () => { return { @@ -38,50 +103,8 @@ jest.mock('hooks/queries', () => ({ isLoading: false, isError: false, queueResult: { - totalCount: 2, - data: [ - { - id: 'move1', - customer: { - agency: 'AIR_FORCE', - first_name: 'test first', - last_name: 'test last', - dodID: '555555555', - }, - locator: 'AB5P', - departmentIndicator: 'ARMY', - shipmentsCount: 2, - status: 'SUBMITTED', - originDutyLocation: { - name: 'Area 51', - }, - originGBLOC: 'EEEE', - requestedMoveDate: '2023-02-10', - appearedInTooAt: '2023-02-10T00:00:00.000Z', - lockExpiresAt: '2099-02-10T00:00:00.000Z', - lockedByOfficeUserID: '2744435d-7ba8-4cc5-bae5-f302c72c966e', - }, - { - id: 'move2', - customer: { - agency: 'COAST_GUARD', - first_name: 'test another first', - last_name: 'test another last', - dodID: '4444444444', - emplid: '4589652', - }, - locator: 'T12A', - departmentIndicator: 'COAST_GUARD', - shipmentsCount: 1, - status: 'APPROVED', - originDutyLocation: { - name: 'Los Alamos', - }, - originGBLOC: 'EEEE', - requestedMoveDate: '2023-02-12', - appearedInTooAt: '2023-02-12T00:00:00.000Z', - }, - ], + totalCount: 3, + data: moveData, }, }; }, @@ -103,7 +126,7 @@ describe('MoveQueue', () => { }); it('should render the h1', () => { - expect(GetMountedComponent(tooRoutes.MOVE_QUEUE).find('h1').text()).toBe('All moves (2)'); + expect(GetMountedComponent(tooRoutes.MOVE_QUEUE).find('h1').text()).toBe('All moves (3)'); }); it('should render the table', () => { @@ -111,32 +134,89 @@ describe('MoveQueue', () => { }); it('should format the column data', () => { + let currentIndex = 0; + let currentMove; const moves = GetMountedComponent(tooRoutes.MOVE_QUEUE).find('tbody tr'); - const firstMove = moves.at(0); - expect(firstMove.find({ 'data-testid': 'lastName-0' }).text()).toBe('test last, test first'); - expect(firstMove.find({ 'data-testid': 'dodID-0' }).text()).toBe('555555555'); - expect(firstMove.find({ 'data-testid': 'status-0' }).text()).toBe('New move'); - expect(firstMove.find({ 'data-testid': 'locator-0' }).text()).toBe('AB5P'); - expect(firstMove.find({ 'data-testid': 'branch-0' }).text()).toBe('Air Force'); - expect(firstMove.find({ 'data-testid': 'shipmentsCount-0' }).text()).toBe('2'); - expect(firstMove.find({ 'data-testid': 'originDutyLocation-0' }).text()).toBe('Area 51'); - expect(firstMove.find({ 'data-testid': 'originGBLOC-0' }).text()).toBe('EEEE'); - expect(firstMove.find({ 'data-testid': 'requestedMoveDate-0' }).text()).toBe('10 Feb 2023'); - expect(firstMove.find({ 'data-testid': 'appearedInTooAt-0' }).text()).toBe('10 Feb 2023'); + currentMove = moves.at(currentIndex); + expect(currentMove.find({ 'data-testid': `lastName-${currentIndex}` }).text()).toBe( + `${moveData[currentIndex].customer.last_name}, ${moveData[currentIndex].customer.first_name}`, + ); + expect(currentMove.find({ 'data-testid': `dodID-${currentIndex}` }).text()).toBe( + moveData[currentIndex].customer.dodID, + ); + expect(currentMove.find({ 'data-testid': `status-${currentIndex}` }).text()).toBe('New move'); + expect(currentMove.find({ 'data-testid': `locator-${currentIndex}` }).text()).toBe(moveData[currentIndex].locator); + expect(currentMove.find({ 'data-testid': `branch-${currentIndex}` }).text()).toBe( + BRANCH_OPTIONS.find((value) => value.value === moveData[currentIndex].customer.agency).label, + ); + expect(currentMove.find({ 'data-testid': `shipmentsCount-${currentIndex}` }).text()).toBe( + moveData[currentIndex].shipmentsCount.toString(), + ); + expect(currentMove.find({ 'data-testid': `originDutyLocation-${currentIndex}` }).text()).toBe( + moveData[currentIndex].originDutyLocation.name, + ); + expect(currentMove.find({ 'data-testid': `originGBLOC-${currentIndex}` }).text()).toBe( + moveData[currentIndex].originGBLOC, + ); + expect(currentMove.find({ 'data-testid': `requestedMoveDate-${currentIndex}` }).text()).toBe('10 Feb 2023'); + expect(currentMove.find({ 'data-testid': `appearedInTooAt-${currentIndex}` }).text()).toBe('10 Feb 2023'); + + currentIndex += 1; + currentMove = moves.at(currentIndex); + expect(currentMove.find({ 'data-testid': `lastName-${currentIndex}` }).text()).toBe( + 'test another last, test another first', + ); + expect(currentMove.find({ 'data-testid': `lastName-${currentIndex}` }).text()).toBe( + `${moveData[currentIndex].customer.last_name}, ${moveData[currentIndex].customer.first_name}`, + ); + expect(currentMove.find({ 'data-testid': `dodID-${currentIndex}` }).text()).toBe( + moveData[currentIndex].customer.dodID, + ); + expect(currentMove.find({ 'data-testid': `emplid-${currentIndex}` }).text()).toBe( + moveData[currentIndex].customer.emplid, + ); + expect(currentMove.find({ 'data-testid': `status-${currentIndex}` }).text()).toBe('Move approved'); + expect(currentMove.find({ 'data-testid': `locator-${currentIndex}` }).text()).toBe(moveData[currentIndex].locator); + expect(currentMove.find({ 'data-testid': `branch-${currentIndex}` }).text()).toBe( + BRANCH_OPTIONS.find((value) => value.value === moveData[currentIndex].customer.agency).label, + ); + expect(currentMove.find({ 'data-testid': `shipmentsCount-${currentIndex}` }).text()).toBe( + moveData[currentIndex].shipmentsCount.toString(), + ); + expect(currentMove.find({ 'data-testid': `originDutyLocation-${currentIndex}` }).text()).toBe( + moveData[currentIndex].originDutyLocation.name, + ); + expect(currentMove.find({ 'data-testid': `originGBLOC-${currentIndex}` }).text()).toBe( + moveData[currentIndex].originGBLOC, + ); + expect(currentMove.find({ 'data-testid': `requestedMoveDate-${currentIndex}` }).text()).toBe('12 Feb 2023'); + expect(currentMove.find({ 'data-testid': `appearedInTooAt-${currentIndex}` }).text()).toBe('12 Feb 2023'); - const secondMove = moves.at(1); - expect(secondMove.find({ 'data-testid': 'lastName-1' }).text()).toBe('test another last, test another first'); - expect(secondMove.find({ 'data-testid': 'dodID-1' }).text()).toBe('4444444444'); - expect(secondMove.find({ 'data-testid': 'emplid-1' }).text()).toBe('4589652'); - expect(secondMove.find({ 'data-testid': 'status-1' }).text()).toBe('Move approved'); - expect(secondMove.find({ 'data-testid': 'locator-1' }).text()).toBe('T12A'); - expect(secondMove.find({ 'data-testid': 'branch-1' }).text()).toBe('Coast Guard'); - expect(secondMove.find({ 'data-testid': 'shipmentsCount-1' }).text()).toBe('1'); - expect(secondMove.find({ 'data-testid': 'originDutyLocation-1' }).text()).toBe('Los Alamos'); - expect(secondMove.find({ 'data-testid': 'originGBLOC-1' }).text()).toBe('EEEE'); - expect(secondMove.find({ 'data-testid': 'requestedMoveDate-1' }).text()).toBe('12 Feb 2023'); - expect(secondMove.find({ 'data-testid': 'appearedInTooAt-1' }).text()).toBe('12 Feb 2023'); + currentIndex += 1; + currentMove = moves.at(currentIndex); + expect(currentMove.find({ 'data-testid': `lastName-${currentIndex}` }).text()).toBe( + `${moveData[currentIndex].customer.last_name}, ${moveData[currentIndex].customer.first_name}`, + ); + expect(currentMove.find({ 'data-testid': `dodID-${currentIndex}` }).text()).toBe( + moveData[currentIndex].customer.dodID, + ); + expect(currentMove.find({ 'data-testid': `status-${currentIndex}` }).text()).toBe('New move'); + expect(currentMove.find({ 'data-testid': `locator-${currentIndex}` }).text()).toBe(moveData[currentIndex].locator); + expect(currentMove.find({ 'data-testid': `branch-${currentIndex}` }).text()).toBe( + moveData[currentIndex].customer.agency.toString(), + ); + expect(currentMove.find({ 'data-testid': `shipmentsCount-${currentIndex}` }).text()).toBe( + moveData[currentIndex].shipmentsCount.toString(), + ); + expect(currentMove.find({ 'data-testid': `originDutyLocation-${currentIndex}` }).text()).toBe( + moveData[currentIndex].originDutyLocation.name, + ); + expect(currentMove.find({ 'data-testid': `originGBLOC-${currentIndex}` }).text()).toBe( + moveData[currentIndex].originGBLOC, + ); + expect(currentMove.find({ 'data-testid': `requestedMoveDate-${currentIndex}` }).text()).toBe('12 Mar 2023'); + expect(currentMove.find({ 'data-testid': `appearedInTooAt-${currentIndex}` }).text()).toBe('12 Mar 2023'); }); it('should render the pagination component', () => { @@ -249,7 +329,7 @@ describe('MoveQueue', () => { , ); await waitFor(() => { - const lockIcon = screen.queryByTestId('lock-icon'); + const lockIcon = screen.queryAllByTestId('lock-icon')[0]; expect(lockIcon).toBeInTheDocument(); }); }); diff --git a/src/pages/Office/ServicesCounselingEditShipmentDetails/ServicesCounselingEditShipmentDetails.test.jsx b/src/pages/Office/ServicesCounselingEditShipmentDetails/ServicesCounselingEditShipmentDetails.test.jsx index de1ac1b0ead..26b06a51d85 100644 --- a/src/pages/Office/ServicesCounselingEditShipmentDetails/ServicesCounselingEditShipmentDetails.test.jsx +++ b/src/pages/Office/ServicesCounselingEditShipmentDetails/ServicesCounselingEditShipmentDetails.test.jsx @@ -328,7 +328,7 @@ describe('ServicesCounselingEditShipmentDetails component', () => { expect( screen.getByText('Something went wrong, and your changes were not saved. Please try again.'), ).toBeVisible(); - }); + }, 10000); }); it('routes to the move details page when the cancel button is clicked', async () => { diff --git a/src/pages/Office/ServicesCounselingQueue/ServicesCounselingQueue.jsx b/src/pages/Office/ServicesCounselingQueue/ServicesCounselingQueue.jsx index 398bc9fe860..dc2e4421932 100644 --- a/src/pages/Office/ServicesCounselingQueue/ServicesCounselingQueue.jsx +++ b/src/pages/Office/ServicesCounselingQueue/ServicesCounselingQueue.jsx @@ -10,7 +10,7 @@ import SelectFilter from 'components/Table/Filters/SelectFilter'; import DateSelectFilter from 'components/Table/Filters/DateSelectFilter'; import TableQueue from 'components/Table/TableQueue'; import { - BRANCH_OPTIONS_WITH_MARINE_CORPS, + BRANCH_OPTIONS, SERVICE_COUNSELING_MOVE_STATUS_LABELS, SERVICE_COUNSELING_PPM_TYPE_OPTIONS, SERVICE_COUNSELING_PPM_TYPE_LABELS, @@ -148,7 +148,7 @@ export const counselingColumns = (moveLockFlag, originLocationList, supervisor) isFilterable: true, Filter: (props) => ( // eslint-disable-next-line react/jsx-props-no-spreading - + ), }, ), @@ -252,7 +252,7 @@ export const closeoutColumns = (moveLockFlag, ppmCloseoutGBLOC, ppmCloseoutOrigi isFilterable: true, Filter: (props) => ( // eslint-disable-next-line react/jsx-props-no-spreading - + ), }, ), From c19a339727adf751c9f8cf686a4aa473c66d5b05 Mon Sep 17 00:00:00 2001 From: Tae Jung Date: Fri, 20 Sep 2024 17:51:06 +0000 Subject: [PATCH 36/37] gen --- pkg/gen/ghcapi/embedded_spec.go | 8 +- pkg/gen/primev2api/embedded_spec.go | 118 ++++++++++++- pkg/gen/primev3api/embedded_spec.go | 246 +++++++++++++++++++++++++++- swagger/ghc.yaml | 8 +- swagger/prime_v2.yaml | 49 +++++- swagger/prime_v3.yaml | 102 +++++++++++- 6 files changed, 519 insertions(+), 12 deletions(-) diff --git a/pkg/gen/ghcapi/embedded_spec.go b/pkg/gen/ghcapi/embedded_spec.go index bc87561910d..ed1fb4cba96 100644 --- a/pkg/gen/ghcapi/embedded_spec.go +++ b/pkg/gen/ghcapi/embedded_spec.go @@ -5808,14 +5808,14 @@ func init() { }, "/transportation-offices": { "get": { - "description": "Returns the transportation offices matching the search query", + "description": "Returns the transportation offices matching the search query that is enabled for PPM closeout", "produces": [ "application/json" ], "tags": [ "transportationOffice" ], - "summary": "Returns the transportation offices matching the search query", + "summary": "Returns the transportation offices matching the search query that is enabled for PPM closeout", "operationId": "getTransportationOffices", "parameters": [ { @@ -21413,14 +21413,14 @@ func init() { }, "/transportation-offices": { "get": { - "description": "Returns the transportation offices matching the search query", + "description": "Returns the transportation offices matching the search query that is enabled for PPM closeout", "produces": [ "application/json" ], "tags": [ "transportationOffice" ], - "summary": "Returns the transportation offices matching the search query", + "summary": "Returns the transportation offices matching the search query that is enabled for PPM closeout", "operationId": "getTransportationOffices", "parameters": [ { diff --git a/pkg/gen/primev2api/embedded_spec.go b/pkg/gen/primev2api/embedded_spec.go index f2a0d786fdb..0d45c022097 100644 --- a/pkg/gen/primev2api/embedded_spec.go +++ b/pkg/gen/primev2api/embedded_spec.go @@ -131,6 +131,25 @@ func init() { "shipmentType": "HHG" } }, + "mobileHome": { + "summary": "Mobile Home Shipment", + "value": { + "counselorRemarks": "test", + "mobileHomeShipment": { + "heightFeet": 2, + "heightInches": 2, + "lengthFeet": 2, + "lengthInches": 0, + "make": "make", + "model": "model", + "widthFeet": 2, + "widthInches": 2, + "year": 1999 + }, + "moveTaskOrderID": "d4d95b22-2d9d-428b-9a11-284455aa87ba", + "shipmentType": "MOBILE_HOME" + } + }, "nts": { "summary": "NTS", "value": { @@ -544,7 +563,7 @@ func init() { } }, "CreateBoatShipment": { - "description": "Creation object containing the ` + "`" + `PPM` + "`" + ` shipmentType specific data, not used for other shipment types.", + "description": "Creation object containing the ` + "`" + `Boat` + "`" + ` shipmentType specific data, not used for other shipment types.", "type": "object", "required": [ "year", @@ -676,6 +695,44 @@ func init() { } } }, + "CreateMobileHomeShipment": { + "description": "Creation object containing the ` + "`" + `MobileHome` + "`" + ` shipmentType specific data, not used for other shipment types.", + "type": "object", + "required": [ + "year", + "make", + "model", + "lengthInInches", + "widthInInches", + "heightInInches" + ], + "properties": { + "heightInInches": { + "description": "Height of the Mobile Home in inches", + "type": "integer" + }, + "lengthInInches": { + "description": "Length of the Mobile Home in inches", + "type": "integer" + }, + "make": { + "description": "Make of the Mobile Home", + "type": "string" + }, + "model": { + "description": "Model of the Mobile Home", + "type": "string" + }, + "widthInInches": { + "description": "Width of the Mobile Home in inches", + "type": "integer" + }, + "year": { + "description": "Year of the Mobile Home", + "type": "integer" + } + } + }, "CreatePPMShipment": { "description": "Creation object containing the ` + "`" + `PPM` + "`" + ` shipmentType specific data, not used for other shipment types.", "type": "object", @@ -3503,6 +3560,25 @@ func init() { "shipmentType": "HHG" } }, + "mobileHome": { + "summary": "Mobile Home Shipment", + "value": { + "counselorRemarks": "test", + "mobileHomeShipment": { + "heightFeet": 2, + "heightInches": 2, + "lengthFeet": 2, + "lengthInches": 0, + "make": "make", + "model": "model", + "widthFeet": 2, + "widthInches": 2, + "year": 1999 + }, + "moveTaskOrderID": "d4d95b22-2d9d-428b-9a11-284455aa87ba", + "shipmentType": "MOBILE_HOME" + } + }, "nts": { "summary": "NTS", "value": { @@ -3953,7 +4029,7 @@ func init() { } }, "CreateBoatShipment": { - "description": "Creation object containing the ` + "`" + `PPM` + "`" + ` shipmentType specific data, not used for other shipment types.", + "description": "Creation object containing the ` + "`" + `Boat` + "`" + ` shipmentType specific data, not used for other shipment types.", "type": "object", "required": [ "year", @@ -4085,6 +4161,44 @@ func init() { } } }, + "CreateMobileHomeShipment": { + "description": "Creation object containing the ` + "`" + `MobileHome` + "`" + ` shipmentType specific data, not used for other shipment types.", + "type": "object", + "required": [ + "year", + "make", + "model", + "lengthInInches", + "widthInInches", + "heightInInches" + ], + "properties": { + "heightInInches": { + "description": "Height of the Mobile Home in inches", + "type": "integer" + }, + "lengthInInches": { + "description": "Length of the Mobile Home in inches", + "type": "integer" + }, + "make": { + "description": "Make of the Mobile Home", + "type": "string" + }, + "model": { + "description": "Model of the Mobile Home", + "type": "string" + }, + "widthInInches": { + "description": "Width of the Mobile Home in inches", + "type": "integer" + }, + "year": { + "description": "Year of the Mobile Home", + "type": "integer" + } + } + }, "CreatePPMShipment": { "description": "Creation object containing the ` + "`" + `PPM` + "`" + ` shipmentType specific data, not used for other shipment types.", "type": "object", diff --git a/pkg/gen/primev3api/embedded_spec.go b/pkg/gen/primev3api/embedded_spec.go index 0cb5f3e7eaa..0ee15806bd0 100644 --- a/pkg/gen/primev3api/embedded_spec.go +++ b/pkg/gen/primev3api/embedded_spec.go @@ -131,6 +131,25 @@ func init() { "shipmentType": "HHG" } }, + "mobileHome": { + "summary": "Mobile Home Shipment", + "value": { + "counselorRemarks": "test", + "mobileHomeShipment": { + "heightFeet": 2, + "heightInches": 2, + "lengthFeet": 2, + "lengthInches": 0, + "make": "make", + "model": "model", + "widthFeet": 2, + "widthInches": 2, + "year": 1999 + }, + "moveTaskOrderID": "d4d95b22-2d9d-428b-9a11-284455aa87ba", + "shipmentType": "MOBILE_HOME" + } + }, "nts": { "summary": "NTS", "value": { @@ -640,7 +659,7 @@ func init() { } }, "CreateBoatShipment": { - "description": "Creation object containing the ` + "`" + `PPM` + "`" + ` shipmentType specific data, not used for other shipment types.", + "description": "Creation object containing the ` + "`" + `Boat` + "`" + ` shipmentType specific data, not used for other shipment types.", "type": "object", "required": [ "year", @@ -729,6 +748,9 @@ func init() { "format": "uuid", "example": "1f2270c7-7166-40ae-981e-b200ebdf3054" }, + "mobileHomeShipment": { + "$ref": "#/definitions/CreateMobileHomeShipment" + }, "moveTaskOrderID": { "description": "The ID of the move this new shipment is for.", "type": "string", @@ -775,6 +797,44 @@ func init() { } } }, + "CreateMobileHomeShipment": { + "description": "Creation object containing the ` + "`" + `MobileHome` + "`" + ` shipmentType specific data, not used for other shipment types.", + "type": "object", + "required": [ + "year", + "make", + "model", + "lengthInInches", + "widthInInches", + "heightInInches" + ], + "properties": { + "heightInInches": { + "description": "Height of the Mobile Home in inches", + "type": "integer" + }, + "lengthInInches": { + "description": "Length of the Mobile Home in inches", + "type": "integer" + }, + "make": { + "description": "Make of the Mobile Home", + "type": "string" + }, + "model": { + "description": "Model of the Mobile Home", + "type": "string" + }, + "widthInInches": { + "description": "Width of the Mobile Home in inches", + "type": "integer" + }, + "year": { + "description": "Year of the Mobile Home", + "type": "integer" + } + } + }, "CreatePPMShipment": { "description": "Creation object containing the ` + "`" + `PPM` + "`" + ` shipmentType specific data, not used for other shipment types.", "type": "object", @@ -1719,6 +1779,9 @@ func init() { "readOnly": true, "example": "1f2270c7-7166-40ae-981e-b200ebdf3054" }, + "mobileHomeShipment": { + "$ref": "#/definitions/MobileHome" + }, "moveTaskOrderID": { "description": "The ID of the move for this shipment.", "type": "string", @@ -1872,6 +1935,64 @@ func init() { "$ref": "#/definitions/MTOShipmentWithoutServiceItems" } }, + "MobileHome": { + "description": "A mobile home is a type of shipment that a service member moves a mobile home.", + "properties": { + "createdAt": { + "description": "Timestamp of when a property of this object was created (UTC)", + "type": "string", + "format": "date-time", + "readOnly": true + }, + "eTag": { + "description": "A hash unique to this shipment that should be used as the \"If-Match\" header for any updates.", + "type": "string", + "readOnly": true + }, + "heightInInches": { + "type": "integer" + }, + "id": { + "description": "Primary auto-generated unique identifier of the Mobile Home object", + "type": "string", + "format": "uuid", + "readOnly": true, + "example": "1f2270c7-7166-40ae-981e-b200ebdf3054" + }, + "lengthInInches": { + "type": "integer" + }, + "make": { + "description": "The make of the mobile home", + "type": "string" + }, + "model": { + "description": "The model of the mobile home.", + "type": "string" + }, + "shipmentId": { + "description": "The id of the parent MTOShipment object", + "type": "string", + "format": "uuid", + "readOnly": true, + "example": "1f2270c7-7166-40ae-981e-b200ebdf3054" + }, + "updatedAt": { + "description": "Timestamp of when a property of this object was last updated (UTC)", + "type": "string", + "format": "date-time", + "readOnly": true + }, + "widthInInches": { + "type": "integer" + }, + "year": { + "description": "The year the mobile home was made.", + "type": "integer" + } + }, + "x-nullable": true + }, "MoveTaskOrder": { "type": "object", "required": [ @@ -3745,6 +3866,25 @@ func init() { "shipmentType": "HHG" } }, + "mobileHome": { + "summary": "Mobile Home Shipment", + "value": { + "counselorRemarks": "test", + "mobileHomeShipment": { + "heightFeet": 2, + "heightInches": 2, + "lengthFeet": 2, + "lengthInches": 0, + "make": "make", + "model": "model", + "widthFeet": 2, + "widthInches": 2, + "year": 1999 + }, + "moveTaskOrderID": "d4d95b22-2d9d-428b-9a11-284455aa87ba", + "shipmentType": "MOBILE_HOME" + } + }, "nts": { "summary": "NTS", "value": { @@ -4291,7 +4431,7 @@ func init() { } }, "CreateBoatShipment": { - "description": "Creation object containing the ` + "`" + `PPM` + "`" + ` shipmentType specific data, not used for other shipment types.", + "description": "Creation object containing the ` + "`" + `Boat` + "`" + ` shipmentType specific data, not used for other shipment types.", "type": "object", "required": [ "year", @@ -4380,6 +4520,9 @@ func init() { "format": "uuid", "example": "1f2270c7-7166-40ae-981e-b200ebdf3054" }, + "mobileHomeShipment": { + "$ref": "#/definitions/CreateMobileHomeShipment" + }, "moveTaskOrderID": { "description": "The ID of the move this new shipment is for.", "type": "string", @@ -4426,6 +4569,44 @@ func init() { } } }, + "CreateMobileHomeShipment": { + "description": "Creation object containing the ` + "`" + `MobileHome` + "`" + ` shipmentType specific data, not used for other shipment types.", + "type": "object", + "required": [ + "year", + "make", + "model", + "lengthInInches", + "widthInInches", + "heightInInches" + ], + "properties": { + "heightInInches": { + "description": "Height of the Mobile Home in inches", + "type": "integer" + }, + "lengthInInches": { + "description": "Length of the Mobile Home in inches", + "type": "integer" + }, + "make": { + "description": "Make of the Mobile Home", + "type": "string" + }, + "model": { + "description": "Model of the Mobile Home", + "type": "string" + }, + "widthInInches": { + "description": "Width of the Mobile Home in inches", + "type": "integer" + }, + "year": { + "description": "Year of the Mobile Home", + "type": "integer" + } + } + }, "CreatePPMShipment": { "description": "Creation object containing the ` + "`" + `PPM` + "`" + ` shipmentType specific data, not used for other shipment types.", "type": "object", @@ -5370,6 +5551,9 @@ func init() { "readOnly": true, "example": "1f2270c7-7166-40ae-981e-b200ebdf3054" }, + "mobileHomeShipment": { + "$ref": "#/definitions/MobileHome" + }, "moveTaskOrderID": { "description": "The ID of the move for this shipment.", "type": "string", @@ -5523,6 +5707,64 @@ func init() { "$ref": "#/definitions/MTOShipmentWithoutServiceItems" } }, + "MobileHome": { + "description": "A mobile home is a type of shipment that a service member moves a mobile home.", + "properties": { + "createdAt": { + "description": "Timestamp of when a property of this object was created (UTC)", + "type": "string", + "format": "date-time", + "readOnly": true + }, + "eTag": { + "description": "A hash unique to this shipment that should be used as the \"If-Match\" header for any updates.", + "type": "string", + "readOnly": true + }, + "heightInInches": { + "type": "integer" + }, + "id": { + "description": "Primary auto-generated unique identifier of the Mobile Home object", + "type": "string", + "format": "uuid", + "readOnly": true, + "example": "1f2270c7-7166-40ae-981e-b200ebdf3054" + }, + "lengthInInches": { + "type": "integer" + }, + "make": { + "description": "The make of the mobile home", + "type": "string" + }, + "model": { + "description": "The model of the mobile home.", + "type": "string" + }, + "shipmentId": { + "description": "The id of the parent MTOShipment object", + "type": "string", + "format": "uuid", + "readOnly": true, + "example": "1f2270c7-7166-40ae-981e-b200ebdf3054" + }, + "updatedAt": { + "description": "Timestamp of when a property of this object was last updated (UTC)", + "type": "string", + "format": "date-time", + "readOnly": true + }, + "widthInInches": { + "type": "integer" + }, + "year": { + "description": "The year the mobile home was made.", + "type": "integer" + } + }, + "x-nullable": true + }, "MoveTaskOrder": { "type": "object", "required": [ diff --git a/swagger/ghc.yaml b/swagger/ghc.yaml index 1517f2c9abc..5f8e297f4d8 100644 --- a/swagger/ghc.yaml +++ b/swagger/ghc.yaml @@ -4003,8 +4003,12 @@ paths: get: produces: - application/json - summary: Returns the transportation offices matching the search query - description: Returns the transportation offices matching the search query + summary: >- + Returns the transportation offices matching the search query that is + enabled for PPM closeout + description: >- + Returns the transportation offices matching the search query that is + enabled for PPM closeout operationId: getTransportationOffices tags: - transportationOffice diff --git a/swagger/prime_v2.yaml b/swagger/prime_v2.yaml index f325b2138d4..a1687a48444 100644 --- a/swagger/prime_v2.yaml +++ b/swagger/prime_v2.yaml @@ -222,6 +222,22 @@ paths: counselorRemarks: test moveTaskOrderID: d4d95b22-2d9d-428b-9a11-284455aa87ba shipmentType: HAUL_AWAY + mobileHome: + summary: Mobile Home Shipment + value: + mobileHomeShipment: + heightFeet: 2 + heightInches: 2 + lengthFeet: 2 + lengthInches: 0 + make: make + model: model + widthFeet: 2 + widthInches: 2 + year: 1999 + counselorRemarks: test + moveTaskOrderID: d4d95b22-2d9d-428b-9a11-284455aa87ba + shipmentType: MOBILE_HOME responses: '200': description: Successfully created a MTO shipment. @@ -781,7 +797,7 @@ definitions: - hasProGear CreateBoatShipment: description: >- - Creation object containing the `PPM` shipmentType specific data, not used + Creation object containing the `Boat` shipmentType specific data, not used for other shipment types. type: object properties: @@ -818,6 +834,37 @@ definitions: - widthInInches - heightInInches - hasTrailer + CreateMobileHomeShipment: + description: >- + Creation object containing the `MobileHome` shipmentType specific data, + not used for other shipment types. + type: object + properties: + year: + type: integer + description: Year of the Mobile Home + make: + type: string + description: Make of the Mobile Home + model: + type: string + description: Model of the Mobile Home + lengthInInches: + type: integer + description: Length of the Mobile Home in inches + widthInInches: + type: integer + description: Width of the Mobile Home in inches + heightInInches: + type: integer + description: Height of the Mobile Home in inches + required: + - year + - make + - model + - lengthInInches + - widthInInches + - heightInInches MTOShipment: type: object properties: diff --git a/swagger/prime_v3.yaml b/swagger/prime_v3.yaml index 2f59100a3e6..7ce3a703242 100644 --- a/swagger/prime_v3.yaml +++ b/swagger/prime_v3.yaml @@ -214,6 +214,22 @@ paths: counselorRemarks: test moveTaskOrderID: d4d95b22-2d9d-428b-9a11-284455aa87ba shipmentType: HAUL_AWAY + mobileHome: + summary: Mobile Home Shipment + value: + mobileHomeShipment: + heightFeet: 2 + heightInches: 2 + lengthFeet: 2 + lengthInches: 0 + make: make + model: model + widthFeet: 2 + widthInches: 2 + year: 1999 + counselorRemarks: test + moveTaskOrderID: d4d95b22-2d9d-428b-9a11-284455aa87ba + shipmentType: MOBILE_HOME responses: '200': description: Successfully created a MTO shipment. @@ -678,6 +694,8 @@ definitions: $ref: '#/definitions/CreatePPMShipment' boatShipment: $ref: '#/definitions/CreateBoatShipment' + mobileHomeShipment: + $ref: '#/definitions/CreateMobileHomeShipment' required: - moveTaskOrderID - shipmentType @@ -774,7 +792,7 @@ definitions: - hasProGear CreateBoatShipment: description: >- - Creation object containing the `PPM` shipmentType specific data, not used + Creation object containing the `Boat` shipmentType specific data, not used for other shipment types. type: object properties: @@ -811,6 +829,37 @@ definitions: - widthInInches - heightInInches - hasTrailer + CreateMobileHomeShipment: + description: >- + Creation object containing the `MobileHome` shipmentType specific data, + not used for other shipment types. + type: object + properties: + year: + type: integer + description: Year of the Mobile Home + make: + type: string + description: Make of the Mobile Home + model: + type: string + description: Model of the Mobile Home + lengthInInches: + type: integer + description: Length of the Mobile Home in inches + widthInInches: + type: integer + description: Width of the Mobile Home in inches + heightInInches: + type: integer + description: Height of the Mobile Home in inches + required: + - year + - make + - model + - lengthInInches + - widthInInches + - heightInInches MTOShipment: type: object properties: @@ -2634,6 +2683,55 @@ definitions: - heightInInches - hasTrailer - eTag + MobileHome: + description: >- + A mobile home is a type of shipment that a service member moves a mobile + home. + x-nullable: true + properties: + id: + description: Primary auto-generated unique identifier of the Mobile Home object + example: 1f2270c7-7166-40ae-981e-b200ebdf3054 + format: uuid + type: string + readOnly: true + shipmentId: + description: The id of the parent MTOShipment object + example: 1f2270c7-7166-40ae-981e-b200ebdf3054 + format: uuid + type: string + readOnly: true + make: + description: The make of the mobile home + type: string + model: + description: The model of the mobile home. + type: string + year: + description: The year the mobile home was made. + type: integer + lengthInInches: + type: integer + widthInInches: + type: integer + heightInInches: + type: integer + updatedAt: + description: Timestamp of when a property of this object was last updated (UTC) + format: date-time + type: string + readOnly: true + createdAt: + description: Timestamp of when a property of this object was created (UTC) + format: date-time + type: string + readOnly: true + eTag: + description: >- + A hash unique to this shipment that should be used as the "If-Match" + header for any updates. + type: string + readOnly: true ShipmentAddressUpdateStatus: type: string title: Status @@ -2948,6 +3046,8 @@ definitions: $ref: '#/definitions/PPMShipment' boatShipment: $ref: '#/definitions/BoatShipment' + mobileHomeShipment: + $ref: '#/definitions/MobileHome' deliveryAddressUpdate: $ref: '#/definitions/ShipmentAddressUpdate' eTag: From 48c64ce7e8dc27e3f16808fe24d909e9c55c5b37 Mon Sep 17 00:00:00 2001 From: Tae Jung Date: Fri, 20 Sep 2024 17:53:10 +0000 Subject: [PATCH 37/37] missing conflict --- .../shipment_summary_worksheet.go | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/pkg/services/shipment_summary_worksheet/shipment_summary_worksheet.go b/pkg/services/shipment_summary_worksheet/shipment_summary_worksheet.go index 2bab372e227..d388dc3700d 100644 --- a/pkg/services/shipment_summary_worksheet/shipment_summary_worksheet.go +++ b/pkg/services/shipment_summary_worksheet/shipment_summary_worksheet.go @@ -722,6 +722,35 @@ func FormatAllSITSForPaymentPacket(expenseDocuments models.MovingExpenses) WorkS return formattedSIT } +func (s SSWPPMComputer) calculateShipmentTotalWeight(ppmShipment models.PPMShipment, weightAllotment models.SSWMaxWeightEntitlement) unit.Pound { + + var err error + var ppmActualWeight unit.Pound + var maxLimit unit.Pound + + // Set maxLimit equal to the maximum weight entitlement or the allowable weight, whichever is lower + if weightAllotment.TotalWeight < weightAllotment.Entitlement { + maxLimit = weightAllotment.TotalWeight + } else { + maxLimit = weightAllotment.Entitlement + } + + // Get the actual weight of the ppmShipment + if len(ppmShipment.WeightTickets) > 0 { + ppmActualWeight, err = s.PPMCloseoutFetcher.GetActualWeight(&ppmShipment) + if err != nil { + return 0 + } + } + + // If actual weight is less than the lessor of maximum weight entitlement or the allowable weight, then use ppmActualWeight + if ppmActualWeight < maxLimit { + return ppmActualWeight + } else { + return maxLimit + } +} + // FormatAllSITs formats SIT line items for the Shipment Summary Worksheet AOA Packet func FormatAllSITSForAOAPacket(ppm models.PPMShipment) WorkSheetSIT { formattedSIT := WorkSheetSIT{}