Skip to content

Commit

Permalink
Merge branch 'main' into b-21061-display-sit-authorized-end-dates-main
Browse files Browse the repository at this point in the history
  • Loading branch information
cameroncaci authored Sep 25, 2024
2 parents 9dc2d48 + 6f8012f commit 4d71a4c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
8 changes: 8 additions & 0 deletions pkg/handlers/primeapi/payment_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,14 @@ func (h CreatePaymentRequestHandler) Handle(params paymentrequestop.CreatePaymen
zap.Any("payload", payload))
return paymentrequestop.NewCreatePaymentRequestBadRequest().WithPayload(payload), err
default:
if e.Error() == "cannot have payment start date for additional days SIT earlier than or equal to SIT entry date" {
payload := payloads.ClientError(handlers.ConflictErrMessage, err.Error(), h.GetTraceIDFromRequest(params.HTTPRequest))

appCtx.Logger().Error("Payment Request",
zap.Any("payload", payload))
return paymentrequestop.NewCreatePaymentRequestConflict().WithPayload(payload), err
}

appCtx.Logger().Error("Payment Request",
zap.Any("payload", payload))
return paymentrequestop.NewCreatePaymentRequestInternalServerError().WithPayload(
Expand Down
13 changes: 13 additions & 0 deletions pkg/services/payment_request/payment_request_creator.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,19 @@ func (p *paymentRequestCreator) CreatePaymentRequest(appCtx appcontext.AppContex
return fmt.Errorf("failed to create payment service item param [%s]: %w for %s", paymentServiceItemParam.ServiceItemParamKeyID, err, errMessageString)
}

// check if service item param is for SIT Payment start/end
if param.IncomingKey == "SITPaymentRequestStart" || param.IncomingKey == "SITPaymentRequestEnd" {
paymentDate, err := time.Parse("2006-01-02", param.Value)
if err != nil {
errStr := "failed to parse " + param.IncomingKey
return apperror.NewBadDataError(errStr)
}

if paymentServiceItem.MTOServiceItem.SITEntryDate != nil && !paymentDate.After(*paymentServiceItem.MTOServiceItem.SITEntryDate) {
return apperror.NewConflictError(paymentRequestArg.ID, "cannot have payment start date for additional days SIT earlier than or equal to SIT entry date")
}
}

if param.ID != uuid.Nil && key != nil && value != nil {
incomingMTOServiceItemParams[*key] = *value
newPaymentServiceItemParams = append(newPaymentServiceItemParams, param)
Expand Down
14 changes: 10 additions & 4 deletions pkg/testdatagen/scenario/shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -5214,24 +5214,30 @@ func createHHGWithPaymentServiceItems(

// An origin and destination SIT would normally not be on the same payment request so the TIO totals will appear
// off. Refer to the PARSIT move to see a reviewed and pending payment request with origin and destination SIT.
doaPaymentStartDate := originEntryDate.Add(15 * 24 * time.Hour)
doaPaymentEndDate := originDepartureDate.Add(15 * 24 * time.Hour)

ddaPaymentStartDate := destEntryDate.Add(15 * 24 * time.Hour)
daaPaymentEndDate := destDepartureDate.Add(15 * 24 * time.Hour)

doasitPaymentParams := []models.PaymentServiceItemParam{
{
IncomingKey: models.ServiceItemParamNameSITPaymentRequestStart.String(),
Value: originEntryDate.Format("2006-01-02"),
Value: doaPaymentStartDate.Format("2006-01-02"),
},
{
IncomingKey: models.ServiceItemParamNameSITPaymentRequestEnd.String(),
Value: originDepartureDate.Format("2006-01-02"),
Value: doaPaymentEndDate.Format("2006-01-02"),
}}

ddasitPaymentParams := []models.PaymentServiceItemParam{
{
IncomingKey: models.ServiceItemParamNameSITPaymentRequestStart.String(),
Value: destEntryDate.Format("2006-01-02"),
Value: ddaPaymentStartDate.Format("2006-01-02"),
},
{
IncomingKey: models.ServiceItemParamNameSITPaymentRequestEnd.String(),
Value: destDepartureDate.Format("2006-01-02"),
Value: daaPaymentEndDate.Format("2006-01-02"),
}}

// Ordering the service items based on approved date to ensure the DDFSIT is after the DOASIT.
Expand Down

0 comments on commit 4d71a4c

Please sign in to comment.