From 6ea8f6561d334cb6a0cc9b9538e08de140924874 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Aug 2023 11:19:02 +0000 Subject: [PATCH 001/138] Bump github/webpack-bundlesize-compare-action from 1.8.1 to 1.8.2 Bumps [github/webpack-bundlesize-compare-action](https://github.com/github/webpack-bundlesize-compare-action) from 1.8.1 to 1.8.2. - [Release notes](https://github.com/github/webpack-bundlesize-compare-action/releases) - [Commits](https://github.com/github/webpack-bundlesize-compare-action/compare/v1.8.1...v1.8.2) --- updated-dependencies: - dependency-name: github/webpack-bundlesize-compare-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/analyze-bundle.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/analyze-bundle.yml b/.github/workflows/analyze-bundle.yml index cebc2e9c0a2..76cdae9c785 100644 --- a/.github/workflows/analyze-bundle.yml +++ b/.github/workflows/analyze-bundle.yml @@ -115,7 +115,7 @@ jobs: pull-requests: write steps: - uses: actions/download-artifact@v3 - - uses: github/webpack-bundlesize-compare-action@v1.8.1 + - uses: github/webpack-bundlesize-compare-action@v1.8.2 with: github-token: ${{ secrets.GITHUB_TOKEN }} current-stats-json-path: ./head-stats/bundle-stats.json From 61e4d58f889c26a3e727238acee5b934afe2d660 Mon Sep 17 00:00:00 2001 From: Reggie Riser Date: Mon, 31 Jul 2023 16:30:21 +0000 Subject: [PATCH 002/138] Refactored current FA2 segment code in anticipation of additional segments --- .../ghc_payment_request_invoice_generator.go | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/pkg/services/invoice/ghc_payment_request_invoice_generator.go b/pkg/services/invoice/ghc_payment_request_invoice_generator.go index dcff9281f2f..88d3b25e154 100644 --- a/pkg/services/invoice/ghc_payment_request_invoice_generator.go +++ b/pkg/services/invoice/ghc_payment_request_invoice_generator.go @@ -623,24 +623,26 @@ func (g ghcPaymentRequestInvoiceGenerator) createLoaSegments(orders models.Order AgencyQualifierCode: agencyQualifierCode, } - fa2 := edisegment.FA2{ + // May have multiple FA2 segments: TAC, SAC (optional), and many long LOA values + var fa2s []edisegment.FA2 + + // TAC + fa2TAC := edisegment.FA2{ BreakdownStructureDetailCode: "TA", FinancialInformationCode: tac, } + fa2s = append(fa2s, fa2TAC) - if sac == "" { - - return fa1, []edisegment.FA2{fa2}, nil - - } - - fa2sac := edisegment.FA2{ - BreakdownStructureDetailCode: "ZZ", - FinancialInformationCode: sac, + // SAC (optional) + if sac != "" { + fa2SAC := edisegment.FA2{ + BreakdownStructureDetailCode: "ZZ", + FinancialInformationCode: sac, + } + fa2s = append(fa2s, fa2SAC) } - return fa1, []edisegment.FA2{fa2, fa2sac}, nil - + return fa1, fa2s, nil } func (g ghcPaymentRequestInvoiceGenerator) fetchPaymentServiceItemParam(appCtx appcontext.AppContext, serviceItemID uuid.UUID, key models.ServiceItemParamName) (models.PaymentServiceItemParam, error) { From 73b9c50a9e14b45668cd4bf927960e26a0c59271 Mon Sep 17 00:00:00 2001 From: Reggie Riser Date: Wed, 2 Aug 2023 19:04:56 +0000 Subject: [PATCH 003/138] Added code to query database and populate new long LOA segments --- pkg/edi/segment/fa2.go | 2 +- pkg/services/invoice/gex_sender_http_test.go | 12 +-- .../ghc_payment_request_invoice_generator.go | 101 +++++++++++++++++- 3 files changed, 103 insertions(+), 12 deletions(-) diff --git a/pkg/edi/segment/fa2.go b/pkg/edi/segment/fa2.go index 9469242092a..b54d475573e 100644 --- a/pkg/edi/segment/fa2.go +++ b/pkg/edi/segment/fa2.go @@ -6,7 +6,7 @@ import ( // FA2 represents the FA2 EDI segment type FA2 struct { - BreakdownStructureDetailCode string `validate:"oneof=ZZ TA"` + BreakdownStructureDetailCode string `validate:"oneof=ZZ TA A1 A2 A3 A4 A5 A6 B1 B2 B3 C1 C2 D1 D4 D6 D7 E1 E2 E3 F1 F3 G2 I1 J1 K6 L1 M1 N1 P5"` FinancialInformationCode string `validate:"min=1,max=80"` } diff --git a/pkg/services/invoice/gex_sender_http_test.go b/pkg/services/invoice/gex_sender_http_test.go index 548e5c03e8f..ae422ee495f 100644 --- a/pkg/services/invoice/gex_sender_http_test.go +++ b/pkg/services/invoice/gex_sender_http_test.go @@ -33,9 +33,7 @@ func (suite *GexSuite) TestSendToGexHTTP_Call() { })) resp, err := NewGexSenderHTTP(mockServer.URL, false, nil, "", ""). SendToGex(services.GEXChannelInvoice, bodyString, "test_transaction") - if resp == nil || err != nil { - suite.T().Fatal(err, "Failed mock request") - } + suite.FatalNoError(err, "Failed mock request") expectedStatus := http.StatusOK suite.Equal(expectedStatus, resp.StatusCode) @@ -44,9 +42,7 @@ func (suite *GexSuite) TestSendToGexHTTP_Call() { })) resp, err = NewGexSenderHTTP(mockServer.URL, false, nil, "", ""). SendToGex(services.GEXChannelInvoice, bodyString, "test_transaction") - if resp == nil || err != nil { - suite.T().Fatal(err, "Failed mock request") - } + suite.FatalNoError(err, "Failed mock request") expectedStatus = http.StatusInternalServerError suite.Equal(expectedStatus, resp.StatusCode) @@ -59,9 +55,7 @@ func (suite *GexSuite) TestSendToGexHTTP_QueryParams() { })) resp, err := NewGexSenderHTTP(mockServer.URL, false, nil, "", ""). SendToGex(services.GEXChannelInvoice, bodyString, "test_filename") - if resp == nil || err != nil { - suite.T().Fatal(err, "Failed mock request") - } + suite.FatalNoError(err, "Failed mock request") expectedStatus := http.StatusOK suite.Equal(expectedStatus, resp.StatusCode) diff --git a/pkg/services/invoice/ghc_payment_request_invoice_generator.go b/pkg/services/invoice/ghc_payment_request_invoice_generator.go index 88d3b25e154..37d65005631 100644 --- a/pkg/services/invoice/ghc_payment_request_invoice_generator.go +++ b/pkg/services/invoice/ghc_payment_request_invoice_generator.go @@ -558,7 +558,7 @@ func (g ghcPaymentRequestInvoiceGenerator) createOriginAndDestinationSegments(ap return nil } -func (g ghcPaymentRequestInvoiceGenerator) createLoaSegments(orders models.Order, shipment models.MTOShipment) (edisegment.FA1, []edisegment.FA2, error) { +func (g ghcPaymentRequestInvoiceGenerator) createLoaSegments(appCtx appcontext.AppContext, orders models.Order, shipment models.MTOShipment) (edisegment.FA1, []edisegment.FA2, error) { // We need to determine which TAC to use. We'll default to using the HHG TAC as that's what we've been doing // up to this point. But now we need to look at the service item's MTOShipment (if there is one -- some // service items like MS/CS aren't associated with a shipment) and see if it prefers the NTS TAC instead. @@ -642,9 +642,106 @@ func (g ghcPaymentRequestInvoiceGenerator) createLoaSegments(orders models.Order fa2s = append(fa2s, fa2SAC) } + fa2LongLoaSegments, err := g.createLongLoaSegments(appCtx, orders, tac) + if err != nil { + return edisegment.FA1{}, nil, err + } + fa2s = append(fa2s, fa2LongLoaSegments...) + return fa1, fa2s, nil } +func (g ghcPaymentRequestInvoiceGenerator) createLongLoaSegments(appCtx appcontext.AppContext, orders models.Order, tac string) ([]edisegment.FA2, error) { + var loa models.LineOfAccounting + + err := appCtx.DB().Q(). + Join("transportation_accounting_codes t", "t.loa_id = lines_of_accounting.id"). + Where("t.tac = ?", tac). + Where("? between loa_bgn_dt and loa_end_dt", orders.IssueDate). + First(&loa) + if err != nil { + switch err { + case sql.ErrNoRows: + // If no matching rows, don't include any long lines of accounting. + return nil, nil + default: + return nil, apperror.NewQueryError("lineOfAccounting", err, "Unexpected error") + } + } + + var fa2LongLoaSegments []edisegment.FA2 + + var concatDate *string + if (loa.LoaBgnDt != nil && !loa.LoaBgnDt.IsZero()) && + (loa.LoaEndDt != nil && !loa.LoaEndDt.IsZero()) { + fiscalYearStr := fmt.Sprintf("%d%d", loa.LoaBgnDt.Year(), loa.LoaEndDt.Year()) + concatDate = &fiscalYearStr + } + + // Create long LOA FA2 segments + segmentInputs := []struct { + detailCode string + infoCode *string + }{ + {"A1", loa.LoaDptID}, + {"A2", loa.LoaTnsfrDptNm}, + {"A3", concatDate}, + {"A4", loa.LoaBafID}, + {"A5", loa.LoaTrsySfxTx}, + {"A6", loa.LoaMajClmNm}, + {"B1", loa.LoaOpAgncyID}, + {"B2", loa.LoaAlltSnID}, + {"B3", loa.LoaUic}, + {"C1", loa.LoaPgmElmntID}, + {"C2", loa.LoaTskBdgtSblnTx}, + {"D1", loa.LoaDfAgncyAlctnRcpntID}, + {"D4", loa.LoaJbOrdNm}, + {"D6", loa.LoaSbaltmtRcpntID}, + {"D7", loa.LoaWkCntrRcpntNm}, + {"E1", loa.LoaMajRmbsmtSrcID}, + {"E2", loa.LoaDtlRmbsmtSrcID}, + {"E3", loa.LoaCustNm}, + {"F1", loa.LoaObjClsID}, + {"F3", loa.LoaSrvSrcID}, + {"G2", loa.LoaSpclIntrID}, + {"I1", loa.LoaBdgtAcntClsNm}, + {"J1", loa.LoaDocID}, + {"K6", loa.LoaClsRefID}, + {"L1", loa.LoaInstlAcntgActID}, + {"M1", loa.LoaLclInstlID}, + {"N1", loa.LoaFmsTrnsactnID}, + {"P5", loa.LoaDscTx}, + } + + for _, input := range segmentInputs { + fa2 := createLongLoaSegment(input.detailCode, input.infoCode) + if fa2 != nil { + fa2LongLoaSegments = append(fa2LongLoaSegments, *fa2) + } + } + + return fa2LongLoaSegments, nil +} + +func createLongLoaSegment(detailCode string, infoCode *string) *edisegment.FA2 { + if infoCode == nil || *infoCode == "" { + return nil + } + + value := *infoCode + + // Trim if it exceeds the 80 character limit of the FinancialInformationCode field + // TODO: Is it OK to trim or should we error? + if len(value) > 80 { + value = value[:80] + } + + return &edisegment.FA2{ + BreakdownStructureDetailCode: detailCode, + FinancialInformationCode: value, + } +} + func (g ghcPaymentRequestInvoiceGenerator) fetchPaymentServiceItemParam(appCtx appcontext.AppContext, serviceItemID uuid.UUID, key models.ServiceItemParamName) (models.PaymentServiceItemParam, error) { var paymentServiceItemParam models.PaymentServiceItemParam @@ -883,7 +980,7 @@ func (g ghcPaymentRequestInvoiceGenerator) generatePaymentServiceItemSegments(ap } - fa1, fa2s, err := g.createLoaSegments(orders, serviceItem.MTOServiceItem.MTOShipment) + fa1, fa2s, err := g.createLoaSegments(appCtx, orders, serviceItem.MTOServiceItem.MTOShipment) if err != nil { return segments, l3, err } From f7e05faa4b1849fff07f5d815d72e7faaa39c2d6 Mon Sep 17 00:00:00 2001 From: Reggie Riser Date: Fri, 4 Aug 2023 20:23:59 +0000 Subject: [PATCH 004/138] Added tests and made a few tweaks to error handling --- .../ghc_payment_request_invoice_generator.go | 28 ++- ..._payment_request_invoice_generator_test.go | 207 +++++++++++++++++- 2 files changed, 220 insertions(+), 15 deletions(-) diff --git a/pkg/services/invoice/ghc_payment_request_invoice_generator.go b/pkg/services/invoice/ghc_payment_request_invoice_generator.go index 37d65005631..36321e3ebea 100644 --- a/pkg/services/invoice/ghc_payment_request_invoice_generator.go +++ b/pkg/services/invoice/ghc_payment_request_invoice_generator.go @@ -5,6 +5,7 @@ import ( "fmt" "regexp" "strconv" + "strings" "github.com/benbjohnson/clock" "github.com/gofrs/uuid" @@ -683,6 +684,7 @@ func (g ghcPaymentRequestInvoiceGenerator) createLongLoaSegments(appCtx appconte detailCode string infoCode *string }{ + // If order of these changes, tests will also need to be adjusted. Using alpha order by detailCode. {"A1", loa.LoaDptID}, {"A2", loa.LoaTnsfrDptNm}, {"A3", concatDate}, @@ -714,7 +716,10 @@ func (g ghcPaymentRequestInvoiceGenerator) createLongLoaSegments(appCtx appconte } for _, input := range segmentInputs { - fa2 := createLongLoaSegment(input.detailCode, input.infoCode) + fa2, loaErr := createLongLoaSegment(input.detailCode, input.infoCode) + if loaErr != nil { + return nil, loaErr + } if fa2 != nil { fa2LongLoaSegments = append(fa2LongLoaSegments, *fa2) } @@ -723,23 +728,28 @@ func (g ghcPaymentRequestInvoiceGenerator) createLongLoaSegments(appCtx appconte return fa2LongLoaSegments, nil } -func createLongLoaSegment(detailCode string, infoCode *string) *edisegment.FA2 { - if infoCode == nil || *infoCode == "" { - return nil +func createLongLoaSegment(detailCode string, infoCode *string) (*edisegment.FA2, error) { + // If we don't have an infoCode value, then just ignore this segment + if infoCode == nil || strings.TrimSpace(*infoCode) == "" { + return nil, nil } - value := *infoCode - // Trim if it exceeds the 80 character limit of the FinancialInformationCode field - // TODO: Is it OK to trim or should we error? + // Make sure we have a detailCode + if len(detailCode) != 2 { + return nil, apperror.NewImplementationError("Detail code should have length 2") + } + + // The FinancialInformationCode field is limited to 80 characters, so make sure the value doesn't exceed + // that (given our LOA field schema types, it shouldn't unless we've made a mistake somewhere). if len(value) > 80 { - value = value[:80] + return nil, apperror.NewImplementationError(fmt.Sprintf("Value for FA2 code %s exceeds 80 character limit", detailCode)) } return &edisegment.FA2{ BreakdownStructureDetailCode: detailCode, FinancialInformationCode: value, - } + }, nil } func (g ghcPaymentRequestInvoiceGenerator) fetchPaymentServiceItemParam(appCtx appcontext.AppContext, serviceItemID uuid.UUID, key models.ServiceItemParamName) (models.PaymentServiceItemParam, error) { diff --git a/pkg/services/invoice/ghc_payment_request_invoice_generator_test.go b/pkg/services/invoice/ghc_payment_request_invoice_generator_test.go index 5305b455651..a905b571659 100644 --- a/pkg/services/invoice/ghc_payment_request_invoice_generator_test.go +++ b/pkg/services/invoice/ghc_payment_request_invoice_generator_test.go @@ -1396,9 +1396,11 @@ func (suite *GHCInvoiceSuite) TestNoApprovedPaymentServiceItems() { }) } -func (suite *GHCInvoiceSuite) TestTACs() { +func (suite *GHCInvoiceSuite) TestFA2s() { mockClock := clock.NewMock() currentTime := mockClock.Now() + sixMonthsBefore := currentTime.AddDate(0, -6, 0) + sixMonthsAfter := currentTime.AddDate(0, 6, 0) basicPaymentServiceItemParams := []factory.CreatePaymentServiceItemParams{ { Key: models.ServiceItemParamNameContractCode, @@ -1428,15 +1430,17 @@ func (suite *GHCInvoiceSuite) TestTACs() { ntsTAC := "2222" hhgSAC := "3333" + var move models.Move var mtoShipment models.MTOShipment var paymentRequest models.PaymentRequest setupTestData := func() { - move := factory.BuildMove(suite.DB(), []factory.Customization{ + move = factory.BuildMove(suite.DB(), []factory.Customization{ { Model: models.Order{ - TAC: &hhgTAC, - NtsTAC: &ntsTAC, + TAC: &hhgTAC, + NtsTAC: &ntsTAC, + IssueDate: currentTime, }, }, }, nil) @@ -1492,6 +1496,8 @@ func (suite *GHCInvoiceSuite) TestTACs() { mtoShipment.TACType = nil suite.MustSave(&mtoShipment) + // No long lines of accounting added, so there should be no extra FA2 segments + result, err := generator.Generate(suite.AppContextForTest(), paymentRequest, false) suite.NoError(err) suite.Len(result.ServiceItems[0].FA2s, 1) @@ -1504,6 +1510,8 @@ func (suite *GHCInvoiceSuite) TestTACs() { mtoShipment.TACType = &tacType suite.MustSave(&mtoShipment) + // No long lines of accounting added, so there should be no extra FA2 segments + result, err := generator.Generate(suite.AppContextForTest(), paymentRequest, false) suite.NoError(err) suite.Len(result.ServiceItems[0].FA2s, 1) @@ -1516,6 +1524,8 @@ func (suite *GHCInvoiceSuite) TestTACs() { mtoShipment.TACType = &tacType suite.MustSave(&mtoShipment) + // No long lines of accounting added, so there should be no extra FA2 segments + result, err := generator.Generate(suite.AppContextForTest(), paymentRequest, false) suite.NoError(err) suite.Len(result.ServiceItems[0].FA2s, 1) @@ -1530,6 +1540,8 @@ func (suite *GHCInvoiceSuite) TestTACs() { paymentRequest.MoveTaskOrder.Orders.TAC = nil suite.MustSave(&paymentRequest.MoveTaskOrder.Orders) + // No long lines of accounting added, so there should be no extra FA2 segments + _, err := generator.Generate(suite.AppContextForTest(), paymentRequest, false) suite.Error(err) suite.Contains(err.Error(), "Must have an HHG TAC value") @@ -1543,6 +1555,8 @@ func (suite *GHCInvoiceSuite) TestTACs() { paymentRequest.MoveTaskOrder.Orders.NtsTAC = nil suite.MustSave(&paymentRequest.MoveTaskOrder.Orders) + // No long lines of accounting added, so there should be no extra FA2 segments + _, err := generator.Generate(suite.AppContextForTest(), paymentRequest, false) suite.Error(err) suite.Contains(err.Error(), "Must have an NTS TAC value") @@ -1555,6 +1569,8 @@ func (suite *GHCInvoiceSuite) TestTACs() { paymentRequest.MoveTaskOrder.Orders.SAC = &hhgSAC suite.MustSave(&paymentRequest.MoveTaskOrder.Orders) + // No long lines of accounting added, so there should be no extra FA2 segments + result, err := generator.Generate(suite.AppContextForTest(), paymentRequest, false) suite.NoError(err) suite.Len(result.ServiceItems[0].FA2s, 2) @@ -1570,12 +1586,13 @@ func (suite *GHCInvoiceSuite) TestTACs() { paymentRequest.MoveTaskOrder.Orders.SAC = &hhgSAC suite.MustSave(&paymentRequest.MoveTaskOrder.Orders) + // No long lines of accounting added, so there should be no extra FA2 segments + result, err := generator.Generate(suite.AppContextForTest(), paymentRequest, false) suite.NoError(err) suite.Len(result.ServiceItems[0].FA2s, 2) suite.Equal(hhgTAC, result.ServiceItems[0].FA2s[0].FinancialInformationCode) suite.Equal(hhgSAC, result.ServiceItems[0].FA2s[1].FinancialInformationCode) - }) suite.Run("shipment with NTS SAC/SDN type set", func() { @@ -1584,6 +1601,8 @@ func (suite *GHCInvoiceSuite) TestTACs() { mtoShipment.TACType = &tacType suite.MustSave(&mtoShipment) + // No long lines of accounting added, so there should be no extra FA2 segments + result, err := generator.Generate(suite.AppContextForTest(), paymentRequest, false) suite.NoError(err) suite.Len(result.ServiceItems[0].FA2s, 1) @@ -1598,11 +1617,12 @@ func (suite *GHCInvoiceSuite) TestTACs() { paymentRequest.MoveTaskOrder.Orders.SAC = nil suite.MustSave(&paymentRequest.MoveTaskOrder.Orders) + // No long lines of accounting added, so there should be no extra FA2 segments + result, err := generator.Generate(suite.AppContextForTest(), paymentRequest, false) suite.NoError(err) suite.Len(result.ServiceItems[0].FA2s, 1) suite.Equal(ntsTAC, result.ServiceItems[0].FA2s[0].FinancialInformationCode) - }) suite.Run("shipment with HHG TAC set up and TAC, but no SAC/SDN; It will display TAC only", func() { @@ -1613,13 +1633,188 @@ func (suite *GHCInvoiceSuite) TestTACs() { paymentRequest.MoveTaskOrder.Orders.SAC = nil suite.MustSave(&paymentRequest.MoveTaskOrder.Orders) + // No long lines of accounting added, so there should be no extra FA2 segments + result, err := generator.Generate(suite.AppContextForTest(), paymentRequest, false) suite.NoError(err) suite.Len(result.ServiceItems[0].FA2s, 1) suite.Equal(hhgTAC, result.ServiceItems[0].FA2s[0].FinancialInformationCode) + }) + + suite.Run("shipment with complete long line of accounting", func() { + setupTestData() + + // Add TAC/LOA records with fully filled out LOA fields + loa := factory.BuildFullLineOfAccounting(nil) + loa.LoaBgnDt = &sixMonthsBefore + loa.LoaEndDt = &sixMonthsAfter + factory.BuildTransportationAccountingCode(suite.DB(), []factory.Customization{ + { + Model: models.TransportationAccountingCode{ + TAC: *move.Orders.TAC, + }, + }, + { + Model: loa, + }, + }, nil) + result, err := generator.Generate(suite.AppContextForTest(), paymentRequest, false) + suite.NoError(err) + + concatDate := fmt.Sprintf("%d%d", loa.LoaBgnDt.Year(), loa.LoaEndDt.Year()) + fa2Assertions := []struct { + expectedDetailCode string + expectedInfoCode *string + }{ + {"TA", move.Orders.TAC}, + {"A1", loa.LoaDptID}, + {"A2", loa.LoaTnsfrDptNm}, + {"A3", &concatDate}, + {"A4", loa.LoaBafID}, + {"A5", loa.LoaTrsySfxTx}, + {"A6", loa.LoaMajClmNm}, + {"B1", loa.LoaOpAgncyID}, + {"B2", loa.LoaAlltSnID}, + {"B3", loa.LoaUic}, + {"C1", loa.LoaPgmElmntID}, + {"C2", loa.LoaTskBdgtSblnTx}, + {"D1", loa.LoaDfAgncyAlctnRcpntID}, + {"D4", loa.LoaJbOrdNm}, + {"D6", loa.LoaSbaltmtRcpntID}, + {"D7", loa.LoaWkCntrRcpntNm}, + {"E1", loa.LoaMajRmbsmtSrcID}, + {"E2", loa.LoaDtlRmbsmtSrcID}, + {"E3", loa.LoaCustNm}, + {"F1", loa.LoaObjClsID}, + {"F3", loa.LoaSrvSrcID}, + {"G2", loa.LoaSpclIntrID}, + {"I1", loa.LoaBdgtAcntClsNm}, + {"J1", loa.LoaDocID}, + {"K6", loa.LoaClsRefID}, + {"L1", loa.LoaInstlAcntgActID}, + {"M1", loa.LoaLclInstlID}, + {"N1", loa.LoaFmsTrnsactnID}, + {"P5", loa.LoaDscTx}, + } + + suite.Len(result.ServiceItems[0].FA2s, len(fa2Assertions)) + for i, fa2Assertion := range fa2Assertions { + fa2Segment := result.ServiceItems[0].FA2s[i] + suite.Equal(fa2Assertion.expectedDetailCode, fa2Segment.BreakdownStructureDetailCode) + suite.Equal(*fa2Assertion.expectedInfoCode, fa2Segment.FinancialInformationCode) + } }) + suite.Run("shipment with nil/blank long line of accounting (except fiscal year)", func() { + setupTestData() + + // Add TAC/LOA records, with an LOA containing empty strings and nils + emptyString := "" + tac := factory.BuildTransportationAccountingCode(suite.DB(), []factory.Customization{ + { + Model: models.TransportationAccountingCode{ + TAC: *move.Orders.TAC, // TA + }, + }, + { + Model: models.LineOfAccounting{ + LoaDptID: &emptyString, // A1 + LoaTnsfrDptNm: &emptyString, // A2 + LoaBgnDt: &sixMonthsBefore, // A3 (first part) + LoaEndDt: &sixMonthsAfter, // A3 (second part) + // rest of fields will be nil + }, + }, + }, nil) + + result, err := generator.Generate(suite.AppContextForTest(), paymentRequest, false) + suite.NoError(err) + + concatDate := fmt.Sprintf("%d%d", tac.LineOfAccounting.LoaBgnDt.Year(), tac.LineOfAccounting.LoaEndDt.Year()) + fa2Assertions := []struct { + expectedDetailCode string + expectedInfoCode *string + }{ + {"TA", move.Orders.TAC}, + {"A3", &concatDate}, + } + + suite.Len(result.ServiceItems[0].FA2s, len(fa2Assertions)) + for i, fa2Assertion := range fa2Assertions { + fa2Segment := result.ServiceItems[0].FA2s[i] + suite.Equal(fa2Assertion.expectedDetailCode, fa2Segment.BreakdownStructureDetailCode) + suite.Equal(*fa2Assertion.expectedInfoCode, fa2Segment.FinancialInformationCode) + } + }) + + suite.Run("shipment with partial long line of accounting (except fiscal year)", func() { + setupTestData() + + // Add TAC/LOA records, with the LOA containing only some of the values + tac := factory.BuildTransportationAccountingCode(suite.DB(), []factory.Customization{ + { + Model: models.TransportationAccountingCode{ + TAC: *move.Orders.TAC, // TA + }, + }, + { + Model: models.LineOfAccounting{ + LoaSysID: models.IntPointer(123456), + LoaDptID: models.StringPointer("12"), // A1 + LoaTnsfrDptNm: models.StringPointer("1234"), // A2 + LoaBafID: models.StringPointer("1234"), // A4 + LoaTrsySfxTx: models.StringPointer("1234"), // A5 + LoaMajClmNm: models.StringPointer("1234"), // A6 + LoaOpAgncyID: models.StringPointer("1234"), // B1 + LoaAlltSnID: models.StringPointer("12345"), // B2 + LoaPgmElmntID: models.StringPointer("123456789012"), // C1 + LoaTskBdgtSblnTx: models.StringPointer("88888888"), // C2 + LoaDfAgncyAlctnRcpntID: models.StringPointer("1234"), // D1 + LoaJbOrdNm: models.StringPointer("1234567890"), // D4 + LoaSbaltmtRcpntID: models.StringPointer("1"), // D6 + LoaWkCntrRcpntNm: models.StringPointer("123456"), // D7 + LoaBgnDt: &sixMonthsBefore, // A3 (first part) + LoaEndDt: &sixMonthsAfter, // A3 (second part) + // rest of fields will be nil + }, + }, + }, nil) + + loa := tac.LineOfAccounting + + result, err := generator.Generate(suite.AppContextForTest(), paymentRequest, false) + suite.NoError(err) + + concatDate := fmt.Sprintf("%d%d", tac.LineOfAccounting.LoaBgnDt.Year(), tac.LineOfAccounting.LoaEndDt.Year()) + fa2Assertions := []struct { + expectedDetailCode string + expectedInfoCode *string + }{ + {"TA", move.Orders.TAC}, + {"A1", loa.LoaDptID}, + {"A2", loa.LoaTnsfrDptNm}, + {"A3", &concatDate}, + {"A4", loa.LoaBafID}, + {"A5", loa.LoaTrsySfxTx}, + {"A6", loa.LoaMajClmNm}, + {"B1", loa.LoaOpAgncyID}, + {"B2", loa.LoaAlltSnID}, + {"C1", loa.LoaPgmElmntID}, + {"C2", loa.LoaTskBdgtSblnTx}, + {"D1", loa.LoaDfAgncyAlctnRcpntID}, + {"D4", loa.LoaJbOrdNm}, + {"D6", loa.LoaSbaltmtRcpntID}, + {"D7", loa.LoaWkCntrRcpntNm}, + } + + suite.Len(result.ServiceItems[0].FA2s, len(fa2Assertions)) + for i, fa2Assertion := range fa2Assertions { + fa2Segment := result.ServiceItems[0].FA2s[i] + suite.Equal(fa2Assertion.expectedDetailCode, fa2Segment.BreakdownStructureDetailCode) + suite.Equal(*fa2Assertion.expectedInfoCode, fa2Segment.FinancialInformationCode) + } + }) } func (suite *GHCInvoiceSuite) TestDetermineDutyLocationPhoneLinesFunc() { From c9213005e49a3e495b6d13b0ef3429afa583a6b4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 8 Aug 2023 11:23:40 +0000 Subject: [PATCH 005/138] Bump alpine from 3.18.2 to 3.18.3 Bumps alpine from 3.18.2 to 3.18.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 ec7b405c8e4..1e914001481 100644 --- a/Dockerfile.e2e +++ b/Dockerfile.e2e @@ -1,4 +1,4 @@ -FROM alpine:3.18.2 +FROM alpine:3.18.3 # hadolint ignore=DL3017 RUN apk upgrade --no-cache busybox diff --git a/Dockerfile.migrations b/Dockerfile.migrations index 2e2fb81bac1..940312bc0c8 100644 --- a/Dockerfile.migrations +++ b/Dockerfile.migrations @@ -1,4 +1,4 @@ -FROM alpine:3.18.2 +FROM alpine:3.18.3 # hadolint ignore=DL3017 RUN apk upgrade --no-cache busybox diff --git a/Dockerfile.migrations_local b/Dockerfile.migrations_local index 791dd40900c..26449170fd3 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.18.2 +FROM alpine:3.18.3 # hadolint ignore=DL3017 RUN apk upgrade --no-cache busybox diff --git a/Dockerfile.reviewapp b/Dockerfile.reviewapp index c37e70992b8..a0fed64dd99 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.18.2 as migrate +FROM alpine:3.18.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 c737a4b5fd8..3b23897853f 100644 --- a/Dockerfile.tools +++ b/Dockerfile.tools @@ -1,4 +1,4 @@ -FROM alpine:3.18.2 +FROM alpine:3.18.3 # hadolint ignore=DL3017 RUN apk upgrade --no-cache busybox diff --git a/Dockerfile.tools_local b/Dockerfile.tools_local index 638fd327923..22a4ab6a459 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.18.2 +FROM alpine:3.18.3 # hadolint ignore=DL3017 RUN apk upgrade --no-cache busybox From 40e416988ff5507bc714536912ad247a8e82de60 Mon Sep 17 00:00:00 2001 From: Reggie Riser Date: Tue, 8 Aug 2023 18:19:37 +0000 Subject: [PATCH 006/138] Created custom type and constants for FA2 BreakdownStructureDetailCode --- pkg/edi/invoice/generator_test.go | 2 +- pkg/edi/segment/fa2.go | 77 +++++++++++++- pkg/edi/segment/fa2_test.go | 2 +- .../ghc_payment_request_invoice_generator.go | 64 +++++------ ..._payment_request_invoice_generator_test.go | 100 +++++++++--------- 5 files changed, 157 insertions(+), 88 deletions(-) diff --git a/pkg/edi/invoice/generator_test.go b/pkg/edi/invoice/generator_test.go index aaf42796215..9241412ceec 100644 --- a/pkg/edi/invoice/generator_test.go +++ b/pkg/edi/invoice/generator_test.go @@ -211,7 +211,7 @@ func MakeValidEdi() Invoice858C { }, FA2s: []edisegment.FA2{ { - BreakdownStructureDetailCode: "TA", + BreakdownStructureDetailCode: edisegment.FA2DetailCodeTA, FinancialInformationCode: "1234", }, }, diff --git a/pkg/edi/segment/fa2.go b/pkg/edi/segment/fa2.go index b54d475573e..95939cc66e2 100644 --- a/pkg/edi/segment/fa2.go +++ b/pkg/edi/segment/fa2.go @@ -4,15 +4,84 @@ import ( "fmt" ) +type FA2DetailCode string + +func (d FA2DetailCode) String() string { + return string(d) +} + +const ( + // FA2DetailCodeTA is Transportation Account Code (TAC) + FA2DetailCodeTA FA2DetailCode = "TA" + // FA2DetailCodeZZ is Mutually Defined + FA2DetailCodeZZ FA2DetailCode = "ZZ" + // FA2DetailCodeA1 is Department Indicator + FA2DetailCodeA1 FA2DetailCode = "A1" + // FA2DetailCodeA2 is Transfer from Department + FA2DetailCodeA2 FA2DetailCode = "A2" + // FA2DetailCodeA3 is Fiscal Year Indicator + FA2DetailCodeA3 FA2DetailCode = "A3" + // FA2DetailCodeA4 is Basic Symbol Number + FA2DetailCodeA4 FA2DetailCode = "A4" + // FA2DetailCodeA5 is Sub-class + FA2DetailCodeA5 FA2DetailCode = "A5" + // FA2DetailCodeA6 is Sub-Account Symbol + FA2DetailCodeA6 FA2DetailCode = "A6" + // FA2DetailCodeB1 is Budget Activity Number + FA2DetailCodeB1 FA2DetailCode = "B1" + // FA2DetailCodeB2 is Budget Sub-activity Number + FA2DetailCodeB2 FA2DetailCode = "B2" + // FA2DetailCodeB3 is Budget Program Activity + FA2DetailCodeB3 FA2DetailCode = "B3" + // FA2DetailCodeC1 is Program Element + FA2DetailCodeC1 FA2DetailCode = "C1" + // FA2DetailCodeC2 is Project Task or Budget Subline + FA2DetailCodeC2 FA2DetailCode = "C2" + // FA2DetailCodeD1 is Defense Agency Allocation Recipient + FA2DetailCodeD1 FA2DetailCode = "D1" + // FA2DetailCodeD4 is Component Sub-allocation Recipient + FA2DetailCodeD4 FA2DetailCode = "D4" + // FA2DetailCodeD6 is Sub-allotment Recipient + FA2DetailCodeD6 FA2DetailCode = "D6" + // FA2DetailCodeD7 is Work Center Recipient + FA2DetailCodeD7 FA2DetailCode = "D7" + // FA2DetailCodeE1 is Major Reimbursement Source Code + FA2DetailCodeE1 FA2DetailCode = "E1" + // FA2DetailCodeE2 is Detail Reimbursement Source Code + FA2DetailCodeE2 FA2DetailCode = "E2" + // FA2DetailCodeE3 is Customer Indicator + FA2DetailCodeE3 FA2DetailCode = "E3" + // FA2DetailCodeF1 is Object Class + FA2DetailCodeF1 FA2DetailCode = "F1" + // FA2DetailCodeF3 is Government or Public Sector Identifier + FA2DetailCodeF3 FA2DetailCode = "F3" + // FA2DetailCodeG2 is Special Interest Code or Special Program Cost Code + FA2DetailCodeG2 FA2DetailCode = "G2" + // FA2DetailCodeI1 is Abbreviated Department of Defense (DoD) Budget and Accounting Classification Code (BACC) + FA2DetailCodeI1 FA2DetailCode = "I1" + // FA2DetailCodeJ1 is Document or Record Reference Number + FA2DetailCodeJ1 FA2DetailCode = "J1" + // FA2DetailCodeK6 is Accounting Classification Reference Code + FA2DetailCodeK6 FA2DetailCode = "K6" + // FA2DetailCodeL1 is Accounting Installation Number + FA2DetailCodeL1 FA2DetailCode = "L1" + // FA2DetailCodeM1 is Local Installation Data + FA2DetailCodeM1 FA2DetailCode = "M1" + // FA2DetailCodeN1 is Transaction Type + FA2DetailCodeN1 FA2DetailCode = "N1" + // FA2DetailCodeP5 is Security Cooperation Case Line Item Identifier + FA2DetailCodeP5 FA2DetailCode = "P5" +) + // FA2 represents the FA2 EDI segment type FA2 struct { - BreakdownStructureDetailCode string `validate:"oneof=ZZ TA A1 A2 A3 A4 A5 A6 B1 B2 B3 C1 C2 D1 D4 D6 D7 E1 E2 E3 F1 F3 G2 I1 J1 K6 L1 M1 N1 P5"` - FinancialInformationCode string `validate:"min=1,max=80"` + BreakdownStructureDetailCode FA2DetailCode `validate:"oneof=TA ZZ A1 A2 A3 A4 A5 A6 B1 B2 B3 C1 C2 D1 D4 D6 D7 E1 E2 E3 F1 F3 G2 I1 J1 K6 L1 M1 N1 P5"` + FinancialInformationCode string `validate:"min=1,max=80"` } // StringArray converts FA2 to an array of strings func (s *FA2) StringArray() []string { - return []string{"FA2", s.BreakdownStructureDetailCode, s.FinancialInformationCode} + return []string{"FA2", s.BreakdownStructureDetailCode.String(), s.FinancialInformationCode} } // Parse parses an X12 string that's split into an array into the FA2 struct @@ -22,7 +91,7 @@ func (s *FA2) Parse(elements []string) error { return fmt.Errorf("FA2: Wrong number of elements, expected %d, got %d", expectedNumElements, len(elements)) } - s.BreakdownStructureDetailCode = elements[0] + s.BreakdownStructureDetailCode = FA2DetailCode(elements[0]) s.FinancialInformationCode = elements[1] return nil } diff --git a/pkg/edi/segment/fa2_test.go b/pkg/edi/segment/fa2_test.go index b9deba6ef1a..d47d46b5b1c 100644 --- a/pkg/edi/segment/fa2_test.go +++ b/pkg/edi/segment/fa2_test.go @@ -2,7 +2,7 @@ package edisegment func (suite *SegmentSuite) TestValidateFA2() { validFA2 := FA2{ - BreakdownStructureDetailCode: "TA", + BreakdownStructureDetailCode: FA2DetailCodeTA, FinancialInformationCode: "307", } diff --git a/pkg/services/invoice/ghc_payment_request_invoice_generator.go b/pkg/services/invoice/ghc_payment_request_invoice_generator.go index 36321e3ebea..ebefba2f5b7 100644 --- a/pkg/services/invoice/ghc_payment_request_invoice_generator.go +++ b/pkg/services/invoice/ghc_payment_request_invoice_generator.go @@ -629,7 +629,7 @@ func (g ghcPaymentRequestInvoiceGenerator) createLoaSegments(appCtx appcontext.A // TAC fa2TAC := edisegment.FA2{ - BreakdownStructureDetailCode: "TA", + BreakdownStructureDetailCode: edisegment.FA2DetailCodeTA, FinancialInformationCode: tac, } fa2s = append(fa2s, fa2TAC) @@ -637,7 +637,7 @@ func (g ghcPaymentRequestInvoiceGenerator) createLoaSegments(appCtx appcontext.A // SAC (optional) if sac != "" { fa2SAC := edisegment.FA2{ - BreakdownStructureDetailCode: "ZZ", + BreakdownStructureDetailCode: edisegment.FA2DetailCodeZZ, FinancialInformationCode: sac, } fa2s = append(fa2s, fa2SAC) @@ -681,38 +681,38 @@ func (g ghcPaymentRequestInvoiceGenerator) createLongLoaSegments(appCtx appconte // Create long LOA FA2 segments segmentInputs := []struct { - detailCode string + detailCode edisegment.FA2DetailCode infoCode *string }{ // If order of these changes, tests will also need to be adjusted. Using alpha order by detailCode. - {"A1", loa.LoaDptID}, - {"A2", loa.LoaTnsfrDptNm}, - {"A3", concatDate}, - {"A4", loa.LoaBafID}, - {"A5", loa.LoaTrsySfxTx}, - {"A6", loa.LoaMajClmNm}, - {"B1", loa.LoaOpAgncyID}, - {"B2", loa.LoaAlltSnID}, - {"B3", loa.LoaUic}, - {"C1", loa.LoaPgmElmntID}, - {"C2", loa.LoaTskBdgtSblnTx}, - {"D1", loa.LoaDfAgncyAlctnRcpntID}, - {"D4", loa.LoaJbOrdNm}, - {"D6", loa.LoaSbaltmtRcpntID}, - {"D7", loa.LoaWkCntrRcpntNm}, - {"E1", loa.LoaMajRmbsmtSrcID}, - {"E2", loa.LoaDtlRmbsmtSrcID}, - {"E3", loa.LoaCustNm}, - {"F1", loa.LoaObjClsID}, - {"F3", loa.LoaSrvSrcID}, - {"G2", loa.LoaSpclIntrID}, - {"I1", loa.LoaBdgtAcntClsNm}, - {"J1", loa.LoaDocID}, - {"K6", loa.LoaClsRefID}, - {"L1", loa.LoaInstlAcntgActID}, - {"M1", loa.LoaLclInstlID}, - {"N1", loa.LoaFmsTrnsactnID}, - {"P5", loa.LoaDscTx}, + {edisegment.FA2DetailCodeA1, loa.LoaDptID}, + {edisegment.FA2DetailCodeA2, loa.LoaTnsfrDptNm}, + {edisegment.FA2DetailCodeA3, concatDate}, + {edisegment.FA2DetailCodeA4, loa.LoaBafID}, + {edisegment.FA2DetailCodeA5, loa.LoaTrsySfxTx}, + {edisegment.FA2DetailCodeA6, loa.LoaMajClmNm}, + {edisegment.FA2DetailCodeB1, loa.LoaOpAgncyID}, + {edisegment.FA2DetailCodeB2, loa.LoaAlltSnID}, + {edisegment.FA2DetailCodeB3, loa.LoaUic}, + {edisegment.FA2DetailCodeC1, loa.LoaPgmElmntID}, + {edisegment.FA2DetailCodeC2, loa.LoaTskBdgtSblnTx}, + {edisegment.FA2DetailCodeD1, loa.LoaDfAgncyAlctnRcpntID}, + {edisegment.FA2DetailCodeD4, loa.LoaJbOrdNm}, + {edisegment.FA2DetailCodeD6, loa.LoaSbaltmtRcpntID}, + {edisegment.FA2DetailCodeD7, loa.LoaWkCntrRcpntNm}, + {edisegment.FA2DetailCodeE1, loa.LoaMajRmbsmtSrcID}, + {edisegment.FA2DetailCodeE2, loa.LoaDtlRmbsmtSrcID}, + {edisegment.FA2DetailCodeE3, loa.LoaCustNm}, + {edisegment.FA2DetailCodeF1, loa.LoaObjClsID}, + {edisegment.FA2DetailCodeF3, loa.LoaSrvSrcID}, + {edisegment.FA2DetailCodeG2, loa.LoaSpclIntrID}, + {edisegment.FA2DetailCodeI1, loa.LoaBdgtAcntClsNm}, + {edisegment.FA2DetailCodeJ1, loa.LoaDocID}, + {edisegment.FA2DetailCodeK6, loa.LoaClsRefID}, + {edisegment.FA2DetailCodeL1, loa.LoaInstlAcntgActID}, + {edisegment.FA2DetailCodeM1, loa.LoaLclInstlID}, + {edisegment.FA2DetailCodeN1, loa.LoaFmsTrnsactnID}, + {edisegment.FA2DetailCodeP5, loa.LoaDscTx}, } for _, input := range segmentInputs { @@ -728,7 +728,7 @@ func (g ghcPaymentRequestInvoiceGenerator) createLongLoaSegments(appCtx appconte return fa2LongLoaSegments, nil } -func createLongLoaSegment(detailCode string, infoCode *string) (*edisegment.FA2, error) { +func createLongLoaSegment(detailCode edisegment.FA2DetailCode, infoCode *string) (*edisegment.FA2, error) { // If we don't have an infoCode value, then just ignore this segment if infoCode == nil || strings.TrimSpace(*infoCode) == "" { return nil, nil diff --git a/pkg/services/invoice/ghc_payment_request_invoice_generator_test.go b/pkg/services/invoice/ghc_payment_request_invoice_generator_test.go index a905b571659..ae1ee009464 100644 --- a/pkg/services/invoice/ghc_payment_request_invoice_generator_test.go +++ b/pkg/services/invoice/ghc_payment_request_invoice_generator_test.go @@ -927,7 +927,7 @@ func (suite *GHCInvoiceSuite) TestAllGenerateEdi() { suite.Run("adds fa2 service item segment", func() { fa2 := result.ServiceItems[segmentOffset].FA2s - suite.Equal("TA", fa2[0].BreakdownStructureDetailCode) + suite.Equal(edisegment.FA2DetailCodeTA, fa2[0].BreakdownStructureDetailCode) suite.Equal(*paymentRequest.MoveTaskOrder.Orders.TAC, fa2[0].FinancialInformationCode) }) @@ -1664,38 +1664,38 @@ func (suite *GHCInvoiceSuite) TestFA2s() { concatDate := fmt.Sprintf("%d%d", loa.LoaBgnDt.Year(), loa.LoaEndDt.Year()) fa2Assertions := []struct { - expectedDetailCode string + expectedDetailCode edisegment.FA2DetailCode expectedInfoCode *string }{ - {"TA", move.Orders.TAC}, - {"A1", loa.LoaDptID}, - {"A2", loa.LoaTnsfrDptNm}, - {"A3", &concatDate}, - {"A4", loa.LoaBafID}, - {"A5", loa.LoaTrsySfxTx}, - {"A6", loa.LoaMajClmNm}, - {"B1", loa.LoaOpAgncyID}, - {"B2", loa.LoaAlltSnID}, - {"B3", loa.LoaUic}, - {"C1", loa.LoaPgmElmntID}, - {"C2", loa.LoaTskBdgtSblnTx}, - {"D1", loa.LoaDfAgncyAlctnRcpntID}, - {"D4", loa.LoaJbOrdNm}, - {"D6", loa.LoaSbaltmtRcpntID}, - {"D7", loa.LoaWkCntrRcpntNm}, - {"E1", loa.LoaMajRmbsmtSrcID}, - {"E2", loa.LoaDtlRmbsmtSrcID}, - {"E3", loa.LoaCustNm}, - {"F1", loa.LoaObjClsID}, - {"F3", loa.LoaSrvSrcID}, - {"G2", loa.LoaSpclIntrID}, - {"I1", loa.LoaBdgtAcntClsNm}, - {"J1", loa.LoaDocID}, - {"K6", loa.LoaClsRefID}, - {"L1", loa.LoaInstlAcntgActID}, - {"M1", loa.LoaLclInstlID}, - {"N1", loa.LoaFmsTrnsactnID}, - {"P5", loa.LoaDscTx}, + {edisegment.FA2DetailCodeTA, move.Orders.TAC}, + {edisegment.FA2DetailCodeA1, loa.LoaDptID}, + {edisegment.FA2DetailCodeA2, loa.LoaTnsfrDptNm}, + {edisegment.FA2DetailCodeA3, &concatDate}, + {edisegment.FA2DetailCodeA4, loa.LoaBafID}, + {edisegment.FA2DetailCodeA5, loa.LoaTrsySfxTx}, + {edisegment.FA2DetailCodeA6, loa.LoaMajClmNm}, + {edisegment.FA2DetailCodeB1, loa.LoaOpAgncyID}, + {edisegment.FA2DetailCodeB2, loa.LoaAlltSnID}, + {edisegment.FA2DetailCodeB3, loa.LoaUic}, + {edisegment.FA2DetailCodeC1, loa.LoaPgmElmntID}, + {edisegment.FA2DetailCodeC2, loa.LoaTskBdgtSblnTx}, + {edisegment.FA2DetailCodeD1, loa.LoaDfAgncyAlctnRcpntID}, + {edisegment.FA2DetailCodeD4, loa.LoaJbOrdNm}, + {edisegment.FA2DetailCodeD6, loa.LoaSbaltmtRcpntID}, + {edisegment.FA2DetailCodeD7, loa.LoaWkCntrRcpntNm}, + {edisegment.FA2DetailCodeE1, loa.LoaMajRmbsmtSrcID}, + {edisegment.FA2DetailCodeE2, loa.LoaDtlRmbsmtSrcID}, + {edisegment.FA2DetailCodeE3, loa.LoaCustNm}, + {edisegment.FA2DetailCodeF1, loa.LoaObjClsID}, + {edisegment.FA2DetailCodeF3, loa.LoaSrvSrcID}, + {edisegment.FA2DetailCodeG2, loa.LoaSpclIntrID}, + {edisegment.FA2DetailCodeI1, loa.LoaBdgtAcntClsNm}, + {edisegment.FA2DetailCodeJ1, loa.LoaDocID}, + {edisegment.FA2DetailCodeK6, loa.LoaClsRefID}, + {edisegment.FA2DetailCodeL1, loa.LoaInstlAcntgActID}, + {edisegment.FA2DetailCodeM1, loa.LoaLclInstlID}, + {edisegment.FA2DetailCodeN1, loa.LoaFmsTrnsactnID}, + {edisegment.FA2DetailCodeP5, loa.LoaDscTx}, } suite.Len(result.ServiceItems[0].FA2s, len(fa2Assertions)) @@ -1733,11 +1733,11 @@ func (suite *GHCInvoiceSuite) TestFA2s() { concatDate := fmt.Sprintf("%d%d", tac.LineOfAccounting.LoaBgnDt.Year(), tac.LineOfAccounting.LoaEndDt.Year()) fa2Assertions := []struct { - expectedDetailCode string + expectedDetailCode edisegment.FA2DetailCode expectedInfoCode *string }{ - {"TA", move.Orders.TAC}, - {"A3", &concatDate}, + {edisegment.FA2DetailCodeTA, move.Orders.TAC}, + {edisegment.FA2DetailCodeA3, &concatDate}, } suite.Len(result.ServiceItems[0].FA2s, len(fa2Assertions)) @@ -1788,24 +1788,24 @@ func (suite *GHCInvoiceSuite) TestFA2s() { concatDate := fmt.Sprintf("%d%d", tac.LineOfAccounting.LoaBgnDt.Year(), tac.LineOfAccounting.LoaEndDt.Year()) fa2Assertions := []struct { - expectedDetailCode string + expectedDetailCode edisegment.FA2DetailCode expectedInfoCode *string }{ - {"TA", move.Orders.TAC}, - {"A1", loa.LoaDptID}, - {"A2", loa.LoaTnsfrDptNm}, - {"A3", &concatDate}, - {"A4", loa.LoaBafID}, - {"A5", loa.LoaTrsySfxTx}, - {"A6", loa.LoaMajClmNm}, - {"B1", loa.LoaOpAgncyID}, - {"B2", loa.LoaAlltSnID}, - {"C1", loa.LoaPgmElmntID}, - {"C2", loa.LoaTskBdgtSblnTx}, - {"D1", loa.LoaDfAgncyAlctnRcpntID}, - {"D4", loa.LoaJbOrdNm}, - {"D6", loa.LoaSbaltmtRcpntID}, - {"D7", loa.LoaWkCntrRcpntNm}, + {edisegment.FA2DetailCodeTA, move.Orders.TAC}, + {edisegment.FA2DetailCodeA1, loa.LoaDptID}, + {edisegment.FA2DetailCodeA2, loa.LoaTnsfrDptNm}, + {edisegment.FA2DetailCodeA3, &concatDate}, + {edisegment.FA2DetailCodeA4, loa.LoaBafID}, + {edisegment.FA2DetailCodeA5, loa.LoaTrsySfxTx}, + {edisegment.FA2DetailCodeA6, loa.LoaMajClmNm}, + {edisegment.FA2DetailCodeB1, loa.LoaOpAgncyID}, + {edisegment.FA2DetailCodeB2, loa.LoaAlltSnID}, + {edisegment.FA2DetailCodeC1, loa.LoaPgmElmntID}, + {edisegment.FA2DetailCodeC2, loa.LoaTskBdgtSblnTx}, + {edisegment.FA2DetailCodeD1, loa.LoaDfAgncyAlctnRcpntID}, + {edisegment.FA2DetailCodeD4, loa.LoaJbOrdNm}, + {edisegment.FA2DetailCodeD6, loa.LoaSbaltmtRcpntID}, + {edisegment.FA2DetailCodeD7, loa.LoaWkCntrRcpntNm}, } suite.Len(result.ServiceItems[0].FA2s, len(fa2Assertions)) From e04c8d79f6c903a061ebb9ccaa0607b96e239757 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 9 Aug 2023 15:05:13 +0000 Subject: [PATCH 007/138] Bump golang.org/x/net from 0.12.0 to 0.14.0 Bumps [golang.org/x/net](https://github.com/golang/net) from 0.12.0 to 0.14.0. - [Commits](https://github.com/golang/net/compare/v0.12.0...v0.14.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 10 +++++----- go.sum | 20 ++++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/go.mod b/go.mod index 016f2c1b679..b53ff93b75a 100644 --- a/go.mod +++ b/go.mod @@ -88,10 +88,10 @@ require ( go.opentelemetry.io/otel/sdk/metric v0.39.0 go.opentelemetry.io/otel/trace v1.16.0 go.uber.org/zap v1.24.0 - golang.org/x/crypto v0.11.0 - golang.org/x/net v0.12.0 + golang.org/x/crypto v0.12.0 + golang.org/x/net v0.14.0 golang.org/x/oauth2 v0.10.0 - golang.org/x/text v0.11.0 + golang.org/x/text v0.12.0 golang.org/x/tools v0.11.0 gotest.tools/gotestsum v1.10.1 pault.ag/go/pksigner v1.0.2 @@ -231,8 +231,8 @@ require ( golang.org/x/image v0.5.0 // indirect golang.org/x/mod v0.12.0 // indirect golang.org/x/sync v0.3.0 // indirect - golang.org/x/sys v0.10.0 // indirect - golang.org/x/term v0.10.0 // indirect + golang.org/x/sys v0.11.0 // indirect + golang.org/x/term v0.11.0 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/genproto v0.0.0-20230530153820-e85fd2cbaebc // indirect google.golang.org/genproto/googleapis/api v0.0.0-20230530153820-e85fd2cbaebc // indirect diff --git a/go.sum b/go.sum index 316f4aff3da..8647ac033eb 100644 --- a/go.sum +++ b/go.sum @@ -877,8 +877,8 @@ golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0 golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= -golang.org/x/crypto v0.11.0 h1:6Ewdq3tDic1mg5xRO4milcWCfMVQhI4NkqWWvqejpuA= -golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio= +golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk= +golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -966,8 +966,8 @@ golang.org/x/net v0.0.0-20220826154423-83b083e8dc8b/go.mod h1:YDH+HFinaLZZlnHAfS golang.org/x/net v0.0.0-20221002022538-bcab6841153b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50= -golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA= +golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14= +golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1062,8 +1062,8 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA= -golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= +golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= @@ -1073,8 +1073,8 @@ golang.org/x/term v0.0.0-20220526004731-065cf7ba2467/go.mod h1:jbD1KX2456YbFQfuX golang.org/x/term v0.0.0-20220722155259-a9ba230a4035/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= -golang.org/x/term v0.10.0 h1:3R7pNqamzBraeqj/Tj8qt1aQ2HpmlC+Cx/qL/7hn4/c= -golang.org/x/term v0.10.0/go.mod h1:lpqdcUyK/oCiQxvxVrppt5ggO2KCZ5QblwqPnfZ6d5o= +golang.org/x/term v0.11.0 h1:F9tnn/DA/Im8nCwm+fX+1/eBwi4qFjRT++MhtVC4ZX0= +golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1087,8 +1087,8 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/text v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4= -golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc= +golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= From ec16d8f70ce09ff6c6b69061a9bf0176893d11e2 Mon Sep 17 00:00:00 2001 From: ruizajtruss Date: Sat, 12 Aug 2023 06:25:40 +0000 Subject: [PATCH 008/138] button and route --- src/constants/routes.js | 1 + src/pages/Office/index.jsx | 12 ++++++++++++ src/pages/PrimeUI/MoveTaskOrder/MoveDetails.jsx | 7 ++++++- .../PrimeUI/MoveTaskOrder/MoveDetails.module.scss | 2 +- 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/constants/routes.js b/src/constants/routes.js index 2c52066cf5c..2f5a92f0dd9 100644 --- a/src/constants/routes.js +++ b/src/constants/routes.js @@ -120,6 +120,7 @@ export const primeSimulatorRoutes = { UPDATE_SHIPMENT_PATH: `${BASE_PRIME_SIMULATOR_PATH}/shipments/:shipmentId`, CREATE_PAYMENT_REQUEST_PATH: `${BASE_PRIME_SIMULATOR_PATH}/payment-requests/new`, CREATE_SERVICE_ITEM_PATH: `${BASE_PRIME_SIMULATOR_PATH}/shipments/:shipmentId/service-items/new`, + UPDATE_SERVICE_ITEMS_PATH: `${BASE_PRIME_SIMULATOR_PATH}/mto-service-items`, UPLOAD_DOCUMENTS_PATH: `${BASE_PRIME_SIMULATOR_PATH}/payment-requests/:paymentRequestId/upload`, UPLOAD_SERVICE_REQUEST_DOCUMENTS_PATH: `${BASE_PRIME_SIMULATOR_PATH}/mto-service-items/:mtoServiceItemId/upload`, SHIPMENT_UPDATE_ADDRESS_PATH: `${BASE_PRIME_SIMULATOR_PATH}/shipments/:shipmentId/addresses/update`, diff --git a/src/pages/Office/index.jsx b/src/pages/Office/index.jsx index b06e4d8cec0..6f4517ad42f 100644 --- a/src/pages/Office/index.jsx +++ b/src/pages/Office/index.jsx @@ -71,6 +71,9 @@ const PrimeSimulatorUploadServiceRequestDocuments = lazy(() => import('pages/PrimeUI/UploadServiceRequestDocuments/UploadServiceRequestDocuments'), ); const PrimeSimulatorCreateServiceItem = lazy(() => import('pages/PrimeUI/CreateServiceItem/CreateServiceItem')); +const PrimeSimulatorUpdateServiceItems = lazy(() => + import('pages/PrimeUI/UpdateServiceItems/PrimeUIUpdateServiceItems'), +); const PrimeUIShipmentUpdateAddress = lazy(() => import('pages/PrimeUI/Shipment/PrimeUIShipmentUpdateAddress')); const PrimeUIShipmentUpdateReweigh = lazy(() => import('pages/PrimeUI/Shipment/PrimeUIShipmentUpdateReweigh')); @@ -326,6 +329,15 @@ export class OfficeApp extends Component { } /> + + + + } + /> { return (
- {moveTaskOrder.mtoServiceItems?.length > 0 &&

Service Items

} +
+ {moveTaskOrder.mtoServiceItems?.length > 0 &&

Service Items

} + + Update Service Items + +
{moveTaskOrder.mtoServiceItems?.map((serviceItem) => { if (serviceItem.mtoShipmentID === mtoShipment.id) { return ( diff --git a/src/pages/PrimeUI/MoveTaskOrder/MoveDetails.module.scss b/src/pages/PrimeUI/MoveTaskOrder/MoveDetails.module.scss index cdb00b1a51c..6692b00f3ae 100644 --- a/src/pages/PrimeUI/MoveTaskOrder/MoveDetails.module.scss +++ b/src/pages/PrimeUI/MoveTaskOrder/MoveDetails.module.scss @@ -2,7 +2,7 @@ @import 'shared/styles/colors'; .MoveDetails { - .moveHeader, .mainShipmentHeader { + .moveHeader, .mainShipmentHeader, .serviceItemHeader { @include u-display(flex); align-items: flex-start; From c617b8ad3103ccd673137c559f2824df62b37cca Mon Sep 17 00:00:00 2001 From: ruizajtruss Date: Sat, 12 Aug 2023 06:28:42 +0000 Subject: [PATCH 009/138] WIP component to create request --- ...PrimeUIRequestSITDestAddressChangeForm.jsx | 69 +++++++++++++++++++ .../PrimeUIUpdateServiceItems.jsx | 50 ++++++++++++++ .../PrimeUIUpdateServiceItems.test.jsx | 0 3 files changed, 119 insertions(+) create mode 100644 src/pages/PrimeUI/UpdateServiceItems/PrimeUIRequestSITDestAddressChangeForm.jsx create mode 100644 src/pages/PrimeUI/UpdateServiceItems/PrimeUIUpdateServiceItems.jsx create mode 100644 src/pages/PrimeUI/UpdateServiceItems/PrimeUIUpdateServiceItems.test.jsx diff --git a/src/pages/PrimeUI/UpdateServiceItems/PrimeUIRequestSITDestAddressChangeForm.jsx b/src/pages/PrimeUI/UpdateServiceItems/PrimeUIRequestSITDestAddressChangeForm.jsx new file mode 100644 index 00000000000..51690ae8a11 --- /dev/null +++ b/src/pages/PrimeUI/UpdateServiceItems/PrimeUIRequestSITDestAddressChangeForm.jsx @@ -0,0 +1,69 @@ +import React from 'react'; +import { Formik } from 'formik'; +import { useNavigate, useParams, generatePath } from 'react-router-dom'; +import PropTypes from 'prop-types'; +import { FormGroup } from '@trussworks/react-uswds'; +import classnames from 'classnames'; + +import SectionWrapper from 'components/Customer/SectionWrapper'; +import AddressFields from 'components/form/AddressFields/AddressFields'; +import { ResidentialAddressShape } from 'types/address'; +import formStyles from 'styles/form.module.scss'; +import { Form } from 'components/form/Form'; +import WizardNavigation from 'components/Customer/WizardNavigation/WizardNavigation'; +import { primeSimulatorRoutes } from 'constants/routes'; + +const PrimeUIRequestSITDestAddressChangeForm = ({ name, initialValues, onSubmit, destAddressChangeRequestSchema }) => { + const { moveCodeOrID } = useParams(); + const navigate = useNavigate(); + + const handleClose = () => { + navigate(generatePath(primeSimulatorRoutes.VIEW_MOVE_PATH, { moveCodeOrID })); + }; + + return ( + + {({ isValid, isSubmitting, handleSubmit, errors }) => ( +
+ 0 ? 1 : 0}> + +

Request Destination SIT Address Change

+ +
+ +
+
+ )} +
+ ); +}; + +PrimeUIRequestSITDestAddressChangeForm.propTypes = { + initialValues: PropTypes.shape({ + pickupAddress: PropTypes.shape({ + address: ResidentialAddressShape, + }), + destinationAddress: PropTypes.shape({ + address: ResidentialAddressShape, + }), + addressID: PropTypes.string, + eTag: PropTypes.string, + }).isRequired, + // onSubmit: PropTypes.func.isRequired, + destAddressChangeRequestSchema: PropTypes.shape({ + address: ResidentialAddressShape, + addressID: PropTypes.string, + eTag: PropTypes.string, + }).isRequired, + name: PropTypes.string.isRequired, +}; + +export default PrimeUIRequestSITDestAddressChangeForm; diff --git a/src/pages/PrimeUI/UpdateServiceItems/PrimeUIUpdateServiceItems.jsx b/src/pages/PrimeUI/UpdateServiceItems/PrimeUIUpdateServiceItems.jsx new file mode 100644 index 00000000000..07747a5eff0 --- /dev/null +++ b/src/pages/PrimeUI/UpdateServiceItems/PrimeUIUpdateServiceItems.jsx @@ -0,0 +1,50 @@ +import React, { useState } from 'react'; +import { Alert, Grid, GridContainer } from '@trussworks/react-uswds'; +import * as Yup from 'yup'; + +import PrimeUIRequestSITDestAddressChangeForm from './PrimeUIRequestSITDestAddressChangeForm'; + +import styles from 'components/Office/CustomerContactInfoForm/CustomerContactInfoForm.module.scss'; +import primeStyles from 'pages/PrimeUI/Prime.module.scss'; +import { addressSchema } from 'utils/validation'; + +const UpdateServiceItems = () => { + const [errorMessage, setErrorMessage] = useState(); + setErrorMessage('just a placeholder so i can commit'); + + const destAddressChangeRequestSchema = Yup.object().shape({ + addressID: Yup.string(), + destinationAddress: Yup.object().shape({ + address: addressSchema, + }), + eTag: Yup.string(), + }); + + return ( +
+
+ + + + {errorMessage?.detail && ( +
+ + {errorMessage.title} + {errorMessage.detail} + +
+ )} +

Update Service Items

+ +
+
+
+
+
+ ); +}; + +export default UpdateServiceItems; diff --git a/src/pages/PrimeUI/UpdateServiceItems/PrimeUIUpdateServiceItems.test.jsx b/src/pages/PrimeUI/UpdateServiceItems/PrimeUIUpdateServiceItems.test.jsx new file mode 100644 index 00000000000..e69de29bb2d From fbf2182fa1d97fd0fd4fd9da9afdb19d1b5b7bbb Mon Sep 17 00:00:00 2001 From: Andrew Hobson Date: Mon, 14 Aug 2023 16:44:21 +0000 Subject: [PATCH 010/138] Handle ChunkLoadError to deal with redeployed client code --- src/App/index.jsx | 87 +++++++++++-------- .../MilMoveErrorBoundary.test.jsx | 53 +++++++++++ src/components/MilMoveErrorBoundary/index.jsx | 37 ++++++++ src/pages/Office/index.jsx | 2 + src/registerServiceWorker.js | 3 +- src/scenes/MyMove/index.jsx | 2 + src/scenes/SystemAdmin/index.jsx | 2 + src/shared/SomethingWentWrong/index.jsx | 2 +- src/utils/retryPageLoading.js | 18 ++++ src/utils/retryPageLoading.test.js | 51 +++++++++++ 10 files changed, 218 insertions(+), 39 deletions(-) create mode 100644 src/components/MilMoveErrorBoundary/MilMoveErrorBoundary.test.jsx create mode 100644 src/components/MilMoveErrorBoundary/index.jsx create mode 100644 src/utils/retryPageLoading.js create mode 100644 src/utils/retryPageLoading.test.js diff --git a/src/App/index.jsx b/src/App/index.jsx index c3faa09a122..6ad79b33655 100644 --- a/src/App/index.jsx +++ b/src/App/index.jsx @@ -6,6 +6,7 @@ import { QueryClientProvider, QueryClient } from '@tanstack/react-query'; import { ReactQueryDevtools } from '@tanstack/react-query-devtools'; import LoadingPlaceholder from 'shared/LoadingPlaceholder'; +import SomethingWentWrong from 'shared/SomethingWentWrong'; import { isOfficeSite, isAdminSite, serviceName } from 'shared/constants'; import { store, persistor } from 'shared/store'; import { AppContext, defaultOfficeContext, defaultMyMoveContext, defaultAdminContext } from 'shared/AppContext'; @@ -15,6 +16,7 @@ import '../icons'; import 'shared/shared.css'; import './index.css'; import MarkerIO from 'components/ThirdParty/MarkerIO'; +import MilMoveErrorBoundary from 'components/MilMoveErrorBoundary'; import ScrollToTop from 'components/ScrollToTop'; import PageTitle from 'components/PageTitle'; @@ -58,53 +60,64 @@ const officeQueryConfig = new QueryClient({ const App = () => { configureLogger(serviceName(), { loggingType, loggingLevel }); + // We need an error boundary around each of the main apps (Office, + // SystemAdmin, MyMove) because they are lazy loaded and it's + // possible we could get a ChunkLoadError when trying to load them. + // Each of the main apps has its own componentDidCatch which would + // mean the MilMoveErrorBoundary is probably unlikely to be reached if (isOfficeSite) { return ( - - - } persistor={persistor}> - - - }> - - - - {flags.markerIO && } - - - - - - - + }> + + + } persistor={persistor}> + + + }> + + + + {flags.markerIO && } + + + + + + + + ); } if (isAdminSite) { return ( - - - }> - - - - - + }> + + + }> + + + + + + ); } return ( - - - - }> - - - - {flags.markerIO && } - - - - + }> + + + + }> + + + + {flags.markerIO && } + + + + + ); }; diff --git a/src/components/MilMoveErrorBoundary/MilMoveErrorBoundary.test.jsx b/src/components/MilMoveErrorBoundary/MilMoveErrorBoundary.test.jsx new file mode 100644 index 00000000000..0a64b751332 --- /dev/null +++ b/src/components/MilMoveErrorBoundary/MilMoveErrorBoundary.test.jsx @@ -0,0 +1,53 @@ +import React from 'react'; +import { render, screen, waitFor } from '@testing-library/react'; + +import MilMoveErrorBoundary from './index'; + +jest.mock('utils/milmoveLog', () => ({ + milmoveLogger: { + error: jest.fn(), + }, +})); + +jest.mock('utils/retryPageLoading', () => ({ + retryPageLoading: jest.fn(), +})); + +describe('MoveMoveErrorBoundary', () => { + // to quiet the test, mock console.error + beforeEach(() => { + jest.spyOn(console, 'error').mockImplementation(() => null); + }); + + const Fallback = () => { + return ( +
+ My Fallback +
+ ); + }; + it('catches errors', async () => { + const Thrower = () => { + throw new Error('MyError'); + }; + render( + }> + + , + ); + await waitFor(() => { + expect(screen.getByText('My Fallback')).toBeVisible(); + }); + }); + + it('shows children', () => { + render( + }> +
+ All Good +
+
, + ); + expect(screen.getByText('All Good')).toBeVisible(); + }); +}); diff --git a/src/components/MilMoveErrorBoundary/index.jsx b/src/components/MilMoveErrorBoundary/index.jsx new file mode 100644 index 00000000000..b1c1ed37523 --- /dev/null +++ b/src/components/MilMoveErrorBoundary/index.jsx @@ -0,0 +1,37 @@ +import React from 'react'; +import * as PropTypes from 'prop-types'; + +import { milmoveLogger } from 'utils/milmoveLog'; +import { retryPageLoading } from 'utils/retryPageLoading'; + +// This error boundary will probably not be reached for most errors. +// See more comments in App/index.jsx +export class MilMoveErrorBoundary extends React.Component { + constructor(props) { + super(props); + this.state = { hasError: false }; + } + + componentDidCatch(error, info) { + this.setState({ hasError: true }); + const { message } = error; + milmoveLogger.error({ message, info }); + retryPageLoading(error); + } + + render() { + const { hasError } = this.state; + const { children, fallback } = this.props; + if (hasError) { + return fallback; + } + return children; + } +} + +MilMoveErrorBoundary.propTypes = { + children: PropTypes.node.isRequired, + fallback: PropTypes.node.isRequired, +}; + +export default MilMoveErrorBoundary; diff --git a/src/pages/Office/index.jsx b/src/pages/Office/index.jsx index 50c728d03bc..9a945cc98b6 100644 --- a/src/pages/Office/index.jsx +++ b/src/pages/Office/index.jsx @@ -12,6 +12,7 @@ import 'scenes/Office/office.scss'; // Logger import { milmoveLogger } from 'utils/milmoveLog'; +import { retryPageLoading } from 'utils/retryPageLoading'; // API / Redux actions import { selectGetCurrentUserIsLoading, selectIsLoggedIn } from 'store/auth/selectors'; import { loadUser as loadUserAction } from 'store/auth/actions'; @@ -105,6 +106,7 @@ export class OfficeApp extends Component { error, info, }); + retryPageLoading(error); } render() { diff --git a/src/registerServiceWorker.js b/src/registerServiceWorker.js index 0bd0a817935..6715a1128e6 100644 --- a/src/registerServiceWorker.js +++ b/src/registerServiceWorker.js @@ -84,7 +84,8 @@ export function unregister() { } export default function register() { - if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { + const isServiceWorkerEnv = process.env.NODE_ENV === 'production' || process.env.REACT_APP_SERVICE_WORKER === 'true'; + if (isServiceWorkerEnv && 'serviceWorker' in navigator) { // The URL constructor is available in all browsers that support SW. const publicUrl = new URL(process.env.PUBLIC_URL, window.location); if (publicUrl.origin !== window.location.origin) { diff --git a/src/scenes/MyMove/index.jsx b/src/scenes/MyMove/index.jsx index d3bc6e60db5..e832199b433 100644 --- a/src/scenes/MyMove/index.jsx +++ b/src/scenes/MyMove/index.jsx @@ -11,6 +11,7 @@ import { getWorkflowRoutes } from './getWorkflowRoutes'; // Logger import { milmoveLogger } from 'utils/milmoveLog'; +import { retryPageLoading } from 'utils/retryPageLoading'; import BypassBlock from 'components/BypassBlock'; import CUIHeader from 'components/CUIHeader/CUIHeader'; import LoggedOutHeader from 'containers/Headers/LoggedOutHeader'; @@ -102,6 +103,7 @@ export class CustomerApp extends Component { error, info, }); + retryPageLoading(error); } render() { diff --git a/src/scenes/SystemAdmin/index.jsx b/src/scenes/SystemAdmin/index.jsx index 08dcde4adde..45982b14369 100644 --- a/src/scenes/SystemAdmin/index.jsx +++ b/src/scenes/SystemAdmin/index.jsx @@ -7,6 +7,7 @@ import { GetLoggedInUser } from 'utils/api'; import CUIHeader from 'components/CUIHeader/CUIHeader'; // Logger import { milmoveLogger } from 'utils/milmoveLog'; +import { retryPageLoading } from 'utils/retryPageLoading'; // Lazy load these dependencies (they correspond to unique routes & only need to be loaded when that URL is accessed) const SignIn = lazy(() => import('pages/SignIn/SignIn')); const InvalidPermissions = lazy(() => import('pages/InvalidPermissions/InvalidPermissions')); @@ -28,6 +29,7 @@ class AdminWrapper extends Component { componentDidCatch(error, info) { const { message } = error; milmoveLogger.error({ message, info }); + retryPageLoading(error); } render() { diff --git a/src/shared/SomethingWentWrong/index.jsx b/src/shared/SomethingWentWrong/index.jsx index b9995843a3a..406fc4d401e 100644 --- a/src/shared/SomethingWentWrong/index.jsx +++ b/src/shared/SomethingWentWrong/index.jsx @@ -2,7 +2,7 @@ import React from 'react'; import sadComputer from 'shared/images/sad-computer.png'; -const SomethingWentWrong = ({ error, info }) => ( +const SomethingWentWrong = () => (

diff --git a/src/utils/retryPageLoading.js b/src/utils/retryPageLoading.js new file mode 100644 index 00000000000..75291e5721c --- /dev/null +++ b/src/utils/retryPageLoading.js @@ -0,0 +1,18 @@ +const MilmoveHasBeenForceRefreshed = 'milmove-has-been-force-refreshed'; + +export const retryPageLoading = (error) => { + // if we see a chuck load error, try to reload the window to get + // the latest version of the code + if (!!error && error.name === 'ChunkLoadError' && !!window) { + const pageHasAlreadyBeenForceRefreshed = window.localStorage.getItem(MilmoveHasBeenForceRefreshed) === 'true'; + + if (!pageHasAlreadyBeenForceRefreshed) { + window.localStorage.setItem(MilmoveHasBeenForceRefreshed, 'true'); + return window.location.reload(); + } + window.localStorage.setItem(MilmoveHasBeenForceRefreshed, 'false'); + } + return false; +}; + +export default retryPageLoading; diff --git a/src/utils/retryPageLoading.test.js b/src/utils/retryPageLoading.test.js new file mode 100644 index 00000000000..f43d13972ee --- /dev/null +++ b/src/utils/retryPageLoading.test.js @@ -0,0 +1,51 @@ +import { retryPageLoading } from './retryPageLoading'; + +describe('retryPageLoading', () => { + let windowSpy; + let windowObj; + + const setUpWindow = (localStorageItem) => { + windowObj = { + localStorage: { + getItem: jest.fn().mockImplementation(() => localStorageItem), + setItem: jest.fn(), + }, + location: { + reload: jest.fn(), + }, + }; + windowSpy.mockImplementation(() => windowObj); + }; + + beforeEach(() => { + windowSpy = jest.spyOn(global, 'window', 'get'); + }); + + afterEach(() => { + windowSpy.mockRestore(); + }); + + it('does not reload on non chuck errors', () => { + setUpWindow(null); + retryPageLoading({ name: 'SomethingError' }); + expect(windowObj.localStorage.getItem).not.toBeCalled(); + expect(windowObj.localStorage.setItem).not.toBeCalled(); + expect(windowObj.location.reload).not.toBeCalled(); + }); + + it('reloads on first chuck error', () => { + setUpWindow('false'); + retryPageLoading({ name: 'ChunkLoadError' }); + expect(windowObj.localStorage.getItem).toBeCalled(); + expect(windowObj.localStorage.setItem).toBeCalledWith(expect.any(String), 'true'); + expect(windowObj.location.reload).toBeCalled(); + }); + + it('does not reload on 2nd chuck error', () => { + setUpWindow('true'); + retryPageLoading({ name: 'ChunkLoadError' }); + expect(windowObj.localStorage.getItem).toBeCalled(); + expect(windowObj.localStorage.setItem).toBeCalledWith(expect.any(String), 'false'); + expect(windowObj.location.reload).not.toBeCalled(); + }); +}); From 030eb9af41123e8eb654c1293162fdac54b800b1 Mon Sep 17 00:00:00 2001 From: Felipe Lee Date: Wed, 9 Aug 2023 00:05:52 +0000 Subject: [PATCH 011/138] feat (test): Update a PPM shipment factory to allow customizations Didn't extend it to allow traits too because that would need to then change even more functions, but we need the customizations to be able to run integration tests w/routing & middleware that need an active user. JIRA Ticket: MB-16387 --- pkg/factory/ppm_shipment_factory.go | 7 +++---- pkg/factory/ppm_shipment_factory_test.go | 4 ++-- pkg/handlers/internalapi/ppm_shipment_test.go | 8 ++++---- .../ppmshipment/ppm_shipment_fetcher_test.go | 14 +++++++------- .../ppmshipment/ppm_shipment_new_submitter_test.go | 6 +++--- .../ppmshipment/ppm_shipment_router_test.go | 10 +++++----- .../ppm_shipment_updated_submitter_test.go | 2 +- 7 files changed, 25 insertions(+), 26 deletions(-) diff --git a/pkg/factory/ppm_shipment_factory.go b/pkg/factory/ppm_shipment_factory.go index ec6964d6d48..8f6c36b594a 100644 --- a/pkg/factory/ppm_shipment_factory.go +++ b/pkg/factory/ppm_shipment_factory.go @@ -426,9 +426,8 @@ func buildPPMShipmentReadyForFinalCustomerCloseOutWithCustoms(db *pop.Connection // // This function does not accept customizations to reduce the // complexity of supporting different variations for tests -func BuildPPMShipmentReadyForFinalCustomerCloseOut(db *pop.Connection, userUploader *uploader.UserUploader) models.PPMShipment { - return buildPPMShipmentReadyForFinalCustomerCloseOutWithCustoms(db, userUploader, - nil) +func BuildPPMShipmentReadyForFinalCustomerCloseOut(db *pop.Connection, userUploader *uploader.UserUploader, customs []Customization) models.PPMShipment { + return buildPPMShipmentReadyForFinalCustomerCloseOutWithCustoms(db, userUploader, customs) } // BuildPPMShipmentReadyForFinalCustomerCloseOutWithAllDocTypes @@ -442,7 +441,7 @@ func BuildPPMShipmentReadyForFinalCustomerCloseOutWithAllDocTypes(db *pop.Connec // It's easier to use some of the data from other downstream // functions if we have them go first and then make our changes on // top of those changes. - ppmShipment := BuildPPMShipmentReadyForFinalCustomerCloseOut(db, userUploader) + ppmShipment := BuildPPMShipmentReadyForFinalCustomerCloseOut(db, userUploader, nil) AddProgearWeightTicketToPPMShipment(db, &ppmShipment, userUploader, nil) AddMovingExpenseToPPMShipment(db, &ppmShipment, userUploader, nil) diff --git a/pkg/factory/ppm_shipment_factory_test.go b/pkg/factory/ppm_shipment_factory_test.go index 6d8979cd85b..0dd41e25ed7 100644 --- a/pkg/factory/ppm_shipment_factory_test.go +++ b/pkg/factory/ppm_shipment_factory_test.go @@ -232,7 +232,7 @@ func (suite *FactorySuite) TestBuildPPMShipment() { // Expected outcome: New PPMShipment should be created with // Weight Ticket - ppmShipment := BuildPPMShipmentReadyForFinalCustomerCloseOut(suite.DB(), nil) + ppmShipment := BuildPPMShipmentReadyForFinalCustomerCloseOut(suite.DB(), nil, nil) suite.NotNil(ppmShipment.ActualPickupPostalCode) suite.Equal(ppmShipment.PickupPostalCode, *ppmShipment.ActualPickupPostalCode) @@ -255,7 +255,7 @@ func (suite *FactorySuite) TestBuildPPMShipment() { // Expected outcome: New PPMShipment should be created with // Weight Ticket - ppmShipment := BuildPPMShipmentReadyForFinalCustomerCloseOut(nil, nil) + ppmShipment := BuildPPMShipmentReadyForFinalCustomerCloseOut(nil, nil, nil) suite.False(ppmShipment.ID.IsNil()) suite.NotNil(ppmShipment.ActualPickupPostalCode) diff --git a/pkg/handlers/internalapi/ppm_shipment_test.go b/pkg/handlers/internalapi/ppm_shipment_test.go index 10008cc3b4e..28286207e5a 100644 --- a/pkg/handlers/internalapi/ppm_shipment_test.go +++ b/pkg/handlers/internalapi/ppm_shipment_test.go @@ -29,7 +29,7 @@ import ( func (suite *HandlerSuite) TestSubmitPPMShipmentDocumentationHandlerUnit() { setUpPPMShipment := func() models.PPMShipment { - ppmShipment := factory.BuildPPMShipmentReadyForFinalCustomerCloseOut(nil, nil) + ppmShipment := factory.BuildPPMShipmentReadyForFinalCustomerCloseOut(nil, nil, nil) ppmShipment.ID = uuid.Must(uuid.NewV4()) ppmShipment.CreatedAt = time.Now() @@ -343,7 +343,7 @@ func (suite *HandlerSuite) TestSubmitPPMShipmentDocumentationHandlerIntegration( } suite.Run("Returns an error if the PPM shipment is not found", func() { - ppmShipment := factory.BuildPPMShipmentReadyForFinalCustomerCloseOut(suite.DB(), nil) + ppmShipment := factory.BuildPPMShipmentReadyForFinalCustomerCloseOut(suite.DB(), nil, nil) ppmShipment.ID = uuid.Must(uuid.NewV4()) @@ -366,7 +366,7 @@ func (suite *HandlerSuite) TestSubmitPPMShipmentDocumentationHandlerIntegration( }) suite.Run("Returns an error if the SignedCertification has any errors", func() { - ppmShipment := factory.BuildPPMShipmentReadyForFinalCustomerCloseOut(suite.DB(), nil) + ppmShipment := factory.BuildPPMShipmentReadyForFinalCustomerCloseOut(suite.DB(), nil, nil) params, handler := setUpParamsAndHandler(ppmShipment, &internalmessages.SavePPMShipmentSignedCertification{ CertificationText: handlers.FmtString("certification text"), @@ -416,7 +416,7 @@ func (suite *HandlerSuite) TestSubmitPPMShipmentDocumentationHandlerIntegration( }) suite.Run("Can successfully submit a PPM shipment for close out", func() { - ppmShipment := factory.BuildPPMShipmentReadyForFinalCustomerCloseOut(suite.DB(), nil) + ppmShipment := factory.BuildPPMShipmentReadyForFinalCustomerCloseOut(suite.DB(), nil, nil) certText := "certification text" signature := "signature" diff --git a/pkg/services/ppmshipment/ppm_shipment_fetcher_test.go b/pkg/services/ppmshipment/ppm_shipment_fetcher_test.go index 89b92eb469b..046954ccca5 100644 --- a/pkg/services/ppmshipment/ppm_shipment_fetcher_test.go +++ b/pkg/services/ppmshipment/ppm_shipment_fetcher_test.go @@ -325,7 +325,7 @@ func (suite *PPMShipmentSuite) TestPPMShipmentFetcher() { suite.Run("Can fetch a ppm shipment and get both eagerPreloadAssociations and postloadAssociations", func() { appCtx := suite.AppContextForTest() - ppmShipment := factory.BuildPPMShipmentReadyForFinalCustomerCloseOut(suite.DB(), nil) + ppmShipment := factory.BuildPPMShipmentReadyForFinalCustomerCloseOut(suite.DB(), nil, nil) ppmShipmentReturned, err := fetcher.GetPPMShipment( appCtx, @@ -352,7 +352,7 @@ func (suite *PPMShipmentSuite) TestPPMShipmentFetcher() { suite.Run("Doesn't return postload association if a necessary higher level association isn't eagerly preloaded", func() { appCtx := suite.AppContextForTest() - ppmShipment := factory.BuildPPMShipmentReadyForFinalCustomerCloseOut(suite.DB(), userUploader) + ppmShipment := factory.BuildPPMShipmentReadyForFinalCustomerCloseOut(suite.DB(), userUploader, nil) suite.FatalTrue(len(ppmShipment.WeightTickets) > 0, "Test data that was set up is invalid, no weight tickets found") @@ -770,7 +770,7 @@ func (suite *PPMShipmentSuite) TestFetchPPMShipment() { }) suite.Run("FindPPMShipment - loads weight tickets association", func() { - ppmShipment := factory.BuildPPMShipmentReadyForFinalCustomerCloseOut(suite.DB(), nil) + ppmShipment := factory.BuildPPMShipmentReadyForFinalCustomerCloseOut(suite.DB(), nil, nil) // No uploads are added by default for the ProofOfTrailerOwnershipDocument to the WeightTicket model testdatagen.GetOrCreateDocumentWithUploads(suite.DB(), @@ -787,7 +787,7 @@ func (suite *PPMShipmentSuite) TestFetchPPMShipment() { }) suite.Run("FindPPMShipment - loads ProgearWeightTicket and MovingExpense associations", func() { - ppmShipment := factory.BuildPPMShipmentReadyForFinalCustomerCloseOut(suite.DB(), nil) + ppmShipment := factory.BuildPPMShipmentReadyForFinalCustomerCloseOut(suite.DB(), nil, nil) factory.BuildProgearWeightTicket(suite.DB(), []factory.Customization{ { @@ -815,7 +815,7 @@ func (suite *PPMShipmentSuite) TestFetchPPMShipment() { suite.Run("FindPPMShipment - loads signed certification", func() { signedCertification := factory.BuildSignedCertification(suite.DB(), nil, nil) - ppmShipment := factory.BuildPPMShipmentReadyForFinalCustomerCloseOut(suite.DB(), nil) + ppmShipment := factory.BuildPPMShipmentReadyForFinalCustomerCloseOut(suite.DB(), nil, nil) signedCertification.PpmID = &ppmShipment.ID suite.NoError(suite.DB().Save(&signedCertification)) @@ -859,7 +859,7 @@ func (suite *PPMShipmentSuite) TestFetchPPMShipment() { }) suite.Run("FindPPMShipment - deleted uploads are removed", func() { - ppmShipment := factory.BuildPPMShipmentReadyForFinalCustomerCloseOut(suite.DB(), nil) + ppmShipment := factory.BuildPPMShipmentReadyForFinalCustomerCloseOut(suite.DB(), nil, nil) testdatagen.GetOrCreateDocumentWithUploads(suite.DB(), ppmShipment.WeightTickets[0].ProofOfTrailerOwnershipDocument, @@ -982,7 +982,7 @@ func (suite *PPMShipmentSuite) TestFetchPPMShipment() { }) suite.Run("FindPPMShipmentByMTOID - Success deleted line items are excluded", func() { - ppmShipment := factory.BuildPPMShipmentReadyForFinalCustomerCloseOut(suite.DB(), nil) + ppmShipment := factory.BuildPPMShipmentReadyForFinalCustomerCloseOut(suite.DB(), nil, nil) weightTicketToDelete := factory.BuildWeightTicket(suite.DB(), []factory.Customization{ { diff --git a/pkg/services/ppmshipment/ppm_shipment_new_submitter_test.go b/pkg/services/ppmshipment/ppm_shipment_new_submitter_test.go index 53468c501dd..c4c124057fb 100644 --- a/pkg/services/ppmshipment/ppm_shipment_new_submitter_test.go +++ b/pkg/services/ppmshipment/ppm_shipment_new_submitter_test.go @@ -85,7 +85,7 @@ func (suite *PPMShipmentSuite) TestSubmitNewCustomerCloseOut() { }) suite.Run("Returns an error if creating a new signed certification fails", func() { - existingPPMShipment := factory.BuildPPMShipmentReadyForFinalCustomerCloseOut(suite.DB(), nil) + existingPPMShipment := factory.BuildPPMShipmentReadyForFinalCustomerCloseOut(suite.DB(), nil, nil) appCtx := suite.AppContextWithSessionForTest(&auth.Session{ UserID: existingPPMShipment.Shipment.MoveTaskOrder.Orders.ServiceMember.UserID, @@ -114,7 +114,7 @@ func (suite *PPMShipmentSuite) TestSubmitNewCustomerCloseOut() { }) suite.Run("Returns an error if submitting the close out documentation fails", func() { - existingPPMShipment := factory.BuildPPMShipmentReadyForFinalCustomerCloseOut(suite.DB(), nil) + existingPPMShipment := factory.BuildPPMShipmentReadyForFinalCustomerCloseOut(suite.DB(), nil, nil) appCtx := suite.AppContextWithSessionForTest(&auth.Session{ UserID: existingPPMShipment.Shipment.MoveTaskOrder.Orders.ServiceMember.UserID, @@ -146,7 +146,7 @@ func (suite *PPMShipmentSuite) TestSubmitNewCustomerCloseOut() { }) suite.Run("Can create a signed certification and route the PPMShipment properly", func() { - existingPPMShipment := factory.BuildPPMShipmentReadyForFinalCustomerCloseOut(suite.DB(), nil) + existingPPMShipment := factory.BuildPPMShipmentReadyForFinalCustomerCloseOut(suite.DB(), nil, nil) appCtx := suite.AppContextWithSessionForTest(&auth.Session{ UserID: existingPPMShipment.Shipment.MoveTaskOrder.Orders.ServiceMember.UserID, diff --git a/pkg/services/ppmshipment/ppm_shipment_router_test.go b/pkg/services/ppmshipment/ppm_shipment_router_test.go index 4a75de2235b..86151ef3b62 100644 --- a/pkg/services/ppmshipment/ppm_shipment_router_test.go +++ b/pkg/services/ppmshipment/ppm_shipment_router_test.go @@ -302,7 +302,7 @@ func (suite *PPMShipmentSuite) TestSubmitCloseOutDocumentation() { mtoShipmentRouterMethodToMock := "" suite.Run(fmt.Sprintf("Can set status to %s if it is currently %s", models.PPMShipmentStatusNeedsPaymentApproval, models.PPMShipmentStatusWaitingOnCustomer), func() { - ppmShipment := factory.BuildPPMShipmentReadyForFinalCustomerCloseOut(nil, nil) + ppmShipment := factory.BuildPPMShipmentReadyForFinalCustomerCloseOut(nil, nil, nil) ppmShipmentRouter := setUpPPMShipmentRouter(mtoShipmentRouterMethodToMock, nil) @@ -390,7 +390,7 @@ func (suite *PPMShipmentSuite) TestSubmitReviewPPMDocuments() { mtoShipmentRouterMethodToMock := "" suite.Run("Update PPMShipment Status to WAITING_ON_CUSTOMER when there are rejected weight tickets", func() { - ppmShipment := factory.BuildPPMShipmentReadyForFinalCustomerCloseOut(nil, nil) + ppmShipment := factory.BuildPPMShipmentReadyForFinalCustomerCloseOut(nil, nil, nil) rejected := models.PPMDocumentStatusRejected weightTicket := factory.BuildWeightTicket(suite.DB(), []factory.Customization{ { @@ -415,7 +415,7 @@ func (suite *PPMShipmentSuite) TestSubmitReviewPPMDocuments() { }) suite.Run("Update PPMShipment Status to WAITING_ON_CUSTOMER when there are rejected progear weight tickets", func() { - ppmShipment := factory.BuildPPMShipmentReadyForFinalCustomerCloseOut(nil, nil) + ppmShipment := factory.BuildPPMShipmentReadyForFinalCustomerCloseOut(nil, nil, nil) ppmShipment.Status = models.PPMShipmentStatusNeedsPaymentApproval rejected := models.PPMDocumentStatusRejected progear := factory.BuildProgearWeightTicket(suite.DB(), []factory.Customization{ @@ -440,7 +440,7 @@ func (suite *PPMShipmentSuite) TestSubmitReviewPPMDocuments() { }) suite.Run("Update PPMShipment Status to WAITING_ON_CUSTOMER when there are rejected moving expenses", func() { - ppmShipment := factory.BuildPPMShipmentReadyForFinalCustomerCloseOut(nil, nil) + ppmShipment := factory.BuildPPMShipmentReadyForFinalCustomerCloseOut(nil, nil, nil) ppmShipment.Status = models.PPMShipmentStatusNeedsPaymentApproval rejected := models.PPMDocumentStatusRejected movingExpense := factory.BuildMovingExpense(suite.DB(), []factory.Customization{ @@ -465,7 +465,7 @@ func (suite *PPMShipmentSuite) TestSubmitReviewPPMDocuments() { }) suite.Run("Update PPMShipment Status to PAYMENT_APPROVED when there are no rejected PPM Documents", func() { - ppmShipment := factory.BuildPPMShipmentReadyForFinalCustomerCloseOut(nil, nil) + ppmShipment := factory.BuildPPMShipmentReadyForFinalCustomerCloseOut(nil, nil, nil) ppmShipment.Status = models.PPMShipmentStatusNeedsPaymentApproval movingExpense := factory.BuildMovingExpense(suite.DB(), nil, nil) progear := factory.BuildProgearWeightTicket(suite.DB(), nil, nil) diff --git a/pkg/services/ppmshipment/ppm_shipment_updated_submitter_test.go b/pkg/services/ppmshipment/ppm_shipment_updated_submitter_test.go index b5984c09eb5..a0580527625 100644 --- a/pkg/services/ppmshipment/ppm_shipment_updated_submitter_test.go +++ b/pkg/services/ppmshipment/ppm_shipment_updated_submitter_test.go @@ -120,7 +120,7 @@ func (suite *PPMShipmentSuite) TestSubmitCustomerCloseOut() { }) suite.Run("Returns an error if submitting the close out documentation fails", func() { - existingPPMShipment := factory.BuildPPMShipmentReadyForFinalCustomerCloseOut(suite.DB(), nil) + existingPPMShipment := factory.BuildPPMShipmentReadyForFinalCustomerCloseOut(suite.DB(), nil, nil) appCtx := suite.AppContextWithSessionForTest(&auth.Session{ UserID: existingPPMShipment.Shipment.MoveTaskOrder.Orders.ServiceMember.User.ID, From eb487bea9b0f10a361c470e01bacda6e7899b9f3 Mon Sep 17 00:00:00 2001 From: Felipe Lee Date: Mon, 14 Aug 2023 22:27:08 +0000 Subject: [PATCH 012/138] feat (service): update `GetPPMShipment` to account for customer authz Should work the way it was before if the request is coming from the prime API or the office app. Only adds authz check if it is from the customer app. If it is a customer request, we ensure the service member in the session matches the one that the shipment belongs to (via orders association). Updated `moving_expense_creator` and `progear_weight_ticket_creator` to call `GetPPMShipment` differently now that it has the logic to use the logged in customer info as appropriate. Also updated `moving_expense_creator` to pass the errors from `GetPPMShipment` along rather than turning them into server errors. JIRA-Ticket: MB-16387 --- .../moving_expense/moving_expense_creator.go | 18 +++-- .../moving_expense_creator_test.go | 20 +++-- .../ppmshipment/ppm_shipment_fetcher.go | 27 ++++++- .../ppmshipment/ppm_shipment_fetcher_test.go | 81 ++++++++++++++++++- .../progear_weight_ticket_creator.go | 15 ++-- .../progear_weight_ticket_creator_test.go | 17 ++-- 6 files changed, 143 insertions(+), 35 deletions(-) diff --git a/pkg/services/moving_expense/moving_expense_creator.go b/pkg/services/moving_expense/moving_expense_creator.go index 8064f44709b..9b31a9c9207 100644 --- a/pkg/services/moving_expense/moving_expense_creator.go +++ b/pkg/services/moving_expense/moving_expense_creator.go @@ -1,8 +1,6 @@ package movingexpense import ( - "fmt" - "github.com/gofrs/uuid" "github.com/transcom/mymove/pkg/appcontext" @@ -23,18 +21,22 @@ func NewMovingExpenseCreator() services.MovingExpenseCreator { } func (f *movingExpenseCreator) CreateMovingExpense(appCtx appcontext.AppContext, ppmShipmentID uuid.UUID) (*models.MovingExpense, error) { + // TODO: Ideally this service would be passed in as a dependency to the `NewMovingExpenseCreator` function. + // Our docs have an example, though instead of using the dependency in the service function, it is being used in + // the check functions, but the idea is similar: + // https://transcom.github.io/mymove-docs/docs/backend/guides/service-objects/implementation#creating-an-instance-of-our-service-object ppmShipmentFetcher := ppmshipment.NewPPMShipmentFetcher() - ppmShipment, ppmShipmentErr := ppmShipmentFetcher.GetPPMShipment(appCtx, ppmShipmentID, []string{ppmshipment.EagerPreloadAssociationServiceMember}, []string{}) + // This serves as a way of ensuring that the PPM shipment exists. It also ensures a shipment belongs to the logged + // in user, for customer app requests. + ppmShipment, ppmShipmentErr := ppmShipmentFetcher.GetPPMShipment(appCtx, ppmShipmentID, nil, nil) + if ppmShipmentErr != nil { - return nil, apperror.NewInternalServerError(fmt.Sprintf("Error fetching PPM with ID %s", ppmShipmentID)) + return nil, ppmShipmentErr } - if ppmShipment.Shipment.MoveTaskOrder.Orders.ServiceMemberID != appCtx.Session().ServiceMemberID { - return nil, apperror.NewNotFoundError(ppmShipmentID, "No such shipment found for this service member") - } newMovingExpense := &models.MovingExpense{ - PPMShipmentID: ppmShipmentID, + PPMShipmentID: ppmShipment.ID, Document: models.Document{ ServiceMemberID: appCtx.Session().ServiceMemberID, }, diff --git a/pkg/services/moving_expense/moving_expense_creator_test.go b/pkg/services/moving_expense/moving_expense_creator_test.go index 1242ec47a03..849c8148d79 100644 --- a/pkg/services/moving_expense/moving_expense_creator_test.go +++ b/pkg/services/moving_expense/moving_expense_creator_test.go @@ -1,8 +1,6 @@ package movingexpense import ( - "fmt" - "github.com/gofrs/uuid" "github.com/transcom/mymove/pkg/apperror" @@ -16,6 +14,7 @@ func (suite *MovingExpenseSuite) TestMovingExpenseCreator() { serviceMemberID := ppmShipment.Shipment.MoveTaskOrder.Orders.ServiceMemberID session := &auth.Session{ + ApplicationName: auth.MilApp, ServiceMemberID: serviceMemberID, } @@ -32,6 +31,7 @@ func (suite *MovingExpenseSuite) TestMovingExpenseCreator() { suite.Run("Fails when an invalid ppmShipmentID is used", func() { serviceMember := factory.BuildServiceMember(suite.DB(), nil, nil) session := &auth.Session{ + ApplicationName: auth.MilApp, ServiceMemberID: serviceMember.ID, } @@ -39,12 +39,16 @@ func (suite *MovingExpenseSuite) TestMovingExpenseCreator() { movingExpense, err := movingExpenseCreator.CreateMovingExpense(suite.AppContextWithSessionForTest(session), uuid.Nil) suite.Nil(movingExpense) - suite.ErrorContains(err, fmt.Sprintf("Error fetching PPM with ID %s", uuid.Nil)) + + expectedErr := apperror.NewNotFoundError(uuid.Nil, "while looking for PPMShipment") + + suite.ErrorIs(err, expectedErr) }) suite.Run("Fails when session has invalid serviceMemberID", func() { session := &auth.Session{ - ServiceMemberID: uuid.Nil, + ApplicationName: auth.MilApp, + ServiceMemberID: uuid.Must(uuid.NewV4()), } ppmShipment := factory.BuildMinimalPPMShipment(suite.DB(), nil, nil) @@ -52,9 +56,9 @@ func (suite *MovingExpenseSuite) TestMovingExpenseCreator() { movingExpense, err := movingExpenseCreator.CreateMovingExpense(suite.AppContextWithSessionForTest(session), ppmShipment.ID) suite.Nil(movingExpense) - suite.NotNil(err) - suite.IsType(apperror.NotFoundError{}, err) - suite.Contains(err.Error(), "No such shipment found for this service member") - }) + expectedErr := apperror.NewNotFoundError(ppmShipment.ID, "while looking for PPMShipment") + + suite.ErrorIs(err, expectedErr) + }) } diff --git a/pkg/services/ppmshipment/ppm_shipment_fetcher.go b/pkg/services/ppmshipment/ppm_shipment_fetcher.go index fba3de9de42..c135ae32568 100644 --- a/pkg/services/ppmshipment/ppm_shipment_fetcher.go +++ b/pkg/services/ppmshipment/ppm_shipment_fetcher.go @@ -82,7 +82,12 @@ func GetListOfAllPostloadAssociations() []string { } // GetPPMShipment returns a PPMShipment with any desired associations by ID -func (f ppmShipmentFetcher) GetPPMShipment(appCtx appcontext.AppContext, ppmShipmentID uuid.UUID, eagerPreloadAssociations []string, postloadAssociations []string) (*models.PPMShipment, error) { +func (f ppmShipmentFetcher) GetPPMShipment( + appCtx appcontext.AppContext, + ppmShipmentID uuid.UUID, + eagerPreloadAssociations []string, + postloadAssociations []string, +) (*models.PPMShipment, error) { if eagerPreloadAssociations != nil { validPreloadAssociations := make(map[string]bool) for _, v := range GetListOfAllPreloadAssociations() { @@ -91,7 +96,9 @@ func (f ppmShipmentFetcher) GetPPMShipment(appCtx appcontext.AppContext, ppmShip for _, association := range eagerPreloadAssociations { if !validPreloadAssociations[association] { - return nil, apperror.NewNotImplementedError(fmt.Sprintf("Requested eager preload association %s is not implemented", association)) + msg := fmt.Sprintf("Requested eager preload association %s is not implemented", association) + + return nil, apperror.NewNotImplementedError(msg) } } } @@ -99,12 +106,20 @@ func (f ppmShipmentFetcher) GetPPMShipment(appCtx appcontext.AppContext, ppmShip var ppmShipment models.PPMShipment q := appCtx.DB().Q(). - Scope(utilities.ExcludeDeletedScope()) + Scope(utilities.ExcludeDeletedScope(models.PPMShipment{})) if eagerPreloadAssociations != nil { q.EagerPreload(eagerPreloadAssociations...) } + if appCtx.Session() != nil && appCtx.Session().IsMilApp() { + q. + InnerJoin("mto_shipments", "mto_shipments.id = ppm_shipments.shipment_id"). + InnerJoin("moves", "moves.id = mto_shipments.move_id"). + LeftJoin("orders", "orders.id = moves.orders_id"). + Where("orders.service_member_id = ?", appCtx.Session().ServiceMemberID) + } + err := q.Find(&ppmShipment, ppmShipmentID) if err != nil { @@ -132,7 +147,11 @@ func (f ppmShipmentFetcher) GetPPMShipment(appCtx appcontext.AppContext, ppmShip } // PostloadAssociations loads associations that can't be eager preloaded due to bugs in pop -func (f ppmShipmentFetcher) PostloadAssociations(appCtx appcontext.AppContext, ppmShipment *models.PPMShipment, postloadAssociations []string) error { +func (f ppmShipmentFetcher) PostloadAssociations( + appCtx appcontext.AppContext, + ppmShipment *models.PPMShipment, + postloadAssociations []string, +) error { for _, association := range postloadAssociations { switch association { case PostLoadAssociationSignedCertification: diff --git a/pkg/services/ppmshipment/ppm_shipment_fetcher_test.go b/pkg/services/ppmshipment/ppm_shipment_fetcher_test.go index 046954ccca5..285c67847f7 100644 --- a/pkg/services/ppmshipment/ppm_shipment_fetcher_test.go +++ b/pkg/services/ppmshipment/ppm_shipment_fetcher_test.go @@ -7,6 +7,7 @@ import ( "github.com/gofrs/uuid" "github.com/transcom/mymove/pkg/apperror" + "github.com/transcom/mymove/pkg/auth" "github.com/transcom/mymove/pkg/db/utilities" "github.com/transcom/mymove/pkg/factory" "github.com/transcom/mymove/pkg/models" @@ -75,11 +76,13 @@ func (suite *PPMShipmentSuite) TestPPMShipmentFetcher() { } suite.Run("GetPPMShipment", func() { - suite.Run("Can fetch a PPM Shipment", func() { + suite.Run("Can fetch a PPM Shipment if there is no session (e.g. a prime request)", func() { + appCtx := suite.AppContextWithSessionForTest(nil) + ppmShipment := factory.BuildPPMShipment(suite.DB(), nil, nil) ppmShipmentReturned, err := fetcher.GetPPMShipment( - suite.AppContextForTest(), + appCtx, ppmShipment.ID, nil, nil, @@ -90,6 +93,76 @@ func (suite *PPMShipmentSuite) TestPPMShipmentFetcher() { } }) + suite.Run("Can fetch a PPM Shipment if it is an office user making a request from the office app", func() { + officeUser := factory.BuildOfficeUser(suite.DB(), factory.GetTraitActiveOfficeUser(), nil) + + appCtx := suite.AppContextWithSessionForTest(&auth.Session{ + ApplicationName: auth.OfficeApp, + UserID: officeUser.User.ID, + OfficeUserID: officeUser.ID, + }) + + ppmShipment := factory.BuildPPMShipment(suite.DB(), nil, nil) + + ppmShipmentReturned, err := fetcher.GetPPMShipment( + appCtx, + ppmShipment.ID, + nil, + nil, + ) + + if suite.NoError(err) && suite.NotNil(ppmShipmentReturned) { + suite.Equal(ppmShipment.ID, ppmShipmentReturned.ID) + } + }) + + suite.Run("Can fetch a PPM Shipment if it is a customer app request by the customer it belongs to", func() { + ppmShipment := factory.BuildPPMShipment(suite.DB(), factory.GetTraitActiveServiceMemberUser(), nil) + serviceMember := ppmShipment.Shipment.MoveTaskOrder.Orders.ServiceMember + + appCtx := suite.AppContextWithSessionForTest(&auth.Session{ + ApplicationName: auth.MilApp, + UserID: serviceMember.User.ID, + ServiceMemberID: serviceMember.ID, + }) + + ppmShipmentReturned, err := fetcher.GetPPMShipment( + appCtx, + ppmShipment.ID, + nil, + nil, + ) + + if suite.NoError(err) && suite.NotNil(ppmShipmentReturned) { + suite.Equal(ppmShipment.ID, ppmShipmentReturned.ID) + } + }) + + suite.Run("Returns a not found error if it is a customer app request by a customer that it doesn't belong to", func() { + maliciousUser := factory.BuildExtendedServiceMember(suite.DB(), factory.GetTraitActiveServiceMemberUser(), nil) + + appCtx := suite.AppContextWithSessionForTest(&auth.Session{ + ApplicationName: auth.MilApp, + UserID: maliciousUser.User.ID, + ServiceMemberID: maliciousUser.ID, + }) + + ppmShipment := factory.BuildPPMShipment(suite.DB(), factory.GetTraitActiveServiceMemberUser(), nil) + + ppmShipmentReturned, err := fetcher.GetPPMShipment( + appCtx, + ppmShipment.ID, + nil, + nil, + ) + + if suite.Error(err) && suite.Nil(ppmShipmentReturned) { + suite.IsType(apperror.NotFoundError{}, err) + + suite.Equal(fmt.Sprintf("ID: %s not found while looking for PPMShipment", ppmShipment.ID), err.Error()) + } + }) + associationTestCases := map[string]struct { eagerPreloadAssociations []string successAssertionFunc func(*models.PPMShipment, *models.PPMShipment) @@ -360,7 +433,9 @@ func (suite *PPMShipmentSuite) TestPPMShipmentFetcher() { appCtx, ppmShipment.ID, nil, - nil, + []string{ + PostLoadAssociationWeightTicketUploads, + }, ) if suite.NoError(err) && suite.NotNil(ppmShipmentReturned) { diff --git a/pkg/services/progear_weight_ticket/progear_weight_ticket_creator.go b/pkg/services/progear_weight_ticket/progear_weight_ticket_creator.go index e842cac70ce..263495ac562 100644 --- a/pkg/services/progear_weight_ticket/progear_weight_ticket_creator.go +++ b/pkg/services/progear_weight_ticket/progear_weight_ticket_creator.go @@ -28,18 +28,19 @@ func (f *progearWeightTicketCreator) CreateProgearWeightTicket(appCtx appcontext return nil, err } + // TODO: Ideally this service would be passed in as a dependency to the `NewMovingExpenseCreator` function. + // Our docs have an example, though instead of using the dependency in the service function, it is being used in + // the check functions, but the idea is similar: + // https://transcom.github.io/mymove-docs/docs/backend/guides/service-objects/implementation#creating-an-instance-of-our-service-object shipmentFetcher := ppmshipment.NewPPMShipmentFetcher() - ppmShipment, ppmShipmentErr := shipmentFetcher.GetPPMShipment(appCtx, ppmShipmentID, []string{ - ppmshipment.EagerPreloadAssociationServiceMember, - }, []string{}) + // This serves as a way of ensuring that the PPM shipment exists. It also ensures a shipment belongs to the logged + // in user, for customer app requests. + ppmShipment, ppmShipmentErr := shipmentFetcher.GetPPMShipment(appCtx, ppmShipmentID, nil, nil) if ppmShipmentErr != nil { return nil, ppmShipmentErr } - if ppmShipment.Shipment.MoveTaskOrder.Orders.ServiceMemberID != appCtx.Session().ServiceMemberID { - return nil, apperror.NewNotFoundError(ppmShipmentID, "No such shipment found for this service member") - } var progearWeightTicket models.ProgearWeightTicket @@ -60,7 +61,7 @@ func (f *progearWeightTicketCreator) CreateProgearWeightTicket(appCtx appcontext progearWeightTicket = models.ProgearWeightTicket{ Document: *document, DocumentID: document.ID, - PPMShipmentID: ppmShipmentID, + PPMShipmentID: ppmShipment.ID, } verrs, err = txnCtx.DB().ValidateAndCreate(&progearWeightTicket) diff --git a/pkg/services/progear_weight_ticket/progear_weight_ticket_creator_test.go b/pkg/services/progear_weight_ticket/progear_weight_ticket_creator_test.go index 51ece3fe89f..97a962230f0 100644 --- a/pkg/services/progear_weight_ticket/progear_weight_ticket_creator_test.go +++ b/pkg/services/progear_weight_ticket/progear_weight_ticket_creator_test.go @@ -14,6 +14,7 @@ func (suite *ProgearWeightTicketSuite) TestProgearWeightTicketCreator() { serviceMemberID := ppmShipment.Shipment.MoveTaskOrder.Orders.ServiceMemberID session := &auth.Session{ + ApplicationName: auth.MilApp, ServiceMemberID: serviceMemberID, } @@ -30,6 +31,7 @@ func (suite *ProgearWeightTicketSuite) TestProgearWeightTicketCreator() { suite.Run("Fails when an invalid ppmShipmentID is used", func() { serviceMember := factory.BuildServiceMember(suite.DB(), nil, nil) session := &auth.Session{ + ApplicationName: auth.MilApp, ServiceMemberID: serviceMember.ID, } @@ -37,12 +39,16 @@ func (suite *ProgearWeightTicketSuite) TestProgearWeightTicketCreator() { progearWeightTicket, err := progearWeightTicketCreator.CreateProgearWeightTicket(suite.AppContextWithSessionForTest(session), uuid.Nil) suite.Nil(progearWeightTicket) - suite.NotNil(err) + + expectedErr := apperror.NewNotFoundError(uuid.Nil, "while looking for PPMShipment") + + suite.ErrorIs(err, expectedErr) }) suite.Run("Fails when session has invalid serviceMemberID", func() { session := &auth.Session{ - ServiceMemberID: uuid.Nil, + ApplicationName: auth.MilApp, + ServiceMemberID: uuid.Must(uuid.NewV4()), } ppmShipment := factory.BuildMinimalPPMShipment(suite.DB(), nil, nil) @@ -50,8 +56,9 @@ func (suite *ProgearWeightTicketSuite) TestProgearWeightTicketCreator() { progearWeightTicket, err := progearWeightTicketCreator.CreateProgearWeightTicket(suite.AppContextWithSessionForTest(session), ppmShipment.ID) suite.Nil(progearWeightTicket) - suite.NotNil(err) - suite.IsType(apperror.NotFoundError{}, err) - suite.Contains(err.Error(), "No such shipment found for this service member") + + expectedErr := apperror.NewNotFoundError(ppmShipment.ID, "while looking for PPMShipment") + + suite.ErrorIs(err, expectedErr) }) } From b41ca60e82c68d37a67c79f7517e6438fcf930e0 Mon Sep 17 00:00:00 2001 From: Felipe Lee Date: Tue, 15 Aug 2023 02:05:45 +0000 Subject: [PATCH 013/138] fix (api): ensure customer authz are checked for ppm closeout submission We accomplish this by using the `GetPPMShipment` service instead of `FetchPPMShipment` in the `SubmitNewCustomerCloseOut` service. This also gives us the ability to mock out the dependency, which wasn't possible before. JIRA-Ticket: MB-16837 --- pkg/handlers/internalapi/api.go | 4 +- pkg/handlers/internalapi/ppm_shipment.go | 8 - pkg/handlers/internalapi/ppm_shipment_test.go | 189 ++++++++++-------- .../internalapi_test/ppm_shipment_test.go | 106 ++++++++++ .../ppmshipment/ppm_shipment_new_submitter.go | 20 +- .../ppm_shipment_new_submitter_test.go | 55 ++++- 6 files changed, 279 insertions(+), 103 deletions(-) create mode 100644 pkg/handlers/routing/internalapi_test/ppm_shipment_test.go diff --git a/pkg/handlers/internalapi/api.go b/pkg/handlers/internalapi/api.go index 6638b32e021..d6e0bf72251 100644 --- a/pkg/handlers/internalapi/api.go +++ b/pkg/handlers/internalapi/api.go @@ -55,6 +55,8 @@ func NewInternalAPI(handlerConfig handlers.HandlerConfig) *internalops.MymoveAPI transportationOfficeFetcher := transportationoffice.NewTransportationOfficesFetcher() closeoutOfficeUpdater := move.NewCloseoutOfficeUpdater(move.NewMoveFetcher(), transportationOfficeFetcher) + ppmShipmentFetcher := ppmshipment.NewPPMShipmentFetcher() + internalAPI.UsersShowLoggedInUserHandler = ShowLoggedInUserHandler{handlerConfig, officeuser.NewOfficeUserFetcherPop()} internalAPI.CertificationCreateSignedCertificationHandler = CreateSignedCertificationHandler{handlerConfig} internalAPI.CertificationIndexSignedCertificationHandler = IndexSignedCertificationsHandler{handlerConfig} @@ -192,7 +194,7 @@ func NewInternalAPI(handlerConfig handlers.HandlerConfig) *internalops.MymoveAPI internalAPI.PpmCreatePPMUploadHandler = CreatePPMUploadHandler{handlerConfig} - ppmShipmentNewSubmitter := ppmshipment.NewPPMShipmentNewSubmitter(signedCertificationCreator, ppmShipmentRouter) + ppmShipmentNewSubmitter := ppmshipment.NewPPMShipmentNewSubmitter(ppmShipmentFetcher, signedCertificationCreator, ppmShipmentRouter) internalAPI.PpmSubmitPPMShipmentDocumentationHandler = SubmitPPMShipmentDocumentationHandler{handlerConfig, ppmShipmentNewSubmitter} diff --git a/pkg/handlers/internalapi/ppm_shipment.go b/pkg/handlers/internalapi/ppm_shipment.go index d14d890225f..182f58b7af2 100644 --- a/pkg/handlers/internalapi/ppm_shipment.go +++ b/pkg/handlers/internalapi/ppm_shipment.go @@ -24,14 +24,6 @@ type SubmitPPMShipmentDocumentationHandler struct { func (h SubmitPPMShipmentDocumentationHandler) Handle(params ppmops.SubmitPPMShipmentDocumentationParams) middleware.Responder { return h.AuditableAppContextFromRequestWithErrors(params.HTTPRequest, func(appCtx appcontext.AppContext) (middleware.Responder, error) { - if appCtx.Session() == nil { - return ppmops.NewSubmitPPMShipmentDocumentationUnauthorized(), apperror.NewSessionError("No user session") - } else if !appCtx.Session().IsMilApp() { - return ppmops.NewSubmitPPMShipmentDocumentationForbidden(), apperror.NewSessionError("Request is not from the customer app") - } else if appCtx.Session().UserID.IsNil() { - return ppmops.NewSubmitPPMShipmentDocumentationForbidden(), apperror.NewSessionError("No user ID in session") - } - ppmShipmentID, err := uuid.FromString(params.PpmShipmentID.String()) if err != nil || ppmShipmentID.IsNil() { appCtx.Logger().Error("error with PPM Shipment ID", zap.Error(err)) diff --git a/pkg/handlers/internalapi/ppm_shipment_test.go b/pkg/handlers/internalapi/ppm_shipment_test.go index 28286207e5a..3bb84229ab9 100644 --- a/pkg/handlers/internalapi/ppm_shipment_test.go +++ b/pkg/handlers/internalapi/ppm_shipment_test.go @@ -39,18 +39,20 @@ func (suite *HandlerSuite) TestSubmitPPMShipmentDocumentationHandlerUnit() { return ppmShipment } - setUpRequestAndParams := func(ppmShipment models.PPMShipment, authUser bool, setUpPayload bool) (*http.Request, ppmops.SubmitPPMShipmentDocumentationParams) { - endpoint := fmt.Sprintf("/ppm-shipments/%s/submit-ppm-shipment-documentation", ppmShipment.ID.String()) + setUpRequestAndParams := func( + ppmShipmentID uuid.UUID, + serviceMemberToAuth models.ServiceMember, + setUpPayload bool, + ) (*http.Request, ppmops.SubmitPPMShipmentDocumentationParams) { + endpoint := fmt.Sprintf("/ppm-shipments/%s/submit-ppm-shipment-documentation", ppmShipmentID.String()) request := httptest.NewRequest("POST", endpoint, nil) - if authUser { - request = suite.AuthenticateRequest(request, ppmShipment.Shipment.MoveTaskOrder.Orders.ServiceMember) - } + request = suite.AuthenticateRequest(request, serviceMemberToAuth) params := ppmops.SubmitPPMShipmentDocumentationParams{ HTTPRequest: request, - PpmShipmentID: handlers.FmtUUIDValue(ppmShipment.ID), + PpmShipmentID: handlers.FmtUUIDValue(ppmShipmentID), SavePPMShipmentSignedCertificationPayload: nil, } @@ -88,52 +90,10 @@ func (suite *HandlerSuite) TestSubmitPPMShipmentDocumentationHandlerUnit() { } } - suite.Run("Returns an error if there is no session information", func() { - ppmShipment := setUpPPMShipment() - - _, params := setUpRequestAndParams(ppmShipment, false, false) - - handler := setUpHandler(setUpPPMShipmentNewSubmitter(nil, nil)) - - response := handler.Handle(params) - - suite.IsType(&ppmops.SubmitPPMShipmentDocumentationUnauthorized{}, response) - }) - - suite.Run("Returns an error if the request isn't coming from the correct app", func() { - ppmShipment := setUpPPMShipment() - - request, params := setUpRequestAndParams(ppmShipment, false, false) - - officeUser := factory.BuildOfficeUser(nil, nil, nil) - request = suite.AuthenticateOfficeRequest(request, officeUser) - params.HTTPRequest = request - - handler := setUpHandler(setUpPPMShipmentNewSubmitter(nil, nil)) - - response := handler.Handle(params) - - suite.IsType(&ppmops.SubmitPPMShipmentDocumentationForbidden{}, response) - }) - - suite.Run("Returns an error if the user ID is missing from the session", func() { - ppmShipment := setUpPPMShipment() - ppmShipment.Shipment.MoveTaskOrder.Orders.ServiceMember.UserID = uuid.Nil - - _, params := setUpRequestAndParams(ppmShipment, true, false) - - handler := setUpHandler(setUpPPMShipmentNewSubmitter(nil, nil)) - - response := handler.Handle(params) - - suite.IsType(&ppmops.SubmitPPMShipmentDocumentationForbidden{}, response) - }) - suite.Run("Returns an error if the PPMShipment ID in the url is invalid", func() { ppmShipment := setUpPPMShipment() - ppmShipment.ID = uuid.Nil - _, params := setUpRequestAndParams(ppmShipment, true, false) + _, params := setUpRequestAndParams(uuid.Nil, ppmShipment.Shipment.MoveTaskOrder.Orders.ServiceMember, false) handler := setUpHandler(setUpPPMShipmentNewSubmitter(nil, nil)) @@ -149,7 +109,7 @@ func (suite *HandlerSuite) TestSubmitPPMShipmentDocumentationHandlerUnit() { suite.Run("Returns an error if there is no request body", func() { ppmShipment := setUpPPMShipment() - _, params := setUpRequestAndParams(ppmShipment, true, false) + _, params := setUpRequestAndParams(ppmShipment.ID, ppmShipment.Shipment.MoveTaskOrder.Orders.ServiceMember, false) handler := setUpHandler(setUpPPMShipmentNewSubmitter(nil, nil)) @@ -165,12 +125,14 @@ func (suite *HandlerSuite) TestSubmitPPMShipmentDocumentationHandlerUnit() { suite.Run("Returns an error if the submitter service returns a BadDataError", func() { ppmShipment := setUpPPMShipment() - _, params := setUpRequestAndParams(ppmShipment, true, true) + _, params := setUpRequestAndParams(ppmShipment.ID, ppmShipment.Shipment.MoveTaskOrder.Orders.ServiceMember, true) err := apperror.NewBadDataError("Bad data") handler := setUpHandler(setUpPPMShipmentNewSubmitter(nil, err)) + suite.NoError(params.SavePPMShipmentSignedCertificationPayload.Validate(strfmt.Default)) + response := handler.Handle(params) if suite.IsType(&ppmops.SubmitPPMShipmentDocumentationBadRequest{}, response) { @@ -183,12 +145,14 @@ func (suite *HandlerSuite) TestSubmitPPMShipmentDocumentationHandlerUnit() { suite.Run("Returns an error if the submitter service returns a NotFoundError", func() { ppmShipment := setUpPPMShipment() - _, params := setUpRequestAndParams(ppmShipment, true, true) + _, params := setUpRequestAndParams(ppmShipment.ID, ppmShipment.Shipment.MoveTaskOrder.Orders.ServiceMember, true) err := apperror.NewNotFoundError(ppmShipment.ID, "Can't find PPM shipment") handler := setUpHandler(setUpPPMShipmentNewSubmitter(nil, err)) + suite.NoError(params.SavePPMShipmentSignedCertificationPayload.Validate(strfmt.Default)) + response := handler.Handle(params) if suite.IsType(&ppmops.SubmitPPMShipmentDocumentationNotFound{}, response) { @@ -201,12 +165,14 @@ func (suite *HandlerSuite) TestSubmitPPMShipmentDocumentationHandlerUnit() { suite.Run("Returns an error if the submitter service returns a QueryError", func() { ppmShipment := setUpPPMShipment() - _, params := setUpRequestAndParams(ppmShipment, true, true) + _, params := setUpRequestAndParams(ppmShipment.ID, ppmShipment.Shipment.MoveTaskOrder.Orders.ServiceMember, true) err := apperror.NewQueryError("PPMShipment", nil, "Error getting PPM shipment") handler := setUpHandler(setUpPPMShipmentNewSubmitter(nil, err)) + suite.NoError(params.SavePPMShipmentSignedCertificationPayload.Validate(strfmt.Default)) + response := handler.Handle(params) suite.IsType(&ppmops.SubmitPPMShipmentDocumentationInternalServerError{}, response) @@ -215,16 +181,18 @@ func (suite *HandlerSuite) TestSubmitPPMShipmentDocumentationHandlerUnit() { suite.Run("Returns an error if the submitter service returns a InvalidInputError", func() { ppmShipment := setUpPPMShipment() - _, params := setUpRequestAndParams(ppmShipment, true, true) + _, params := setUpRequestAndParams(ppmShipment.ID, ppmShipment.Shipment.MoveTaskOrder.Orders.ServiceMember, true) verrs := validate.NewErrors() fieldWithErr := "field" fieldErrorMsg := "Field error" verrs.Add(fieldWithErr, fieldErrorMsg) - err := apperror.NewInvalidInputError(ppmShipment.ID, nil, verrs, "Invalid input") + fakeErr := apperror.NewInvalidInputError(ppmShipment.ID, nil, verrs, "Invalid input") - handler := setUpHandler(setUpPPMShipmentNewSubmitter(nil, err)) + handler := setUpHandler(setUpPPMShipmentNewSubmitter(nil, fakeErr)) + + suite.NoError(params.SavePPMShipmentSignedCertificationPayload.Validate(strfmt.Default)) response := handler.Handle(params) @@ -242,12 +210,14 @@ func (suite *HandlerSuite) TestSubmitPPMShipmentDocumentationHandlerUnit() { suite.Run("Returns an error if the submitter service returns a ConflictError", func() { ppmShipment := setUpPPMShipment() - _, params := setUpRequestAndParams(ppmShipment, true, true) + _, params := setUpRequestAndParams(ppmShipment.ID, ppmShipment.Shipment.MoveTaskOrder.Orders.ServiceMember, true) err := apperror.NewConflictError(ppmShipment.ID, "Can't route PPM shipment") handler := setUpHandler(setUpPPMShipmentNewSubmitter(nil, err)) + suite.NoError(params.SavePPMShipmentSignedCertificationPayload.Validate(strfmt.Default)) + response := handler.Handle(params) if suite.IsType(&ppmops.SubmitPPMShipmentDocumentationConflict{}, response) { @@ -260,12 +230,14 @@ func (suite *HandlerSuite) TestSubmitPPMShipmentDocumentationHandlerUnit() { suite.Run("Returns an error if the submitter service returns an unexpected error", func() { ppmShipment := setUpPPMShipment() - _, params := setUpRequestAndParams(ppmShipment, true, true) + _, params := setUpRequestAndParams(ppmShipment.ID, ppmShipment.Shipment.MoveTaskOrder.Orders.ServiceMember, true) err := apperror.NewNotImplementedError("Not implemented") handler := setUpHandler(setUpPPMShipmentNewSubmitter(nil, err)) + suite.NoError(params.SavePPMShipmentSignedCertificationPayload.Validate(strfmt.Default)) + response := handler.Handle(params) suite.IsType(&ppmops.SubmitPPMShipmentDocumentationInternalServerError{}, response) @@ -274,7 +246,7 @@ func (suite *HandlerSuite) TestSubmitPPMShipmentDocumentationHandlerUnit() { suite.Run("Returns the PPM shipment if all goes well", func() { ppmShipment := setUpPPMShipment() - _, params := setUpRequestAndParams(ppmShipment, true, true) + _, params := setUpRequestAndParams(ppmShipment.ID, ppmShipment.Shipment.MoveTaskOrder.Orders.ServiceMember, true) expectedPPMShipment := ppmShipment expectedPPMShipment.Status = models.PPMShipmentStatusNeedsPaymentApproval @@ -300,6 +272,8 @@ func (suite *HandlerSuite) TestSubmitPPMShipmentDocumentationHandlerUnit() { handler := setUpHandler(setUpPPMShipmentNewSubmitter(&expectedPPMShipment, nil)) + suite.NoError(params.SavePPMShipmentSignedCertificationPayload.Validate(strfmt.Default)) + response := handler.Handle(params) if suite.IsType(&ppmops.SubmitPPMShipmentDocumentationOK{}, response) { @@ -315,22 +289,27 @@ func (suite *HandlerSuite) TestSubmitPPMShipmentDocumentationHandlerUnit() { } func (suite *HandlerSuite) TestSubmitPPMShipmentDocumentationHandlerIntegration() { + ppmShipmentFetcher := ppmshipment.NewPPMShipmentFetcher() signedCertificationCreator := signedcertification.NewSignedCertificationCreator() mtoShipmentRouter := mtoshipment.NewShipmentRouter() ppmShipmentRouter := ppmshipment.NewPPMShipmentRouter(mtoShipmentRouter) - submitter := ppmshipment.NewPPMShipmentNewSubmitter(signedCertificationCreator, ppmShipmentRouter) + submitter := ppmshipment.NewPPMShipmentNewSubmitter(ppmShipmentFetcher, signedCertificationCreator, ppmShipmentRouter) - setUpParamsAndHandler := func(ppmShipment models.PPMShipment, payload *internalmessages.SavePPMShipmentSignedCertification) (ppmops.SubmitPPMShipmentDocumentationParams, SubmitPPMShipmentDocumentationHandler) { - endpoint := fmt.Sprintf("/ppm-shipments/%s/submit-ppm-shipment-documentation", ppmShipment.ID.String()) + setUpParamsAndHandler := func( + ppmShipmentID uuid.UUID, + serviceMemberToAuth models.ServiceMember, + payload *internalmessages.SavePPMShipmentSignedCertification, + ) (ppmops.SubmitPPMShipmentDocumentationParams, SubmitPPMShipmentDocumentationHandler) { + endpoint := fmt.Sprintf("/ppm-shipments/%s/submit-ppm-shipment-documentation", ppmShipmentID.String()) request := httptest.NewRequest("POST", endpoint, nil) - request = suite.AuthenticateRequest(request, ppmShipment.Shipment.MoveTaskOrder.Orders.ServiceMember) + request = suite.AuthenticateRequest(request, serviceMemberToAuth) params := ppmops.SubmitPPMShipmentDocumentationParams{ HTTPRequest: request, - PpmShipmentID: handlers.FmtUUIDValue(ppmShipment.ID), + PpmShipmentID: handlers.FmtUUIDValue(ppmShipmentID), SavePPMShipmentSignedCertificationPayload: payload, } @@ -345,16 +324,41 @@ func (suite *HandlerSuite) TestSubmitPPMShipmentDocumentationHandlerIntegration( suite.Run("Returns an error if the PPM shipment is not found", func() { ppmShipment := factory.BuildPPMShipmentReadyForFinalCustomerCloseOut(suite.DB(), nil, nil) - ppmShipment.ID = uuid.Must(uuid.NewV4()) + params, handler := setUpParamsAndHandler( + uuid.Must(uuid.NewV4()), + ppmShipment.Shipment.MoveTaskOrder.Orders.ServiceMember, + &internalmessages.SavePPMShipmentSignedCertification{ + CertificationText: handlers.FmtString("certification text"), + Date: handlers.FmtDate(time.Now()), + Signature: handlers.FmtString("signature"), + }) - params, handler := setUpParamsAndHandler(ppmShipment, &internalmessages.SavePPMShipmentSignedCertification{ - CertificationText: handlers.FmtString("certification text"), - Date: handlers.FmtDate(time.Now()), - Signature: handlers.FmtString("signature"), - }) + suite.NoError(params.SavePPMShipmentSignedCertificationPayload.Validate(strfmt.Default)) - err := params.SavePPMShipmentSignedCertificationPayload.Validate(strfmt.Default) - suite.NoError(err) + response := handler.Handle(params) + + if suite.IsType(&ppmops.SubmitPPMShipmentDocumentationNotFound{}, response) { + errResponse := response.(*ppmops.SubmitPPMShipmentDocumentationNotFound) + + suite.Contains(*errResponse.Payload.Detail, "not found while looking for PPMShipment") + } + }) + + suite.Run("Returns an error if the PPM shipment belongs to a different service member", func() { + ppmShipment := factory.BuildPPMShipmentReadyForFinalCustomerCloseOut(suite.DB(), nil, nil) + + otherServiceMember := factory.BuildExtendedServiceMember(suite.DB(), factory.GetTraitActiveServiceMemberUser(), nil) + + params, handler := setUpParamsAndHandler( + ppmShipment.ID, + otherServiceMember, + &internalmessages.SavePPMShipmentSignedCertification{ + CertificationText: handlers.FmtString("certification text"), + Date: handlers.FmtDate(time.Now()), + Signature: handlers.FmtString("signature"), + }) + + suite.NoError(params.SavePPMShipmentSignedCertificationPayload.Validate(strfmt.Default)) response := handler.Handle(params) @@ -368,10 +372,13 @@ func (suite *HandlerSuite) TestSubmitPPMShipmentDocumentationHandlerIntegration( suite.Run("Returns an error if the SignedCertification has any errors", func() { ppmShipment := factory.BuildPPMShipmentReadyForFinalCustomerCloseOut(suite.DB(), nil, nil) - params, handler := setUpParamsAndHandler(ppmShipment, &internalmessages.SavePPMShipmentSignedCertification{ - CertificationText: handlers.FmtString("certification text"), - Signature: handlers.FmtString("signature"), - }) + params, handler := setUpParamsAndHandler( + ppmShipment.ID, + ppmShipment.Shipment.MoveTaskOrder.Orders.ServiceMember, + &internalmessages.SavePPMShipmentSignedCertification{ + CertificationText: handlers.FmtString("certification text"), + Signature: handlers.FmtString("signature"), + }) err := params.SavePPMShipmentSignedCertificationPayload.Validate(strfmt.Default) suite.Error(err) @@ -393,11 +400,16 @@ func (suite *HandlerSuite) TestSubmitPPMShipmentDocumentationHandlerIntegration( suite.Run("Returns an error if the PPM shipment is not in the right status", func() { ppmShipment := factory.BuildPPMShipmentThatNeedsPaymentApproval(suite.DB(), nil, nil) - params, handler := setUpParamsAndHandler(ppmShipment, &internalmessages.SavePPMShipmentSignedCertification{ - CertificationText: handlers.FmtString("certification text"), - Signature: handlers.FmtString("signature"), - Date: handlers.FmtDate(time.Now()), - }) + params, handler := setUpParamsAndHandler( + ppmShipment.ID, + ppmShipment.Shipment.MoveTaskOrder.Orders.ServiceMember, + &internalmessages.SavePPMShipmentSignedCertification{ + CertificationText: handlers.FmtString("certification text"), + Signature: handlers.FmtString("signature"), + Date: handlers.FmtDate(time.Now()), + }) + + suite.NoError(params.SavePPMShipmentSignedCertificationPayload.Validate(strfmt.Default)) response := handler.Handle(params) @@ -422,11 +434,16 @@ func (suite *HandlerSuite) TestSubmitPPMShipmentDocumentationHandlerIntegration( signature := "signature" signDate := time.Now() - params, handler := setUpParamsAndHandler(ppmShipment, &internalmessages.SavePPMShipmentSignedCertification{ - CertificationText: handlers.FmtString(certText), - Signature: handlers.FmtString(signature), - Date: handlers.FmtDate(signDate), - }) + params, handler := setUpParamsAndHandler( + ppmShipment.ID, + ppmShipment.Shipment.MoveTaskOrder.Orders.ServiceMember, + &internalmessages.SavePPMShipmentSignedCertification{ + CertificationText: handlers.FmtString(certText), + Signature: handlers.FmtString(signature), + Date: handlers.FmtDate(signDate), + }) + + suite.NoError(params.SavePPMShipmentSignedCertificationPayload.Validate(strfmt.Default)) response := handler.Handle(params) diff --git a/pkg/handlers/routing/internalapi_test/ppm_shipment_test.go b/pkg/handlers/routing/internalapi_test/ppm_shipment_test.go new file mode 100644 index 00000000000..2f68f85d843 --- /dev/null +++ b/pkg/handlers/routing/internalapi_test/ppm_shipment_test.go @@ -0,0 +1,106 @@ +package internalapi_test + +import ( + "bytes" + "encoding/json" + "fmt" + "net/http" + "net/http/httptest" + "time" + + "github.com/transcom/mymove/pkg/factory" + "github.com/transcom/mymove/pkg/gen/internalmessages" + "github.com/transcom/mymove/pkg/handlers" +) + +func (suite *InternalAPISuite) TestSubmitPPMShipmentDocumentation() { + // setUpRequestBody sets up the request body for the ppm document submission request. + setUpRequestBody := func() *bytes.Buffer { + // Not sure if I like or dislike the use of internalmessages here. On the one hand, it makes it easier for + // people that are used to the way we set up request bodies in the existing integration tests. On the other, + // it ties us to the go-swagger types and imports. Alternatively, we could do something like: + // + // body := map[string]string{ + // "certification_text": "I accept all the liability!", + // "signature": "Best Customer", + // "date": "2023-08-08", + // } + // + // and use json.Marshal(body) the same way. I think either option is better ergonomically than the way we did + // the first ones with byte slices like: + // + // jsonBody := []byte(`{"certification_text": "I accept all the liability!", "signature": "Best Customer", "date": "2023-08-08"}`) + // + // but at the time I hadn't known we could do it either of these other two ways. + body := &internalmessages.SavePPMShipmentSignedCertification{ + CertificationText: handlers.FmtString("I accept all the liability!"), + Signature: handlers.FmtString("Best Customer"), + Date: handlers.FmtDate(time.Now()), + } + + jsonBody, err := json.Marshal(body) + + suite.FatalNoError(err) + + bodyBuffer := bytes.NewBuffer(jsonBody) + + return bodyBuffer + } + + suite.Run("Unauthorized call to /ppm-shipments/{ppmShipmentId}/submit-ppm-shipment-documentation by another service member", func() { + ppmShipment := factory.BuildPPMShipmentReadyForFinalCustomerCloseOut(suite.DB(), nil, factory.GetTraitActiveServiceMemberUser()) + + maliciousUser := factory.BuildServiceMember(suite.DB(), factory.GetTraitActiveServiceMemberUser(), nil) + + endpointPath := fmt.Sprintf("/internal/ppm-shipments/%s/submit-ppm-shipment-documentation", ppmShipment.ID.String()) + + body := setUpRequestBody() + + req := suite.NewAuthenticatedMilRequest(http.MethodPost, endpointPath, body, maliciousUser) + + req.Header.Set("Content-Type", "application/json") + + rr := httptest.NewRecorder() + + suite.SetupSiteHandler().ServeHTTP(rr, req) + + suite.Equal(http.StatusNotFound, rr.Code) + }) + + suite.Run("Unauthorized call to /ppm-shipments/{ppmShipmentId}/submit-ppm-shipment-documentation by user that isn't logged in", func() { + ppmShipment := factory.BuildPPMShipmentReadyForFinalCustomerCloseOut(suite.DB(), nil, factory.GetTraitActiveServiceMemberUser()) + + endpointPath := fmt.Sprintf("/internal/ppm-shipments/%s/submit-ppm-shipment-documentation", ppmShipment.ID.String()) + + body := setUpRequestBody() + + req := suite.NewMilRequest(http.MethodPost, endpointPath, body) + + req.Header.Set("Content-Type", "application/json") + + rr := httptest.NewRecorder() + + suite.SetupSiteHandler().ServeHTTP(rr, req) + + // Happens because we don't have a CSRF token, since they aren't logged in. + suite.Equal(http.StatusForbidden, rr.Code) + }) + + suite.Run("Authorized call to /ppm-shipments/{ppmShipmentId}/submit-ppm-shipment-documentation", func() { + ppmShipment := factory.BuildPPMShipmentReadyForFinalCustomerCloseOut(suite.DB(), nil, factory.GetTraitActiveServiceMemberUser()) + + endpointPath := fmt.Sprintf("/internal/ppm-shipments/%s/submit-ppm-shipment-documentation", ppmShipment.ID.String()) + + body := setUpRequestBody() + + req := suite.NewAuthenticatedMilRequest(http.MethodPost, endpointPath, body, ppmShipment.Shipment.MoveTaskOrder.Orders.ServiceMember) + + req.Header.Set("Content-Type", "application/json") + + rr := httptest.NewRecorder() + + suite.SetupSiteHandler().ServeHTTP(rr, req) + + suite.Equal(http.StatusOK, rr.Code) + }) +} diff --git a/pkg/services/ppmshipment/ppm_shipment_new_submitter.go b/pkg/services/ppmshipment/ppm_shipment_new_submitter.go index 4deac62d9d9..abfebcd0b3f 100644 --- a/pkg/services/ppmshipment/ppm_shipment_new_submitter.go +++ b/pkg/services/ppmshipment/ppm_shipment_new_submitter.go @@ -12,16 +12,19 @@ import ( // ppmShipmentNewSubmitter is the concrete struct implementing the services.PPMShipmentNewSubmitter interface type ppmShipmentNewSubmitter struct { + services.PPMShipmentFetcher services.SignedCertificationCreator services.PPMShipmentRouter } // NewPPMShipmentNewSubmitter creates a new ppmShipmentNewSubmitter func NewPPMShipmentNewSubmitter( + ppmShipmentFetcher services.PPMShipmentFetcher, signedCertificationCreator services.SignedCertificationCreator, ppmShipmentRouter services.PPMShipmentRouter, ) services.PPMShipmentNewSubmitter { return &ppmShipmentNewSubmitter{ + PPMShipmentFetcher: ppmShipmentFetcher, SignedCertificationCreator: signedCertificationCreator, PPMShipmentRouter: ppmShipmentRouter, } @@ -33,7 +36,22 @@ func (p *ppmShipmentNewSubmitter) SubmitNewCustomerCloseOut(appCtx appcontext.Ap return nil, apperror.NewBadDataError("PPM ID is required") } - ppmShipment, err := FindPPMShipment(appCtx, ppmShipmentID) + ppmShipment, err := p.GetPPMShipment( + appCtx, + ppmShipmentID, + []string{ + EagerPreloadAssociationShipment, + EagerPreloadAssociationWeightTickets, + EagerPreloadAssociationProgearWeightTickets, + EagerPreloadAssociationMovingExpenses, + EagerPreloadAssociationW2Address, + }, []string{ + PostLoadAssociationSignedCertification, + PostLoadAssociationWeightTicketUploads, + PostLoadAssociationProgearWeightTicketUploads, + PostLoadAssociationMovingExpenseUploads, + }, + ) if err != nil { return nil, err diff --git a/pkg/services/ppmshipment/ppm_shipment_new_submitter_test.go b/pkg/services/ppmshipment/ppm_shipment_new_submitter_test.go index c4c124057fb..77089eac1e3 100644 --- a/pkg/services/ppmshipment/ppm_shipment_new_submitter_test.go +++ b/pkg/services/ppmshipment/ppm_shipment_new_submitter_test.go @@ -18,6 +18,35 @@ import ( ) func (suite *PPMShipmentSuite) TestSubmitNewCustomerCloseOut() { + refectchPPMShipment := func(ppmShipmentID uuid.UUID) *models.PPMShipment { + // The submitter uses a copier which runs into an issue because of all of the extra references our test data + // will have filled out because of how our factories work, including some circular references. In practice, + // we wouldn't have all of those relationships loaded at once, so the copier works fine during regular usage. + // Here we'll only retrieve the bare minimum. + + var ppmShipment models.PPMShipment + + err := suite.DB().EagerPreload(EagerPreloadAssociationShipment).Find(&ppmShipment, ppmShipmentID) + + suite.FatalNoError(err) + + return &ppmShipment + } + + setUpPPMShipmentFetcherMock := func(returnValue ...interface{}) services.PPMShipmentFetcher { + mockFetcher := &mocks.PPMShipmentFetcher{} + + mockFetcher.On( + "GetPPMShipment", + mock.AnythingOfType("*appcontext.appContext"), + mock.AnythingOfType("uuid.UUID"), + mock.AnythingOfType("[]string"), + mock.AnythingOfType("[]string"), + ).Return(returnValue...) + + return mockFetcher + } + setUpSignedCertificationCreatorMock := func(returnValue ...interface{}) services.SignedCertificationCreator { mockCreator := &mocks.SignedCertificationCreator{} @@ -44,6 +73,7 @@ func (suite *PPMShipmentSuite) TestSubmitNewCustomerCloseOut() { suite.Run("Returns an error if PPM ID is invalid", func() { submitter := NewPPMShipmentNewSubmitter( + setUpPPMShipmentFetcherMock(nil, nil), setUpSignedCertificationCreatorMock(nil, nil), setUpPPMShipperRouterMock(nil), ) @@ -62,10 +92,13 @@ func (suite *PPMShipmentSuite) TestSubmitNewCustomerCloseOut() { } }) - suite.Run("Returns an error if PPM shipment does not exist", func() { + suite.Run("Returns an error if there is a failure fetching the PPM shipment", func() { nonexistentPPMShipmentID := uuid.Must(uuid.NewV4()) + fakeErr := apperror.NewNotFoundError(nonexistentPPMShipmentID, "while looking for PPMShipment") + submitter := NewPPMShipmentNewSubmitter( + setUpPPMShipmentFetcherMock(nil, fakeErr), setUpSignedCertificationCreatorMock(nil, nil), setUpPPMShipperRouterMock(nil), ) @@ -76,12 +109,8 @@ func (suite *PPMShipmentSuite) TestSubmitNewCustomerCloseOut() { models.SignedCertification{}, ) - if suite.Error(err) { - suite.Nil(updatedPPMShipment) - - suite.IsType(apperror.NotFoundError{}, err) - suite.Contains(err.Error(), "not found while looking for PPMShipment") - } + suite.ErrorIs(err, fakeErr) + suite.Nil(updatedPPMShipment) }) suite.Run("Returns an error if creating a new signed certification fails", func() { @@ -94,7 +123,11 @@ func (suite *PPMShipmentSuite) TestSubmitNewCustomerCloseOut() { fakeErr := apperror.NewQueryError("SignedCertification", nil, "Unable to create signed certification") creator := setUpSignedCertificationCreatorMock(nil, fakeErr) + expectedShipment := refectchPPMShipment(existingPPMShipment.ID) + mockFetcher := setUpPPMShipmentFetcherMock(expectedShipment, nil) + submitter := NewPPMShipmentNewSubmitter( + mockFetcher, creator, setUpPPMShipperRouterMock(nil), ) @@ -126,7 +159,11 @@ func (suite *PPMShipmentSuite) TestSubmitNewCustomerCloseOut() { ) router := setUpPPMShipperRouterMock(fakeErr) + expectedShipment := refectchPPMShipment(existingPPMShipment.ID) + mockFetcher := setUpPPMShipmentFetcherMock(expectedShipment, nil) + submitter := NewPPMShipmentNewSubmitter( + mockFetcher, setUpSignedCertificationCreatorMock(nil, nil), router, ) @@ -183,7 +220,11 @@ func (suite *PPMShipmentSuite) TestSubmitNewCustomerCloseOut() { return nil }) + expectedShipment := refectchPPMShipment(existingPPMShipment.ID) + mockFetcher := setUpPPMShipmentFetcherMock(expectedShipment, nil) + submitter := NewPPMShipmentNewSubmitter( + mockFetcher, creator, router, ) From d2f9194b4844332e2c00cc6fb42f5478a43e803b Mon Sep 17 00:00:00 2001 From: Felipe Lee Date: Tue, 15 Aug 2023 18:41:20 +0000 Subject: [PATCH 014/138] docs (comment): remove comment about ways of setting up request bodies Got alignment from several people on the team that using the `go-swagger` types for integration tests with routing & middleware enabled seems to be the best path forward in terms of dev ergonomics and type safety. Someone brought up a great point that if you change the type in the yaml file, this will also lead to a compilation error in the integration tests, which is a faster feedback loop than having to wait for the tests to run to see that the body is no longer being set up properly. JIRA-Ticket: MB-16387 --- .../internalapi_test/ppm_shipment_test.go | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/pkg/handlers/routing/internalapi_test/ppm_shipment_test.go b/pkg/handlers/routing/internalapi_test/ppm_shipment_test.go index 2f68f85d843..ae206b4cfd3 100644 --- a/pkg/handlers/routing/internalapi_test/ppm_shipment_test.go +++ b/pkg/handlers/routing/internalapi_test/ppm_shipment_test.go @@ -16,22 +16,6 @@ import ( func (suite *InternalAPISuite) TestSubmitPPMShipmentDocumentation() { // setUpRequestBody sets up the request body for the ppm document submission request. setUpRequestBody := func() *bytes.Buffer { - // Not sure if I like or dislike the use of internalmessages here. On the one hand, it makes it easier for - // people that are used to the way we set up request bodies in the existing integration tests. On the other, - // it ties us to the go-swagger types and imports. Alternatively, we could do something like: - // - // body := map[string]string{ - // "certification_text": "I accept all the liability!", - // "signature": "Best Customer", - // "date": "2023-08-08", - // } - // - // and use json.Marshal(body) the same way. I think either option is better ergonomically than the way we did - // the first ones with byte slices like: - // - // jsonBody := []byte(`{"certification_text": "I accept all the liability!", "signature": "Best Customer", "date": "2023-08-08"}`) - // - // but at the time I hadn't known we could do it either of these other two ways. body := &internalmessages.SavePPMShipmentSignedCertification{ CertificationText: handlers.FmtString("I accept all the liability!"), Signature: handlers.FmtString("Best Customer"), From fd0eff793fcd1869ab5da58f15c2ac9ecf458768 Mon Sep 17 00:00:00 2001 From: Felipe Lee Date: Tue, 15 Aug 2023 19:24:11 +0000 Subject: [PATCH 015/138] refactor (service): update joins for `GetPPMShipment` to be the same I don't think it matters if we do an inner or left join for this since there should always be a record on the joined table for the one we're starting from, so I'm just ensuring they all are the same type of join. JIRA Ticket: MB-16387 --- pkg/services/ppmshipment/ppm_shipment_fetcher.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/services/ppmshipment/ppm_shipment_fetcher.go b/pkg/services/ppmshipment/ppm_shipment_fetcher.go index c135ae32568..452cb19f1d0 100644 --- a/pkg/services/ppmshipment/ppm_shipment_fetcher.go +++ b/pkg/services/ppmshipment/ppm_shipment_fetcher.go @@ -116,7 +116,7 @@ func (f ppmShipmentFetcher) GetPPMShipment( q. InnerJoin("mto_shipments", "mto_shipments.id = ppm_shipments.shipment_id"). InnerJoin("moves", "moves.id = mto_shipments.move_id"). - LeftJoin("orders", "orders.id = moves.orders_id"). + InnerJoin("orders", "orders.id = moves.orders_id"). Where("orders.service_member_id = ?", appCtx.Session().ServiceMemberID) } From 34c33ec64e12473f32445166bd8b89b9f6d480e1 Mon Sep 17 00:00:00 2001 From: Felipe Lee Date: Tue, 15 Aug 2023 21:48:26 +0000 Subject: [PATCH 016/138] refactor (test): create func for common setup for ppm_shipment int tests JIRA Ticket: MB-16387 --- .../internalapi_test/ppm_shipment_test.go | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/pkg/handlers/routing/internalapi_test/ppm_shipment_test.go b/pkg/handlers/routing/internalapi_test/ppm_shipment_test.go index ae206b4cfd3..d4fedcbf8df 100644 --- a/pkg/handlers/routing/internalapi_test/ppm_shipment_test.go +++ b/pkg/handlers/routing/internalapi_test/ppm_shipment_test.go @@ -11,9 +11,18 @@ import ( "github.com/transcom/mymove/pkg/factory" "github.com/transcom/mymove/pkg/gen/internalmessages" "github.com/transcom/mymove/pkg/handlers" + "github.com/transcom/mymove/pkg/models" ) func (suite *InternalAPISuite) TestSubmitPPMShipmentDocumentation() { + setUpDataAndEndpointPath := func() (*models.PPMShipment, string) { + ppmShipment := factory.BuildPPMShipmentReadyForFinalCustomerCloseOut(suite.DB(), nil, factory.GetTraitActiveServiceMemberUser()) + + endpointPath := fmt.Sprintf("/internal/ppm-shipments/%s/submit-ppm-shipment-documentation", ppmShipment.ID.String()) + + return &ppmShipment, endpointPath + } + // setUpRequestBody sets up the request body for the ppm document submission request. setUpRequestBody := func() *bytes.Buffer { body := &internalmessages.SavePPMShipmentSignedCertification{ @@ -32,12 +41,10 @@ func (suite *InternalAPISuite) TestSubmitPPMShipmentDocumentation() { } suite.Run("Unauthorized call to /ppm-shipments/{ppmShipmentId}/submit-ppm-shipment-documentation by another service member", func() { - ppmShipment := factory.BuildPPMShipmentReadyForFinalCustomerCloseOut(suite.DB(), nil, factory.GetTraitActiveServiceMemberUser()) + _, endpointPath := setUpDataAndEndpointPath() maliciousUser := factory.BuildServiceMember(suite.DB(), factory.GetTraitActiveServiceMemberUser(), nil) - endpointPath := fmt.Sprintf("/internal/ppm-shipments/%s/submit-ppm-shipment-documentation", ppmShipment.ID.String()) - body := setUpRequestBody() req := suite.NewAuthenticatedMilRequest(http.MethodPost, endpointPath, body, maliciousUser) @@ -52,9 +59,7 @@ func (suite *InternalAPISuite) TestSubmitPPMShipmentDocumentation() { }) suite.Run("Unauthorized call to /ppm-shipments/{ppmShipmentId}/submit-ppm-shipment-documentation by user that isn't logged in", func() { - ppmShipment := factory.BuildPPMShipmentReadyForFinalCustomerCloseOut(suite.DB(), nil, factory.GetTraitActiveServiceMemberUser()) - - endpointPath := fmt.Sprintf("/internal/ppm-shipments/%s/submit-ppm-shipment-documentation", ppmShipment.ID.String()) + _, endpointPath := setUpDataAndEndpointPath() body := setUpRequestBody() @@ -71,9 +76,7 @@ func (suite *InternalAPISuite) TestSubmitPPMShipmentDocumentation() { }) suite.Run("Authorized call to /ppm-shipments/{ppmShipmentId}/submit-ppm-shipment-documentation", func() { - ppmShipment := factory.BuildPPMShipmentReadyForFinalCustomerCloseOut(suite.DB(), nil, factory.GetTraitActiveServiceMemberUser()) - - endpointPath := fmt.Sprintf("/internal/ppm-shipments/%s/submit-ppm-shipment-documentation", ppmShipment.ID.String()) + ppmShipment, endpointPath := setUpDataAndEndpointPath() body := setUpRequestBody() From 3350a9522d040d3da718c378b3cd6565a0e788de Mon Sep 17 00:00:00 2001 From: Roger Steve Ruiz Date: Wed, 16 Aug 2023 21:57:24 +0000 Subject: [PATCH 017/138] Cleaning up the file's empty lines and spaces --- .../ServicesCounselingMoveInfo.jsx | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/pages/Office/ServicesCounselingMoveInfo/ServicesCounselingMoveInfo.jsx b/src/pages/Office/ServicesCounselingMoveInfo/ServicesCounselingMoveInfo.jsx index abc011f971f..0b89c267937 100644 --- a/src/pages/Office/ServicesCounselingMoveInfo/ServicesCounselingMoveInfo.jsx +++ b/src/pages/Office/ServicesCounselingMoveInfo/ServicesCounselingMoveInfo.jsx @@ -138,7 +138,6 @@ const ServicesCounselingMoveInfo = () => { {/* TODO - Routes not finalized, revisit */} } /> - { /> } /> - } /> - } /> - } /> - { end element={} /> - } /> - } /> - } /> - {/* TODO - clarify role/tab access */} } /> From 9c0a558f883087c0fed278fb4ea5bdf269801238 Mon Sep 17 00:00:00 2001 From: Roger Steve Ruiz Date: Wed, 16 Aug 2023 22:01:13 +0000 Subject: [PATCH 018/138] Adding a check for mtoShipments; Since in MB-15562 mentioned that there was an error related to `mtoShipments` being undefined, there's now a try-catch to attempt to catch any errors related to the server code not returning any shipments on a move task order. Co-Authored-By: Marjo Poindexter Co-Authored-By: Michael Valdes --- .../MovePaymentRequests.jsx | 34 ++++++++++++------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/src/pages/Office/MovePaymentRequests/MovePaymentRequests.jsx b/src/pages/Office/MovePaymentRequests/MovePaymentRequests.jsx index 0da8c4969ad..0f005ff48cf 100644 --- a/src/pages/Office/MovePaymentRequests/MovePaymentRequests.jsx +++ b/src/pages/Office/MovePaymentRequests/MovePaymentRequests.jsx @@ -149,20 +149,30 @@ const MovePaymentRequests = ({ const shipmentsInfo = []; if (paymentRequests.length) { - mtoShipments.forEach((shipment) => { - const tacType = shipment.shipmentType === SHIPMENT_OPTIONS.HHG ? LOA_TYPE.HHG : shipment.tacType; - const sacType = shipment.shipmentType === SHIPMENT_OPTIONS.HHG ? LOA_TYPE.HHG : shipment.sacType; + // NOTE: We are attempting a try-catch here for the `mtoShipments` + // iteration because it has previously been flagged as a bug in our + // backlog, MB-15562. + try { + mtoShipments.forEach((shipment) => { + const tacType = shipment.shipmentType === SHIPMENT_OPTIONS.HHG ? LOA_TYPE.HHG : shipment.tacType; + const sacType = shipment.shipmentType === SHIPMENT_OPTIONS.HHG ? LOA_TYPE.HHG : shipment.sacType; - shipmentsInfo.push({ - mtoShipmentID: shipment.id, - address: formatPaymentRequestAddressString(shipment.pickupAddress, shipment.destinationAddress), - departureDate: shipment.actualPickupDate, - modificationType: getShipmentModificationType(shipment), - mtoServiceItems: shipment.mtoServiceItems, - tacType, - sacType, + shipmentsInfo.push({ + mtoShipmentID: shipment.id, + address: formatPaymentRequestAddressString(shipment.pickupAddress, shipment.destinationAddress), + departureDate: shipment.actualPickupDate, + modificationType: getShipmentModificationType(shipment), + mtoServiceItems: shipment.mtoServiceItems, + tacType, + sacType, + }); }); - }); + } catch (error) { + milmoveLogger.warn( + 'MovePaymentRequests.jsx: Move Task Orders should always have Shipments associated with them.', + error, + ); + } } const handleReviewWeightsClick = () => { From 934ee1af0ffb7e7b3a0e26358fdf73789eb12338 Mon Sep 17 00:00:00 2001 From: Roger Steve Ruiz Date: Wed, 16 Aug 2023 22:05:25 +0000 Subject: [PATCH 019/138] Adding a check for order; Since in MB-15562 mentioned that there was an error related to `order` being undefined/null, there's an expression now to check to see that `order` is "truthy" or "defined" in order to render these components. Without it, these components don't get returned on this page. Co-Authored-By: Marjo Poindexter Co-Authored-By: Michael Valdes --- .../ServicesCounselingMoveInfo.jsx | 33 ++++---- src/pages/Office/TXOMoveInfo/TXOMoveInfo.jsx | 79 +++++++++++-------- 2 files changed, 65 insertions(+), 47 deletions(-) diff --git a/src/pages/Office/ServicesCounselingMoveInfo/ServicesCounselingMoveInfo.jsx b/src/pages/Office/ServicesCounselingMoveInfo/ServicesCounselingMoveInfo.jsx index 0b89c267937..7c5c9647a38 100644 --- a/src/pages/Office/ServicesCounselingMoveInfo/ServicesCounselingMoveInfo.jsx +++ b/src/pages/Office/ServicesCounselingMoveInfo/ServicesCounselingMoveInfo.jsx @@ -171,20 +171,25 @@ const ServicesCounselingMoveInfo = () => { element={} /> - - } - /> - + {/* WARN: MB-15562 captured this as a potential bug. An error was reported */} + {/* that `order` was without an `id` field. Therefore this broke the */} + {/* `CustomerInfo` component because it is expecting an `ordersId` to come */} + {/* from the `order.id` property returned by `useTXOMoveInfoQueries`. */} + {order.id && ( + + } + /> + )} { /> } /> } /> - - } - /> - }> - - - } - /> - }> - - - } - /> + } + /> + )} + {order.grade && ( + }> + + + } + /> + )} + {order.grade && ( + }> + + + } + /> + )} + } /> {/* TODO - clarify role/tab access */} } /> From 09761bea215deeb0cb5308be78af7898b8a801d0 Mon Sep 17 00:00:00 2001 From: Felipe Lee Date: Wed, 16 Aug 2023 22:52:30 +0000 Subject: [PATCH 020/138] docs: update docs for ppm shipment factory to reflect customs changes Previously we didn't allow customizations, but now we do. Updated to show that we don't accept traits still (though they can be passed in as customs if the caller sends the return value from the trait). JIRA Ticket: MB-16387 --- pkg/factory/ppm_shipment_factory.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/factory/ppm_shipment_factory.go b/pkg/factory/ppm_shipment_factory.go index 8f6c36b594a..d7d9fd2487d 100644 --- a/pkg/factory/ppm_shipment_factory.go +++ b/pkg/factory/ppm_shipment_factory.go @@ -424,7 +424,7 @@ func buildPPMShipmentReadyForFinalCustomerCloseOutWithCustoms(db *pop.Connection // PPMShipment that has customer documents and is ready for the // customer to sign and submit. // -// This function does not accept customizations to reduce the +// This function does not accept traits directly to reduce the // complexity of supporting different variations for tests func BuildPPMShipmentReadyForFinalCustomerCloseOut(db *pop.Connection, userUploader *uploader.UserUploader, customs []Customization) models.PPMShipment { return buildPPMShipmentReadyForFinalCustomerCloseOutWithCustoms(db, userUploader, customs) From d5d931a8ff5559da0df426b17b1c24d80e96e72a Mon Sep 17 00:00:00 2001 From: Marty Boren Date: Wed, 16 Aug 2023 23:25:50 +0000 Subject: [PATCH 021/138] Initial pass at updating LOA search logic This is all very rough!! Lots of prints and goofy logic. Still need some tests, and does not account for tac_fn_bl_mod_cd = P --- pkg/models/line_of_accounting.go | 9 + .../ghc_payment_request_invoice_generator.go | 59 ++++- ..._payment_request_invoice_generator_test.go | 220 ++++++++++++++++++ 3 files changed, 287 insertions(+), 1 deletion(-) diff --git a/pkg/models/line_of_accounting.go b/pkg/models/line_of_accounting.go index b65fb78f37a..c18253785ab 100644 --- a/pkg/models/line_of_accounting.go +++ b/pkg/models/line_of_accounting.go @@ -6,6 +6,15 @@ import ( "github.com/gofrs/uuid" ) +const ( + LineOfAccountingHouseholdGoodsCodeCivilian string = "HC" + LineOfAccountingHouseholdGoodsCodeEnlisted string = "HE" + LineOfAccountingHouseholdGoodsCodeOfficer string = "HO" + LineOfAccountingHouseholdGoodsCodeOther string = "HT" + LineOfAccountingHouseholdGoodsCodeDual string = "HD" + LineOfAccountingHouseholdGoodsCodeNTS string = "HS" +) + type LineOfAccounting struct { ID uuid.UUID `json:"id" db:"id"` LoaSysID *int `json:"loa_sys_id" db:"loa_sys_id"` diff --git a/pkg/services/invoice/ghc_payment_request_invoice_generator.go b/pkg/services/invoice/ghc_payment_request_invoice_generator.go index ebefba2f5b7..3729e78525b 100644 --- a/pkg/services/invoice/ghc_payment_request_invoice_generator.go +++ b/pkg/services/invoice/ghc_payment_request_invoice_generator.go @@ -653,13 +653,20 @@ func (g ghcPaymentRequestInvoiceGenerator) createLoaSegments(appCtx appcontext.A } func (g ghcPaymentRequestInvoiceGenerator) createLongLoaSegments(appCtx appcontext.AppContext, orders models.Order, tac string) ([]edisegment.FA2, error) { + var loas []models.LineOfAccounting var loa models.LineOfAccounting + // seems like we're missing year strings and dates, but maybe that just works bc sql + // coerces strings that are years into dates? + // also should we be using the end date? + // tac_fn_bl_mod_cd is a char(1) field. It has a mix of letters and numbers. We want to get lowest numbers first, and + // numbers before letters. This is the behavior we get from order by. err := appCtx.DB().Q(). Join("transportation_accounting_codes t", "t.loa_id = lines_of_accounting.id"). Where("t.tac = ?", tac). Where("? between loa_bgn_dt and loa_end_dt", orders.IssueDate). - First(&loa) + Order("t.tac_fn_bl_mod_cd asc"). + All(&loas) if err != nil { switch err { case sql.ErrNoRows: @@ -670,6 +677,56 @@ func (g ghcPaymentRequestInvoiceGenerator) createLongLoaSegments(appCtx appconte } } + fmt.Println("orders.issueDate", orders.IssueDate.String(), *orders.TAC) + fmt.Println("-----------------------------", len(loas)) + if len(loas) == 0 { + fmt.Print("no TAC or LOA found") + return nil, nil + } + //"HE" - E-1 through E-9 and Special Enlisted + //"HO" - O-1 Academy graduate through O-10, W1 - W5, Aviation Cadet, Academy Cadet, and Midshipman + //"HC" - Civilian employee + + // find a better way + if orders.ServiceMember.Rank == nil { + return nil, apperror.NewQueryError("SM not loaded!!!!", nil, "") + } + rank := *orders.ServiceMember.Rank + fmt.Println("rank", rank) + hhgCode := "" + + // we should probably just use a map instead of doing string shenanigans + if rank[:2] == "E_" { + hhgCode = "HE" + } else if rank[:2] == "O_" || rank[:2] == "W_" || rank == models.ServiceMemberRankACADEMYCADET || rank == models.ServiceMemberRankAVIATIONCADET || rank == models.ServiceMemberRankMIDSHIPMAN { + hhgCode = "HO" + } else if rank == models.ServiceMemberRankCIVILIANEMPLOYEE { + hhgCode = "HC" + } else { + return nil, apperror.NotImplementedError{} + } + // if just one, pick it + // if multiple,lowest FBMC + var loaWithMatchingCode []models.LineOfAccounting + + for _, line := range loas { + fmt.Println("checking", *line.LoaHsGdsCd, "against", hhgCode) + if line.LoaHsGdsCd != nil && *line.LoaHsGdsCd == hhgCode { + fmt.Println("found matching code", *line.LoaHsGdsCd, hhgCode) + loaWithMatchingCode = append(loaWithMatchingCode, line) + } + } + if len(loaWithMatchingCode) == 0 { + fmt.Println("no loa with matching code") + // fall back to the whole set and then sort by fbmc + // take first thing from whole set + loa = loas[0] + } + if len(loaWithMatchingCode) >= 1 { + // take first of loaWithMatchingCode + loa = loaWithMatchingCode[0] + } + var fa2LongLoaSegments []edisegment.FA2 var concatDate *string diff --git a/pkg/services/invoice/ghc_payment_request_invoice_generator_test.go b/pkg/services/invoice/ghc_payment_request_invoice_generator_test.go index ae1ee009464..ee5283fa2df 100644 --- a/pkg/services/invoice/ghc_payment_request_invoice_generator_test.go +++ b/pkg/services/invoice/ghc_payment_request_invoice_generator_test.go @@ -307,6 +307,21 @@ func (suite *GHCInvoiceSuite) TestAllGenerateEdi() { paymentServiceItems = models.PaymentServiceItems{} paymentServiceItems = append(paymentServiceItems, dlh, fsc, ms, cs, dsh, dop, ddp, dpk, dnpk, dupk, ddfsit, ddasit, dofsit, doasit, doshut, ddshut, dcrt, ducrt, dddsit, dopsit) + //// Add TAC/LOA records with fully filled out LOA fields + //loa := factory.BuildFullLineOfAccounting(nil) + //loa.LoaBgnDt = &mto.Orders.IssueDate + //endDate := mto.Orders.IssueDate.AddDate(5, 0, 0) + //loa.LoaEndDt = &endDate + //factory.BuildTransportationAccountingCode(suite.DB(), []factory.Customization{ + // { + // Model: models.TransportationAccountingCode{ + // TAC: *mto.Orders.TAC, + // }, + // }, + // { + // Model: loa, + // }, + //}, nil) // setup known next value icnErr := suite.icnSequencer.SetVal(suite.AppContextForTest(), 122) suite.NoError(icnErr) @@ -533,6 +548,22 @@ func (suite *GHCInvoiceSuite) TestAllGenerateEdi() { paymentServiceItems = models.PaymentServiceItems{} paymentServiceItems = append(paymentServiceItems, dopsit) + //// Add TAC/LOA records with fully filled out LOA fields + //loa := factory.BuildFullLineOfAccounting(nil) + //loa.LoaBgnDt = &mto.Orders.IssueDate + //endDate := mto.Orders.IssueDate.AddDate(5, 0, 0) + //loa.LoaEndDt = &endDate + //factory.BuildTransportationAccountingCode(suite.DB(), []factory.Customization{ + // { + // Model: models.TransportationAccountingCode{ + // TAC: *mto.Orders.TAC, + // }, + // }, + // { + // Model: loa, + // }, + //}, nil) + // // setup known next value icnErr := suite.icnSequencer.SetVal(suite.AppContextForTest(), 122) suite.NoError(icnErr) @@ -1080,6 +1111,7 @@ func (suite *GHCInvoiceSuite) TestAllGenerateEdi() { } }) + // shouldnt this be in the thing above? suite.Run("adds l3 service item segment", func() { l3 := result.L3 // Will need to be updated as more service items are supported @@ -1815,6 +1847,194 @@ func (suite *GHCInvoiceSuite) TestFA2s() { suite.Equal(*fa2Assertion.expectedInfoCode, fa2Segment.FinancialInformationCode) } }) + +} + +func (suite *GHCInvoiceSuite) TestUseTacToFindLoa() { + mockClock := clock.NewMock() + currentTime := mockClock.Now() + sixMonthsBefore := currentTime.AddDate(0, -6, 0) + sixMonthsAfter := currentTime.AddDate(0, 6, 0) + basicPaymentServiceItemParams := []factory.CreatePaymentServiceItemParams{ + { + Key: models.ServiceItemParamNameContractCode, + KeyType: models.ServiceItemParamTypeString, + Value: factory.DefaultContractCode, + }, + { + Key: models.ServiceItemParamNameReferenceDate, + KeyType: models.ServiceItemParamTypeDate, + Value: currentTime.Format(testDateFormat), + }, + { + Key: models.ServiceItemParamNameWeightBilled, + KeyType: models.ServiceItemParamTypeInteger, + Value: "4242", + }, + { + Key: models.ServiceItemParamNameDistanceZip, + KeyType: models.ServiceItemParamTypeInteger, + Value: "24246", + }, + } + + generator := NewGHCPaymentRequestInvoiceGenerator(suite.icnSequencer, mockClock) + + hhgTAC := "1111" + ntsTAC := "2222" + + var move models.Move + var mtoShipment models.MTOShipment + var paymentRequest models.PaymentRequest + setupLoaTestData := func() { + allLoaHsGdsCds := []string{models.LineOfAccountingHouseholdGoodsCodeCivilian, models.LineOfAccountingHouseholdGoodsCodeEnlisted, models.LineOfAccountingHouseholdGoodsCodeDual, models.LineOfAccountingHouseholdGoodsCodeOfficer, models.LineOfAccountingHouseholdGoodsCodeNTS, models.LineOfAccountingHouseholdGoodsCodeOther} + for i := range allLoaHsGdsCds { + loa := factory.BuildFullLineOfAccounting(nil) + loa.LoaBgnDt = &sixMonthsBefore + loa.LoaEndDt = &sixMonthsAfter + loa.LoaHsGdsCd = &allLoaHsGdsCds[i] + // The LoaDocID is not used in our LOA selection logic, and it appears in the final EDI. + // Most of the fields that we use internally to identify or pick the LOA are carried through to the final + // EDI. So we can use this LoaDocID field to identify which LOA was used to generate an EDI. + // This is a hack. Hopefully there's a better way. + loa.LoaDocID = &allLoaHsGdsCds[i] + + factory.BuildTransportationAccountingCode(suite.DB(), []factory.Customization{ + { + Model: models.TransportationAccountingCode{ + TAC: *move.Orders.TAC, + }, + }, + { + Model: loa, + }, + }, nil) + + } + } + + setupTestData := func() { + move = factory.BuildMove(suite.DB(), []factory.Customization{ + { + Model: models.Order{ + TAC: &hhgTAC, + NtsTAC: &ntsTAC, + IssueDate: currentTime, + }, + }, + }, nil) + + paymentRequest = factory.BuildPaymentRequest(suite.DB(), []factory.Customization{ + { + Model: move, + LinkOnly: true, + }, + { + Model: models.PaymentRequest{ + IsFinal: false, + Status: models.PaymentRequestStatusReviewed, + }, + }, + }, nil) + + mtoShipment = factory.BuildMTOShipment(suite.DB(), []factory.Customization{ + { + Model: move, + LinkOnly: true, + }, + }, nil) + + factory.BuildPaymentServiceItemWithParams( + suite.DB(), + models.ReServiceCodeDNPK, + basicPaymentServiceItemParams, + []factory.Customization{ + { + Model: move, + LinkOnly: true, + }, + { + Model: mtoShipment, + LinkOnly: true, + }, + { + Model: paymentRequest, + LinkOnly: true, + }, + { + Model: models.PaymentServiceItem{ + Status: models.PaymentServiceItemStatusApproved, + }, + }, + }, nil, + ) + } + suite.Run("when there are multiple LOAs for a given TAC, the one matching the customer's rank should be used", func() { + setupTestData() + setupLoaTestData() + + rankTestCases := []struct { + rank models.ServiceMemberRank + expectedLoaCode string + }{ + {models.ServiceMemberRankE1, models.LineOfAccountingHouseholdGoodsCodeEnlisted}, + {models.ServiceMemberRankE2, models.LineOfAccountingHouseholdGoodsCodeEnlisted}, + {models.ServiceMemberRankE3, models.LineOfAccountingHouseholdGoodsCodeEnlisted}, + {models.ServiceMemberRankE4, models.LineOfAccountingHouseholdGoodsCodeEnlisted}, + {models.ServiceMemberRankE5, models.LineOfAccountingHouseholdGoodsCodeEnlisted}, + {models.ServiceMemberRankE6, models.LineOfAccountingHouseholdGoodsCodeEnlisted}, + {models.ServiceMemberRankE7, models.LineOfAccountingHouseholdGoodsCodeEnlisted}, + {models.ServiceMemberRankE8, models.LineOfAccountingHouseholdGoodsCodeEnlisted}, + {models.ServiceMemberRankE9, models.LineOfAccountingHouseholdGoodsCodeEnlisted}, + {models.ServiceMemberRankE9SPECIALSENIORENLISTED, models.LineOfAccountingHouseholdGoodsCodeEnlisted}, + {models.ServiceMemberRankO1ACADEMYGRADUATE, models.LineOfAccountingHouseholdGoodsCodeOfficer}, + {models.ServiceMemberRankO2, models.LineOfAccountingHouseholdGoodsCodeOfficer}, + {models.ServiceMemberRankO3, models.LineOfAccountingHouseholdGoodsCodeOfficer}, + {models.ServiceMemberRankO4, models.LineOfAccountingHouseholdGoodsCodeOfficer}, + {models.ServiceMemberRankO5, models.LineOfAccountingHouseholdGoodsCodeOfficer}, + {models.ServiceMemberRankO6, models.LineOfAccountingHouseholdGoodsCodeOfficer}, + {models.ServiceMemberRankO7, models.LineOfAccountingHouseholdGoodsCodeOfficer}, + {models.ServiceMemberRankO8, models.LineOfAccountingHouseholdGoodsCodeOfficer}, + {models.ServiceMemberRankO9, models.LineOfAccountingHouseholdGoodsCodeOfficer}, + {models.ServiceMemberRankO10, models.LineOfAccountingHouseholdGoodsCodeOfficer}, + {models.ServiceMemberRankW1, models.LineOfAccountingHouseholdGoodsCodeOfficer}, + {models.ServiceMemberRankW2, models.LineOfAccountingHouseholdGoodsCodeOfficer}, + {models.ServiceMemberRankW3, models.LineOfAccountingHouseholdGoodsCodeOfficer}, + {models.ServiceMemberRankW4, models.LineOfAccountingHouseholdGoodsCodeOfficer}, + {models.ServiceMemberRankW5, models.LineOfAccountingHouseholdGoodsCodeOfficer}, + {models.ServiceMemberRankAVIATIONCADET, models.LineOfAccountingHouseholdGoodsCodeOfficer}, + {models.ServiceMemberRankCIVILIANEMPLOYEE, models.LineOfAccountingHouseholdGoodsCodeCivilian}, + {models.ServiceMemberRankACADEMYCADET, models.LineOfAccountingHouseholdGoodsCodeOfficer}, + {models.ServiceMemberRankMIDSHIPMAN, models.LineOfAccountingHouseholdGoodsCodeOfficer}, + } + + for _, testCase := range rankTestCases { + // Update service member rank + move.Orders.ServiceMember.Rank = &testCase.rank + paymentRequest.MoveTaskOrder.Orders.ServiceMember.Rank = &testCase.rank + err := suite.DB().Save(&move.Orders.ServiceMember) + suite.NoError(err) + + // Create invoice + result, err := generator.Generate(suite.AppContextForTest(), paymentRequest, false) + suite.NoError(err) + + // Check if invoice used the LOA we expected. + // The doc ID field would not work like this in real data, i'm just using it + // to get what the test needs into the EDI. + var actualDocID string + for _, fa2 := range result.ServiceItems[0].FA2s { + if fa2.BreakdownStructureDetailCode == edisegment.FA2DetailCodeJ1 { + actualDocID = fa2.FinancialInformationCode + break + } + } + suite.NotNil(actualDocID) + suite.Equal(testCase.expectedLoaCode, actualDocID) + } + }) + // test that we still get an LOA if none match the service member's rank + // test that the lowest tac_fn_bl_mod_cd is used as a tiebreaker } func (suite *GHCInvoiceSuite) TestDetermineDutyLocationPhoneLinesFunc() { From 03fd34c9426bfad451ce90bf3aa3220c7d74ed9b Mon Sep 17 00:00:00 2001 From: Marty Boren Date: Wed, 16 Aug 2023 23:55:01 +0000 Subject: [PATCH 022/138] Delete commented out code --- ..._payment_request_invoice_generator_test.go | 31 ------------------- 1 file changed, 31 deletions(-) diff --git a/pkg/services/invoice/ghc_payment_request_invoice_generator_test.go b/pkg/services/invoice/ghc_payment_request_invoice_generator_test.go index ee5283fa2df..ae81146c207 100644 --- a/pkg/services/invoice/ghc_payment_request_invoice_generator_test.go +++ b/pkg/services/invoice/ghc_payment_request_invoice_generator_test.go @@ -307,21 +307,6 @@ func (suite *GHCInvoiceSuite) TestAllGenerateEdi() { paymentServiceItems = models.PaymentServiceItems{} paymentServiceItems = append(paymentServiceItems, dlh, fsc, ms, cs, dsh, dop, ddp, dpk, dnpk, dupk, ddfsit, ddasit, dofsit, doasit, doshut, ddshut, dcrt, ducrt, dddsit, dopsit) - //// Add TAC/LOA records with fully filled out LOA fields - //loa := factory.BuildFullLineOfAccounting(nil) - //loa.LoaBgnDt = &mto.Orders.IssueDate - //endDate := mto.Orders.IssueDate.AddDate(5, 0, 0) - //loa.LoaEndDt = &endDate - //factory.BuildTransportationAccountingCode(suite.DB(), []factory.Customization{ - // { - // Model: models.TransportationAccountingCode{ - // TAC: *mto.Orders.TAC, - // }, - // }, - // { - // Model: loa, - // }, - //}, nil) // setup known next value icnErr := suite.icnSequencer.SetVal(suite.AppContextForTest(), 122) suite.NoError(icnErr) @@ -548,22 +533,6 @@ func (suite *GHCInvoiceSuite) TestAllGenerateEdi() { paymentServiceItems = models.PaymentServiceItems{} paymentServiceItems = append(paymentServiceItems, dopsit) - //// Add TAC/LOA records with fully filled out LOA fields - //loa := factory.BuildFullLineOfAccounting(nil) - //loa.LoaBgnDt = &mto.Orders.IssueDate - //endDate := mto.Orders.IssueDate.AddDate(5, 0, 0) - //loa.LoaEndDt = &endDate - //factory.BuildTransportationAccountingCode(suite.DB(), []factory.Customization{ - // { - // Model: models.TransportationAccountingCode{ - // TAC: *mto.Orders.TAC, - // }, - // }, - // { - // Model: loa, - // }, - //}, nil) - // // setup known next value icnErr := suite.icnSequencer.SetVal(suite.AppContextForTest(), 122) suite.NoError(icnErr) From a0ce8dc85fdd50abf0ed7a3bc9e0a24a2ed44233 Mon Sep 17 00:00:00 2001 From: Marty Boren Date: Thu, 17 Aug 2023 00:01:47 +0000 Subject: [PATCH 023/138] Remove debug prints --- .../invoice/ghc_payment_request_invoice_generator.go | 7 ------- 1 file changed, 7 deletions(-) diff --git a/pkg/services/invoice/ghc_payment_request_invoice_generator.go b/pkg/services/invoice/ghc_payment_request_invoice_generator.go index 3729e78525b..19c6fbbe80c 100644 --- a/pkg/services/invoice/ghc_payment_request_invoice_generator.go +++ b/pkg/services/invoice/ghc_payment_request_invoice_generator.go @@ -677,10 +677,7 @@ func (g ghcPaymentRequestInvoiceGenerator) createLongLoaSegments(appCtx appconte } } - fmt.Println("orders.issueDate", orders.IssueDate.String(), *orders.TAC) - fmt.Println("-----------------------------", len(loas)) if len(loas) == 0 { - fmt.Print("no TAC or LOA found") return nil, nil } //"HE" - E-1 through E-9 and Special Enlisted @@ -692,7 +689,6 @@ func (g ghcPaymentRequestInvoiceGenerator) createLongLoaSegments(appCtx appconte return nil, apperror.NewQueryError("SM not loaded!!!!", nil, "") } rank := *orders.ServiceMember.Rank - fmt.Println("rank", rank) hhgCode := "" // we should probably just use a map instead of doing string shenanigans @@ -710,14 +706,11 @@ func (g ghcPaymentRequestInvoiceGenerator) createLongLoaSegments(appCtx appconte var loaWithMatchingCode []models.LineOfAccounting for _, line := range loas { - fmt.Println("checking", *line.LoaHsGdsCd, "against", hhgCode) if line.LoaHsGdsCd != nil && *line.LoaHsGdsCd == hhgCode { - fmt.Println("found matching code", *line.LoaHsGdsCd, hhgCode) loaWithMatchingCode = append(loaWithMatchingCode, line) } } if len(loaWithMatchingCode) == 0 { - fmt.Println("no loa with matching code") // fall back to the whole set and then sort by fbmc // take first thing from whole set loa = loas[0] From 5020d96ed939ac4edcdd28fb304863614e4b1878 Mon Sep 17 00:00:00 2001 From: ruizajtruss Date: Thu, 17 Aug 2023 03:03:42 +0000 Subject: [PATCH 024/138] components completed and query added --- .../form/AddressFields/AddressFields.jsx | 8 ++ ...PrimeUIRequestSITDestAddressChangeForm.jsx | 19 ++- .../PrimeUIUpdateServiceItems.jsx | 115 ++++++++++++++++-- src/services/primeApi.js | 8 ++ 4 files changed, 129 insertions(+), 21 deletions(-) diff --git a/src/components/form/AddressFields/AddressFields.jsx b/src/components/form/AddressFields/AddressFields.jsx index ee5ac9bac2f..9a484b0c5af 100644 --- a/src/components/form/AddressFields/AddressFields.jsx +++ b/src/components/form/AddressFields/AddressFields.jsx @@ -132,6 +132,13 @@ export const AddressFields = ({ name={`${name}.streetAddress2`} validate={validators?.streetAddress2} /> +

Request Destination SIT Address Change

+ { +const UpdateServiceItems = ({ setFlashMessage }) => { const [errorMessage, setErrorMessage] = useState(); - setErrorMessage('just a placeholder so i can commit'); + const navigate = useNavigate(); + const { moveCodeOrID } = useParams(); + const { moveTaskOrder, isLoading, isError } = usePrimeSimulatorGetMove(moveCodeOrID); + const destinationServiceItem = moveTaskOrder?.mtoServiceItems.find( + (serviceItem) => serviceItem?.reServiceCode === 'DDDSIT', + ); const destAddressChangeRequestSchema = Yup.object().shape({ - addressID: Yup.string(), - destinationAddress: Yup.object().shape({ - address: addressSchema, - }), - eTag: Yup.string(), + requestedAddress: Yup.object().shape({ addressSchema }), + contractorRemarks: Yup.string(), + mtoServiceItemID: Yup.string(), }); + const reformatPrimeApiSITDestinationAddress = fromPrimeAPIAddressFormat( + destinationServiceItem.sitDestinationFinalAddress, + ); + + const initialValues = { + address: reformatPrimeApiSITDestinationAddress, + contractorRemarks: '', + mtoServiceItemID: destinationServiceItem.id, + }; + + const { mutate: createAdressUpdateRequestMutation } = useMutation(createSITAddressUpdateRequest, { + onSuccess: () => { + setFlashMessage( + `MSG_CREATE_ADDRESS_UPDATE_REQUEST_SUCCESS${moveCodeOrID}`, + 'success', + 'Successfully created SIT address update request', + '', + true, + ); + + navigate(generatePath(primeSimulatorRoutes.VIEW_MOVE_PATH, { moveCodeOrID })); + }, + onError: (error) => { + const { response: { body } = {} } = error; + + if (body) { + let additionalDetails = ''; + if (body.invalidFields) { + Object.keys(body.invalidFields).forEach((key) => { + additionalDetails += `:\n${key} - ${body.invalidFields[key]}`; + }); + } + + setErrorMessage({ + title: `Prime API: ${body.title} `, + detail: `${body.detail}${additionalDetails}`, + }); + } else { + setErrorMessage({ + title: 'Unexpected error', + detail: + 'An unknown error has occurred, please check the state of the shipment and service items data for this move', + }); + } + scrollToTop(); + }, + }); + + if (isLoading) return ; + if (isError) return ; + + const onSubmit = (values) => { + const { address, contractorRemarks, mtoServiceItemID } = values; + + const body = { + newAddress: { + streetAddress1: address.streetAddress1, + streetAddress2: address.streetAddress2, + streetAddress3: address.streetAddress3, + city: address.city, + state: address.state, + postalCode: address.postalCode, + }, + contractorRemarks, + mtoServiceItemID, + }; + + createAdressUpdateRequestMutation({ body }); + }; + return (
@@ -36,8 +121,10 @@ const UpdateServiceItems = () => { )}

Update Service Items

@@ -47,4 +134,12 @@ const UpdateServiceItems = () => { ); }; -export default UpdateServiceItems; +UpdateServiceItems.propTypes = { + setFlashMessage: func.isRequired, +}; + +const mapDispatchToProps = { + setFlashMessage: setFlashMessageAction, +}; + +export default connect(() => ({}), mapDispatchToProps)(UpdateServiceItems); diff --git a/src/services/primeApi.js b/src/services/primeApi.js index 45ba4c10dae..4b90e153ab8 100644 --- a/src/services/primeApi.js +++ b/src/services/primeApi.js @@ -96,6 +96,14 @@ export function createServiceItem({ body }) { return makePrimeSimulatorRequest('mtoServiceItem.createMTOServiceItem', { body: { ...body } }, { normalize: false }); } +export function createSITAddressUpdateRequest({ body }) { + return makePrimeSimulatorRequest( + 'sitAddressUpdate.createSITAddressUpdateRequest', + { body: { ...body } }, + { normalize: false }, + ); +} + export function updatePrimeMTOShipmentAddress({ mtoShipmentID, ifMatchETag, From 0f2a90204fd8740c0d7133d69c894b3a91a2b4f7 Mon Sep 17 00:00:00 2001 From: ruizajtruss Date: Thu, 17 Aug 2023 03:04:24 +0000 Subject: [PATCH 025/138] updated route --- src/constants/routes.js | 2 +- src/pages/PrimeUI/MoveTaskOrder/MoveDetails.jsx | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/constants/routes.js b/src/constants/routes.js index 2f5a92f0dd9..9d569219d2a 100644 --- a/src/constants/routes.js +++ b/src/constants/routes.js @@ -120,7 +120,7 @@ export const primeSimulatorRoutes = { UPDATE_SHIPMENT_PATH: `${BASE_PRIME_SIMULATOR_PATH}/shipments/:shipmentId`, CREATE_PAYMENT_REQUEST_PATH: `${BASE_PRIME_SIMULATOR_PATH}/payment-requests/new`, CREATE_SERVICE_ITEM_PATH: `${BASE_PRIME_SIMULATOR_PATH}/shipments/:shipmentId/service-items/new`, - UPDATE_SERVICE_ITEMS_PATH: `${BASE_PRIME_SIMULATOR_PATH}/mto-service-items`, + UPDATE_SERVICE_ITEMS_PATH: `${BASE_PRIME_SIMULATOR_PATH}/mto-service-items/update`, UPLOAD_DOCUMENTS_PATH: `${BASE_PRIME_SIMULATOR_PATH}/payment-requests/:paymentRequestId/upload`, UPLOAD_SERVICE_REQUEST_DOCUMENTS_PATH: `${BASE_PRIME_SIMULATOR_PATH}/mto-service-items/:mtoServiceItemId/upload`, SHIPMENT_UPDATE_ADDRESS_PATH: `${BASE_PRIME_SIMULATOR_PATH}/shipments/:shipmentId/addresses/update`, diff --git a/src/pages/PrimeUI/MoveTaskOrder/MoveDetails.jsx b/src/pages/PrimeUI/MoveTaskOrder/MoveDetails.jsx index a1333feaf6c..f5fdeddaed4 100644 --- a/src/pages/PrimeUI/MoveTaskOrder/MoveDetails.jsx +++ b/src/pages/PrimeUI/MoveTaskOrder/MoveDetails.jsx @@ -155,7 +155,11 @@ const MoveDetails = ({ setFlashMessage }) => {
{moveTaskOrder.mtoServiceItems?.length > 0 &&

Service Items

} - + Update Service Items
From 45b237152429afe681cbcd7b7e915f34df8079dd Mon Sep 17 00:00:00 2001 From: Kyle Hill Date: Thu, 17 Aug 2023 18:33:57 +0000 Subject: [PATCH 026/138] Adds authz check to weight ticket creation endpoint --- .../internalapi/weight_ticket_test.go | 9 +++-- .../internalapi_test/weight_ticket_test.go | 35 +++++++++++++++++++ .../weight_ticket/weight_ticket_creator.go | 15 ++++++++ .../weight_ticket_creator_test.go | 9 ++--- 4 files changed, 59 insertions(+), 9 deletions(-) create mode 100644 pkg/handlers/routing/internalapi_test/weight_ticket_test.go diff --git a/pkg/handlers/internalapi/weight_ticket_test.go b/pkg/handlers/internalapi/weight_ticket_test.go index 3b9e54ab29d..63bc11d6fa3 100644 --- a/pkg/handlers/internalapi/weight_ticket_test.go +++ b/pkg/handlers/internalapi/weight_ticket_test.go @@ -13,7 +13,6 @@ import ( "github.com/transcom/mymove/pkg/gen/internalmessages" "github.com/transcom/mymove/pkg/handlers" "github.com/transcom/mymove/pkg/models" - "github.com/transcom/mymove/pkg/models/roles" "github.com/transcom/mymove/pkg/services/mocks" weightticket "github.com/transcom/mymove/pkg/services/weight_ticket" "github.com/transcom/mymove/pkg/testdatagen" @@ -86,19 +85,19 @@ func (suite *HandlerSuite) TestCreateWeightTicketHandler() { suite.IsType(&weightticketops.CreateWeightTicketUnauthorized{}, response) }) - suite.Run("POST failure - 403- permission denied - wrong application", func() { + suite.Run("POST failure - 404- not found - wrong service member", func() { subtestData := makeCreateSubtestData(false) - officeUser := factory.BuildOfficeUserWithRoles(suite.DB(), nil, []roles.RoleType{roles.RoleTypeTOO}) + unauthorizedUser := factory.BuildServiceMember(suite.DB(), nil, nil) req := subtestData.params.HTTPRequest - unauthorizedReq := suite.AuthenticateOfficeRequest(req, officeUser) + unauthorizedReq := suite.AuthenticateRequest(req, unauthorizedUser) unauthorizedParams := subtestData.params unauthorizedParams.HTTPRequest = unauthorizedReq response := subtestData.handler.Handle(unauthorizedParams) - suite.IsType(&weightticketops.CreateWeightTicketForbidden{}, response) + suite.IsType(&weightticketops.CreateWeightTicketNotFound{}, response) }) suite.Run("Post failure - 500 - Server Error", func() { diff --git a/pkg/handlers/routing/internalapi_test/weight_ticket_test.go b/pkg/handlers/routing/internalapi_test/weight_ticket_test.go new file mode 100644 index 00000000000..80b7e49edb7 --- /dev/null +++ b/pkg/handlers/routing/internalapi_test/weight_ticket_test.go @@ -0,0 +1,35 @@ +package internalapi_test + +import ( + "fmt" + "net/http" + "net/http/httptest" + + "github.com/transcom/mymove/pkg/factory" +) + +func (suite *InternalAPISuite) TestUploadWeightTicket() { + suite.Run("Authorized post to /ppm-shipments/{ppmShipmentId}/weight-ticket", func() { + ppmShipment := factory.BuildPPMShipment(suite.DB(), factory.GetTraitActiveServiceMemberUser(), nil) + serviceMember := ppmShipment.Shipment.MoveTaskOrder.Orders.ServiceMember + endpointPath := fmt.Sprintf("/internal/ppm-shipments/%s/weight-ticket", ppmShipment.ID.String()) + + req := suite.NewAuthenticatedMilRequest("POST", endpointPath, nil, serviceMember) + rr := httptest.NewRecorder() + + suite.SetupSiteHandler().ServeHTTP(rr, req) + suite.Equal(http.StatusOK, rr.Code) + }) + + suite.Run("Unauthorized post to /ppm-shipments/{ppmShipmentId}/weight-ticket", func() { + ppmShipment := factory.BuildPPMShipment(suite.DB(), nil, nil) + serviceMember := factory.BuildServiceMember(suite.DB(), factory.GetTraitActiveServiceMemberUser(), nil) + endpointPath := fmt.Sprintf("/internal/ppm-shipments/%s/weight-ticket", ppmShipment.ID.String()) + + req := suite.NewAuthenticatedMilRequest("POST", endpointPath, nil, serviceMember) + rr := httptest.NewRecorder() + + suite.SetupSiteHandler().ServeHTTP(rr, req) + suite.Equal(http.StatusNotFound, rr.Code) + }) +} diff --git a/pkg/services/weight_ticket/weight_ticket_creator.go b/pkg/services/weight_ticket/weight_ticket_creator.go index 80c5f1f97d0..4cbfc2234e5 100644 --- a/pkg/services/weight_ticket/weight_ticket_creator.go +++ b/pkg/services/weight_ticket/weight_ticket_creator.go @@ -7,6 +7,7 @@ import ( "github.com/transcom/mymove/pkg/apperror" "github.com/transcom/mymove/pkg/models" "github.com/transcom/mymove/pkg/services" + "github.com/transcom/mymove/pkg/services/ppmshipment" ) type weightTicketCreator struct { @@ -27,6 +28,20 @@ func (f *weightTicketCreator) CreateWeightTicket(appCtx appcontext.AppContext, p return nil, err } + shipmentFetcher := ppmshipment.NewPPMShipmentFetcher() + + ppmShipment, ppmShipmentErr := shipmentFetcher.GetPPMShipment(appCtx, ppmShipmentID, []string{ + ppmshipment.EagerPreloadAssociationServiceMember, + }, []string{}) + + if ppmShipmentErr != nil { + return nil, ppmShipmentErr + } + + if ppmShipment.Shipment.MoveTaskOrder.Orders.ServiceMemberID != appCtx.Session().ServiceMemberID { + return nil, apperror.NewNotFoundError(ppmShipmentID, "No such shipment found for this service member") + } + var weightTicket models.WeightTicket txnErr := appCtx.NewTransaction(func(txnCtx appcontext.AppContext) error { diff --git a/pkg/services/weight_ticket/weight_ticket_creator_test.go b/pkg/services/weight_ticket/weight_ticket_creator_test.go index 57b69fff966..3902389afc9 100644 --- a/pkg/services/weight_ticket/weight_ticket_creator_test.go +++ b/pkg/services/weight_ticket/weight_ticket_creator_test.go @@ -10,12 +10,13 @@ import ( func (suite *WeightTicketSuite) TestWeightTicketCreator() { suite.Run("Successfully creates a WeightTicket", func() { - serviceMember := factory.BuildServiceMember(suite.DB(), nil, nil) + ppmShipment := factory.BuildMinimalPPMShipment(suite.DB(), nil, nil) + serviceMember := ppmShipment.Shipment.MoveTaskOrder.Orders.ServiceMember + session := &auth.Session{ ServiceMemberID: serviceMember.ID, } - ppmShipment := factory.BuildMinimalPPMShipment(suite.DB(), nil, nil) weightTicketCreator := NewCustomerWeightTicketCreator() weightTicket, err := weightTicketCreator.CreateWeightTicket(suite.AppContextWithSessionForTest(session), ppmShipment.ID) @@ -54,7 +55,7 @@ func (suite *WeightTicketSuite) TestWeightTicketCreator() { suite.Nil(weightTicket) suite.NotNil(err) - suite.IsType(apperror.InvalidInputError{}, err) - suite.Equal("Invalid input found while creating the Document.", err.Error()) + suite.IsType(apperror.NotFoundError{}, err) + suite.Contains(err.Error(), "No such shipment found for this service member") }) } From e18cae53b484b6cc8aa1e2c651eb3a8de7fa490b Mon Sep 17 00:00:00 2001 From: Amanda P Date: Thu, 17 Aug 2023 16:43:15 -0400 Subject: [PATCH 027/138] allow minimum of 0 for AK9 --- pkg/edi/segment/ak9.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/edi/segment/ak9.go b/pkg/edi/segment/ak9.go index f973360dde3..a138b1a5ace 100644 --- a/pkg/edi/segment/ak9.go +++ b/pkg/edi/segment/ak9.go @@ -8,9 +8,9 @@ import ( // AK9 represents the AK9 EDI segment type AK9 struct { FunctionalGroupAcknowledgeCode string `validate:"oneof=A E P R"` - NumberOfTransactionSetsIncluded int `validate:"min=1,max=999999"` - NumberOfReceivedTransactionSets int `validate:"min=1,max=999999"` - NumberOfAcceptedTransactionSets int `validate:"min=1,max=999999"` + NumberOfTransactionSetsIncluded int `validate:"min=0,max=999999"` + NumberOfReceivedTransactionSets int `validate:"min=0,max=999999"` + NumberOfAcceptedTransactionSets int `validate:"min=0,max=999999"` FunctionalGroupSyntaxErrorCodeAK905 string `validate:"omitempty,max=3"` FunctionalGroupSyntaxErrorCodeAK906 string `validate:"omitempty,max=3"` FunctionalGroupSyntaxErrorCodeAK907 string `validate:"omitempty,max=3"` From fad010f0ae34b2f3051bbf5b46425a1434cfde6f Mon Sep 17 00:00:00 2001 From: ruizajtruss Date: Fri, 18 Aug 2023 00:37:57 +0000 Subject: [PATCH 028/138] testing --- ...PrimeUIRequestSITDestAddressChangeForm.jsx | 21 ++-- ...UIRequestSITDestAddressChangeForm.test.jsx | 95 +++++++++++++++++++ .../PrimeUIUpdateServiceItems.jsx | 15 +-- .../PrimeUIUpdateServiceItems.test.jsx | 69 ++++++++++++++ 4 files changed, 179 insertions(+), 21 deletions(-) create mode 100644 src/pages/PrimeUI/UpdateServiceItems/PrimeUIRequestSITDestAddressChangeForm.test.jsx diff --git a/src/pages/PrimeUI/UpdateServiceItems/PrimeUIRequestSITDestAddressChangeForm.jsx b/src/pages/PrimeUI/UpdateServiceItems/PrimeUIRequestSITDestAddressChangeForm.jsx index f03f7ca78ad..f44363c2299 100644 --- a/src/pages/PrimeUI/UpdateServiceItems/PrimeUIRequestSITDestAddressChangeForm.jsx +++ b/src/pages/PrimeUI/UpdateServiceItems/PrimeUIRequestSITDestAddressChangeForm.jsx @@ -4,20 +4,28 @@ import { useNavigate, useParams, generatePath } from 'react-router-dom'; import PropTypes from 'prop-types'; import { FormGroup } from '@trussworks/react-uswds'; import classnames from 'classnames'; +import * as Yup from 'yup'; +import { addressSchema } from 'utils/validation'; import SectionWrapper from 'components/Customer/SectionWrapper'; import AddressFields from 'components/form/AddressFields/AddressFields'; import TextField from 'components/form/fields/TextField/TextField'; -import { ResidentialAddressShape } from 'types/address'; +import { AddressShape } from 'types/address'; import formStyles from 'styles/form.module.scss'; import { Form } from 'components/form/Form'; import WizardNavigation from 'components/Customer/WizardNavigation/WizardNavigation'; import { primeSimulatorRoutes } from 'constants/routes'; -const PrimeUIRequestSITDestAddressChangeForm = ({ name, initialValues, onSubmit, destAddressChangeRequestSchema }) => { +const PrimeUIRequestSITDestAddressChangeForm = ({ name, initialValues, onSubmit }) => { const { moveCodeOrID } = useParams(); const navigate = useNavigate(); + const destAddressChangeRequestSchema = Yup.object().shape({ + requestedAddress: addressSchema, + contractorRemarks: Yup.string().required(), + mtoServiceItemID: Yup.string(), + }); + const handleClose = () => { navigate(generatePath(primeSimulatorRoutes.VIEW_MOVE_PATH, { moveCodeOrID })); }; @@ -30,7 +38,7 @@ const PrimeUIRequestSITDestAddressChangeForm = ({ name, initialValues, onSubmit,

Request Destination SIT Address Change

- +
{ + it('renders the address change request form', async () => { + renderWithProviders( + , + ); + + expect( + screen.getByRole('heading', { name: 'Request Destination SIT Address Change', level: 2 }), + ).toBeInTheDocument(); + expect(screen.getByLabelText('Address 1')).toBeInTheDocument(); + expect(screen.getByLabelText(/Address 2/)).toBeInTheDocument(); + expect(screen.getByLabelText(/Address 3/)).toBeInTheDocument(); + expect(screen.getByLabelText('City')).toBeInTheDocument(); + expect(screen.getByLabelText('State')).toBeInTheDocument(); + expect(screen.getByLabelText('ZIP')).toBeInTheDocument(); + expect(screen.getByLabelText('Contractor Remarks')).toBeInTheDocument(); + expect(screen.getByRole('button', { name: 'Save' })).toBeEnabled(); + expect(screen.getByRole('button', { name: 'Cancel' })).toBeEnabled(); + }); + + it('Prepopulates the form with the current destination address of the DDDSIT service item', async () => { + renderWithProviders( + , + ); + + expect(screen.getByLabelText('Address 1')).toHaveValue('444 Main Ave'); + expect(screen.getByLabelText(/Address 2/)).toHaveValue('Apartment 9000'); + expect(screen.getByLabelText(/Address 3/)).toHaveValue('c/o Some Person'); + expect(screen.getByLabelText('City')).toHaveValue('Anytown'); + expect(screen.getByLabelText('State')).toHaveValue('AL'); + expect(screen.getByLabelText('Contractor Remarks')).toHaveValue(''); + expect(screen.getByLabelText('ZIP')).toHaveValue('90210'); + }); + + it('disables the save button when a field is invalid', async () => { + renderWithProviders( + , + ); + + await userEvent.type(screen.getByLabelText('ZIP'), '1'); + (await screen.getByLabelText('ZIP')).blur(); + await waitFor(() => { + expect(screen.getByRole('button', { name: 'Save' })).toBeDisabled(); + }); + }); +}); diff --git a/src/pages/PrimeUI/UpdateServiceItems/PrimeUIUpdateServiceItems.jsx b/src/pages/PrimeUI/UpdateServiceItems/PrimeUIUpdateServiceItems.jsx index 143473c898a..c5b5950bd8a 100644 --- a/src/pages/PrimeUI/UpdateServiceItems/PrimeUIUpdateServiceItems.jsx +++ b/src/pages/PrimeUI/UpdateServiceItems/PrimeUIUpdateServiceItems.jsx @@ -1,14 +1,12 @@ import React, { useState } from 'react'; import { Alert, Grid, GridContainer } from '@trussworks/react-uswds'; import { useNavigate, useParams, generatePath } from 'react-router-dom'; -import * as Yup from 'yup'; import { useMutation } from '@tanstack/react-query'; import { connect } from 'react-redux'; import { func } from 'prop-types'; import PrimeUIRequestSITDestAddressChangeForm from './PrimeUIRequestSITDestAddressChangeForm'; -import { addressSchema } from 'utils/validation'; import { createSITAddressUpdateRequest } from 'services/primeApi'; import { fromPrimeAPIAddressFormat } from 'utils/formatters'; import scrollToTop from 'shared/scrollToTop'; @@ -20,7 +18,7 @@ import LoadingPlaceholder from 'shared/LoadingPlaceholder'; import primeStyles from 'pages/PrimeUI/Prime.module.scss'; import { primeSimulatorRoutes } from 'constants/routes'; -const UpdateServiceItems = ({ setFlashMessage }) => { +const PrimeUIUpdateServiceItems = ({ setFlashMessage }) => { const [errorMessage, setErrorMessage] = useState(); const navigate = useNavigate(); const { moveCodeOrID } = useParams(); @@ -29,12 +27,6 @@ const UpdateServiceItems = ({ setFlashMessage }) => { (serviceItem) => serviceItem?.reServiceCode === 'DDDSIT', ); - const destAddressChangeRequestSchema = Yup.object().shape({ - requestedAddress: Yup.object().shape({ addressSchema }), - contractorRemarks: Yup.string(), - mtoServiceItemID: Yup.string(), - }); - const reformatPrimeApiSITDestinationAddress = fromPrimeAPIAddressFormat( destinationServiceItem.sitDestinationFinalAddress, ); @@ -122,7 +114,6 @@ const UpdateServiceItems = ({ setFlashMessage }) => {

Update Service Items

@@ -134,7 +125,7 @@ const UpdateServiceItems = ({ setFlashMessage }) => { ); }; -UpdateServiceItems.propTypes = { +PrimeUIUpdateServiceItems.propTypes = { setFlashMessage: func.isRequired, }; @@ -142,4 +133,4 @@ const mapDispatchToProps = { setFlashMessage: setFlashMessageAction, }; -export default connect(() => ({}), mapDispatchToProps)(UpdateServiceItems); +export default connect(() => ({}), mapDispatchToProps)(PrimeUIUpdateServiceItems); diff --git a/src/pages/PrimeUI/UpdateServiceItems/PrimeUIUpdateServiceItems.test.jsx b/src/pages/PrimeUI/UpdateServiceItems/PrimeUIUpdateServiceItems.test.jsx index e69de29bb2d..8ff71e7644c 100644 --- a/src/pages/PrimeUI/UpdateServiceItems/PrimeUIUpdateServiceItems.test.jsx +++ b/src/pages/PrimeUI/UpdateServiceItems/PrimeUIUpdateServiceItems.test.jsx @@ -0,0 +1,69 @@ +import React from 'react'; +import { render, screen } from '@testing-library/react'; + +import { usePrimeSimulatorGetMove } from '../../../hooks/queries'; + +import PrimeUIUpdateServiceItems from './PrimeUIUpdateServiceItems'; + +import { ReactQueryWrapper, MockProviders } from 'testUtils'; +import { primeSimulatorRoutes } from 'constants/routes'; + +jest.mock('hooks/queries', () => ({ + usePrimeSimulatorGetMove: jest.fn(), +})); + +const routingParams = { moveCodeOrID: 'bf2fc98f-3cb5-40a0-a125-4c222096c35b' }; + +const moveTaskOrder = { + id: '1', + moveCode: 'LN4T89', + mtoShipments: [ + { + id: '2', + shipmentType: 'HHG', + requestedPickupDate: '2021-11-26', + pickupAddress: { streetAddress1: '100 1st Avenue', city: 'New York', state: 'NY', postalCode: '10001' }, + }, + ], + mtoServiceItems: [ + { + reServiceCode: 'DDDSIT', + reason: 'Holiday break', + sitDestinationFinalAddress: { + streetAddress1: '444 Main Ave', + streetAddress2: 'Apartment 9000', + streetAddress3: 'c/o Some Person', + city: 'Anytown', + state: 'AL', + postalCode: '90210', + }, + id: '45fe9475-d592-48f5-896a-45d4d6eb7e76', + }, + ], +}; + +const moveReturnValue = { + moveTaskOrder, + isLoading: false, + isError: false, +}; + +const renderComponent = () => { + render( + + + + + , + ); +}; + +describe('PrimeUIUpdateServiceItems page', () => { + it('renders the update service items page', async () => { + usePrimeSimulatorGetMove.mockReturnValue(moveReturnValue); + + renderComponent(); + + expect(screen.getByRole('heading', { name: 'Update Service Items', level: 1 })).toBeInTheDocument(); + }); +}); From f89d0bfdbf1146be38149c30912cfe610fcb03a9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 18 Aug 2023 11:09:34 +0000 Subject: [PATCH 029/138] Bump github.com/go-playground/validator/v10 from 10.14.1 to 10.15.1 Bumps [github.com/go-playground/validator/v10](https://github.com/go-playground/validator) from 10.14.1 to 10.15.1. - [Release notes](https://github.com/go-playground/validator/releases) - [Commits](https://github.com/go-playground/validator/compare/v10.14.1...v10.15.1) --- updated-dependencies: - dependency-name: github.com/go-playground/validator/v10 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 4 ++-- go.sum | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 1bc78308089..018e36bfe9e 100644 --- a/go.mod +++ b/go.mod @@ -36,7 +36,7 @@ require ( github.com/go-openapi/strfmt v0.21.7 github.com/go-openapi/swag v0.22.4 github.com/go-openapi/validate v0.22.1 - github.com/go-playground/validator/v10 v10.14.1 + github.com/go-playground/validator/v10 v10.15.1 github.com/go-swagger/go-swagger v0.30.5 github.com/gobuffalo/envy v1.10.2 github.com/gobuffalo/fizz v1.14.4 @@ -51,7 +51,6 @@ require ( github.com/gorilla/csrf v1.7.1 github.com/imdario/mergo v0.3.16 github.com/jackc/pgerrcode v0.0.0-20220416144525-469b46aa5efa - github.com/jackc/pgx/v4 v4.18.1 github.com/jessevdk/go-flags v1.5.0 github.com/jinzhu/copier v0.3.5 github.com/jmoiron/sqlx v1.3.5 @@ -180,6 +179,7 @@ require ( github.com/jackc/pgproto3/v2 v2.3.2 // indirect github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect github.com/jackc/pgtype v1.14.0 // indirect + github.com/jackc/pgx/v4 v4.18.1 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/joho/godotenv v1.5.1 // indirect github.com/josharian/intern v1.0.0 // indirect diff --git a/go.sum b/go.sum index 859aa034536..2e0b47be177 100644 --- a/go.sum +++ b/go.sum @@ -271,8 +271,8 @@ github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/o github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= -github.com/go-playground/validator/v10 v10.14.1 h1:9c50NUPC30zyuKprjL3vNZ0m5oG+jU0zvx4AqHGnv4k= -github.com/go-playground/validator/v10 v10.14.1/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU= +github.com/go-playground/validator/v10 v10.15.1 h1:BSe8uhN+xQ4r5guV/ywQI4gO59C2raYcGffYWZEjZzM= +github.com/go-playground/validator/v10 v10.15.1/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU= github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-sql-driver/mysql v1.7.0 h1:ueSltNNllEqE3qcWBTD0iQd3IpL/6U+mJxLkazJ7YPc= github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= From b5626d3902c902d303b7761bcd8fb6efd48aeaad Mon Sep 17 00:00:00 2001 From: Andrew Hobson Date: Fri, 18 Aug 2023 13:47:46 +0000 Subject: [PATCH 030/138] Fix typos in retryPageLoading test --- src/utils/retryPageLoading.test.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/utils/retryPageLoading.test.js b/src/utils/retryPageLoading.test.js index f43d13972ee..68a95f403cd 100644 --- a/src/utils/retryPageLoading.test.js +++ b/src/utils/retryPageLoading.test.js @@ -25,7 +25,7 @@ describe('retryPageLoading', () => { windowSpy.mockRestore(); }); - it('does not reload on non chuck errors', () => { + it('does not reload on non chunk errors', () => { setUpWindow(null); retryPageLoading({ name: 'SomethingError' }); expect(windowObj.localStorage.getItem).not.toBeCalled(); @@ -33,7 +33,7 @@ describe('retryPageLoading', () => { expect(windowObj.location.reload).not.toBeCalled(); }); - it('reloads on first chuck error', () => { + it('reloads on first chunk error', () => { setUpWindow('false'); retryPageLoading({ name: 'ChunkLoadError' }); expect(windowObj.localStorage.getItem).toBeCalled(); @@ -41,7 +41,7 @@ describe('retryPageLoading', () => { expect(windowObj.location.reload).toBeCalled(); }); - it('does not reload on 2nd chuck error', () => { + it('does not reload on 2nd chunk error', () => { setUpWindow('true'); retryPageLoading({ name: 'ChunkLoadError' }); expect(windowObj.localStorage.getItem).toBeCalled(); From df427cedae193f6954c94086b33dd5189e469116 Mon Sep 17 00:00:00 2001 From: Roger Steve Ruiz Date: Fri, 18 Aug 2023 17:42:49 +0000 Subject: [PATCH 031/138] Upgrading Bootstrap to 5.2.3; This upgrade was done in order to fix the bug here, twbs/boostrap#35297. --- pkg/handlers/testharnessapi/api.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/handlers/testharnessapi/api.go b/pkg/handlers/testharnessapi/api.go index 0cd3e79a7eb..3d2b7350b2c 100644 --- a/pkg/handlers/testharnessapi/api.go +++ b/pkg/handlers/testharnessapi/api.go @@ -47,7 +47,7 @@ func NewDefaultBuilder(handlerConfig handlers.HandlerConfig) http.Handler { t := template.Must(template.New("users").Parse(` - +
@@ -78,7 +78,7 @@ func NewBuilderList(handlerConfig handlers.HandlerConfig) http.Handler { t := template.Must(template.New("actions").Parse(` - +
From 20736f1556ab2f4f2655cc21b730f733adb87879 Mon Sep 17 00:00:00 2001 From: Roger Steve Ruiz Date: Fri, 18 Aug 2023 17:51:27 +0000 Subject: [PATCH 032/138] Adding some descriptive text for the landing page; We didn't have anything here before, so let's add some links for folks who may have questions about what this page is. This is not an exhaustive description, so if there's anything to add here please do! --- pkg/handlers/testharnessapi/api.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/handlers/testharnessapi/api.go b/pkg/handlers/testharnessapi/api.go index 3d2b7350b2c..184ce1fdb16 100644 --- a/pkg/handlers/testharnessapi/api.go +++ b/pkg/handlers/testharnessapi/api.go @@ -82,6 +82,10 @@ func NewBuilderList(handlerConfig handlers.HandlerConfig) http.Handler {
+

Welcome to the Testharness data scenarios New

+
+

These scenarios were introduced in ADR 0076 and addressed further in ADR 0083. These scenarios can be used to create Moves in the MilMove system when working locally or with Ephemeral deployments. Click any of the buttons below to create a Move data scenario.

+
{{range .}} From bedeb68f8f7f5fa87111f6f3e8eedc8f65342163 Mon Sep 17 00:00:00 2001 From: Roger Steve Ruiz Date: Fri, 18 Aug 2023 18:02:14 +0000 Subject: [PATCH 033/138] Adding a Testharness button for local development; This add improves DX and UX on the project by making the Testharness data scenarios more accessible to folks running the application either locally or in an Ephemeral environment. This utilizes the same logic as `showLocalDevLogin` and is only available in the environments mentioned before. --- src/pages/SignIn/SignIn.jsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/pages/SignIn/SignIn.jsx b/src/pages/SignIn/SignIn.jsx index 617d10beede..75322f5871c 100644 --- a/src/pages/SignIn/SignIn.jsx +++ b/src/pages/SignIn/SignIn.jsx @@ -15,7 +15,7 @@ import ConnectedEulaModal from 'components/EulaModal'; import { isDevelopment } from 'shared/constants'; import { useTitle } from 'hooks/custom'; -const SignIn = ({ context, showLocalDevLogin }) => { +const SignIn = ({ context, showLocalDevLogin, showTestharnessList }) => { const location = useLocation(); const [showEula, setShowEula] = useState(false); const navigate = useNavigate(); @@ -101,6 +101,11 @@ const SignIn = ({ context, showLocalDevLogin }) => { Local Sign In )} + {showTestharnessList && ( + + View Testharness Data Scenarios + + )}
@@ -115,10 +120,12 @@ SignIn.propTypes = { showLoginWarning: bool, }).isRequired, showLocalDevLogin: bool, + showTestharnessList: bool, }; SignIn.defaultProps = { showLocalDevLogin: isDevelopment, + showTestharnessList: isDevelopment, }; export default withContext(SignIn); From d31b9038d6e4cb5db440d413a4fd9f3c719283ea Mon Sep 17 00:00:00 2001 From: Roger Steve Ruiz Date: Fri, 18 Aug 2023 18:06:19 +0000 Subject: [PATCH 034/138] Adding tests for the new Testharness button --- src/containers/LoginButton/LoginButton.jsx | 10 +++++++++- src/containers/LoginButton/LoginButton.test.jsx | 7 +++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/containers/LoginButton/LoginButton.jsx b/src/containers/LoginButton/LoginButton.jsx index 024a1fd4a95..532b5ec3e60 100644 --- a/src/containers/LoginButton/LoginButton.jsx +++ b/src/containers/LoginButton/LoginButton.jsx @@ -17,7 +17,7 @@ import ConnectedEulaModal from 'components/EulaModal'; import { customerRoutes } from 'constants/routes'; import { selectIsProfileComplete } from 'store/entities/selectors'; -const LoginButton = ({ isLoggedIn, logOut, showDevlocalButton, isProfileComplete }) => { +const LoginButton = ({ isLoggedIn, logOut, showDevlocalButton, showTestharnessList, isProfileComplete }) => { const [showEula, setShowEula] = useState(false); if (!isLoggedIn) { @@ -42,6 +42,13 @@ const LoginButton = ({ isLoggedIn, logOut, showDevlocalButton, isProfileComplete )} + {showTestharnessList && ( +
  • + + View Testharness Data Scenarios + +
  • + )}
  • + ); + return ( onClose()} /> @@ -38,7 +50,7 @@ export const ShipmentAddressUpdateReviewRequestModal = ({ onSubmit, shipment, er

    Review request

    {errorMessage && ( - + {errorMessage} )} @@ -111,10 +123,12 @@ ShipmentAddressUpdateReviewRequestModal.propTypes = { onSubmit: PropTypes.func.isRequired, onClose: PropTypes.func.isRequired, errorMessage: PropTypes.node, + setErrorMessage: PropTypes.func, }; ShipmentAddressUpdateReviewRequestModal.defaultProps = { errorMessage: null, + setErrorMessage: undefined, }; ShipmentAddressUpdateReviewRequestModal.displayName = 'ShipmentAddressUpdateReviewRequestModal'; diff --git a/src/components/Office/ShipmentAddressUpdateReviewRequestModal/ShipmentAddressUpdateReviewRequestModal.module.scss b/src/components/Office/ShipmentAddressUpdateReviewRequestModal/ShipmentAddressUpdateReviewRequestModal.module.scss index daca8f910a8..7fc1ced1153 100644 --- a/src/components/Office/ShipmentAddressUpdateReviewRequestModal/ShipmentAddressUpdateReviewRequestModal.module.scss +++ b/src/components/Office/ShipmentAddressUpdateReviewRequestModal/ShipmentAddressUpdateReviewRequestModal.module.scss @@ -6,6 +6,10 @@ padding-top: 1rem; } +.alertClose { + color: $base-darkest; +} + .modalbody { @include u-border('base-lighter'); @include u-border('1px'); diff --git a/src/components/Office/ShipmentForm/ShipmentForm.jsx b/src/components/Office/ShipmentForm/ShipmentForm.jsx index 3078c5104ab..a6ea263ff97 100644 --- a/src/components/Office/ShipmentForm/ShipmentForm.jsx +++ b/src/components/Office/ShipmentForm/ShipmentForm.jsx @@ -5,6 +5,7 @@ import { generatePath, useNavigate, useParams } from 'react-router-dom'; import { useQueryClient, useMutation } from '@tanstack/react-query'; import { Alert, Button, Checkbox, Fieldset, FormGroup, Radio } from '@trussworks/react-uswds'; import classNames from 'classnames'; +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import getShipmentOptions from '../../Customer/MtoShipmentForm/getShipmentOptions'; import { CloseoutOfficeInput } from '../../form/fields/CloseoutOfficeInput'; @@ -39,7 +40,6 @@ import { ADDRESS_UPDATE_STATUS, shipmentDestinationTypes } from 'constants/shipm import { officeRoles, roleTypes } from 'constants/userRoles'; import { deleteShipment, reviewShipmentAddressUpdate, updateMoveCloseoutOffice } from 'services/ghcApi'; import { SHIPMENT_OPTIONS } from 'shared/constants'; -import MilMoveAlert from 'shared/Alert'; import formStyles from 'styles/form.module.scss'; import { AccountingCodesShape } from 'types/accountingCodes'; import { AddressShape, SimpleAddressShape } from 'types/address'; @@ -170,6 +170,12 @@ const ShipmentForm = (props) => { setIsCancelModalVisible(true); }; + const successMessageAlertControl = ( + + ); + const deliveryAddressUpdateRequested = mtoShipment?.deliveryAddressUpdate?.status === ADDRESS_UPDATE_STATUS.REQUESTED; const isHHG = shipmentType === SHIPMENT_OPTIONS.HHG; @@ -526,6 +532,7 @@ const ShipmentForm = (props) => { ); }} errorMessage={shipmentAddressUpdateReviewErrorMessage} + setErrorMessage={setShipmentAddressUpdateReviewErrorMessage} /> {errorMessage && ( @@ -535,9 +542,9 @@ const ShipmentForm = (props) => { )} {successMessage && ( - setSuccessMessage(null)}> + {successMessage} - + )} {isTOO && mtoShipment.usesExternalVendor && ( diff --git a/src/components/Office/ShipmentForm/ShipmentForm.module.scss b/src/components/Office/ShipmentForm/ShipmentForm.module.scss index 7a5f4bb2789..2fff6281845 100644 --- a/src/components/Office/ShipmentForm/ShipmentForm.module.scss +++ b/src/components/Office/ShipmentForm/ShipmentForm.module.scss @@ -111,6 +111,10 @@ } } +.alertClose { + color: $base-darkest; +} + .Fieldset { h2 { @include u-margin-bottom(2); From cfd3f7e275041960b5a0b4cf7a65df44e9683259 Mon Sep 17 00:00:00 2001 From: PDickeyTruss Date: Tue, 22 Aug 2023 16:15:56 +0000 Subject: [PATCH 064/138] Exclude NTS loas --- pkg/services/invoice/ghc_payment_request_invoice_generator.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/services/invoice/ghc_payment_request_invoice_generator.go b/pkg/services/invoice/ghc_payment_request_invoice_generator.go index 01d6f0958ff..7a7437940c5 100644 --- a/pkg/services/invoice/ghc_payment_request_invoice_generator.go +++ b/pkg/services/invoice/ghc_payment_request_invoice_generator.go @@ -663,7 +663,7 @@ func (g ghcPaymentRequestInvoiceGenerator) createLongLoaSegments(appCtx appconte Where("t.tac = ?", tac). Where("? between loa_bgn_dt and loa_end_dt", orders.IssueDate). Where("t.tac_fn_bl_mod_cd != 'P'"). - Where("loa_hs_gds_cd != 'HS'"). + Where("loa_hs_gds_cd != ?", models.LineOfAccountingHouseholdGoodsCodeNTS). Order("t.tac_fn_bl_mod_cd asc"). Order("loa_bgn_dt desc"). All(&loas) From 6e1bcccc090ecb58f50e931c3bb635bc5eb85075 Mon Sep 17 00:00:00 2001 From: Roger Steve Ruiz Date: Tue, 22 Aug 2023 00:21:13 +0000 Subject: [PATCH 065/138] Refactoring the domestic destination pricer --- .../ghcrateengine/domestic_destination_pricer.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/pkg/services/ghcrateengine/domestic_destination_pricer.go b/pkg/services/ghcrateengine/domestic_destination_pricer.go index 85412b0d858..f2bf550fc0d 100644 --- a/pkg/services/ghcrateengine/domestic_destination_pricer.go +++ b/pkg/services/ghcrateengine/domestic_destination_pricer.go @@ -45,18 +45,21 @@ func (p domesticDestinationPricer) Price(appCtx appcontext.AppContext, contractC return 0, nil, fmt.Errorf("Could not lookup Domestic Service Area Price: %w", err) } - contractYear, err := fetchContractYear(appCtx, domServiceAreaPrice.ContractID, referenceDate) - if err != nil { - return 0, nil, fmt.Errorf("Could not lookup contract year: %w", err) - } - finalWeight := weight if isPPM && weight < minDomesticWeight { finalWeight = minDomesticWeight } basePrice := domServiceAreaPrice.PriceCents.Float64() * finalWeight.ToCWTFloat64() - escalatedPrice := basePrice * contractYear.EscalationCompounded + // WARN: @rogeruiz: I'm unsure if the `isPeakPeriod` is what I should be + // passing here. I saw a boolean, so I used it. But if `isPeakPeriod` isn't + // equivalent to `isLinehaul`, then we need another boolean calculation + // here. + escalatedPrice, contractYear, err := escalatePriceForContractYear(appCtx, domServiceAreaPrice.ContractID, referenceDate, isPeakPeriod, basePrice) + if err != nil { + return 0, nil, fmt.Errorf("Could not look up escalated price: %w", err) + } + totalCost := unit.Cents(math.Round(escalatedPrice)) pricingParams := services.PricingDisplayParams{ From 809059c282b0307359ef84a37a4bf1b7b597c22b Mon Sep 17 00:00:00 2001 From: Roger Steve Ruiz Date: Tue, 22 Aug 2023 00:25:45 +0000 Subject: [PATCH 066/138] Fixing the tests by accounting for the new errors; This was the only change I had to make to the tests to get things to pass. We still need tests around this new calculation. --- pkg/services/ghcrateengine/domestic_destination_pricer_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/services/ghcrateengine/domestic_destination_pricer_test.go b/pkg/services/ghcrateengine/domestic_destination_pricer_test.go index 7b7b60e5f1b..c47817df872 100644 --- a/pkg/services/ghcrateengine/domestic_destination_pricer_test.go +++ b/pkg/services/ghcrateengine/domestic_destination_pricer_test.go @@ -226,7 +226,8 @@ func (suite *GHCRateEngineServiceSuite) TestPriceDomesticDestination() { ) suite.Error(err) - suite.Equal("Could not lookup contract year: "+models.RecordNotFoundErrorString, err.Error()) + suite.Equal("Could not look up escalated price: could not lookup contract year: "+models.RecordNotFoundErrorString, err.Error()) + }) suite.Run("fail when is weight below minimum and shipment isn't a PPM", func() { From 99662a94a73e8da224950bf8ce5fa0312bb42ad4 Mon Sep 17 00:00:00 2001 From: PDickeyTruss Date: Tue, 22 Aug 2023 16:56:53 +0000 Subject: [PATCH 067/138] Add additional order by to loa query --- pkg/services/invoice/ghc_payment_request_invoice_generator.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/services/invoice/ghc_payment_request_invoice_generator.go b/pkg/services/invoice/ghc_payment_request_invoice_generator.go index 7a7437940c5..d11ccbdc9e0 100644 --- a/pkg/services/invoice/ghc_payment_request_invoice_generator.go +++ b/pkg/services/invoice/ghc_payment_request_invoice_generator.go @@ -666,6 +666,7 @@ func (g ghcPaymentRequestInvoiceGenerator) createLongLoaSegments(appCtx appconte Where("loa_hs_gds_cd != ?", models.LineOfAccountingHouseholdGoodsCodeNTS). Order("t.tac_fn_bl_mod_cd asc"). Order("loa_bgn_dt desc"). + Order("t.tac_fy_txt desc"). All(&loas) if err != nil { switch err { From 6ec50f7921a8b29fe6e16490748967138577b2c1 Mon Sep 17 00:00:00 2001 From: Michael Valdes Date: Tue, 22 Aug 2023 17:00:30 +0000 Subject: [PATCH 068/138] Fix isLinehaul bool and adjust pricer test --- pkg/services/ghcrateengine/domestic_destination_pricer.go | 8 ++------ .../ghcrateengine/domestic_destination_pricer_test.go | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/pkg/services/ghcrateengine/domestic_destination_pricer.go b/pkg/services/ghcrateengine/domestic_destination_pricer.go index f2bf550fc0d..bb3fb50ce07 100644 --- a/pkg/services/ghcrateengine/domestic_destination_pricer.go +++ b/pkg/services/ghcrateengine/domestic_destination_pricer.go @@ -51,13 +51,9 @@ func (p domesticDestinationPricer) Price(appCtx appcontext.AppContext, contractC } basePrice := domServiceAreaPrice.PriceCents.Float64() * finalWeight.ToCWTFloat64() - // WARN: @rogeruiz: I'm unsure if the `isPeakPeriod` is what I should be - // passing here. I saw a boolean, so I used it. But if `isPeakPeriod` isn't - // equivalent to `isLinehaul`, then we need another boolean calculation - // here. - escalatedPrice, contractYear, err := escalatePriceForContractYear(appCtx, domServiceAreaPrice.ContractID, referenceDate, isPeakPeriod, basePrice) + escalatedPrice, contractYear, err := escalatePriceForContractYear(appCtx, domServiceAreaPrice.ContractID, referenceDate, false, basePrice) if err != nil { - return 0, nil, fmt.Errorf("Could not look up escalated price: %w", err) + return 0, nil, fmt.Errorf("could not look up escalated price: %w", err) } totalCost := unit.Cents(math.Round(escalatedPrice)) diff --git a/pkg/services/ghcrateengine/domestic_destination_pricer_test.go b/pkg/services/ghcrateengine/domestic_destination_pricer_test.go index c47817df872..10ded1ee613 100644 --- a/pkg/services/ghcrateengine/domestic_destination_pricer_test.go +++ b/pkg/services/ghcrateengine/domestic_destination_pricer_test.go @@ -226,7 +226,7 @@ func (suite *GHCRateEngineServiceSuite) TestPriceDomesticDestination() { ) suite.Error(err) - suite.Equal("Could not look up escalated price: could not lookup contract year: "+models.RecordNotFoundErrorString, err.Error()) + suite.Contains(err.Error(), "could not look up escalated price") }) From ea1518c4aec8fdda90ff7f81d2394500d916354a Mon Sep 17 00:00:00 2001 From: Michael Valdes Date: Tue, 22 Aug 2023 19:48:51 +0000 Subject: [PATCH 069/138] Round add_days_sit escalated price to nearest cent --- ...domestic_destination_additional_days_sit_pricer_test.go | 4 ++-- .../domestic_origin_additional_days_sit_pricer_test.go | 4 ++-- pkg/services/ghcrateengine/pricer_helpers.go | 7 +++---- pkg/services/ghcrateengine/pricer_helpers_test.go | 2 +- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/pkg/services/ghcrateengine/domestic_destination_additional_days_sit_pricer_test.go b/pkg/services/ghcrateengine/domestic_destination_additional_days_sit_pricer_test.go index 5eeb47f9a8c..a452cf2da84 100644 --- a/pkg/services/ghcrateengine/domestic_destination_additional_days_sit_pricer_test.go +++ b/pkg/services/ghcrateengine/domestic_destination_additional_days_sit_pricer_test.go @@ -20,7 +20,7 @@ const ( ddasitTestEscalationCompounded = 1.042 ddasitTestWeight = unit.Pound(4200) ddasitTestNumberOfDaysInSIT = 29 - ddasitTestPriceCents = unit.Cents(948060) // ddasitTestBasePriceCents * (ddasitTestWeight / 100) * ddasitTestEscalationCompounded * ddasitTestNumberOfDaysInSIT + ddasitTestPriceCents = unit.Cents(948068) // ddasitTestBasePriceCents * (ddasitTestWeight / 100) * ddasitTestEscalationCompounded * ddasitTestNumberOfDaysInSIT ) var ddasitTestRequestedPickupDate = time.Date(testdatagen.TestYear, time.January, 5, 7, 33, 11, 456, time.UTC) @@ -87,7 +87,7 @@ func (suite *GHCRateEngineServiceSuite) TestDomesticDestinationAdditionalDaysSIT twoYearsLaterPickupDate := ddasitTestRequestedPickupDate.AddDate(2, 0, 0) _, _, err := pricer.Price(suite.AppContextForTest(), testdatagen.DefaultContractCode, twoYearsLaterPickupDate, ddasitTestWeight, ddasitTestServiceArea, ddasitTestNumberOfDaysInSIT, false) suite.Error(err) - suite.Contains(err.Error(), "could not fetch contract year") + suite.Contains(err.Error(), "could not lookup contract year") }) } diff --git a/pkg/services/ghcrateengine/domestic_origin_additional_days_sit_pricer_test.go b/pkg/services/ghcrateengine/domestic_origin_additional_days_sit_pricer_test.go index ffc796b19a1..b6660471834 100644 --- a/pkg/services/ghcrateengine/domestic_origin_additional_days_sit_pricer_test.go +++ b/pkg/services/ghcrateengine/domestic_origin_additional_days_sit_pricer_test.go @@ -20,7 +20,7 @@ const ( doasitTestEscalationCompounded = 1.042 doasitTestWeight = unit.Pound(4200) doasitTestNumberOfDaysInSIT = 29 - doasitTestPriceCents = unit.Cents(948060) // doasitTestBasePriceCents * (doasitTestWeight / 100) * doasitTestEscalationCompounded * doasitTestNumberOfDaysInSIT + doasitTestPriceCents = unit.Cents(948068) // doasitTestBasePriceCents * (doasitTestWeight / 100) * doasitTestEscalationCompounded948068 * doasitTestNumberOfDaysInSIT ) var doasitTestRequestedPickupDate = time.Date(testdatagen.TestYear, time.January, 5, 7, 33, 11, 456, time.UTC) @@ -87,7 +87,7 @@ func (suite *GHCRateEngineServiceSuite) TestDomesticOriginAdditionalDaysSITPrice twoYearsLaterPickupDate := doasitTestRequestedPickupDate.AddDate(2, 0, 0) _, _, err := pricer.Price(suite.AppContextForTest(), testdatagen.DefaultContractCode, twoYearsLaterPickupDate, doasitTestWeight, doasitTestServiceArea, doasitTestNumberOfDaysInSIT, false) suite.Error(err) - suite.Contains(err.Error(), "could not fetch contract year") + suite.Contains(err.Error(), "could not lookup contract year") }) } diff --git a/pkg/services/ghcrateengine/pricer_helpers.go b/pkg/services/ghcrateengine/pricer_helpers.go index 13be7df3552..b052e158b7f 100644 --- a/pkg/services/ghcrateengine/pricer_helpers.go +++ b/pkg/services/ghcrateengine/pricer_helpers.go @@ -164,13 +164,12 @@ func priceDomesticAdditionalDaysSIT(appCtx appcontext.AppContext, additionalDayS return unit.Cents(0), nil, fmt.Errorf("could not fetch domestic %s additional days SIT rate: %w", sitType, err) } - contractYear, err := fetchContractYear(appCtx, serviceAreaPrice.ContractID, referenceDate) + baseTotalPrice := serviceAreaPrice.PriceCents.Float64() * weight.ToCWTFloat64() + escalatedTotalPrice, contractYear, err := escalatePriceForContractYear(appCtx, serviceAreaPrice.ContractID, referenceDate, false, baseTotalPrice) if err != nil { - return unit.Cents(0), nil, fmt.Errorf("could not fetch contract year: %w", err) + return 0, nil, fmt.Errorf("could not look up escalated price: %w", err) } - baseTotalPrice := serviceAreaPrice.PriceCents.Float64() * weight.ToCWTFloat64() - escalatedTotalPrice := baseTotalPrice * contractYear.EscalationCompounded totalForNumberOfDaysPrice := escalatedTotalPrice * float64(numberOfDaysInSIT) totalPriceCents := unit.Cents(math.Round(totalForNumberOfDaysPrice)) diff --git a/pkg/services/ghcrateengine/pricer_helpers_test.go b/pkg/services/ghcrateengine/pricer_helpers_test.go index 41d20b89627..b885451670a 100644 --- a/pkg/services/ghcrateengine/pricer_helpers_test.go +++ b/pkg/services/ghcrateengine/pricer_helpers_test.go @@ -239,7 +239,7 @@ func (suite *GHCRateEngineServiceSuite) Test_priceDomesticAdditionalDaysSIT() { twoYearsLaterPickupDate := ddasitTestRequestedPickupDate.AddDate(2, 0, 0) _, _, err := priceDomesticAdditionalDaysSIT(suite.AppContextForTest(), models.ReServiceCodeDDASIT, testdatagen.DefaultContractCode, twoYearsLaterPickupDate, ddasitTestWeight, ddasitTestServiceArea, ddasitTestNumberOfDaysInSIT, false) suite.Error(err) - suite.Contains(err.Error(), "could not fetch contract year") + suite.Contains(err.Error(), "could not look up escalated price") }) } From de2733f5171e9145496d7ffb3723b605f5bdc57e Mon Sep 17 00:00:00 2001 From: belle Date: Tue, 22 Aug 2023 20:01:59 +0000 Subject: [PATCH 070/138] Updated tests and refined auth check --- .../move_task_order_fetcher.go | 16 ++++--- .../move_task_order_fetcher_test.go | 48 +++++++++++++++---- 2 files changed, 49 insertions(+), 15 deletions(-) diff --git a/pkg/services/move_task_order/move_task_order_fetcher.go b/pkg/services/move_task_order/move_task_order_fetcher.go index 79f73dbdb86..d616d13a555 100644 --- a/pkg/services/move_task_order/move_task_order_fetcher.go +++ b/pkg/services/move_task_order/move_task_order_fetcher.go @@ -6,6 +6,7 @@ import ( "github.com/gobuffalo/pop/v6" "github.com/gofrs/uuid" + "go.uber.org/zap" "github.com/transcom/mymove/pkg/appcontext" "github.com/transcom/mymove/pkg/apperror" @@ -233,16 +234,16 @@ func (f moveTaskOrderFetcher) GetMove(appCtx appcontext.AppContext, searchParams findMoveQuery := appCtx.DB().Q() if searchParams == nil { - return &models.Move{}, errors.New("searchParams should not be nil since move ID or locator are required") + return nil, errors.New("searchParams should not be nil since move ID or locator are required") } // Find the move by ID or Locator if searchParams.MoveTaskOrderID != uuid.Nil { - findMoveQuery.Where("id = $1", searchParams.MoveTaskOrderID) + findMoveQuery.Where("moves.id = ?", searchParams.MoveTaskOrderID) } else if searchParams.Locator != "" { - findMoveQuery.Where("locator = $1", searchParams.Locator) + findMoveQuery.Where("locator = ?", searchParams.Locator) } else { - return &models.Move{}, errors.New("searchParams should have either a move ID or locator set") + return nil, errors.New("searchParams should have either a move ID or locator set") } if len(eagerAssociations) > 0 { @@ -258,15 +259,16 @@ func (f moveTaskOrderFetcher) GetMove(appCtx appcontext.AppContext, searchParams setMTOQueryFilters(findMoveQuery, searchParams) err := findMoveQuery.First(move) + if err != nil { + appCtx.Logger().Error("error fetching move", zap.Error(err)) switch err { case sql.ErrNoRows: - return &models.Move{}, apperror.NewNotFoundError(searchParams.MoveTaskOrderID, "") + return nil, apperror.NewNotFoundError(searchParams.MoveTaskOrderID, "") default: - return &models.Move{}, apperror.NewQueryError("Move", err, "") + return nil, apperror.NewQueryError("Move", err, "") } } - return move, nil } diff --git a/pkg/services/move_task_order/move_task_order_fetcher_test.go b/pkg/services/move_task_order/move_task_order_fetcher_test.go index bf52e5d6f44..88892bbe814 100644 --- a/pkg/services/move_task_order/move_task_order_fetcher_test.go +++ b/pkg/services/move_task_order/move_task_order_fetcher_test.go @@ -305,9 +305,20 @@ func (suite *MoveTaskOrderServiceSuite) TestMoveTaskOrderFetcher() { suite.Error(err) }) - //test GetMove() - suite.Run("success getting a move using GetMove", func() { - expectedMTO, _ := setupTestData() +} + +func (suite *MoveTaskOrderServiceSuite) TestGetMoveTaskOrderFetcher() { + setupTestData := func() models.Move { + + expectedMTO := factory.BuildMove(suite.DB(), nil, nil) + + return expectedMTO + } + + mtoFetcher := NewMoveTaskOrderFetcher() + + suite.Run("success getting a move using GetMove for Prime user", func() { + expectedMTO := setupTestData() searchParams := services.MoveTaskOrderFetcherParams{ MoveTaskOrderID: expectedMTO.ID, } @@ -354,15 +365,12 @@ func (suite *MoveTaskOrderServiceSuite) TestMoveTaskOrderFetcher() { &searchParams, ) - // suite.NoError(err) - // suite.NotNil(moveReturned) - // suite.Equal(expectedMTO.ID, moveReturned.ID) if suite.NoError(err) && suite.NotNil(moveReturned) { suite.Equal(expectedMTO.ID, moveReturned.ID) } }) - suite.Run("Returns a not found error if it is a customer app request by a customer that it doesn't belong to", func() { + suite.Run("Returns a not found error if it is a customer app request by a customer that it does not belong to", func() { badUser := factory.BuildExtendedServiceMember(suite.DB(), factory.GetTraitActiveServiceMemberUser(), nil) appCtx := suite.AppContextWithSessionForTest(&auth.Session{ @@ -384,7 +392,31 @@ func (suite *MoveTaskOrderServiceSuite) TestMoveTaskOrderFetcher() { if suite.Error(err) && suite.Nil(moveReturned) { suite.IsType(apperror.NotFoundError{}, err) - suite.Equal(fmt.Sprintf("ID: %s not found while looking for move", expectedMTO.ID), err.Error()) + suite.Contains(err.Error(), fmt.Sprintf("ID: %s not found", expectedMTO.ID)) + } + }) + + suite.Run("success getting a move for Office user", func() { + officeUser := factory.BuildOfficeUser(suite.DB(), factory.GetTraitActiveOfficeUser(), nil) + expectedMTO := factory.BuildMove(suite.DB(), nil, nil) + + searchParams := services.MoveTaskOrderFetcherParams{ + MoveTaskOrderID: expectedMTO.ID, + } + + appCtx := suite.AppContextWithSessionForTest(&auth.Session{ + ApplicationName: auth.OfficeApp, + UserID: officeUser.User.ID, + OfficeUserID: officeUser.ID, + }) + + moveReturned, err := mtoFetcher.GetMove( + appCtx, + &searchParams, + ) + + if suite.NoError(err) && suite.NotNil(moveReturned) { + suite.Equal(expectedMTO.ID, moveReturned.ID) } }) } From 618270f6e160a1b1c5ce16ad530c1b070a59f8f8 Mon Sep 17 00:00:00 2001 From: Michael Valdes Date: Tue, 22 Aug 2023 21:14:14 +0000 Subject: [PATCH 071/138] Fix calculations in payemnt recalculator test --- .../payment_request/payment_request_recalculator_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/services/payment_request/payment_request_recalculator_test.go b/pkg/services/payment_request/payment_request_recalculator_test.go index 4b508faeb7f..dff50362132 100644 --- a/pkg/services/payment_request/payment_request_recalculator_test.go +++ b/pkg/services/payment_request/payment_request_recalculator_test.go @@ -182,7 +182,7 @@ func (suite *PaymentRequestServiceSuite) TestRecalculatePaymentRequestSuccess() { paymentRequest: &oldPaymentRequest, serviceCode: models.ReServiceCodeDOASIT, - priceCents: unit.Cents(254645), + priceCents: unit.Cents(254640), paramsToCheck: []paramMap{ {models.ServiceItemParamNameWeightOriginal, strTestOriginalWeight}, {models.ServiceItemParamNameWeightBilled, strTestOriginalWeight}, @@ -228,7 +228,7 @@ func (suite *PaymentRequestServiceSuite) TestRecalculatePaymentRequestSuccess() isNewPaymentRequest: true, paymentRequest: newPaymentRequest, serviceCode: models.ReServiceCodeDOASIT, - priceCents: unit.Cents(237910), // Price same as before since new weight still in same weight bracket + priceCents: unit.Cents(237920), // Price same as before since new weight still in same weight bracket paramsToCheck: []paramMap{ {models.ServiceItemParamNameWeightOriginal, strTestChangedOriginalWeight}, {models.ServiceItemParamNameWeightBilled, strTestChangedOriginalWeight}, From f8b866ffd0629ab96e0b891be654c675c786ad40 Mon Sep 17 00:00:00 2001 From: belle Date: Tue, 22 Aug 2023 21:28:27 +0000 Subject: [PATCH 072/138] Fixed failing tests on payment_request_test.go, deleted authenticating user request --- pkg/handlers/primeapi/payment_request_test.go | 6 ------ 1 file changed, 6 deletions(-) diff --git a/pkg/handlers/primeapi/payment_request_test.go b/pkg/handlers/primeapi/payment_request_test.go index 51a258ee0a2..af4bba1cc93 100644 --- a/pkg/handlers/primeapi/payment_request_test.go +++ b/pkg/handlers/primeapi/payment_request_test.go @@ -899,10 +899,7 @@ func (suite *HandlerSuite) TestCreatePaymentRequestHandlerInvalidMTOReferenceID( move, mtoServiceItems := suite.setupDomesticLinehaulData() moveTaskOrderID := move.ID - requestUser := factory.BuildUser(nil, nil, nil) - req := httptest.NewRequest("POST", "/payment_requests", nil) - req = suite.AuthenticateUserRequest(req, requestUser) planner := &routemocks.Planner{} planner.On("Zip5TransitDistanceLineHaul", @@ -967,10 +964,7 @@ func (suite *HandlerSuite) TestCreatePaymentRequestHandlerInvalidMTOReferenceID( move, mtoServiceItems := suite.setupDomesticLinehaulData() moveTaskOrderID := move.ID - requestUser := factory.BuildUser(nil, nil, nil) - req := httptest.NewRequest("POST", "/payment_requests", nil) - req = suite.AuthenticateUserRequest(req, requestUser) planner := &routemocks.Planner{} planner.On("Zip5TransitDistanceLineHaul", From 0c914e2a46bb3309db2a57e1e4cc6817f1d55590 Mon Sep 17 00:00:00 2001 From: belle Date: Tue, 22 Aug 2023 21:48:43 +0000 Subject: [PATCH 073/138] Deleted authenticate use requests from tests in payment_request_test.go in prime api handler --- pkg/handlers/primeapi/payment_request_test.go | 9 --------- 1 file changed, 9 deletions(-) diff --git a/pkg/handlers/primeapi/payment_request_test.go b/pkg/handlers/primeapi/payment_request_test.go index af4bba1cc93..8f8a281fada 100644 --- a/pkg/handlers/primeapi/payment_request_test.go +++ b/pkg/handlers/primeapi/payment_request_test.go @@ -730,10 +730,7 @@ func (suite *HandlerSuite) TestCreatePaymentRequestHandlerNewPaymentRequestCreat move, mtoServiceItems := suite.setupDomesticLinehaulData() moveTaskOrderID := move.ID - requestUser := factory.BuildUser(nil, nil, nil) - req := httptest.NewRequest("POST", "/payment_requests", nil) - req = suite.AuthenticateUserRequest(req, requestUser) planner := &routemocks.Planner{} planner.On("Zip5TransitDistanceLineHaul", @@ -802,10 +799,7 @@ func (suite *HandlerSuite) TestCreatePaymentRequestHandlerNewPaymentRequestCreat mtoServiceItems[0].Status = models.MTOServiceItemStatusSubmitted suite.MustSave(&mtoServiceItems[0]) - requestUser := factory.BuildUser(nil, nil, nil) - req := httptest.NewRequest("POST", "/payment_requests", nil) - req = suite.AuthenticateUserRequest(req, requestUser) planner := &routemocks.Planner{} @@ -849,10 +843,7 @@ func (suite *HandlerSuite) TestCreatePaymentRequestHandlerNewPaymentRequestCreat mtoServiceItems[0].Status = models.MTOServiceItemStatusRejected suite.MustSave(&mtoServiceItems[0]) - requestUser := factory.BuildUser(nil, nil, nil) - req := httptest.NewRequest("POST", "/payment_requests", nil) - req = suite.AuthenticateUserRequest(req, requestUser) planner := &routemocks.Planner{} From 00900242f627113de0bf962579480baa9918b87c Mon Sep 17 00:00:00 2001 From: ruizajtruss Date: Wed, 23 Aug 2023 02:14:29 +0000 Subject: [PATCH 074/138] implemented helper function --- pkg/services/ghcrateengine/pricer_helpers.go | 13 ++++--------- pkg/services/ghcrateengine/pricer_helpers_test.go | 2 +- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/pkg/services/ghcrateengine/pricer_helpers.go b/pkg/services/ghcrateengine/pricer_helpers.go index 13be7df3552..a5ca1448005 100644 --- a/pkg/services/ghcrateengine/pricer_helpers.go +++ b/pkg/services/ghcrateengine/pricer_helpers.go @@ -46,21 +46,16 @@ func priceDomesticPackUnpack(appCtx appcontext.AppContext, packUnpackCode models return 0, nil, fmt.Errorf("Could not lookup domestic other price: %w", err) } - var contractYear models.ReContractYear - err = appCtx.DB().Where("contract_id = $1", domOtherPrice.ContractID). - Where("$2 between start_date and end_date", referenceDate). - First(&contractYear) - if err != nil { - return 0, nil, fmt.Errorf("Could not lookup contract year: %w", err) - } - finalWeight := weight if isPPM && weight < minDomesticWeight { finalWeight = minDomesticWeight } basePrice := domOtherPrice.PriceCents.Float64() * finalWeight.ToCWTFloat64() - escalatedPrice := basePrice * contractYear.EscalationCompounded + escalatedPrice, contractYear, err := escalatePriceForContractYear(appCtx, domOtherPrice.ContractID, referenceDate, false, basePrice) + if err != nil { + return 0, nil, fmt.Errorf("Could not lookup escalated price: %w", err) + } displayParams := services.PricingDisplayParams{ { diff --git a/pkg/services/ghcrateengine/pricer_helpers_test.go b/pkg/services/ghcrateengine/pricer_helpers_test.go index 41d20b89627..efed17af9c8 100644 --- a/pkg/services/ghcrateengine/pricer_helpers_test.go +++ b/pkg/services/ghcrateengine/pricer_helpers_test.go @@ -69,7 +69,7 @@ func (suite *GHCRateEngineServiceSuite) Test_priceDomesticPackUnpack() { isPPM := false _, _, err := priceDomesticPackUnpack(suite.AppContextForTest(), models.ReServiceCodeDNPK, testdatagen.DefaultContractCode, twoYearsLaterPickupDate, dnpkTestWeight, dnpkTestServicesScheduleOrigin, isPPM) suite.Error(err) - suite.Contains(err.Error(), "Could not lookup contract year") + suite.Contains(err.Error(), "could not lookup contract year") }) suite.Run("not finding shipment type price", func() { From 405fca712b39972193d3b81ccc5f3a51eea9a74f Mon Sep 17 00:00:00 2001 From: Amina Foon Date: Wed, 23 Aug 2023 09:54:35 -0400 Subject: [PATCH 075/138] update pricers --- .../domestic_destination_sit_delivery_pricer_test.go | 2 +- .../domestic_origin_sit_pickup_pricer_test.go | 2 +- pkg/services/ghcrateengine/pricer_helpers.go | 8 +++----- pkg/services/ghcrateengine/pricer_helpers_test.go | 2 +- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/pkg/services/ghcrateengine/domestic_destination_sit_delivery_pricer_test.go b/pkg/services/ghcrateengine/domestic_destination_sit_delivery_pricer_test.go index e29541a865b..4f06572acc4 100644 --- a/pkg/services/ghcrateengine/domestic_destination_sit_delivery_pricer_test.go +++ b/pkg/services/ghcrateengine/domestic_destination_sit_delivery_pricer_test.go @@ -201,7 +201,7 @@ func (suite *GHCRateEngineServiceSuite) TestDomesticDestinationSITDeliveryPricer twoYearsLaterPickupDate := dddsitTestRequestedPickupDate.AddDate(2, 0, 0) _, _, err := pricer.Price(suite.AppContextForTest(), testdatagen.DefaultContractCode, twoYearsLaterPickupDate, dddsitTestWeight, dddsitTestServiceArea, dddsitTestSchedule, zipDest, zipSITDest, distance) suite.Error(err) - suite.Contains(err.Error(), "could not fetch contract year") + suite.Contains(err.Error(), "could not look up contract year") }) } diff --git a/pkg/services/ghcrateengine/domestic_origin_sit_pickup_pricer_test.go b/pkg/services/ghcrateengine/domestic_origin_sit_pickup_pricer_test.go index 83fab1322f8..45372caf1ef 100644 --- a/pkg/services/ghcrateengine/domestic_origin_sit_pickup_pricer_test.go +++ b/pkg/services/ghcrateengine/domestic_origin_sit_pickup_pricer_test.go @@ -194,7 +194,7 @@ func (suite *GHCRateEngineServiceSuite) TestDomesticOriginSITPickupPricer50Miles twoYearsLaterPickupDate := dopsitTestRequestedPickupDate.AddDate(2, 0, 0) _, _, err := pricer.Price(suite.AppContextForTest(), testdatagen.DefaultContractCode, twoYearsLaterPickupDate, dopsitTestWeight, dopsitTestServiceArea, dopsitTestSchedule, zipOriginal, zipActual, distance) suite.Error(err) - suite.Contains(err.Error(), "could not fetch contract year") + suite.Contains(err.Error(), "could not lookup contract year") }) } diff --git a/pkg/services/ghcrateengine/pricer_helpers.go b/pkg/services/ghcrateengine/pricer_helpers.go index 4d71d307ab0..3f7f6ba68f3 100644 --- a/pkg/services/ghcrateengine/pricer_helpers.go +++ b/pkg/services/ghcrateengine/pricer_helpers.go @@ -260,13 +260,11 @@ func priceDomesticPickupDeliverySIT(appCtx appcontext.AppContext, pickupDelivery if err != nil { return unit.Cents(0), nil, fmt.Errorf("could not fetch domestic %s SIT %s rate: %w", sitType, sitModifier, err) } - contractYear, err := fetchContractYear(appCtx, domOtherPrice.ContractID, referenceDate) + baseTotalPrice := domOtherPrice.PriceCents.Float64() * weight.ToCWTFloat64() + escalatedTotalPrice, contractYear, err := escalatePriceForContractYear(appCtx, domOtherPrice.ContractID, referenceDate, false, baseTotalPrice) if err != nil { - return unit.Cents(0), nil, fmt.Errorf("could not fetch contract year: %w", err) + return 0, nil, fmt.Errorf("could not look up contract year: %w", err) } - - baseTotalPrice := domOtherPrice.PriceCents.Float64() * weight.ToCWTFloat64() - escalatedTotalPrice := baseTotalPrice * contractYear.EscalationCompounded totalPriceCents := unit.Cents(math.Round(escalatedTotalPrice)) displayParams := services.PricingDisplayParams{ diff --git a/pkg/services/ghcrateengine/pricer_helpers_test.go b/pkg/services/ghcrateengine/pricer_helpers_test.go index c50767ab06a..628e25b6269 100644 --- a/pkg/services/ghcrateengine/pricer_helpers_test.go +++ b/pkg/services/ghcrateengine/pricer_helpers_test.go @@ -365,7 +365,7 @@ func (suite *GHCRateEngineServiceSuite) Test_priceDomesticPickupDeliverySIT50Mil twoYearsLaterPickupDate := dddsitTestRequestedPickupDate.AddDate(2, 0, 0) _, _, err = priceDomesticPickupDeliverySIT(suite.AppContextForTest(), models.ReServiceCodeDDDSIT, testdatagen.DefaultContractCode, twoYearsLaterPickupDate, dddsitTestWeight, dddsitTestServiceArea, dddsitTestSchedule, domOtherZipDest, domOtherZipSITDest, domOtherDistance) suite.Error(err) - suite.Contains(err.Error(), "could not fetch contract year") + suite.Contains(err.Error(), "could not look up contract year") }) } From fb49b05bef999124af69e1be5088155b3f4a5747 Mon Sep 17 00:00:00 2001 From: Marjo Poindexter <> Date: Wed, 23 Aug 2023 17:02:02 +0000 Subject: [PATCH 076/138] implement escalated price helper function --- .../domestic_destination_first_day_sit_pricer_test.go | 2 +- .../domestic_origin_first_day_sit_pricer_test.go | 2 +- pkg/services/ghcrateengine/pricer_helpers.go | 11 ++++------- pkg/services/ghcrateengine/pricer_helpers_test.go | 2 +- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/pkg/services/ghcrateengine/domestic_destination_first_day_sit_pricer_test.go b/pkg/services/ghcrateengine/domestic_destination_first_day_sit_pricer_test.go index 0d641d4e758..59735de002b 100644 --- a/pkg/services/ghcrateengine/domestic_destination_first_day_sit_pricer_test.go +++ b/pkg/services/ghcrateengine/domestic_destination_first_day_sit_pricer_test.go @@ -82,7 +82,7 @@ func (suite *GHCRateEngineServiceSuite) TestDomesticDestinationFirstDaySITPricer twoYearsLaterPickupDate := ddfsitTestRequestedPickupDate.AddDate(2, 0, 0) _, _, err := pricer.Price(suite.AppContextForTest(), testdatagen.DefaultContractCode, twoYearsLaterPickupDate, ddfsitTestWeight, ddfsitTestServiceArea, false) suite.Error(err) - suite.Contains(err.Error(), "could not fetch contract year") + suite.Contains(err.Error(), "could not lookup contract year") }) } diff --git a/pkg/services/ghcrateengine/domestic_origin_first_day_sit_pricer_test.go b/pkg/services/ghcrateengine/domestic_origin_first_day_sit_pricer_test.go index 0a067b91c48..60d0b2bd57c 100644 --- a/pkg/services/ghcrateengine/domestic_origin_first_day_sit_pricer_test.go +++ b/pkg/services/ghcrateengine/domestic_origin_first_day_sit_pricer_test.go @@ -82,7 +82,7 @@ func (suite *GHCRateEngineServiceSuite) TestDomesticOriginFirstDaySITPricer() { twoYearsLaterPickupDate := dofsitTestRequestedPickupDate.AddDate(2, 0, 0) _, _, err := pricer.Price(suite.AppContextForTest(), testdatagen.DefaultContractCode, twoYearsLaterPickupDate, dofsitTestWeight, dofsitTestServiceArea, false) suite.Error(err) - suite.Contains(err.Error(), "could not fetch contract year") + suite.Contains(err.Error(), "could not lookup contract year") }) } diff --git a/pkg/services/ghcrateengine/pricer_helpers.go b/pkg/services/ghcrateengine/pricer_helpers.go index 13be7df3552..515ccebed5c 100644 --- a/pkg/services/ghcrateengine/pricer_helpers.go +++ b/pkg/services/ghcrateengine/pricer_helpers.go @@ -124,15 +124,12 @@ func priceDomesticFirstDaySIT(appCtx appcontext.AppContext, firstDaySITCode mode return unit.Cents(0), nil, fmt.Errorf("could not fetch domestic %s first day SIT rate: %w", sitType, err) } - contractYear, err := fetchContractYear(appCtx, serviceAreaPrice.ContractID, referenceDate) + baseTotalPrice := serviceAreaPrice.PriceCents.Float64() * weight.ToCWTFloat64() + escalatedPrice, contractYear, err := escalatePriceForContractYear(appCtx, serviceAreaPrice.ContractID, referenceDate, false, baseTotalPrice) if err != nil { - return unit.Cents(0), nil, fmt.Errorf("could not fetch contract year: %w", err) + return 0, nil, fmt.Errorf("could not look up escalated price: %w", err) } - - baseTotalPrice := serviceAreaPrice.PriceCents.Float64() * weight.ToCWTFloat64() - escalatedTotalPrice := baseTotalPrice * contractYear.EscalationCompounded - - totalPriceCents := unit.Cents(math.Round(escalatedTotalPrice)) + totalPriceCents := unit.Cents(math.Round(escalatedPrice)) params := services.PricingDisplayParams{ {Key: models.ServiceItemParamNameContractYearName, Value: contractYear.Name}, diff --git a/pkg/services/ghcrateengine/pricer_helpers_test.go b/pkg/services/ghcrateengine/pricer_helpers_test.go index 41d20b89627..1fa0fd233cf 100644 --- a/pkg/services/ghcrateengine/pricer_helpers_test.go +++ b/pkg/services/ghcrateengine/pricer_helpers_test.go @@ -178,7 +178,7 @@ func (suite *GHCRateEngineServiceSuite) Test_priceDomesticFirstDaySIT() { twoYearsLaterPickupDate := ddfsitTestRequestedPickupDate.AddDate(2, 0, 0) _, _, err := priceDomesticFirstDaySIT(suite.AppContextForTest(), models.ReServiceCodeDDFSIT, testdatagen.DefaultContractCode, twoYearsLaterPickupDate, ddfsitTestWeight, ddfsitTestServiceArea, false) suite.Error(err) - suite.Contains(err.Error(), "could not fetch contract year") + suite.Contains(err.Error(), "could not lookup contract year") }) } From 805431345cfd47aae6275162ae1f6b9c65cb32bc Mon Sep 17 00:00:00 2001 From: Amina Foon Date: Wed, 23 Aug 2023 13:48:32 -0400 Subject: [PATCH 077/138] update error messages --- .../domestic_destination_sit_delivery_pricer_test.go | 2 +- pkg/services/ghcrateengine/pricer_helpers.go | 2 +- pkg/services/ghcrateengine/pricer_helpers_test.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/services/ghcrateengine/domestic_destination_sit_delivery_pricer_test.go b/pkg/services/ghcrateengine/domestic_destination_sit_delivery_pricer_test.go index 4f06572acc4..e858bb6726d 100644 --- a/pkg/services/ghcrateengine/domestic_destination_sit_delivery_pricer_test.go +++ b/pkg/services/ghcrateengine/domestic_destination_sit_delivery_pricer_test.go @@ -201,7 +201,7 @@ func (suite *GHCRateEngineServiceSuite) TestDomesticDestinationSITDeliveryPricer twoYearsLaterPickupDate := dddsitTestRequestedPickupDate.AddDate(2, 0, 0) _, _, err := pricer.Price(suite.AppContextForTest(), testdatagen.DefaultContractCode, twoYearsLaterPickupDate, dddsitTestWeight, dddsitTestServiceArea, dddsitTestSchedule, zipDest, zipSITDest, distance) suite.Error(err) - suite.Contains(err.Error(), "could not look up contract year") + suite.Contains(err.Error(), "could not lookup contract year") }) } diff --git a/pkg/services/ghcrateengine/pricer_helpers.go b/pkg/services/ghcrateengine/pricer_helpers.go index 3f7f6ba68f3..169ce6a1593 100644 --- a/pkg/services/ghcrateengine/pricer_helpers.go +++ b/pkg/services/ghcrateengine/pricer_helpers.go @@ -263,7 +263,7 @@ func priceDomesticPickupDeliverySIT(appCtx appcontext.AppContext, pickupDelivery baseTotalPrice := domOtherPrice.PriceCents.Float64() * weight.ToCWTFloat64() escalatedTotalPrice, contractYear, err := escalatePriceForContractYear(appCtx, domOtherPrice.ContractID, referenceDate, false, baseTotalPrice) if err != nil { - return 0, nil, fmt.Errorf("could not look up contract year: %w", err) + return 0, nil, fmt.Errorf("unable to calculate escalated total price: %w", err) } totalPriceCents := unit.Cents(math.Round(escalatedTotalPrice)) diff --git a/pkg/services/ghcrateengine/pricer_helpers_test.go b/pkg/services/ghcrateengine/pricer_helpers_test.go index 628e25b6269..ba2789836cf 100644 --- a/pkg/services/ghcrateengine/pricer_helpers_test.go +++ b/pkg/services/ghcrateengine/pricer_helpers_test.go @@ -365,7 +365,7 @@ func (suite *GHCRateEngineServiceSuite) Test_priceDomesticPickupDeliverySIT50Mil twoYearsLaterPickupDate := dddsitTestRequestedPickupDate.AddDate(2, 0, 0) _, _, err = priceDomesticPickupDeliverySIT(suite.AppContextForTest(), models.ReServiceCodeDDDSIT, testdatagen.DefaultContractCode, twoYearsLaterPickupDate, dddsitTestWeight, dddsitTestServiceArea, dddsitTestSchedule, domOtherZipDest, domOtherZipSITDest, domOtherDistance) suite.Error(err) - suite.Contains(err.Error(), "could not look up contract year") + suite.Contains(err.Error(), "could not lookup contract year") }) } From 830cf2bb9e37c5db0c3e48143bd718f1a611ae5a Mon Sep 17 00:00:00 2001 From: belle Date: Wed, 23 Aug 2023 20:22:57 +0000 Subject: [PATCH 078/138] Added helper function to domestic shorthaul pricer and associated test --- pkg/services/ghcrateengine/domestic_shorthaul_pricer.go | 8 +++----- .../ghcrateengine/domestic_shorthaul_pricer_test.go | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/pkg/services/ghcrateengine/domestic_shorthaul_pricer.go b/pkg/services/ghcrateengine/domestic_shorthaul_pricer.go index 6485f74bcde..3882d55dcef 100644 --- a/pkg/services/ghcrateengine/domestic_shorthaul_pricer.go +++ b/pkg/services/ghcrateengine/domestic_shorthaul_pricer.go @@ -54,13 +54,11 @@ func (p domesticShorthaulPricer) Price(appCtx appcontext.AppContext, contractCod return 0, nil, fmt.Errorf("Could not lookup Domestic Service Area Price: %w", err) } - contractYear, err := fetchContractYear(appCtx, domServiceAreaPrice.ContractID, referenceDate) + basePrice := domServiceAreaPrice.PriceCents.Float64() * distance.Float64() * weight.ToCWTFloat64() + escalatedPrice, contractYear, err := escalatePriceForContractYear(appCtx, domServiceAreaPrice.ContractID, referenceDate, false, basePrice) if err != nil { - return 0, nil, fmt.Errorf("Could not lookup contract year: %w", err) + return 0, nil, fmt.Errorf("could not look up escalated price: %w", err) } - - basePrice := domServiceAreaPrice.PriceCents.Float64() * distance.Float64() * weight.ToCWTFloat64() - escalatedPrice := basePrice * contractYear.EscalationCompounded totalCost = unit.Cents(math.Round(escalatedPrice)) var pricingRateEngineParams = services.PricingDisplayParams{ diff --git a/pkg/services/ghcrateengine/domestic_shorthaul_pricer_test.go b/pkg/services/ghcrateengine/domestic_shorthaul_pricer_test.go index c44a337cdfc..853d359803c 100644 --- a/pkg/services/ghcrateengine/domestic_shorthaul_pricer_test.go +++ b/pkg/services/ghcrateengine/domestic_shorthaul_pricer_test.go @@ -197,8 +197,8 @@ func (suite *GHCRateEngineServiceSuite) TestPriceDomesticShorthaul() { ) suite.Error(err) - suite.Equal("Could not lookup contract year: "+models.RecordNotFoundErrorString, err.Error()) suite.Nil(rateEngineParams) + suite.Contains(err.Error(), "could not look up escalated price") }) suite.Run("weight below minimum", func() { From d68737a725aa025369a619f8fc236bcbef77f3eb Mon Sep 17 00:00:00 2001 From: Michael Valdes Date: Wed, 23 Aug 2023 19:06:03 +0000 Subject: [PATCH 079/138] Update rounding for domestic crating pricer --- pkg/services/ghcrateengine/pricer_helpers.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/pkg/services/ghcrateengine/pricer_helpers.go b/pkg/services/ghcrateengine/pricer_helpers.go index ed861fa9d12..04a0ed8798b 100644 --- a/pkg/services/ghcrateengine/pricer_helpers.go +++ b/pkg/services/ghcrateengine/pricer_helpers.go @@ -54,7 +54,7 @@ func priceDomesticPackUnpack(appCtx appcontext.AppContext, packUnpackCode models basePrice := domOtherPrice.PriceCents.Float64() * finalWeight.ToCWTFloat64() escalatedPrice, contractYear, err := escalatePriceForContractYear(appCtx, domOtherPrice.ContractID, referenceDate, false, basePrice) if err != nil { - return 0, nil, fmt.Errorf("Could not lookup escalated price: %w", err) + return 0, nil, fmt.Errorf("unable to calculate escalated total price: %w", err) } displayParams := services.PricingDisplayParams{ @@ -159,7 +159,7 @@ func priceDomesticAdditionalDaysSIT(appCtx appcontext.AppContext, additionalDayS baseTotalPrice := serviceAreaPrice.PriceCents.Float64() * weight.ToCWTFloat64() escalatedTotalPrice, contractYear, err := escalatePriceForContractYear(appCtx, serviceAreaPrice.ContractID, referenceDate, false, baseTotalPrice) if err != nil { - return 0, nil, fmt.Errorf("could not look up escalated price: %w", err) + return 0, nil, fmt.Errorf("unable to calculate escalated total price: %w", err) } totalForNumberOfDaysPrice := escalatedTotalPrice * float64(numberOfDaysInSIT) @@ -350,11 +350,10 @@ func priceDomesticCrating(appCtx appcontext.AppContext, code models.ReServiceCod } basePrice := domAccessorialPrice.PerUnitCents.Float64() * float64(billedCubicFeet) - contractYear, err := fetchContractYear(appCtx, domAccessorialPrice.ContractID, referenceDate) + escalatedPrice, contractYear, err := escalatePriceForContractYear(appCtx, domAccessorialPrice.ContractID, referenceDate, false, basePrice) if err != nil { - return 0, nil, fmt.Errorf("could not lookup contract year: %w", err) + return 0, nil, fmt.Errorf("unable to calculate escalated total price: %w", err) } - escalatedPrice := basePrice * contractYear.EscalationCompounded totalCost := unit.Cents(math.Round(escalatedPrice)) params := services.PricingDisplayParams{ From c14992fe476dd18daebaf6349a19f25e650922ac Mon Sep 17 00:00:00 2001 From: Michael Valdes Date: Wed, 23 Aug 2023 19:06:59 +0000 Subject: [PATCH 080/138] Standardize escalated price error message --- pkg/services/ghcrateengine/domestic_destination_pricer.go | 2 +- pkg/services/ghcrateengine/domestic_destination_pricer_test.go | 2 +- pkg/services/ghcrateengine/pricer_helpers.go | 2 +- pkg/services/ghcrateengine/pricer_helpers_test.go | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/services/ghcrateengine/domestic_destination_pricer.go b/pkg/services/ghcrateengine/domestic_destination_pricer.go index bb3fb50ce07..10d1db3395b 100644 --- a/pkg/services/ghcrateengine/domestic_destination_pricer.go +++ b/pkg/services/ghcrateengine/domestic_destination_pricer.go @@ -53,7 +53,7 @@ func (p domesticDestinationPricer) Price(appCtx appcontext.AppContext, contractC basePrice := domServiceAreaPrice.PriceCents.Float64() * finalWeight.ToCWTFloat64() escalatedPrice, contractYear, err := escalatePriceForContractYear(appCtx, domServiceAreaPrice.ContractID, referenceDate, false, basePrice) if err != nil { - return 0, nil, fmt.Errorf("could not look up escalated price: %w", err) + return 0, nil, fmt.Errorf("unable to calculate escalated total price: %w", err) } totalCost := unit.Cents(math.Round(escalatedPrice)) diff --git a/pkg/services/ghcrateengine/domestic_destination_pricer_test.go b/pkg/services/ghcrateengine/domestic_destination_pricer_test.go index 10ded1ee613..38c2d90516e 100644 --- a/pkg/services/ghcrateengine/domestic_destination_pricer_test.go +++ b/pkg/services/ghcrateengine/domestic_destination_pricer_test.go @@ -226,7 +226,7 @@ func (suite *GHCRateEngineServiceSuite) TestPriceDomesticDestination() { ) suite.Error(err) - suite.Contains(err.Error(), "could not look up escalated price") + suite.Contains(err.Error(), "unable to calculate escalated total price") }) diff --git a/pkg/services/ghcrateengine/pricer_helpers.go b/pkg/services/ghcrateengine/pricer_helpers.go index 04a0ed8798b..50b36fe3c4b 100644 --- a/pkg/services/ghcrateengine/pricer_helpers.go +++ b/pkg/services/ghcrateengine/pricer_helpers.go @@ -122,7 +122,7 @@ func priceDomesticFirstDaySIT(appCtx appcontext.AppContext, firstDaySITCode mode baseTotalPrice := serviceAreaPrice.PriceCents.Float64() * weight.ToCWTFloat64() escalatedPrice, contractYear, err := escalatePriceForContractYear(appCtx, serviceAreaPrice.ContractID, referenceDate, false, baseTotalPrice) if err != nil { - return 0, nil, fmt.Errorf("could not look up escalated price: %w", err) + return 0, nil, fmt.Errorf("unable to calculate escalated total price: %w", err) } totalPriceCents := unit.Cents(math.Round(escalatedPrice)) diff --git a/pkg/services/ghcrateengine/pricer_helpers_test.go b/pkg/services/ghcrateengine/pricer_helpers_test.go index 55132dc9ccd..415e9286788 100644 --- a/pkg/services/ghcrateengine/pricer_helpers_test.go +++ b/pkg/services/ghcrateengine/pricer_helpers_test.go @@ -239,7 +239,7 @@ func (suite *GHCRateEngineServiceSuite) Test_priceDomesticAdditionalDaysSIT() { twoYearsLaterPickupDate := ddasitTestRequestedPickupDate.AddDate(2, 0, 0) _, _, err := priceDomesticAdditionalDaysSIT(suite.AppContextForTest(), models.ReServiceCodeDDASIT, testdatagen.DefaultContractCode, twoYearsLaterPickupDate, ddasitTestWeight, ddasitTestServiceArea, ddasitTestNumberOfDaysInSIT, false) suite.Error(err) - suite.Contains(err.Error(), "could not look up escalated price") + suite.Contains(err.Error(), "unable to calculate escalated total price") }) } From 602a79cb4a25f734493edd52f09a73cc39344eb8 Mon Sep 17 00:00:00 2001 From: Michael Valdes Date: Wed, 23 Aug 2023 21:17:32 +0000 Subject: [PATCH 081/138] Adjust test error message --- pkg/services/ghcrateengine/pricer_helpers_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/services/ghcrateengine/pricer_helpers_test.go b/pkg/services/ghcrateengine/pricer_helpers_test.go index 415e9286788..0bd899b5c36 100644 --- a/pkg/services/ghcrateengine/pricer_helpers_test.go +++ b/pkg/services/ghcrateengine/pricer_helpers_test.go @@ -239,7 +239,7 @@ func (suite *GHCRateEngineServiceSuite) Test_priceDomesticAdditionalDaysSIT() { twoYearsLaterPickupDate := ddasitTestRequestedPickupDate.AddDate(2, 0, 0) _, _, err := priceDomesticAdditionalDaysSIT(suite.AppContextForTest(), models.ReServiceCodeDDASIT, testdatagen.DefaultContractCode, twoYearsLaterPickupDate, ddasitTestWeight, ddasitTestServiceArea, ddasitTestNumberOfDaysInSIT, false) suite.Error(err) - suite.Contains(err.Error(), "unable to calculate escalated total price") + suite.Contains(err.Error(), "could not lookup contract year") }) } From a2ad5f62851935f78c521ea05623782d4a75043f Mon Sep 17 00:00:00 2001 From: Felipe Lee Date: Thu, 24 Aug 2023 00:21:37 +0000 Subject: [PATCH 082/138] feat (domestic origin pricer): update to use new escalated pricing func fix (docs): fix docstring typo JIRA Ticket: MB-16912 --- .../ghcrateengine/domestic_origin_pricer.go | 19 +++++++++++++------ .../domestic_origin_pricer_test.go | 11 +++++++++-- pkg/services/ghcrateengine/pricer_helpers.go | 2 +- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/pkg/services/ghcrateengine/domestic_origin_pricer.go b/pkg/services/ghcrateengine/domestic_origin_pricer.go index cf5e8b285f1..5c2e6914fc3 100644 --- a/pkg/services/ghcrateengine/domestic_origin_pricer.go +++ b/pkg/services/ghcrateengine/domestic_origin_pricer.go @@ -45,18 +45,25 @@ func (p domesticOriginPricer) Price(appCtx appcontext.AppContext, contractCode s return 0, nil, fmt.Errorf("Could not lookup Domestic Service Area Price: %w", err) } - contractYear, err := fetchContractYear(appCtx, domServiceAreaPrice.ContractID, referenceDate) - if err != nil { - return 0, nil, fmt.Errorf("Could not lookup contract year: %w", err) - } - finalWeight := weight if isPPM && weight < minDomesticWeight { finalWeight = minDomesticWeight } basePrice := domServiceAreaPrice.PriceCents.Float64() * finalWeight.ToCWTFloat64() - escalatedPrice := basePrice * contractYear.EscalationCompounded + + escalatedPrice, contractYear, err := escalatePriceForContractYear( + appCtx, + domServiceAreaPrice.ContractID, + referenceDate, + false, + basePrice, + ) + + if err != nil { + return 0, nil, fmt.Errorf("could not calculate escalated price: %w", err) + } + totalCost := unit.Cents(math.Round(escalatedPrice)) params := services.PricingDisplayParams{ diff --git a/pkg/services/ghcrateengine/domestic_origin_pricer_test.go b/pkg/services/ghcrateengine/domestic_origin_pricer_test.go index 225dba31b8b..d1ec0cbad03 100644 --- a/pkg/services/ghcrateengine/domestic_origin_pricer_test.go +++ b/pkg/services/ghcrateengine/domestic_origin_pricer_test.go @@ -1,6 +1,7 @@ package ghcrateengine import ( + "fmt" "strconv" "time" @@ -190,8 +191,14 @@ func (suite *GHCRateEngineServiceSuite) TestPriceDomesticOrigin() { isPPM, ) - suite.Error(err) - suite.Equal("Could not lookup contract year: "+models.RecordNotFoundErrorString, err.Error()) + if suite.Error(err) { + expectedErr := fmt.Sprintf( + "could not calculate escalated price: could not lookup contract year: %s", + models.RecordNotFoundErrorString, + ) + + suite.Equal(expectedErr, err.Error()) + } }) suite.Run("weight below minimum", func() { diff --git a/pkg/services/ghcrateengine/pricer_helpers.go b/pkg/services/ghcrateengine/pricer_helpers.go index 50b36fe3c4b..36d69859d06 100644 --- a/pkg/services/ghcrateengine/pricer_helpers.go +++ b/pkg/services/ghcrateengine/pricer_helpers.go @@ -418,7 +418,7 @@ func createPricerGeneratedParams(appCtx appcontext.AppContext, paymentServiceIte } // escalatePriceForContractYear calculates the escalated price from the base price, which is provided by the caller/pricer, -// and the escalation factor, which is provded by the contract year. The result is rounded to the nearest cent, or to the +// and the escalation factor, which is provided by the contract year. The result is rounded to the nearest cent, or to the // nearest tenth-cent for linehaul prices. The contract year is also returned. func escalatePriceForContractYear(appCtx appcontext.AppContext, contractID uuid.UUID, referenceDate time.Time, isLinehaul bool, basePrice float64) (float64, models.ReContractYear, error) { contractYear, err := fetchContractYear(appCtx, contractID, referenceDate) From 51dc7850d2712ffc37cde6d4d7d8d3a36e1818d4 Mon Sep 17 00:00:00 2001 From: StuTruss Date: Thu, 24 Aug 2023 01:22:22 +0000 Subject: [PATCH 083/138] add pricing to DDSHUT --- .../domestic_destination_shuttling_pricer_test.go | 2 +- .../domestic_origin_shuttling_pricer_test.go | 2 +- pkg/services/ghcrateengine/pricer_helpers.go | 8 +++----- pkg/services/ghcrateengine/pricer_helpers_test.go | 2 +- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/pkg/services/ghcrateengine/domestic_destination_shuttling_pricer_test.go b/pkg/services/ghcrateengine/domestic_destination_shuttling_pricer_test.go index 0a33c4dd300..b31f260d279 100644 --- a/pkg/services/ghcrateengine/domestic_destination_shuttling_pricer_test.go +++ b/pkg/services/ghcrateengine/domestic_destination_shuttling_pricer_test.go @@ -75,7 +75,7 @@ func (suite *GHCRateEngineServiceSuite) TestDomesticDestinationShuttlingPricer() twoYearsLaterPickupDate := ddshutTestRequestedPickupDate.AddDate(2, 0, 0) _, _, err := pricer.Price(suite.AppContextForTest(), testdatagen.DefaultContractCode, twoYearsLaterPickupDate, ddshutTestWeight, ddshutTestServiceSchedule) suite.Error(err) - suite.Contains(err.Error(), "Could not lookup contract year") + suite.Contains(err.Error(), "unable to calculate escalated total price") }) } diff --git a/pkg/services/ghcrateengine/domestic_origin_shuttling_pricer_test.go b/pkg/services/ghcrateengine/domestic_origin_shuttling_pricer_test.go index 61c843cdc87..b8b1ea64313 100644 --- a/pkg/services/ghcrateengine/domestic_origin_shuttling_pricer_test.go +++ b/pkg/services/ghcrateengine/domestic_origin_shuttling_pricer_test.go @@ -75,7 +75,7 @@ func (suite *GHCRateEngineServiceSuite) TestDomesticOriginShuttlingPricer() { twoYearsLaterPickupDate := doshutTestRequestedPickupDate.AddDate(2, 0, 0) _, _, err := pricer.Price(suite.AppContextForTest(), testdatagen.DefaultContractCode, twoYearsLaterPickupDate, doshutTestWeight, doshutTestServiceSchedule) suite.Error(err) - suite.Contains(err.Error(), "Could not lookup contract year") + suite.Contains(err.Error(), "unable to calculate escalated total price: could not lookup contract year") }) } diff --git a/pkg/services/ghcrateengine/pricer_helpers.go b/pkg/services/ghcrateengine/pricer_helpers.go index 50b36fe3c4b..ba4868a6095 100644 --- a/pkg/services/ghcrateengine/pricer_helpers.go +++ b/pkg/services/ghcrateengine/pricer_helpers.go @@ -310,13 +310,11 @@ func priceDomesticShuttling(appCtx appcontext.AppContext, shuttlingCode models.R return 0, nil, fmt.Errorf("Could not lookup Domestic Accessorial Area Price: %w", err) } - contractYear, err := fetchContractYear(appCtx, domAccessorialPrice.ContractID, referenceDate) + basePrice := domAccessorialPrice.PerUnitCents.Float64() * weight.ToCWTFloat64() + escalatedPrice, contractYear, err := escalatePriceForContractYear(appCtx, domAccessorialPrice.ContractID, referenceDate, false, basePrice) if err != nil { - return 0, nil, fmt.Errorf("Could not lookup contract year: %w", err) + return 0, nil, fmt.Errorf("unable to calculate escalated total price: %w", err) } - - basePrice := domAccessorialPrice.PerUnitCents.Float64() * weight.ToCWTFloat64() - escalatedPrice := basePrice * contractYear.EscalationCompounded totalCost := unit.Cents(math.Round(escalatedPrice)) params := services.PricingDisplayParams{ diff --git a/pkg/services/ghcrateengine/pricer_helpers_test.go b/pkg/services/ghcrateengine/pricer_helpers_test.go index 0bd899b5c36..b3054a5e265 100644 --- a/pkg/services/ghcrateengine/pricer_helpers_test.go +++ b/pkg/services/ghcrateengine/pricer_helpers_test.go @@ -553,7 +553,7 @@ func (suite *GHCRateEngineServiceSuite) Test_priceDomesticShuttling() { _, _, err := priceDomesticShuttling(suite.AppContextForTest(), models.ReServiceCodeDDSHUT, testdatagen.DefaultContractCode, twoYearsLaterPickupDate, ddshutTestWeight, ddshutTestServiceSchedule) suite.Error(err) - suite.Contains(err.Error(), "Could not lookup contract year") + suite.Contains(err.Error(), "unable to calculate escalated total price: could not lookup contract year") }) } func (suite *GHCRateEngineServiceSuite) Test_priceDomesticCrating() { From 985a4ef70bf5d94c318fba7757c7c3b64a4c922d Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Thu, 24 Aug 2023 16:00:12 +0000 Subject: [PATCH 084/138] Add migrations for new service item fields --- migrations/app/migrations_manifest.txt | 1 + ...201206_add_fields_for_sit_to_mto_service_items.up.sql | 9 +++++++++ 2 files changed, 10 insertions(+) create mode 100644 migrations/app/schema/20230822201206_add_fields_for_sit_to_mto_service_items.up.sql diff --git a/migrations/app/migrations_manifest.txt b/migrations/app/migrations_manifest.txt index 3d6584f7dad..50d459887c3 100644 --- a/migrations/app/migrations_manifest.txt +++ b/migrations/app/migrations_manifest.txt @@ -842,3 +842,4 @@ 20230804161700_import_trdm_part_1.up.sql 20230807175944_import_trdm_part_2.up.sql 20230807180000_import_trdm_part_3.up.sql +20230822201206_add_fields_for_sit_to_mto_service_items.up.sql diff --git a/migrations/app/schema/20230822201206_add_fields_for_sit_to_mto_service_items.up.sql b/migrations/app/schema/20230822201206_add_fields_for_sit_to_mto_service_items.up.sql new file mode 100644 index 00000000000..d33c96d8f58 --- /dev/null +++ b/migrations/app/schema/20230822201206_add_fields_for_sit_to_mto_service_items.up.sql @@ -0,0 +1,9 @@ +ALTER TABLE mto_service_items + ADD COLUMN sit_customer_contacted date, + ADD COLUMN sit_requested_delivery date, + ADD COLUMN sit_actual_delivery date; + +-- Comment On Column +COMMENT ON COLUMN mto_service_items.sit_customer_contacted IS 'The date when the customer contacted the prime for a delivery out of SIT'; +COMMENT ON COLUMN mto_service_items.sit_requested_delivery IS 'The date when the customer has requested delivery out of SIT'; +COMMENT ON COLUMN mto_service_items.sit_actual_delivery IS 'The date when the customer''s goods are delivered'; From f8a49f7d27338dd3b544c5d26ac445e0cfe787b6 Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Thu, 24 Aug 2023 16:01:10 +0000 Subject: [PATCH 085/138] Update model with new fields --- pkg/models/mto_service_items.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/models/mto_service_items.go b/pkg/models/mto_service_items.go index 47471dd8485..4b8753617d2 100644 --- a/pkg/models/mto_service_items.go +++ b/pkg/models/mto_service_items.go @@ -40,6 +40,9 @@ type MTOServiceItem struct { SITPostalCode *string `db:"sit_postal_code"` SITEntryDate *time.Time `db:"sit_entry_date"` SITDepartureDate *time.Time `db:"sit_departure_date"` + SITCustomerContacted *time.Time `db:"sit_customer_contacted"` + SITRequestedDelivery *time.Time `db:"sit_requested_delivery"` + SITActualDelivery *time.Time `db:"sit_actual_delivery"` SITOriginHHGOriginalAddress *Address `belongs_to:"addresses" fk_id:"sit_origin_hhg_original_address_id"` SITOriginHHGOriginalAddressID *uuid.UUID `db:"sit_origin_hhg_original_address_id"` SITOriginHHGActualAddress *Address `belongs_to:"addresses" fk_id:"sit_origin_hhg_actual_address_id"` From f12e7f572085248fda1640746e6be3bb58bf4772 Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Thu, 24 Aug 2023 16:08:05 +0000 Subject: [PATCH 086/138] Update yaml definitions --- pkg/gen/primeapi/embedded_spec.go | 72 ++++++++++++++ .../m_t_o_service_item_dest_s_i_t.go | 96 +++++++++++++++++++ .../update_m_t_o_service_item_s_i_t.go | 96 +++++++++++++++++++ pkg/gen/primev2api/embedded_spec.go | 36 +++++++ .../m_t_o_service_item_dest_s_i_t.go | 96 +++++++++++++++++++ .../prime/MTOServiceItemDestSIT.yaml | 15 +++ swagger-def/prime.yaml | 18 +++- swagger/prime.yaml | 34 +++++++ swagger/prime_v2.yaml | 17 ++++ 9 files changed, 478 insertions(+), 2 deletions(-) diff --git a/pkg/gen/primeapi/embedded_spec.go b/pkg/gen/primeapi/embedded_spec.go index bbc7e3e86e9..7241e60e663 100644 --- a/pkg/gen/primeapi/embedded_spec.go +++ b/pkg/gen/primeapi/embedded_spec.go @@ -2311,9 +2311,21 @@ func init() { "x-nullable": true, "x-omitempty": false }, + "sitActualDelivery": { + "description": "Date when the customer's goods are delivered.", + "type": "string", + "format": "date", + "x-nullable": true + }, "sitAddressUpdates": { "$ref": "#/definitions/SitAddressUpdates" }, + "sitCustomerContacted": { + "description": "Date when the customer contacted the prime for a delivery out of SIT.", + "type": "string", + "format": "date", + "x-nullable": true + }, "sitDepartureDate": { "description": "Departure date for SIT. This is the end date of the SIT at either origin or destination. This is optional as it can be updated using the UpdateMTOServiceItemSIT modelType at a later date.", "type": "string", @@ -2328,6 +2340,12 @@ func init() { "type": "string", "format": "date" }, + "sitRequestedDelivery": { + "description": "Date when the customer has requested delivery out of SIT.", + "type": "string", + "format": "date", + "x-nullable": true + }, "timeMilitary1": { "description": "Time of attempted contact corresponding to ` + "`" + `dateOfContact1` + "`" + `, in military format.", "type": "string", @@ -4051,6 +4069,18 @@ func init() { "DOPSIT" ] }, + "sitActualDelivery": { + "description": "Date when the customer's goods are delivered.", + "type": "string", + "format": "date", + "x-nullable": true + }, + "sitCustomerContacted": { + "description": "Date when the customer contacted the prime for a delivery out of SIT.", + "type": "string", + "format": "date", + "x-nullable": true + }, "sitDepartureDate": { "description": "Departure date for SIT. This is the end date of the SIT at either origin or destination.", "type": "string", @@ -4059,6 +4089,12 @@ func init() { "sitDestinationFinalAddress": { "$ref": "#/definitions/Address" }, + "sitRequestedDelivery": { + "description": "Date when the customer has requested delivery out of SIT.", + "type": "string", + "format": "date", + "x-nullable": true + }, "timeMilitary1": { "description": "Time of attempted contact by the prime corresponding to 'dateOfContact1', in military format.", "type": "string", @@ -7249,9 +7285,21 @@ func init() { "x-nullable": true, "x-omitempty": false }, + "sitActualDelivery": { + "description": "Date when the customer's goods are delivered.", + "type": "string", + "format": "date", + "x-nullable": true + }, "sitAddressUpdates": { "$ref": "#/definitions/SitAddressUpdates" }, + "sitCustomerContacted": { + "description": "Date when the customer contacted the prime for a delivery out of SIT.", + "type": "string", + "format": "date", + "x-nullable": true + }, "sitDepartureDate": { "description": "Departure date for SIT. This is the end date of the SIT at either origin or destination. This is optional as it can be updated using the UpdateMTOServiceItemSIT modelType at a later date.", "type": "string", @@ -7266,6 +7314,12 @@ func init() { "type": "string", "format": "date" }, + "sitRequestedDelivery": { + "description": "Date when the customer has requested delivery out of SIT.", + "type": "string", + "format": "date", + "x-nullable": true + }, "timeMilitary1": { "description": "Time of attempted contact corresponding to ` + "`" + `dateOfContact1` + "`" + `, in military format.", "type": "string", @@ -8992,6 +9046,18 @@ func init() { "DOPSIT" ] }, + "sitActualDelivery": { + "description": "Date when the customer's goods are delivered.", + "type": "string", + "format": "date", + "x-nullable": true + }, + "sitCustomerContacted": { + "description": "Date when the customer contacted the prime for a delivery out of SIT.", + "type": "string", + "format": "date", + "x-nullable": true + }, "sitDepartureDate": { "description": "Departure date for SIT. This is the end date of the SIT at either origin or destination.", "type": "string", @@ -9000,6 +9066,12 @@ func init() { "sitDestinationFinalAddress": { "$ref": "#/definitions/Address" }, + "sitRequestedDelivery": { + "description": "Date when the customer has requested delivery out of SIT.", + "type": "string", + "format": "date", + "x-nullable": true + }, "timeMilitary1": { "description": "Time of attempted contact by the prime corresponding to 'dateOfContact1', in military format.", "type": "string", diff --git a/pkg/gen/primemessages/m_t_o_service_item_dest_s_i_t.go b/pkg/gen/primemessages/m_t_o_service_item_dest_s_i_t.go index 234e4038440..11b6936fb11 100644 --- a/pkg/gen/primemessages/m_t_o_service_item_dest_s_i_t.go +++ b/pkg/gen/primemessages/m_t_o_service_item_dest_s_i_t.go @@ -62,9 +62,17 @@ type MTOServiceItemDestSIT struct { // Required: true Reason *string `json:"reason"` + // Date when the customer's goods are delivered. + // Format: date + SitActualDelivery *strfmt.Date `json:"sitActualDelivery,omitempty"` + // sit address updates SitAddressUpdates SitAddressUpdates `json:"sitAddressUpdates,omitempty"` + // Date when the customer contacted the prime for a delivery out of SIT. + // Format: date + SitCustomerContacted *strfmt.Date `json:"sitCustomerContacted,omitempty"` + // Departure date for SIT. This is the end date of the SIT at either origin or destination. This is optional as it can be updated using the UpdateMTOServiceItemSIT modelType at a later date. // Format: date SitDepartureDate *strfmt.Date `json:"sitDepartureDate,omitempty"` @@ -77,6 +85,10 @@ type MTOServiceItemDestSIT struct { // Format: date SitEntryDate *strfmt.Date `json:"sitEntryDate"` + // Date when the customer has requested delivery out of SIT. + // Format: date + SitRequestedDelivery *strfmt.Date `json:"sitRequestedDelivery,omitempty"` + // Time of attempted contact corresponding to `dateOfContact1`, in military format. // Example: 1400Z // Pattern: \d{4}Z @@ -207,9 +219,17 @@ func (m *MTOServiceItemDestSIT) UnmarshalJSON(raw []byte) error { // Required: true Reason *string `json:"reason"` + // Date when the customer's goods are delivered. + // Format: date + SitActualDelivery *strfmt.Date `json:"sitActualDelivery,omitempty"` + // sit address updates SitAddressUpdates SitAddressUpdates `json:"sitAddressUpdates,omitempty"` + // Date when the customer contacted the prime for a delivery out of SIT. + // Format: date + SitCustomerContacted *strfmt.Date `json:"sitCustomerContacted,omitempty"` + // Departure date for SIT. This is the end date of the SIT at either origin or destination. This is optional as it can be updated using the UpdateMTOServiceItemSIT modelType at a later date. // Format: date SitDepartureDate *strfmt.Date `json:"sitDepartureDate,omitempty"` @@ -222,6 +242,10 @@ func (m *MTOServiceItemDestSIT) UnmarshalJSON(raw []byte) error { // Format: date SitEntryDate *strfmt.Date `json:"sitEntryDate"` + // Date when the customer has requested delivery out of SIT. + // Format: date + SitRequestedDelivery *strfmt.Date `json:"sitRequestedDelivery,omitempty"` + // Time of attempted contact corresponding to `dateOfContact1`, in military format. // Example: 1400Z // Pattern: \d{4}Z @@ -297,10 +321,13 @@ func (m *MTOServiceItemDestSIT) UnmarshalJSON(raw []byte) error { result.FirstAvailableDeliveryDate2 = data.FirstAvailableDeliveryDate2 result.ReServiceCode = data.ReServiceCode result.Reason = data.Reason + result.SitActualDelivery = data.SitActualDelivery result.SitAddressUpdates = data.SitAddressUpdates + result.SitCustomerContacted = data.SitCustomerContacted result.SitDepartureDate = data.SitDepartureDate result.SitDestinationFinalAddress = data.SitDestinationFinalAddress result.SitEntryDate = data.SitEntryDate + result.SitRequestedDelivery = data.SitRequestedDelivery result.TimeMilitary1 = data.TimeMilitary1 result.TimeMilitary2 = data.TimeMilitary2 @@ -341,9 +368,17 @@ func (m MTOServiceItemDestSIT) MarshalJSON() ([]byte, error) { // Required: true Reason *string `json:"reason"` + // Date when the customer's goods are delivered. + // Format: date + SitActualDelivery *strfmt.Date `json:"sitActualDelivery,omitempty"` + // sit address updates SitAddressUpdates SitAddressUpdates `json:"sitAddressUpdates,omitempty"` + // Date when the customer contacted the prime for a delivery out of SIT. + // Format: date + SitCustomerContacted *strfmt.Date `json:"sitCustomerContacted,omitempty"` + // Departure date for SIT. This is the end date of the SIT at either origin or destination. This is optional as it can be updated using the UpdateMTOServiceItemSIT modelType at a later date. // Format: date SitDepartureDate *strfmt.Date `json:"sitDepartureDate,omitempty"` @@ -356,6 +391,10 @@ func (m MTOServiceItemDestSIT) MarshalJSON() ([]byte, error) { // Format: date SitEntryDate *strfmt.Date `json:"sitEntryDate"` + // Date when the customer has requested delivery out of SIT. + // Format: date + SitRequestedDelivery *strfmt.Date `json:"sitRequestedDelivery,omitempty"` + // Time of attempted contact corresponding to `dateOfContact1`, in military format. // Example: 1400Z // Pattern: \d{4}Z @@ -379,14 +418,20 @@ func (m MTOServiceItemDestSIT) MarshalJSON() ([]byte, error) { Reason: m.Reason, + SitActualDelivery: m.SitActualDelivery, + SitAddressUpdates: m.SitAddressUpdates, + SitCustomerContacted: m.SitCustomerContacted, + SitDepartureDate: m.SitDepartureDate, SitDestinationFinalAddress: m.SitDestinationFinalAddress, SitEntryDate: m.SitEntryDate, + SitRequestedDelivery: m.SitRequestedDelivery, + TimeMilitary1: m.TimeMilitary1, TimeMilitary2: m.TimeMilitary2, @@ -487,10 +532,18 @@ func (m *MTOServiceItemDestSIT) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateSitActualDelivery(formats); err != nil { + res = append(res, err) + } + if err := m.validateSitAddressUpdates(formats); err != nil { res = append(res, err) } + if err := m.validateSitCustomerContacted(formats); err != nil { + res = append(res, err) + } + if err := m.validateSitDepartureDate(formats); err != nil { res = append(res, err) } @@ -503,6 +556,10 @@ func (m *MTOServiceItemDestSIT) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateSitRequestedDelivery(formats); err != nil { + res = append(res, err) + } + if err := m.validateTimeMilitary1(formats); err != nil { res = append(res, err) } @@ -687,6 +744,19 @@ func (m *MTOServiceItemDestSIT) validateReason(formats strfmt.Registry) error { return nil } +func (m *MTOServiceItemDestSIT) validateSitActualDelivery(formats strfmt.Registry) error { + + if swag.IsZero(m.SitActualDelivery) { // not required + return nil + } + + if err := validate.FormatOf("sitActualDelivery", "body", "date", m.SitActualDelivery.String(), formats); err != nil { + return err + } + + return nil +} + func (m *MTOServiceItemDestSIT) validateSitAddressUpdates(formats strfmt.Registry) error { if swag.IsZero(m.SitAddressUpdates) { // not required @@ -705,6 +775,19 @@ func (m *MTOServiceItemDestSIT) validateSitAddressUpdates(formats strfmt.Registr return nil } +func (m *MTOServiceItemDestSIT) validateSitCustomerContacted(formats strfmt.Registry) error { + + if swag.IsZero(m.SitCustomerContacted) { // not required + return nil + } + + if err := validate.FormatOf("sitCustomerContacted", "body", "date", m.SitCustomerContacted.String(), formats); err != nil { + return err + } + + return nil +} + func (m *MTOServiceItemDestSIT) validateSitDepartureDate(formats strfmt.Registry) error { if swag.IsZero(m.SitDepartureDate) { // not required @@ -751,6 +834,19 @@ func (m *MTOServiceItemDestSIT) validateSitEntryDate(formats strfmt.Registry) er return nil } +func (m *MTOServiceItemDestSIT) validateSitRequestedDelivery(formats strfmt.Registry) error { + + if swag.IsZero(m.SitRequestedDelivery) { // not required + return nil + } + + if err := validate.FormatOf("sitRequestedDelivery", "body", "date", m.SitRequestedDelivery.String(), formats); err != nil { + return err + } + + return nil +} + func (m *MTOServiceItemDestSIT) validateTimeMilitary1(formats strfmt.Registry) error { if swag.IsZero(m.TimeMilitary1) { // not required diff --git a/pkg/gen/primemessages/update_m_t_o_service_item_s_i_t.go b/pkg/gen/primemessages/update_m_t_o_service_item_s_i_t.go index 202bee5fc9c..706865168e9 100644 --- a/pkg/gen/primemessages/update_m_t_o_service_item_s_i_t.go +++ b/pkg/gen/primemessages/update_m_t_o_service_item_s_i_t.go @@ -42,6 +42,14 @@ type UpdateMTOServiceItemSIT struct { // Enum: [DDDSIT DOPSIT] ReServiceCode string `json:"reServiceCode,omitempty"` + // Date when the customer's goods are delivered. + // Format: date + SitActualDelivery *strfmt.Date `json:"sitActualDelivery,omitempty"` + + // Date when the customer contacted the prime for a delivery out of SIT. + // Format: date + SitCustomerContacted *strfmt.Date `json:"sitCustomerContacted,omitempty"` + // Departure date for SIT. This is the end date of the SIT at either origin or destination. // Format: date SitDepartureDate strfmt.Date `json:"sitDepartureDate,omitempty"` @@ -49,6 +57,10 @@ type UpdateMTOServiceItemSIT struct { // sit destination final address SitDestinationFinalAddress *Address `json:"sitDestinationFinalAddress,omitempty"` + // Date when the customer has requested delivery out of SIT. + // Format: date + SitRequestedDelivery *strfmt.Date `json:"sitRequestedDelivery,omitempty"` + // Time of attempted contact by the prime corresponding to 'dateOfContact1', in military format. // Example: 1400Z // Pattern: \d{4}Z @@ -103,6 +115,14 @@ func (m *UpdateMTOServiceItemSIT) UnmarshalJSON(raw []byte) error { // Enum: [DDDSIT DOPSIT] ReServiceCode string `json:"reServiceCode,omitempty"` + // Date when the customer's goods are delivered. + // Format: date + SitActualDelivery *strfmt.Date `json:"sitActualDelivery,omitempty"` + + // Date when the customer contacted the prime for a delivery out of SIT. + // Format: date + SitCustomerContacted *strfmt.Date `json:"sitCustomerContacted,omitempty"` + // Departure date for SIT. This is the end date of the SIT at either origin or destination. // Format: date SitDepartureDate strfmt.Date `json:"sitDepartureDate,omitempty"` @@ -110,6 +130,10 @@ func (m *UpdateMTOServiceItemSIT) UnmarshalJSON(raw []byte) error { // sit destination final address SitDestinationFinalAddress *Address `json:"sitDestinationFinalAddress,omitempty"` + // Date when the customer has requested delivery out of SIT. + // Format: date + SitRequestedDelivery *strfmt.Date `json:"sitRequestedDelivery,omitempty"` + // Time of attempted contact by the prime corresponding to 'dateOfContact1', in military format. // Example: 1400Z // Pattern: \d{4}Z @@ -157,8 +181,11 @@ func (m *UpdateMTOServiceItemSIT) UnmarshalJSON(raw []byte) error { result.FirstAvailableDeliveryDate1 = data.FirstAvailableDeliveryDate1 result.FirstAvailableDeliveryDate2 = data.FirstAvailableDeliveryDate2 result.ReServiceCode = data.ReServiceCode + result.SitActualDelivery = data.SitActualDelivery + result.SitCustomerContacted = data.SitCustomerContacted result.SitDepartureDate = data.SitDepartureDate result.SitDestinationFinalAddress = data.SitDestinationFinalAddress + result.SitRequestedDelivery = data.SitRequestedDelivery result.TimeMilitary1 = data.TimeMilitary1 result.TimeMilitary2 = data.TimeMilitary2 @@ -193,6 +220,14 @@ func (m UpdateMTOServiceItemSIT) MarshalJSON() ([]byte, error) { // Enum: [DDDSIT DOPSIT] ReServiceCode string `json:"reServiceCode,omitempty"` + // Date when the customer's goods are delivered. + // Format: date + SitActualDelivery *strfmt.Date `json:"sitActualDelivery,omitempty"` + + // Date when the customer contacted the prime for a delivery out of SIT. + // Format: date + SitCustomerContacted *strfmt.Date `json:"sitCustomerContacted,omitempty"` + // Departure date for SIT. This is the end date of the SIT at either origin or destination. // Format: date SitDepartureDate strfmt.Date `json:"sitDepartureDate,omitempty"` @@ -200,6 +235,10 @@ func (m UpdateMTOServiceItemSIT) MarshalJSON() ([]byte, error) { // sit destination final address SitDestinationFinalAddress *Address `json:"sitDestinationFinalAddress,omitempty"` + // Date when the customer has requested delivery out of SIT. + // Format: date + SitRequestedDelivery *strfmt.Date `json:"sitRequestedDelivery,omitempty"` + // Time of attempted contact by the prime corresponding to 'dateOfContact1', in military format. // Example: 1400Z // Pattern: \d{4}Z @@ -221,10 +260,16 @@ func (m UpdateMTOServiceItemSIT) MarshalJSON() ([]byte, error) { ReServiceCode: m.ReServiceCode, + SitActualDelivery: m.SitActualDelivery, + + SitCustomerContacted: m.SitCustomerContacted, + SitDepartureDate: m.SitDepartureDate, SitDestinationFinalAddress: m.SitDestinationFinalAddress, + SitRequestedDelivery: m.SitRequestedDelivery, + TimeMilitary1: m.TimeMilitary1, TimeMilitary2: m.TimeMilitary2, @@ -277,6 +322,14 @@ func (m *UpdateMTOServiceItemSIT) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateSitActualDelivery(formats); err != nil { + res = append(res, err) + } + + if err := m.validateSitCustomerContacted(formats); err != nil { + res = append(res, err) + } + if err := m.validateSitDepartureDate(formats); err != nil { res = append(res, err) } @@ -285,6 +338,10 @@ func (m *UpdateMTOServiceItemSIT) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateSitRequestedDelivery(formats); err != nil { + res = append(res, err) + } + if err := m.validateTimeMilitary1(formats); err != nil { res = append(res, err) } @@ -398,6 +455,32 @@ func (m *UpdateMTOServiceItemSIT) validateReServiceCode(formats strfmt.Registry) return nil } +func (m *UpdateMTOServiceItemSIT) validateSitActualDelivery(formats strfmt.Registry) error { + + if swag.IsZero(m.SitActualDelivery) { // not required + return nil + } + + if err := validate.FormatOf("sitActualDelivery", "body", "date", m.SitActualDelivery.String(), formats); err != nil { + return err + } + + return nil +} + +func (m *UpdateMTOServiceItemSIT) validateSitCustomerContacted(formats strfmt.Registry) error { + + if swag.IsZero(m.SitCustomerContacted) { // not required + return nil + } + + if err := validate.FormatOf("sitCustomerContacted", "body", "date", m.SitCustomerContacted.String(), formats); err != nil { + return err + } + + return nil +} + func (m *UpdateMTOServiceItemSIT) validateSitDepartureDate(formats strfmt.Registry) error { if swag.IsZero(m.SitDepartureDate) { // not required @@ -431,6 +514,19 @@ func (m *UpdateMTOServiceItemSIT) validateSitDestinationFinalAddress(formats str return nil } +func (m *UpdateMTOServiceItemSIT) validateSitRequestedDelivery(formats strfmt.Registry) error { + + if swag.IsZero(m.SitRequestedDelivery) { // not required + return nil + } + + if err := validate.FormatOf("sitRequestedDelivery", "body", "date", m.SitRequestedDelivery.String(), formats); err != nil { + return err + } + + return nil +} + func (m *UpdateMTOServiceItemSIT) validateTimeMilitary1(formats strfmt.Registry) error { if swag.IsZero(m.TimeMilitary1) { // not required diff --git a/pkg/gen/primev2api/embedded_spec.go b/pkg/gen/primev2api/embedded_spec.go index 49a56b44ef3..93cd730dca4 100644 --- a/pkg/gen/primev2api/embedded_spec.go +++ b/pkg/gen/primev2api/embedded_spec.go @@ -639,9 +639,21 @@ func init() { "x-nullable": true, "x-omitempty": false }, + "sitActualDelivery": { + "description": "Date when the customer's goods are delivered.", + "type": "string", + "format": "date", + "x-nullable": true + }, "sitAddressUpdates": { "$ref": "#/definitions/SitAddressUpdates" }, + "sitCustomerContacted": { + "description": "Date when the customer contacted the prime for a delivery out of SIT.", + "type": "string", + "format": "date", + "x-nullable": true + }, "sitDepartureDate": { "description": "Departure date for SIT. This is the end date of the SIT at either origin or destination. This is optional as it can be updated using the UpdateMTOServiceItemSIT modelType at a later date.", "type": "string", @@ -656,6 +668,12 @@ func init() { "type": "string", "format": "date" }, + "sitRequestedDelivery": { + "description": "Date when the customer has requested delivery out of SIT.", + "type": "string", + "format": "date", + "x-nullable": true + }, "timeMilitary1": { "description": "Time of attempted contact corresponding to ` + "`" + `dateOfContact1` + "`" + `, in military format.", "type": "string", @@ -3003,9 +3021,21 @@ func init() { "x-nullable": true, "x-omitempty": false }, + "sitActualDelivery": { + "description": "Date when the customer's goods are delivered.", + "type": "string", + "format": "date", + "x-nullable": true + }, "sitAddressUpdates": { "$ref": "#/definitions/SitAddressUpdates" }, + "sitCustomerContacted": { + "description": "Date when the customer contacted the prime for a delivery out of SIT.", + "type": "string", + "format": "date", + "x-nullable": true + }, "sitDepartureDate": { "description": "Departure date for SIT. This is the end date of the SIT at either origin or destination. This is optional as it can be updated using the UpdateMTOServiceItemSIT modelType at a later date.", "type": "string", @@ -3020,6 +3050,12 @@ func init() { "type": "string", "format": "date" }, + "sitRequestedDelivery": { + "description": "Date when the customer has requested delivery out of SIT.", + "type": "string", + "format": "date", + "x-nullable": true + }, "timeMilitary1": { "description": "Time of attempted contact corresponding to ` + "`" + `dateOfContact1` + "`" + `, in military format.", "type": "string", diff --git a/pkg/gen/primev2messages/m_t_o_service_item_dest_s_i_t.go b/pkg/gen/primev2messages/m_t_o_service_item_dest_s_i_t.go index e703eba55c2..b4b164a4419 100644 --- a/pkg/gen/primev2messages/m_t_o_service_item_dest_s_i_t.go +++ b/pkg/gen/primev2messages/m_t_o_service_item_dest_s_i_t.go @@ -62,9 +62,17 @@ type MTOServiceItemDestSIT struct { // Required: true Reason *string `json:"reason"` + // Date when the customer's goods are delivered. + // Format: date + SitActualDelivery *strfmt.Date `json:"sitActualDelivery,omitempty"` + // sit address updates SitAddressUpdates SitAddressUpdates `json:"sitAddressUpdates,omitempty"` + // Date when the customer contacted the prime for a delivery out of SIT. + // Format: date + SitCustomerContacted *strfmt.Date `json:"sitCustomerContacted,omitempty"` + // Departure date for SIT. This is the end date of the SIT at either origin or destination. This is optional as it can be updated using the UpdateMTOServiceItemSIT modelType at a later date. // Format: date SitDepartureDate *strfmt.Date `json:"sitDepartureDate,omitempty"` @@ -77,6 +85,10 @@ type MTOServiceItemDestSIT struct { // Format: date SitEntryDate *strfmt.Date `json:"sitEntryDate"` + // Date when the customer has requested delivery out of SIT. + // Format: date + SitRequestedDelivery *strfmt.Date `json:"sitRequestedDelivery,omitempty"` + // Time of attempted contact corresponding to `dateOfContact1`, in military format. // Example: 1400Z // Pattern: \d{4}Z @@ -207,9 +219,17 @@ func (m *MTOServiceItemDestSIT) UnmarshalJSON(raw []byte) error { // Required: true Reason *string `json:"reason"` + // Date when the customer's goods are delivered. + // Format: date + SitActualDelivery *strfmt.Date `json:"sitActualDelivery,omitempty"` + // sit address updates SitAddressUpdates SitAddressUpdates `json:"sitAddressUpdates,omitempty"` + // Date when the customer contacted the prime for a delivery out of SIT. + // Format: date + SitCustomerContacted *strfmt.Date `json:"sitCustomerContacted,omitempty"` + // Departure date for SIT. This is the end date of the SIT at either origin or destination. This is optional as it can be updated using the UpdateMTOServiceItemSIT modelType at a later date. // Format: date SitDepartureDate *strfmt.Date `json:"sitDepartureDate,omitempty"` @@ -222,6 +242,10 @@ func (m *MTOServiceItemDestSIT) UnmarshalJSON(raw []byte) error { // Format: date SitEntryDate *strfmt.Date `json:"sitEntryDate"` + // Date when the customer has requested delivery out of SIT. + // Format: date + SitRequestedDelivery *strfmt.Date `json:"sitRequestedDelivery,omitempty"` + // Time of attempted contact corresponding to `dateOfContact1`, in military format. // Example: 1400Z // Pattern: \d{4}Z @@ -297,10 +321,13 @@ func (m *MTOServiceItemDestSIT) UnmarshalJSON(raw []byte) error { result.FirstAvailableDeliveryDate2 = data.FirstAvailableDeliveryDate2 result.ReServiceCode = data.ReServiceCode result.Reason = data.Reason + result.SitActualDelivery = data.SitActualDelivery result.SitAddressUpdates = data.SitAddressUpdates + result.SitCustomerContacted = data.SitCustomerContacted result.SitDepartureDate = data.SitDepartureDate result.SitDestinationFinalAddress = data.SitDestinationFinalAddress result.SitEntryDate = data.SitEntryDate + result.SitRequestedDelivery = data.SitRequestedDelivery result.TimeMilitary1 = data.TimeMilitary1 result.TimeMilitary2 = data.TimeMilitary2 @@ -341,9 +368,17 @@ func (m MTOServiceItemDestSIT) MarshalJSON() ([]byte, error) { // Required: true Reason *string `json:"reason"` + // Date when the customer's goods are delivered. + // Format: date + SitActualDelivery *strfmt.Date `json:"sitActualDelivery,omitempty"` + // sit address updates SitAddressUpdates SitAddressUpdates `json:"sitAddressUpdates,omitempty"` + // Date when the customer contacted the prime for a delivery out of SIT. + // Format: date + SitCustomerContacted *strfmt.Date `json:"sitCustomerContacted,omitempty"` + // Departure date for SIT. This is the end date of the SIT at either origin or destination. This is optional as it can be updated using the UpdateMTOServiceItemSIT modelType at a later date. // Format: date SitDepartureDate *strfmt.Date `json:"sitDepartureDate,omitempty"` @@ -356,6 +391,10 @@ func (m MTOServiceItemDestSIT) MarshalJSON() ([]byte, error) { // Format: date SitEntryDate *strfmt.Date `json:"sitEntryDate"` + // Date when the customer has requested delivery out of SIT. + // Format: date + SitRequestedDelivery *strfmt.Date `json:"sitRequestedDelivery,omitempty"` + // Time of attempted contact corresponding to `dateOfContact1`, in military format. // Example: 1400Z // Pattern: \d{4}Z @@ -379,14 +418,20 @@ func (m MTOServiceItemDestSIT) MarshalJSON() ([]byte, error) { Reason: m.Reason, + SitActualDelivery: m.SitActualDelivery, + SitAddressUpdates: m.SitAddressUpdates, + SitCustomerContacted: m.SitCustomerContacted, + SitDepartureDate: m.SitDepartureDate, SitDestinationFinalAddress: m.SitDestinationFinalAddress, SitEntryDate: m.SitEntryDate, + SitRequestedDelivery: m.SitRequestedDelivery, + TimeMilitary1: m.TimeMilitary1, TimeMilitary2: m.TimeMilitary2, @@ -487,10 +532,18 @@ func (m *MTOServiceItemDestSIT) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateSitActualDelivery(formats); err != nil { + res = append(res, err) + } + if err := m.validateSitAddressUpdates(formats); err != nil { res = append(res, err) } + if err := m.validateSitCustomerContacted(formats); err != nil { + res = append(res, err) + } + if err := m.validateSitDepartureDate(formats); err != nil { res = append(res, err) } @@ -503,6 +556,10 @@ func (m *MTOServiceItemDestSIT) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateSitRequestedDelivery(formats); err != nil { + res = append(res, err) + } + if err := m.validateTimeMilitary1(formats); err != nil { res = append(res, err) } @@ -687,6 +744,19 @@ func (m *MTOServiceItemDestSIT) validateReason(formats strfmt.Registry) error { return nil } +func (m *MTOServiceItemDestSIT) validateSitActualDelivery(formats strfmt.Registry) error { + + if swag.IsZero(m.SitActualDelivery) { // not required + return nil + } + + if err := validate.FormatOf("sitActualDelivery", "body", "date", m.SitActualDelivery.String(), formats); err != nil { + return err + } + + return nil +} + func (m *MTOServiceItemDestSIT) validateSitAddressUpdates(formats strfmt.Registry) error { if swag.IsZero(m.SitAddressUpdates) { // not required @@ -705,6 +775,19 @@ func (m *MTOServiceItemDestSIT) validateSitAddressUpdates(formats strfmt.Registr return nil } +func (m *MTOServiceItemDestSIT) validateSitCustomerContacted(formats strfmt.Registry) error { + + if swag.IsZero(m.SitCustomerContacted) { // not required + return nil + } + + if err := validate.FormatOf("sitCustomerContacted", "body", "date", m.SitCustomerContacted.String(), formats); err != nil { + return err + } + + return nil +} + func (m *MTOServiceItemDestSIT) validateSitDepartureDate(formats strfmt.Registry) error { if swag.IsZero(m.SitDepartureDate) { // not required @@ -751,6 +834,19 @@ func (m *MTOServiceItemDestSIT) validateSitEntryDate(formats strfmt.Registry) er return nil } +func (m *MTOServiceItemDestSIT) validateSitRequestedDelivery(formats strfmt.Registry) error { + + if swag.IsZero(m.SitRequestedDelivery) { // not required + return nil + } + + if err := validate.FormatOf("sitRequestedDelivery", "body", "date", m.SitRequestedDelivery.String(), formats); err != nil { + return err + } + + return nil +} + func (m *MTOServiceItemDestSIT) validateTimeMilitary1(formats strfmt.Registry) error { if swag.IsZero(m.TimeMilitary1) { // not required diff --git a/swagger-def/definitions/prime/MTOServiceItemDestSIT.yaml b/swagger-def/definitions/prime/MTOServiceItemDestSIT.yaml index 61acdfd3150..0f0032b180a 100644 --- a/swagger-def/definitions/prime/MTOServiceItemDestSIT.yaml +++ b/swagger-def/definitions/prime/MTOServiceItemDestSIT.yaml @@ -60,6 +60,21 @@ allOf: x-omitempty: false sitAddressUpdates: $ref: 'SitAddressUpdates.yaml' + sitRequestedDelivery: + format: date + type: string + description: Date when the customer has requested delivery out of SIT. + x-nullable: true + sitActualDelivery: + format: date + type: string + description: Date when the customer's goods are delivered. + x-nullable: true + sitCustomerContacted: + format: date + type: string + description: Date when the customer contacted the prime for a delivery out of SIT. + x-nullable: true required: - reServiceCode - sitEntryDate diff --git a/swagger-def/prime.yaml b/swagger-def/prime.yaml index ce09268b5f7..09f179fc186 100644 --- a/swagger-def/prime.yaml +++ b/swagger-def/prime.yaml @@ -36,7 +36,6 @@ tags: approved service item. sitAddressUpdates with a distance less than or equal to 50 miles will be automatically approved while a distance greater than 50 miles will typically require office user approval. - x-tagGroups: - name: Endpoints tags: @@ -1489,7 +1488,7 @@ definitions: type: array MoveTaskOrder: $ref: 'definitions/prime/MoveTaskOrder.yaml' - MTOServiceItemBasic: # spectral oas2-unused-definition is OK here due to polymorphism + MTOServiceItemBasic: # spectral oas2-unused-definition is OK here due to polymorphism $ref: 'definitions/prime/MTOServiceItemBasic.yaml' MTOServiceItemDestSIT: # spectral oas2-unused-definition is OK here due to polymorphism $ref: 'definitions/prime/MTOServiceItemDestSIT.yaml' @@ -1672,6 +1671,21 @@ definitions: type: string description: Second available date that Prime can deliver SIT service item. x-nullable: true + sitRequestedDelivery: + format: date + type: string + description: Date when the customer has requested delivery out of SIT. + x-nullable: true + sitActualDelivery: + format: date + type: string + description: Date when the customer's goods are delivered. + x-nullable: true + sitCustomerContacted: + format: date + type: string + description: Date when the customer contacted the prime for a delivery out of SIT. + x-nullable: true UpdateMTOShipment: properties: scheduledPickupDate: diff --git a/swagger/prime.yaml b/swagger/prime.yaml index 70208006aed..5fb1f4061cf 100644 --- a/swagger/prime.yaml +++ b/swagger/prime.yaml @@ -1892,6 +1892,23 @@ definitions: x-omitempty: false sitAddressUpdates: $ref: '#/definitions/SitAddressUpdates' + sitRequestedDelivery: + format: date + type: string + description: Date when the customer has requested delivery out of SIT. + x-nullable: true + sitActualDelivery: + format: date + type: string + description: Date when the customer's goods are delivered. + x-nullable: true + sitCustomerContacted: + format: date + type: string + description: >- + Date when the customer contacted the prime for a delivery out of + SIT. + x-nullable: true required: - reServiceCode - sitEntryDate @@ -2226,6 +2243,23 @@ definitions: type: string description: Second available date that Prime can deliver SIT service item. x-nullable: true + sitRequestedDelivery: + format: date + type: string + description: Date when the customer has requested delivery out of SIT. + x-nullable: true + sitActualDelivery: + format: date + type: string + description: Date when the customer's goods are delivered. + x-nullable: true + sitCustomerContacted: + format: date + type: string + description: >- + Date when the customer contacted the prime for a delivery out of + SIT. + x-nullable: true UpdateMTOShipment: properties: scheduledPickupDate: diff --git a/swagger/prime_v2.yaml b/swagger/prime_v2.yaml index edece313a53..6c6ec965520 100644 --- a/swagger/prime_v2.yaml +++ b/swagger/prime_v2.yaml @@ -155,6 +155,23 @@ definitions: x-omitempty: false sitAddressUpdates: $ref: '#/definitions/SitAddressUpdates' + sitRequestedDelivery: + format: date + type: string + description: Date when the customer has requested delivery out of SIT. + x-nullable: true + sitActualDelivery: + format: date + type: string + description: Date when the customer's goods are delivered. + x-nullable: true + sitCustomerContacted: + format: date + type: string + description: >- + Date when the customer contacted the prime for a delivery out of + SIT. + x-nullable: true required: - reServiceCode - sitEntryDate From e149be470cbfb90a5a7385e6a99878925022c695 Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Thu, 24 Aug 2023 16:13:42 +0000 Subject: [PATCH 087/138] Update relevant handler files for marshalling and unmarshalling new fields --- pkg/handlers/primeapi/payloads/model_to_payload.go | 3 +++ pkg/handlers/primeapi/payloads/payload_to_model.go | 3 +++ pkg/handlers/primeapiv2/payloads/model_to_payload.go | 3 +++ pkg/services/mto_service_item/mto_service_item_validators.go | 4 ++++ 4 files changed, 13 insertions(+) diff --git a/pkg/handlers/primeapi/payloads/model_to_payload.go b/pkg/handlers/primeapi/payloads/model_to_payload.go index a43d69887d9..895b3943753 100644 --- a/pkg/handlers/primeapi/payloads/model_to_payload.go +++ b/pkg/handlers/primeapi/payloads/model_to_payload.go @@ -624,6 +624,9 @@ func MTOServiceItem(mtoServiceItem *models.MTOServiceItem) primemessages.MTOServ SitEntryDate: handlers.FmtDatePtr(mtoServiceItem.SITEntryDate), SitDestinationFinalAddress: Address(mtoServiceItem.SITDestinationFinalAddress), SitAddressUpdates: SITAddressUpdates(mtoServiceItem.SITAddressUpdates), + SitCustomerContacted: handlers.FmtDatePtr(mtoServiceItem.SITCustomerContacted), + SitRequestedDelivery: handlers.FmtDatePtr(mtoServiceItem.SITRequestedDelivery), + SitActualDelivery: handlers.FmtDatePtr(mtoServiceItem.SITActualDelivery), } case models.ReServiceCodeDCRT, models.ReServiceCodeDUCRT: diff --git a/pkg/handlers/primeapi/payloads/payload_to_model.go b/pkg/handlers/primeapi/payloads/payload_to_model.go index 0b8b6f1a1d3..cfb930cbf4e 100644 --- a/pkg/handlers/primeapi/payloads/payload_to_model.go +++ b/pkg/handlers/primeapi/payloads/payload_to_model.go @@ -597,6 +597,9 @@ func MTOServiceItemModelFromUpdate(mtoServiceItemID string, mtoServiceItem prime model.CustomerContacts = customerContacts } + model.SITCustomerContacted = handlers.FmtDatePtrToPopPtr(sit.SitCustomerContacted) + model.SITRequestedDelivery = handlers.FmtDatePtrToPopPtr(sit.SitRequestedDelivery) + model.SITActualDelivery = handlers.FmtDatePtrToPopPtr(sit.SitActualDelivery) } if verrs != nil && verrs.HasAny() { diff --git a/pkg/handlers/primeapiv2/payloads/model_to_payload.go b/pkg/handlers/primeapiv2/payloads/model_to_payload.go index c3fbfa23db3..1bccd55bca5 100644 --- a/pkg/handlers/primeapiv2/payloads/model_to_payload.go +++ b/pkg/handlers/primeapiv2/payloads/model_to_payload.go @@ -572,6 +572,9 @@ func MTOServiceItem(mtoServiceItem *models.MTOServiceItem) primev2messages.MTOSe SitEntryDate: handlers.FmtDatePtr(mtoServiceItem.SITEntryDate), SitDestinationFinalAddress: Address(mtoServiceItem.SITDestinationFinalAddress), SitAddressUpdates: SITAddressUpdates(mtoServiceItem.SITAddressUpdates), + SitCustomerContacted: handlers.FmtDatePtr(mtoServiceItem.SITCustomerContacted), + SitRequestedDelivery: handlers.FmtDatePtr(mtoServiceItem.SITRequestedDelivery), + SitActualDelivery: handlers.FmtDatePtr(mtoServiceItem.SITActualDelivery), } case models.ReServiceCodeDCRT, models.ReServiceCodeDUCRT: diff --git a/pkg/services/mto_service_item/mto_service_item_validators.go b/pkg/services/mto_service_item/mto_service_item_validators.go index 1ec24f372e2..efc70ea4836 100644 --- a/pkg/services/mto_service_item/mto_service_item_validators.go +++ b/pkg/services/mto_service_item/mto_service_item_validators.go @@ -299,6 +299,10 @@ func (v *updateMTOServiceItemData) setNewMTOServiceItem() *models.MTOServiceItem newMTOServiceItem.SITDepartureDate = services.SetOptionalDateTimeField( v.updatedServiceItem.SITDepartureDate, newMTOServiceItem.SITDepartureDate) + newMTOServiceItem.SITCustomerContacted = services.SetOptionalDateTimeField(v.updatedServiceItem.SITCustomerContacted, newMTOServiceItem.SITCustomerContacted) + newMTOServiceItem.SITRequestedDelivery = services.SetOptionalDateTimeField(v.updatedServiceItem.SITRequestedDelivery, newMTOServiceItem.SITRequestedDelivery) + newMTOServiceItem.SITActualDelivery = services.SetOptionalDateTimeField(v.updatedServiceItem.SITActualDelivery, newMTOServiceItem.SITActualDelivery) + if v.updatedServiceItem.SITDestinationFinalAddress != nil { newMTOServiceItem.SITDestinationFinalAddress = v.updatedServiceItem.SITDestinationFinalAddress newMTOServiceItem.SITDestinationFinalAddressID = &v.updatedServiceItem.SITDestinationFinalAddress.ID From 6a68a7a2f9b07c604b7a5d07e558dd8234ca50af Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Thu, 24 Aug 2023 16:20:31 +0000 Subject: [PATCH 088/138] Update tests to account for new fields --- pkg/handlers/primeapi/move_task_order_test.go | 18 ++++++++++++------ pkg/handlers/primeapi/mto_service_item_test.go | 8 +++++++- .../primeapi/payloads/payload_to_model_test.go | 7 ++++++- .../primeapiv2/move_task_order_test.go | 18 ++++++++++++------ .../mto_service_item_validators_test.go | 7 +++++++ 5 files changed, 44 insertions(+), 14 deletions(-) diff --git a/pkg/handlers/primeapi/move_task_order_test.go b/pkg/handlers/primeapi/move_task_order_test.go index e0c82edf9c9..2c83fd7dfd8 100644 --- a/pkg/handlers/primeapi/move_task_order_test.go +++ b/pkg/handlers/primeapi/move_task_order_test.go @@ -1131,12 +1131,15 @@ func (suite *HandlerSuite) TestGetMoveTaskOrder() { serviceItem := factory.BuildMTOServiceItem(suite.DB(), []factory.Customization{ { Model: models.MTOServiceItem{ - RejectionReason: models.StringPointer("not applicable"), - MTOShipmentID: &successShipment.ID, - Reason: models.StringPointer("there was a delay in getting the apartment"), - SITEntryDate: &nowDate, - SITDepartureDate: &later, - CustomerContacts: models.MTOServiceItemCustomerContacts{contact1, contact2}, + RejectionReason: models.StringPointer("not applicable"), + MTOShipmentID: &successShipment.ID, + Reason: models.StringPointer("there was a delay in getting the apartment"), + SITEntryDate: &nowDate, + SITDepartureDate: &later, + CustomerContacts: models.MTOServiceItemCustomerContacts{contact1, contact2}, + SITCustomerContacted: &nowDate, + SITRequestedDelivery: &nowDate, + SITActualDelivery: &later, }, }, { @@ -1197,6 +1200,9 @@ func (suite *HandlerSuite) TestGetMoveTaskOrder() { suite.Equal(*serviceItem.Reason, *payload.Reason) suite.Equal(serviceItem.SITEntryDate.Format(time.RFC3339), handlers.FmtDatePtrToPop(payload.SitEntryDate).Format(time.RFC3339)) suite.Equal(serviceItem.SITDepartureDate.Format(time.RFC3339), handlers.FmtDatePtrToPop(payload.SitDepartureDate).Format(time.RFC3339)) + suite.Equal(serviceItem.SITCustomerContacted.Format(time.RFC3339), handlers.FmtDatePtrToPop(payload.SitCustomerContacted).Format(time.RFC3339)) + suite.Equal(serviceItem.SITRequestedDelivery.Format(time.RFC3339), handlers.FmtDatePtrToPop(payload.SitRequestedDelivery).Format(time.RFC3339)) + suite.Equal(serviceItem.SITActualDelivery.Format(time.RFC3339), handlers.FmtDatePtrToPop(payload.SitActualDelivery).Format(time.RFC3339)) suite.Equal(serviceItem.CustomerContacts[0].DateOfContact.Format(time.RFC3339), handlers.FmtDatePtrToPop(payload.DateOfContact1).Format(time.RFC3339)) suite.Equal(serviceItem.CustomerContacts[0].TimeMilitary, *payload.TimeMilitary1) suite.Equal(serviceItem.CustomerContacts[0].FirstAvailableDeliveryDate.Format(time.RFC3339), handlers.FmtDatePtrToPop(payload.FirstAvailableDeliveryDate1).Format(time.RFC3339)) diff --git a/pkg/handlers/primeapi/mto_service_item_test.go b/pkg/handlers/primeapi/mto_service_item_test.go index bf2fe105dd4..ecfccce2e01 100644 --- a/pkg/handlers/primeapi/mto_service_item_test.go +++ b/pkg/handlers/primeapi/mto_service_item_test.go @@ -1344,6 +1344,9 @@ func (suite *HandlerSuite) TestUpdateMTOServiceItemDDDSIT() { DateOfContact1: handlers.FmtDate(time.Date(2020, time.December, 04, 0, 0, 0, 0, time.UTC)), TimeMilitary1: handlers.FmtStringPtrNonEmpty(&milTime), FirstAvailableDeliveryDate1: handlers.FmtDate(time.Date(2020, time.December, 02, 0, 0, 0, 0, time.UTC)), + SitCustomerContacted: handlers.FmtDate(time.Now()), + SitRequestedDelivery: handlers.FmtDate(time.Now().AddDate(0, 0, 3)), + SitActualDelivery: handlers.FmtDate(time.Now().AddDate(0, 0, 4)), } subtestData.reqPayload.SetID(strfmt.UUID(subtestData.dddsit.ID.String())) @@ -1369,7 +1372,7 @@ func (suite *HandlerSuite) TestUpdateMTOServiceItemDDDSIT() { return subtestData } - suite.Run("Successful PATCH - Updated SITDepartureDate and FADD Fields on DDDSIT", func() { + suite.Run("Successful PATCH - Updated SITDepartureDate and FADD Fields and other date fields on DDDSIT", func() { subtestData := makeSubtestData() // Under test: updateMTOServiceItemHandler.Handle function // MTOServiceItemUpdater.Update service object function @@ -1408,6 +1411,9 @@ func (suite *HandlerSuite) TestUpdateMTOServiceItemDDDSIT() { suite.Equal(subtestData.reqPayload.DateOfContact1, respPayload.DateOfContact1) suite.Equal(subtestData.reqPayload.TimeMilitary1, respPayload.TimeMilitary1) suite.Equal(subtestData.reqPayload.FirstAvailableDeliveryDate1, respPayload.FirstAvailableDeliveryDate1) + suite.Equal(*subtestData.reqPayload.SitCustomerContacted, *respPayload.SitCustomerContacted) + suite.Equal(*subtestData.reqPayload.SitRequestedDelivery, *respPayload.SitRequestedDelivery) + suite.Equal(*subtestData.reqPayload.SitActualDelivery, *respPayload.SitActualDelivery) }) suite.Run("Failed PATCH - No DDDSIT found", func() { diff --git a/pkg/handlers/primeapi/payloads/payload_to_model_test.go b/pkg/handlers/primeapi/payloads/payload_to_model_test.go index 870c904ece7..51fc89be90b 100644 --- a/pkg/handlers/primeapi/payloads/payload_to_model_test.go +++ b/pkg/handlers/primeapi/payloads/payload_to_model_test.go @@ -152,6 +152,9 @@ func (suite *PayloadsSuite) TestMTOServiceItemModel() { TimeMilitary2: &destTime, SitDestinationFinalAddress: &sitFinalDestAddress, Reason: &destReason, + SitCustomerContacted: &destDate, + SitRequestedDelivery: &destDate, + SitActualDelivery: &destDate, } destSITServiceItem.SetMoveTaskOrderID(handlers.FmtUUID(moveTaskOrderIDField)) @@ -164,7 +167,9 @@ func (suite *PayloadsSuite) TestMTOServiceItemModel() { suite.Equal(models.ReServiceCodeDDFSIT, returnedModel.ReService.Code) suite.Equal(destPostalCode, returnedModel.SITDestinationFinalAddress.PostalCode) suite.Equal(destStreet, returnedModel.SITDestinationFinalAddress.StreetAddress1) - + suite.Equal(handlers.FmtDatePtrToPop(&destDate), *returnedModel.SITCustomerContacted) + suite.Equal(handlers.FmtDatePtrToPop(&destDate), *returnedModel.SITRequestedDelivery) + suite.Equal(handlers.FmtDatePtrToPop(&destDate), *returnedModel.SITActualDelivery) }) suite.Run("Success - Returns SIT destination service item model without customer contact fields", func() { diff --git a/pkg/handlers/primeapiv2/move_task_order_test.go b/pkg/handlers/primeapiv2/move_task_order_test.go index 94b20dd16fb..254562e312b 100644 --- a/pkg/handlers/primeapiv2/move_task_order_test.go +++ b/pkg/handlers/primeapiv2/move_task_order_test.go @@ -1086,12 +1086,15 @@ func (suite *HandlerSuite) TestGetMoveTaskOrder() { serviceItem := factory.BuildMTOServiceItem(suite.DB(), []factory.Customization{ { Model: models.MTOServiceItem{ - RejectionReason: models.StringPointer("not applicable"), - MTOShipmentID: &successShipment.ID, - Reason: models.StringPointer("there was a delay in getting the apartment"), - SITEntryDate: &nowDate, - SITDepartureDate: &later, - CustomerContacts: models.MTOServiceItemCustomerContacts{contact1, contact2}, + RejectionReason: models.StringPointer("not applicable"), + MTOShipmentID: &successShipment.ID, + Reason: models.StringPointer("there was a delay in getting the apartment"), + SITEntryDate: &nowDate, + SITDepartureDate: &later, + CustomerContacts: models.MTOServiceItemCustomerContacts{contact1, contact2}, + SITCustomerContacted: &nowDate, + SITRequestedDelivery: &nowDate, + SITActualDelivery: &later, }, }, { @@ -1152,6 +1155,9 @@ func (suite *HandlerSuite) TestGetMoveTaskOrder() { suite.Equal(*serviceItem.Reason, *payload.Reason) suite.Equal(serviceItem.SITEntryDate.Format(time.RFC3339), handlers.FmtDatePtrToPop(payload.SitEntryDate).Format(time.RFC3339)) suite.Equal(serviceItem.SITDepartureDate.Format(time.RFC3339), handlers.FmtDatePtrToPop(payload.SitDepartureDate).Format(time.RFC3339)) + suite.Equal(serviceItem.SITCustomerContacted.Format(time.RFC3339), handlers.FmtDatePtrToPop(payload.SitCustomerContacted).Format(time.RFC3339)) + suite.Equal(serviceItem.SITRequestedDelivery.Format(time.RFC3339), handlers.FmtDatePtrToPop(payload.SitRequestedDelivery).Format(time.RFC3339)) + suite.Equal(serviceItem.SITActualDelivery.Format(time.RFC3339), handlers.FmtDatePtrToPop(payload.SitActualDelivery).Format(time.RFC3339)) suite.Equal(serviceItem.CustomerContacts[0].DateOfContact.Format(time.RFC3339), handlers.FmtDatePtrToPop(payload.DateOfContact1).Format(time.RFC3339)) suite.Equal(serviceItem.CustomerContacts[0].TimeMilitary, *payload.TimeMilitary1) suite.Equal(serviceItem.CustomerContacts[0].FirstAvailableDeliveryDate.Format(time.RFC3339), handlers.FmtDatePtrToPop(payload.FirstAvailableDeliveryDate1).Format(time.RFC3339)) diff --git a/pkg/services/mto_service_item/mto_service_item_validators_test.go b/pkg/services/mto_service_item/mto_service_item_validators_test.go index 4c43b9e1fb0..a1bb6dfb987 100644 --- a/pkg/services/mto_service_item/mto_service_item_validators_test.go +++ b/pkg/services/mto_service_item/mto_service_item_validators_test.go @@ -20,6 +20,7 @@ func (suite *MTOServiceItemServiceSuite) TestUpdateMTOServiceItemData() { // Set up the data needed for updateMTOServiceItemData obj checker := movetaskorder.NewMoveTaskOrderChecker() now := time.Now() + later := now.AddDate(0, 0, 3) setupTestData := func() (models.MTOServiceItem, models.MTOServiceItem) { // Create a service item to serve as the old object oldServiceItem := testdatagen.MakeDefaultMTOServiceItem(suite.DB()) @@ -355,6 +356,9 @@ func (suite *MTOServiceItemServiceSuite) TestUpdateMTOServiceItemData() { FirstAvailableDeliveryDate: time.Now().AddDate(0, 0, 5), }, } + editServiceItem.SITCustomerContacted = &now + editServiceItem.SITRequestedDelivery = &now + editServiceItem.SITActualDelivery = &later serviceItemData := updateMTOServiceItemData{ updatedServiceItem: editServiceItem, oldServiceItem: oldServiceItem, @@ -367,6 +371,9 @@ func (suite *MTOServiceItemServiceSuite) TestUpdateMTOServiceItemData() { suite.Nil(newServiceItem.ApprovedAt) suite.Equal(newServiceItem.SITEntryDate, editServiceItem.SITEntryDate) suite.Equal(newServiceItem.Description, editServiceItem.Description) + suite.Equal(*newServiceItem.SITCustomerContacted, *editServiceItem.SITCustomerContacted) + suite.Equal(*newServiceItem.SITRequestedDelivery, *editServiceItem.SITRequestedDelivery) + suite.Equal(*newServiceItem.SITActualDelivery, *editServiceItem.SITActualDelivery) suite.NotEqual(newServiceItem.Description, oldServiceItem.Description) suite.NotEqual(newServiceItem.Description, serviceItemData.oldServiceItem.Description) suite.NotEqual(newServiceItem.CustomerContacts[0].TimeMilitary, serviceItemData.oldServiceItem.CustomerContacts[0].TimeMilitary) From 1b26db1daf179f12caf7452ecefc9c6cff1265b5 Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Thu, 24 Aug 2023 16:44:43 +0000 Subject: [PATCH 089/138] Remove instances of new actual date field since it is no longer required --- ...fields_for_sit_to_mto_service_items.up.sql | 2 -- pkg/gen/primeapi/embedded_spec.go | 24 -------------- .../m_t_o_service_item_dest_s_i_t.go | 32 ------------------- .../update_m_t_o_service_item_s_i_t.go | 32 ------------------- pkg/gen/primev2api/embedded_spec.go | 12 ------- .../m_t_o_service_item_dest_s_i_t.go | 32 ------------------- pkg/handlers/primeapi/move_task_order_test.go | 2 -- .../primeapi/mto_service_item_test.go | 2 -- .../primeapi/payloads/model_to_payload.go | 1 - .../primeapi/payloads/payload_to_model.go | 1 - .../payloads/payload_to_model_test.go | 2 -- .../primeapiv2/move_task_order_test.go | 4 +-- .../primeapiv2/payloads/model_to_payload.go | 1 - pkg/models/mto_service_items.go | 1 - .../mto_service_item_validators.go | 1 - .../mto_service_item_validators_test.go | 4 +-- .../prime/MTOServiceItemDestSIT.yaml | 5 --- swagger-def/prime.yaml | 5 --- swagger/prime.yaml | 10 ------ swagger/prime_v2.yaml | 5 --- 20 files changed, 2 insertions(+), 176 deletions(-) diff --git a/migrations/app/schema/20230822201206_add_fields_for_sit_to_mto_service_items.up.sql b/migrations/app/schema/20230822201206_add_fields_for_sit_to_mto_service_items.up.sql index d33c96d8f58..fe154bf1db5 100644 --- a/migrations/app/schema/20230822201206_add_fields_for_sit_to_mto_service_items.up.sql +++ b/migrations/app/schema/20230822201206_add_fields_for_sit_to_mto_service_items.up.sql @@ -1,9 +1,7 @@ ALTER TABLE mto_service_items ADD COLUMN sit_customer_contacted date, ADD COLUMN sit_requested_delivery date, - ADD COLUMN sit_actual_delivery date; -- Comment On Column COMMENT ON COLUMN mto_service_items.sit_customer_contacted IS 'The date when the customer contacted the prime for a delivery out of SIT'; COMMENT ON COLUMN mto_service_items.sit_requested_delivery IS 'The date when the customer has requested delivery out of SIT'; -COMMENT ON COLUMN mto_service_items.sit_actual_delivery IS 'The date when the customer''s goods are delivered'; diff --git a/pkg/gen/primeapi/embedded_spec.go b/pkg/gen/primeapi/embedded_spec.go index 7241e60e663..855e6b4e702 100644 --- a/pkg/gen/primeapi/embedded_spec.go +++ b/pkg/gen/primeapi/embedded_spec.go @@ -2311,12 +2311,6 @@ func init() { "x-nullable": true, "x-omitempty": false }, - "sitActualDelivery": { - "description": "Date when the customer's goods are delivered.", - "type": "string", - "format": "date", - "x-nullable": true - }, "sitAddressUpdates": { "$ref": "#/definitions/SitAddressUpdates" }, @@ -4069,12 +4063,6 @@ func init() { "DOPSIT" ] }, - "sitActualDelivery": { - "description": "Date when the customer's goods are delivered.", - "type": "string", - "format": "date", - "x-nullable": true - }, "sitCustomerContacted": { "description": "Date when the customer contacted the prime for a delivery out of SIT.", "type": "string", @@ -7285,12 +7273,6 @@ func init() { "x-nullable": true, "x-omitempty": false }, - "sitActualDelivery": { - "description": "Date when the customer's goods are delivered.", - "type": "string", - "format": "date", - "x-nullable": true - }, "sitAddressUpdates": { "$ref": "#/definitions/SitAddressUpdates" }, @@ -9046,12 +9028,6 @@ func init() { "DOPSIT" ] }, - "sitActualDelivery": { - "description": "Date when the customer's goods are delivered.", - "type": "string", - "format": "date", - "x-nullable": true - }, "sitCustomerContacted": { "description": "Date when the customer contacted the prime for a delivery out of SIT.", "type": "string", diff --git a/pkg/gen/primemessages/m_t_o_service_item_dest_s_i_t.go b/pkg/gen/primemessages/m_t_o_service_item_dest_s_i_t.go index 11b6936fb11..b62c90c425c 100644 --- a/pkg/gen/primemessages/m_t_o_service_item_dest_s_i_t.go +++ b/pkg/gen/primemessages/m_t_o_service_item_dest_s_i_t.go @@ -62,10 +62,6 @@ type MTOServiceItemDestSIT struct { // Required: true Reason *string `json:"reason"` - // Date when the customer's goods are delivered. - // Format: date - SitActualDelivery *strfmt.Date `json:"sitActualDelivery,omitempty"` - // sit address updates SitAddressUpdates SitAddressUpdates `json:"sitAddressUpdates,omitempty"` @@ -219,10 +215,6 @@ func (m *MTOServiceItemDestSIT) UnmarshalJSON(raw []byte) error { // Required: true Reason *string `json:"reason"` - // Date when the customer's goods are delivered. - // Format: date - SitActualDelivery *strfmt.Date `json:"sitActualDelivery,omitempty"` - // sit address updates SitAddressUpdates SitAddressUpdates `json:"sitAddressUpdates,omitempty"` @@ -321,7 +313,6 @@ func (m *MTOServiceItemDestSIT) UnmarshalJSON(raw []byte) error { result.FirstAvailableDeliveryDate2 = data.FirstAvailableDeliveryDate2 result.ReServiceCode = data.ReServiceCode result.Reason = data.Reason - result.SitActualDelivery = data.SitActualDelivery result.SitAddressUpdates = data.SitAddressUpdates result.SitCustomerContacted = data.SitCustomerContacted result.SitDepartureDate = data.SitDepartureDate @@ -368,10 +359,6 @@ func (m MTOServiceItemDestSIT) MarshalJSON() ([]byte, error) { // Required: true Reason *string `json:"reason"` - // Date when the customer's goods are delivered. - // Format: date - SitActualDelivery *strfmt.Date `json:"sitActualDelivery,omitempty"` - // sit address updates SitAddressUpdates SitAddressUpdates `json:"sitAddressUpdates,omitempty"` @@ -418,8 +405,6 @@ func (m MTOServiceItemDestSIT) MarshalJSON() ([]byte, error) { Reason: m.Reason, - SitActualDelivery: m.SitActualDelivery, - SitAddressUpdates: m.SitAddressUpdates, SitCustomerContacted: m.SitCustomerContacted, @@ -532,10 +517,6 @@ func (m *MTOServiceItemDestSIT) Validate(formats strfmt.Registry) error { res = append(res, err) } - if err := m.validateSitActualDelivery(formats); err != nil { - res = append(res, err) - } - if err := m.validateSitAddressUpdates(formats); err != nil { res = append(res, err) } @@ -744,19 +725,6 @@ func (m *MTOServiceItemDestSIT) validateReason(formats strfmt.Registry) error { return nil } -func (m *MTOServiceItemDestSIT) validateSitActualDelivery(formats strfmt.Registry) error { - - if swag.IsZero(m.SitActualDelivery) { // not required - return nil - } - - if err := validate.FormatOf("sitActualDelivery", "body", "date", m.SitActualDelivery.String(), formats); err != nil { - return err - } - - return nil -} - func (m *MTOServiceItemDestSIT) validateSitAddressUpdates(formats strfmt.Registry) error { if swag.IsZero(m.SitAddressUpdates) { // not required diff --git a/pkg/gen/primemessages/update_m_t_o_service_item_s_i_t.go b/pkg/gen/primemessages/update_m_t_o_service_item_s_i_t.go index 706865168e9..5b2593c6a57 100644 --- a/pkg/gen/primemessages/update_m_t_o_service_item_s_i_t.go +++ b/pkg/gen/primemessages/update_m_t_o_service_item_s_i_t.go @@ -42,10 +42,6 @@ type UpdateMTOServiceItemSIT struct { // Enum: [DDDSIT DOPSIT] ReServiceCode string `json:"reServiceCode,omitempty"` - // Date when the customer's goods are delivered. - // Format: date - SitActualDelivery *strfmt.Date `json:"sitActualDelivery,omitempty"` - // Date when the customer contacted the prime for a delivery out of SIT. // Format: date SitCustomerContacted *strfmt.Date `json:"sitCustomerContacted,omitempty"` @@ -115,10 +111,6 @@ func (m *UpdateMTOServiceItemSIT) UnmarshalJSON(raw []byte) error { // Enum: [DDDSIT DOPSIT] ReServiceCode string `json:"reServiceCode,omitempty"` - // Date when the customer's goods are delivered. - // Format: date - SitActualDelivery *strfmt.Date `json:"sitActualDelivery,omitempty"` - // Date when the customer contacted the prime for a delivery out of SIT. // Format: date SitCustomerContacted *strfmt.Date `json:"sitCustomerContacted,omitempty"` @@ -181,7 +173,6 @@ func (m *UpdateMTOServiceItemSIT) UnmarshalJSON(raw []byte) error { result.FirstAvailableDeliveryDate1 = data.FirstAvailableDeliveryDate1 result.FirstAvailableDeliveryDate2 = data.FirstAvailableDeliveryDate2 result.ReServiceCode = data.ReServiceCode - result.SitActualDelivery = data.SitActualDelivery result.SitCustomerContacted = data.SitCustomerContacted result.SitDepartureDate = data.SitDepartureDate result.SitDestinationFinalAddress = data.SitDestinationFinalAddress @@ -220,10 +211,6 @@ func (m UpdateMTOServiceItemSIT) MarshalJSON() ([]byte, error) { // Enum: [DDDSIT DOPSIT] ReServiceCode string `json:"reServiceCode,omitempty"` - // Date when the customer's goods are delivered. - // Format: date - SitActualDelivery *strfmt.Date `json:"sitActualDelivery,omitempty"` - // Date when the customer contacted the prime for a delivery out of SIT. // Format: date SitCustomerContacted *strfmt.Date `json:"sitCustomerContacted,omitempty"` @@ -260,8 +247,6 @@ func (m UpdateMTOServiceItemSIT) MarshalJSON() ([]byte, error) { ReServiceCode: m.ReServiceCode, - SitActualDelivery: m.SitActualDelivery, - SitCustomerContacted: m.SitCustomerContacted, SitDepartureDate: m.SitDepartureDate, @@ -322,10 +307,6 @@ func (m *UpdateMTOServiceItemSIT) Validate(formats strfmt.Registry) error { res = append(res, err) } - if err := m.validateSitActualDelivery(formats); err != nil { - res = append(res, err) - } - if err := m.validateSitCustomerContacted(formats); err != nil { res = append(res, err) } @@ -455,19 +436,6 @@ func (m *UpdateMTOServiceItemSIT) validateReServiceCode(formats strfmt.Registry) return nil } -func (m *UpdateMTOServiceItemSIT) validateSitActualDelivery(formats strfmt.Registry) error { - - if swag.IsZero(m.SitActualDelivery) { // not required - return nil - } - - if err := validate.FormatOf("sitActualDelivery", "body", "date", m.SitActualDelivery.String(), formats); err != nil { - return err - } - - return nil -} - func (m *UpdateMTOServiceItemSIT) validateSitCustomerContacted(formats strfmt.Registry) error { if swag.IsZero(m.SitCustomerContacted) { // not required diff --git a/pkg/gen/primev2api/embedded_spec.go b/pkg/gen/primev2api/embedded_spec.go index 93cd730dca4..031ee49b4b8 100644 --- a/pkg/gen/primev2api/embedded_spec.go +++ b/pkg/gen/primev2api/embedded_spec.go @@ -639,12 +639,6 @@ func init() { "x-nullable": true, "x-omitempty": false }, - "sitActualDelivery": { - "description": "Date when the customer's goods are delivered.", - "type": "string", - "format": "date", - "x-nullable": true - }, "sitAddressUpdates": { "$ref": "#/definitions/SitAddressUpdates" }, @@ -3021,12 +3015,6 @@ func init() { "x-nullable": true, "x-omitempty": false }, - "sitActualDelivery": { - "description": "Date when the customer's goods are delivered.", - "type": "string", - "format": "date", - "x-nullable": true - }, "sitAddressUpdates": { "$ref": "#/definitions/SitAddressUpdates" }, diff --git a/pkg/gen/primev2messages/m_t_o_service_item_dest_s_i_t.go b/pkg/gen/primev2messages/m_t_o_service_item_dest_s_i_t.go index b4b164a4419..8c0302f30e3 100644 --- a/pkg/gen/primev2messages/m_t_o_service_item_dest_s_i_t.go +++ b/pkg/gen/primev2messages/m_t_o_service_item_dest_s_i_t.go @@ -62,10 +62,6 @@ type MTOServiceItemDestSIT struct { // Required: true Reason *string `json:"reason"` - // Date when the customer's goods are delivered. - // Format: date - SitActualDelivery *strfmt.Date `json:"sitActualDelivery,omitempty"` - // sit address updates SitAddressUpdates SitAddressUpdates `json:"sitAddressUpdates,omitempty"` @@ -219,10 +215,6 @@ func (m *MTOServiceItemDestSIT) UnmarshalJSON(raw []byte) error { // Required: true Reason *string `json:"reason"` - // Date when the customer's goods are delivered. - // Format: date - SitActualDelivery *strfmt.Date `json:"sitActualDelivery,omitempty"` - // sit address updates SitAddressUpdates SitAddressUpdates `json:"sitAddressUpdates,omitempty"` @@ -321,7 +313,6 @@ func (m *MTOServiceItemDestSIT) UnmarshalJSON(raw []byte) error { result.FirstAvailableDeliveryDate2 = data.FirstAvailableDeliveryDate2 result.ReServiceCode = data.ReServiceCode result.Reason = data.Reason - result.SitActualDelivery = data.SitActualDelivery result.SitAddressUpdates = data.SitAddressUpdates result.SitCustomerContacted = data.SitCustomerContacted result.SitDepartureDate = data.SitDepartureDate @@ -368,10 +359,6 @@ func (m MTOServiceItemDestSIT) MarshalJSON() ([]byte, error) { // Required: true Reason *string `json:"reason"` - // Date when the customer's goods are delivered. - // Format: date - SitActualDelivery *strfmt.Date `json:"sitActualDelivery,omitempty"` - // sit address updates SitAddressUpdates SitAddressUpdates `json:"sitAddressUpdates,omitempty"` @@ -418,8 +405,6 @@ func (m MTOServiceItemDestSIT) MarshalJSON() ([]byte, error) { Reason: m.Reason, - SitActualDelivery: m.SitActualDelivery, - SitAddressUpdates: m.SitAddressUpdates, SitCustomerContacted: m.SitCustomerContacted, @@ -532,10 +517,6 @@ func (m *MTOServiceItemDestSIT) Validate(formats strfmt.Registry) error { res = append(res, err) } - if err := m.validateSitActualDelivery(formats); err != nil { - res = append(res, err) - } - if err := m.validateSitAddressUpdates(formats); err != nil { res = append(res, err) } @@ -744,19 +725,6 @@ func (m *MTOServiceItemDestSIT) validateReason(formats strfmt.Registry) error { return nil } -func (m *MTOServiceItemDestSIT) validateSitActualDelivery(formats strfmt.Registry) error { - - if swag.IsZero(m.SitActualDelivery) { // not required - return nil - } - - if err := validate.FormatOf("sitActualDelivery", "body", "date", m.SitActualDelivery.String(), formats); err != nil { - return err - } - - return nil -} - func (m *MTOServiceItemDestSIT) validateSitAddressUpdates(formats strfmt.Registry) error { if swag.IsZero(m.SitAddressUpdates) { // not required diff --git a/pkg/handlers/primeapi/move_task_order_test.go b/pkg/handlers/primeapi/move_task_order_test.go index 2c83fd7dfd8..a7571170800 100644 --- a/pkg/handlers/primeapi/move_task_order_test.go +++ b/pkg/handlers/primeapi/move_task_order_test.go @@ -1139,7 +1139,6 @@ func (suite *HandlerSuite) TestGetMoveTaskOrder() { CustomerContacts: models.MTOServiceItemCustomerContacts{contact1, contact2}, SITCustomerContacted: &nowDate, SITRequestedDelivery: &nowDate, - SITActualDelivery: &later, }, }, { @@ -1202,7 +1201,6 @@ func (suite *HandlerSuite) TestGetMoveTaskOrder() { suite.Equal(serviceItem.SITDepartureDate.Format(time.RFC3339), handlers.FmtDatePtrToPop(payload.SitDepartureDate).Format(time.RFC3339)) suite.Equal(serviceItem.SITCustomerContacted.Format(time.RFC3339), handlers.FmtDatePtrToPop(payload.SitCustomerContacted).Format(time.RFC3339)) suite.Equal(serviceItem.SITRequestedDelivery.Format(time.RFC3339), handlers.FmtDatePtrToPop(payload.SitRequestedDelivery).Format(time.RFC3339)) - suite.Equal(serviceItem.SITActualDelivery.Format(time.RFC3339), handlers.FmtDatePtrToPop(payload.SitActualDelivery).Format(time.RFC3339)) suite.Equal(serviceItem.CustomerContacts[0].DateOfContact.Format(time.RFC3339), handlers.FmtDatePtrToPop(payload.DateOfContact1).Format(time.RFC3339)) suite.Equal(serviceItem.CustomerContacts[0].TimeMilitary, *payload.TimeMilitary1) suite.Equal(serviceItem.CustomerContacts[0].FirstAvailableDeliveryDate.Format(time.RFC3339), handlers.FmtDatePtrToPop(payload.FirstAvailableDeliveryDate1).Format(time.RFC3339)) diff --git a/pkg/handlers/primeapi/mto_service_item_test.go b/pkg/handlers/primeapi/mto_service_item_test.go index ecfccce2e01..9283b27c9e5 100644 --- a/pkg/handlers/primeapi/mto_service_item_test.go +++ b/pkg/handlers/primeapi/mto_service_item_test.go @@ -1346,7 +1346,6 @@ func (suite *HandlerSuite) TestUpdateMTOServiceItemDDDSIT() { FirstAvailableDeliveryDate1: handlers.FmtDate(time.Date(2020, time.December, 02, 0, 0, 0, 0, time.UTC)), SitCustomerContacted: handlers.FmtDate(time.Now()), SitRequestedDelivery: handlers.FmtDate(time.Now().AddDate(0, 0, 3)), - SitActualDelivery: handlers.FmtDate(time.Now().AddDate(0, 0, 4)), } subtestData.reqPayload.SetID(strfmt.UUID(subtestData.dddsit.ID.String())) @@ -1413,7 +1412,6 @@ func (suite *HandlerSuite) TestUpdateMTOServiceItemDDDSIT() { suite.Equal(subtestData.reqPayload.FirstAvailableDeliveryDate1, respPayload.FirstAvailableDeliveryDate1) suite.Equal(*subtestData.reqPayload.SitCustomerContacted, *respPayload.SitCustomerContacted) suite.Equal(*subtestData.reqPayload.SitRequestedDelivery, *respPayload.SitRequestedDelivery) - suite.Equal(*subtestData.reqPayload.SitActualDelivery, *respPayload.SitActualDelivery) }) suite.Run("Failed PATCH - No DDDSIT found", func() { diff --git a/pkg/handlers/primeapi/payloads/model_to_payload.go b/pkg/handlers/primeapi/payloads/model_to_payload.go index 895b3943753..3e8fc0adec9 100644 --- a/pkg/handlers/primeapi/payloads/model_to_payload.go +++ b/pkg/handlers/primeapi/payloads/model_to_payload.go @@ -626,7 +626,6 @@ func MTOServiceItem(mtoServiceItem *models.MTOServiceItem) primemessages.MTOServ SitAddressUpdates: SITAddressUpdates(mtoServiceItem.SITAddressUpdates), SitCustomerContacted: handlers.FmtDatePtr(mtoServiceItem.SITCustomerContacted), SitRequestedDelivery: handlers.FmtDatePtr(mtoServiceItem.SITRequestedDelivery), - SitActualDelivery: handlers.FmtDatePtr(mtoServiceItem.SITActualDelivery), } case models.ReServiceCodeDCRT, models.ReServiceCodeDUCRT: diff --git a/pkg/handlers/primeapi/payloads/payload_to_model.go b/pkg/handlers/primeapi/payloads/payload_to_model.go index cfb930cbf4e..9a3e53fccf8 100644 --- a/pkg/handlers/primeapi/payloads/payload_to_model.go +++ b/pkg/handlers/primeapi/payloads/payload_to_model.go @@ -599,7 +599,6 @@ func MTOServiceItemModelFromUpdate(mtoServiceItemID string, mtoServiceItem prime model.SITCustomerContacted = handlers.FmtDatePtrToPopPtr(sit.SitCustomerContacted) model.SITRequestedDelivery = handlers.FmtDatePtrToPopPtr(sit.SitRequestedDelivery) - model.SITActualDelivery = handlers.FmtDatePtrToPopPtr(sit.SitActualDelivery) } if verrs != nil && verrs.HasAny() { diff --git a/pkg/handlers/primeapi/payloads/payload_to_model_test.go b/pkg/handlers/primeapi/payloads/payload_to_model_test.go index 51fc89be90b..62293593c0d 100644 --- a/pkg/handlers/primeapi/payloads/payload_to_model_test.go +++ b/pkg/handlers/primeapi/payloads/payload_to_model_test.go @@ -154,7 +154,6 @@ func (suite *PayloadsSuite) TestMTOServiceItemModel() { Reason: &destReason, SitCustomerContacted: &destDate, SitRequestedDelivery: &destDate, - SitActualDelivery: &destDate, } destSITServiceItem.SetMoveTaskOrderID(handlers.FmtUUID(moveTaskOrderIDField)) @@ -169,7 +168,6 @@ func (suite *PayloadsSuite) TestMTOServiceItemModel() { suite.Equal(destStreet, returnedModel.SITDestinationFinalAddress.StreetAddress1) suite.Equal(handlers.FmtDatePtrToPop(&destDate), *returnedModel.SITCustomerContacted) suite.Equal(handlers.FmtDatePtrToPop(&destDate), *returnedModel.SITRequestedDelivery) - suite.Equal(handlers.FmtDatePtrToPop(&destDate), *returnedModel.SITActualDelivery) }) suite.Run("Success - Returns SIT destination service item model without customer contact fields", func() { diff --git a/pkg/handlers/primeapiv2/move_task_order_test.go b/pkg/handlers/primeapiv2/move_task_order_test.go index 254562e312b..69df49410a9 100644 --- a/pkg/handlers/primeapiv2/move_task_order_test.go +++ b/pkg/handlers/primeapiv2/move_task_order_test.go @@ -1093,8 +1093,7 @@ func (suite *HandlerSuite) TestGetMoveTaskOrder() { SITDepartureDate: &later, CustomerContacts: models.MTOServiceItemCustomerContacts{contact1, contact2}, SITCustomerContacted: &nowDate, - SITRequestedDelivery: &nowDate, - SITActualDelivery: &later, + SITRequestedDelivery: &later, }, }, { @@ -1157,7 +1156,6 @@ func (suite *HandlerSuite) TestGetMoveTaskOrder() { suite.Equal(serviceItem.SITDepartureDate.Format(time.RFC3339), handlers.FmtDatePtrToPop(payload.SitDepartureDate).Format(time.RFC3339)) suite.Equal(serviceItem.SITCustomerContacted.Format(time.RFC3339), handlers.FmtDatePtrToPop(payload.SitCustomerContacted).Format(time.RFC3339)) suite.Equal(serviceItem.SITRequestedDelivery.Format(time.RFC3339), handlers.FmtDatePtrToPop(payload.SitRequestedDelivery).Format(time.RFC3339)) - suite.Equal(serviceItem.SITActualDelivery.Format(time.RFC3339), handlers.FmtDatePtrToPop(payload.SitActualDelivery).Format(time.RFC3339)) suite.Equal(serviceItem.CustomerContacts[0].DateOfContact.Format(time.RFC3339), handlers.FmtDatePtrToPop(payload.DateOfContact1).Format(time.RFC3339)) suite.Equal(serviceItem.CustomerContacts[0].TimeMilitary, *payload.TimeMilitary1) suite.Equal(serviceItem.CustomerContacts[0].FirstAvailableDeliveryDate.Format(time.RFC3339), handlers.FmtDatePtrToPop(payload.FirstAvailableDeliveryDate1).Format(time.RFC3339)) diff --git a/pkg/handlers/primeapiv2/payloads/model_to_payload.go b/pkg/handlers/primeapiv2/payloads/model_to_payload.go index 1bccd55bca5..9428f84e01b 100644 --- a/pkg/handlers/primeapiv2/payloads/model_to_payload.go +++ b/pkg/handlers/primeapiv2/payloads/model_to_payload.go @@ -574,7 +574,6 @@ func MTOServiceItem(mtoServiceItem *models.MTOServiceItem) primev2messages.MTOSe SitAddressUpdates: SITAddressUpdates(mtoServiceItem.SITAddressUpdates), SitCustomerContacted: handlers.FmtDatePtr(mtoServiceItem.SITCustomerContacted), SitRequestedDelivery: handlers.FmtDatePtr(mtoServiceItem.SITRequestedDelivery), - SitActualDelivery: handlers.FmtDatePtr(mtoServiceItem.SITActualDelivery), } case models.ReServiceCodeDCRT, models.ReServiceCodeDUCRT: diff --git a/pkg/models/mto_service_items.go b/pkg/models/mto_service_items.go index 4b8753617d2..0e30e428cdb 100644 --- a/pkg/models/mto_service_items.go +++ b/pkg/models/mto_service_items.go @@ -42,7 +42,6 @@ type MTOServiceItem struct { SITDepartureDate *time.Time `db:"sit_departure_date"` SITCustomerContacted *time.Time `db:"sit_customer_contacted"` SITRequestedDelivery *time.Time `db:"sit_requested_delivery"` - SITActualDelivery *time.Time `db:"sit_actual_delivery"` SITOriginHHGOriginalAddress *Address `belongs_to:"addresses" fk_id:"sit_origin_hhg_original_address_id"` SITOriginHHGOriginalAddressID *uuid.UUID `db:"sit_origin_hhg_original_address_id"` SITOriginHHGActualAddress *Address `belongs_to:"addresses" fk_id:"sit_origin_hhg_actual_address_id"` diff --git a/pkg/services/mto_service_item/mto_service_item_validators.go b/pkg/services/mto_service_item/mto_service_item_validators.go index efc70ea4836..ec88984fe09 100644 --- a/pkg/services/mto_service_item/mto_service_item_validators.go +++ b/pkg/services/mto_service_item/mto_service_item_validators.go @@ -301,7 +301,6 @@ func (v *updateMTOServiceItemData) setNewMTOServiceItem() *models.MTOServiceItem newMTOServiceItem.SITCustomerContacted = services.SetOptionalDateTimeField(v.updatedServiceItem.SITCustomerContacted, newMTOServiceItem.SITCustomerContacted) newMTOServiceItem.SITRequestedDelivery = services.SetOptionalDateTimeField(v.updatedServiceItem.SITRequestedDelivery, newMTOServiceItem.SITRequestedDelivery) - newMTOServiceItem.SITActualDelivery = services.SetOptionalDateTimeField(v.updatedServiceItem.SITActualDelivery, newMTOServiceItem.SITActualDelivery) if v.updatedServiceItem.SITDestinationFinalAddress != nil { newMTOServiceItem.SITDestinationFinalAddress = v.updatedServiceItem.SITDestinationFinalAddress diff --git a/pkg/services/mto_service_item/mto_service_item_validators_test.go b/pkg/services/mto_service_item/mto_service_item_validators_test.go index a1bb6dfb987..23bdbffd4f9 100644 --- a/pkg/services/mto_service_item/mto_service_item_validators_test.go +++ b/pkg/services/mto_service_item/mto_service_item_validators_test.go @@ -357,8 +357,7 @@ func (suite *MTOServiceItemServiceSuite) TestUpdateMTOServiceItemData() { }, } editServiceItem.SITCustomerContacted = &now - editServiceItem.SITRequestedDelivery = &now - editServiceItem.SITActualDelivery = &later + editServiceItem.SITRequestedDelivery = &later serviceItemData := updateMTOServiceItemData{ updatedServiceItem: editServiceItem, oldServiceItem: oldServiceItem, @@ -373,7 +372,6 @@ func (suite *MTOServiceItemServiceSuite) TestUpdateMTOServiceItemData() { suite.Equal(newServiceItem.Description, editServiceItem.Description) suite.Equal(*newServiceItem.SITCustomerContacted, *editServiceItem.SITCustomerContacted) suite.Equal(*newServiceItem.SITRequestedDelivery, *editServiceItem.SITRequestedDelivery) - suite.Equal(*newServiceItem.SITActualDelivery, *editServiceItem.SITActualDelivery) suite.NotEqual(newServiceItem.Description, oldServiceItem.Description) suite.NotEqual(newServiceItem.Description, serviceItemData.oldServiceItem.Description) suite.NotEqual(newServiceItem.CustomerContacts[0].TimeMilitary, serviceItemData.oldServiceItem.CustomerContacts[0].TimeMilitary) diff --git a/swagger-def/definitions/prime/MTOServiceItemDestSIT.yaml b/swagger-def/definitions/prime/MTOServiceItemDestSIT.yaml index 0f0032b180a..388e9a5bb7f 100644 --- a/swagger-def/definitions/prime/MTOServiceItemDestSIT.yaml +++ b/swagger-def/definitions/prime/MTOServiceItemDestSIT.yaml @@ -65,11 +65,6 @@ allOf: type: string description: Date when the customer has requested delivery out of SIT. x-nullable: true - sitActualDelivery: - format: date - type: string - description: Date when the customer's goods are delivered. - x-nullable: true sitCustomerContacted: format: date type: string diff --git a/swagger-def/prime.yaml b/swagger-def/prime.yaml index 09f179fc186..95fcb934b58 100644 --- a/swagger-def/prime.yaml +++ b/swagger-def/prime.yaml @@ -1676,11 +1676,6 @@ definitions: type: string description: Date when the customer has requested delivery out of SIT. x-nullable: true - sitActualDelivery: - format: date - type: string - description: Date when the customer's goods are delivered. - x-nullable: true sitCustomerContacted: format: date type: string diff --git a/swagger/prime.yaml b/swagger/prime.yaml index 5fb1f4061cf..fd8c78b4b9f 100644 --- a/swagger/prime.yaml +++ b/swagger/prime.yaml @@ -1897,11 +1897,6 @@ definitions: type: string description: Date when the customer has requested delivery out of SIT. x-nullable: true - sitActualDelivery: - format: date - type: string - description: Date when the customer's goods are delivered. - x-nullable: true sitCustomerContacted: format: date type: string @@ -2248,11 +2243,6 @@ definitions: type: string description: Date when the customer has requested delivery out of SIT. x-nullable: true - sitActualDelivery: - format: date - type: string - description: Date when the customer's goods are delivered. - x-nullable: true sitCustomerContacted: format: date type: string diff --git a/swagger/prime_v2.yaml b/swagger/prime_v2.yaml index 6c6ec965520..cf3762510ad 100644 --- a/swagger/prime_v2.yaml +++ b/swagger/prime_v2.yaml @@ -160,11 +160,6 @@ definitions: type: string description: Date when the customer has requested delivery out of SIT. x-nullable: true - sitActualDelivery: - format: date - type: string - description: Date when the customer's goods are delivered. - x-nullable: true sitCustomerContacted: format: date type: string From c22d038eb34022b0973a7703c0571095fc3e2ef3 Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Thu, 24 Aug 2023 17:20:34 +0000 Subject: [PATCH 090/138] Remove trailing comma --- ...0230822201206_add_fields_for_sit_to_mto_service_items.up.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/migrations/app/schema/20230822201206_add_fields_for_sit_to_mto_service_items.up.sql b/migrations/app/schema/20230822201206_add_fields_for_sit_to_mto_service_items.up.sql index fe154bf1db5..0c73c54588c 100644 --- a/migrations/app/schema/20230822201206_add_fields_for_sit_to_mto_service_items.up.sql +++ b/migrations/app/schema/20230822201206_add_fields_for_sit_to_mto_service_items.up.sql @@ -1,6 +1,6 @@ ALTER TABLE mto_service_items ADD COLUMN sit_customer_contacted date, - ADD COLUMN sit_requested_delivery date, + ADD COLUMN sit_requested_delivery date -- Comment On Column COMMENT ON COLUMN mto_service_items.sit_customer_contacted IS 'The date when the customer contacted the prime for a delivery out of SIT'; From d68edaa749e4acab982e61846001c075aedeabab Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Thu, 24 Aug 2023 17:38:37 +0000 Subject: [PATCH 091/138] Add missing semicolon --- ...0230822201206_add_fields_for_sit_to_mto_service_items.up.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/migrations/app/schema/20230822201206_add_fields_for_sit_to_mto_service_items.up.sql b/migrations/app/schema/20230822201206_add_fields_for_sit_to_mto_service_items.up.sql index 0c73c54588c..b983faf195e 100644 --- a/migrations/app/schema/20230822201206_add_fields_for_sit_to_mto_service_items.up.sql +++ b/migrations/app/schema/20230822201206_add_fields_for_sit_to_mto_service_items.up.sql @@ -1,6 +1,6 @@ ALTER TABLE mto_service_items ADD COLUMN sit_customer_contacted date, - ADD COLUMN sit_requested_delivery date + ADD COLUMN sit_requested_delivery date; -- Comment On Column COMMENT ON COLUMN mto_service_items.sit_customer_contacted IS 'The date when the customer contacted the prime for a delivery out of SIT'; From 911495157a1abe109863050c0ca48326dc7d6c24 Mon Sep 17 00:00:00 2001 From: Kyle Hill Date: Thu, 24 Aug 2023 18:06:16 +0000 Subject: [PATCH 092/138] Adds rounding to the domestic linehaul pricer --- .../ghcrateengine/domestic_linehaul_pricer.go | 17 +++++++++++------ .../domestic_linehaul_pricer_test.go | 4 ++++ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/pkg/services/ghcrateengine/domestic_linehaul_pricer.go b/pkg/services/ghcrateengine/domestic_linehaul_pricer.go index 013edda14ef..dfea88ca6ac 100644 --- a/pkg/services/ghcrateengine/domestic_linehaul_pricer.go +++ b/pkg/services/ghcrateengine/domestic_linehaul_pricer.go @@ -50,15 +50,20 @@ func (p domesticLinehaulPricer) Price(appCtx appcontext.AppContext, contractCode return unit.Cents(0), nil, fmt.Errorf("could not fetch domestic linehaul rate: %w", err) } - contractYear, err := fetchContractYear(appCtx, domesticLinehaulPrice.ContractID, referenceDate) + baseTotalPrice := finalWeight.ToCWTFloat64() * distance.Float64() * domesticLinehaulPrice.PriceMillicents.Float64() + + escalatedPrice, contractYear, err := escalatePriceForContractYear( + appCtx, + domesticLinehaulPrice.ContractID, + referenceDate, + true, + baseTotalPrice) + if err != nil { - return 0, nil, fmt.Errorf("Could not lookup contract year: %w", err) + return 0, nil, fmt.Errorf("could not calculate escalated price: %w", err) } - baseTotalPrice := finalWeight.ToCWTFloat64() * distance.Float64() * domesticLinehaulPrice.PriceMillicents.Float64() - escalatedTotalPrice := contractYear.EscalationCompounded * baseTotalPrice - - totalPriceMillicents := unit.Millicents(escalatedTotalPrice) + totalPriceMillicents := unit.Millicents(escalatedPrice) totalPriceCents := totalPriceMillicents.ToCents() params := services.PricingDisplayParams{ diff --git a/pkg/services/ghcrateengine/domestic_linehaul_pricer_test.go b/pkg/services/ghcrateengine/domestic_linehaul_pricer_test.go index 0422210d2e5..ce3e986f5b5 100644 --- a/pkg/services/ghcrateengine/domestic_linehaul_pricer_test.go +++ b/pkg/services/ghcrateengine/domestic_linehaul_pricer_test.go @@ -198,6 +198,10 @@ func (suite *GHCRateEngineServiceSuite) TestPriceDomesticLinehaul() { _, _, err = linehaulServicePricer.Price(suite.AppContextForTest(), testdatagen.DefaultContractCode, dlhRequestedPickupDate, dlhTestDistance, dlhTestWeight, "", isPPM) suite.Error(err) suite.Equal("ServiceArea is required", err.Error()) + + _, _, err = linehaulServicePricer.Price(suite.AppContextForTest(), testdatagen.DefaultContractCode, time.Date(testdatagen.TestYear+1, 1, 1, 1, 1, 1, 1, time.UTC), dlhTestDistance, dlhTestWeight, dlhTestServiceArea, isPPM) + suite.Error(err) + suite.Contains(err.Error(), "could not fetch domestic linehaul rate") }) } From 2fc2ba7511bc3447f7c6b25a7b1063528b31ea33 Mon Sep 17 00:00:00 2001 From: Ronak Patel Date: Thu, 24 Aug 2023 18:19:20 +0000 Subject: [PATCH 093/138] Clean up tests because it wasn't testing a function that changed --- pkg/handlers/primeapi/payloads/payload_to_model_test.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/pkg/handlers/primeapi/payloads/payload_to_model_test.go b/pkg/handlers/primeapi/payloads/payload_to_model_test.go index 62293593c0d..a6e679614a1 100644 --- a/pkg/handlers/primeapi/payloads/payload_to_model_test.go +++ b/pkg/handlers/primeapi/payloads/payload_to_model_test.go @@ -152,8 +152,6 @@ func (suite *PayloadsSuite) TestMTOServiceItemModel() { TimeMilitary2: &destTime, SitDestinationFinalAddress: &sitFinalDestAddress, Reason: &destReason, - SitCustomerContacted: &destDate, - SitRequestedDelivery: &destDate, } destSITServiceItem.SetMoveTaskOrderID(handlers.FmtUUID(moveTaskOrderIDField)) @@ -166,8 +164,6 @@ func (suite *PayloadsSuite) TestMTOServiceItemModel() { suite.Equal(models.ReServiceCodeDDFSIT, returnedModel.ReService.Code) suite.Equal(destPostalCode, returnedModel.SITDestinationFinalAddress.PostalCode) suite.Equal(destStreet, returnedModel.SITDestinationFinalAddress.StreetAddress1) - suite.Equal(handlers.FmtDatePtrToPop(&destDate), *returnedModel.SITCustomerContacted) - suite.Equal(handlers.FmtDatePtrToPop(&destDate), *returnedModel.SITRequestedDelivery) }) suite.Run("Success - Returns SIT destination service item model without customer contact fields", func() { From 24ae2fa3ecab06aa8f8c8cce8ef4ed224aee9c95 Mon Sep 17 00:00:00 2001 From: Brandon Lenz Date: Thu, 24 Aug 2023 20:19:55 +0000 Subject: [PATCH 094/138] Create script to generate the secure migration --- .../load-updated-loa-trnsn-ids.py | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 cmd/load-spreadsheet-data/load-updated-loa-trnsn-ids.py diff --git a/cmd/load-spreadsheet-data/load-updated-loa-trnsn-ids.py b/cmd/load-spreadsheet-data/load-updated-loa-trnsn-ids.py new file mode 100644 index 00000000000..2a40d95fc93 --- /dev/null +++ b/cmd/load-spreadsheet-data/load-updated-loa-trnsn-ids.py @@ -0,0 +1,65 @@ +import os, sys, pandas as pd +from datetime import datetime + +ZERO = '0' + +if len(sys.argv) < 2: + sys.exit("Input file required.") + + +# Generate to gitignored tmp directory to prevent committing secure data +current_dir = os.getcwd() +destination_directory = 'tmp/generated-secure-migrations' +now = datetime.now() +year = str(now.year).rjust(4, ZERO) +month = str(now.month).rjust(2, ZERO) +day = str(now.day).rjust(2, ZERO) +hour = str(now.hour).rjust(2, ZERO) +minute = str(now.minute).rjust(2, ZERO) +second = str(now.second).rjust(2, ZERO) +filename = f'{year}{month}{day}{hour}{minute}{second}00_update_loa_trnsn_ids.sql' +secure_migration_filename = ( + f'{current_dir}/{destination_directory}/{filename}' +) + +destination_path = f'{current_dir}/{destination_directory}' +if not os.path.exists(destination_path): + os.makedirs(destination_path) + +with open(secure_migration_filename, "w+") as f: + f.write('-- Update loa_trnsn_id column constraint\n') # TODO: Update the Model constraint expectations as well + f.write('ALTER TABLE lines_of_accounting ALTER COLUMN loa_trnsn_id TYPE char (2);\n') # TODO: Confirm nullable char (2) is correct + + # Skip the first and last rows which are just "unclassified" + input_file = pd.read_excel(sys.argv[1], skiprows=1, skipfooter=1) + + # Missing values should be NULL + input_file = input_file.fillna('NULL') + + f.write('-- Update lines_of_accounting with updated loa_trnsn_id values, mapped by loa_sys_id\n') + f.write('UPDATE lines_of_accounting AS loas SET\n') + f.write('\tloa_trnsn_id = updated.loa_trnsn_id\n') + f.write('FROM (VALUES\n') + + for index, row in input_file.iterrows(): + loa_sys_id = row['LOA_SYS_ID'] + + # Ignore rows where loa_sys_id is missing + if loa_sys_id == 'NULL': + continue + + # Add single quotes around non-null values, otherwise, just use NULL + loa_trnsn_id = row['LOA_TRNSN_ID'] + loa_trnsn_id_write_value = loa_trnsn_id if loa_trnsn_id == 'NULL' else f"'{loa_trnsn_id}'" + + f.write(f'\t({loa_sys_id}, {loa_trnsn_id_write_value})') + + # only add a comma to rows that are not the last row + if index == len(input_file) - 1: + f.write('\n') + else: + f.write(',\n') + + f.write(') AS updated(loa_sys_id, loa_trnsn_id)\n') + f.write('WHERE updated.loa_sys_id = loas.loa_sys_id;\n') +sys.exit() From 0752b38d883be589ffa8ca02f6e38781d8e52f59 Mon Sep 17 00:00:00 2001 From: Brandon Lenz Date: Thu, 24 Aug 2023 20:51:05 +0000 Subject: [PATCH 095/138] Fix filename generation --- cmd/load-spreadsheet-data/load-updated-loa-trnsn-ids.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/load-spreadsheet-data/load-updated-loa-trnsn-ids.py b/cmd/load-spreadsheet-data/load-updated-loa-trnsn-ids.py index 2a40d95fc93..2959fcd5eaf 100644 --- a/cmd/load-spreadsheet-data/load-updated-loa-trnsn-ids.py +++ b/cmd/load-spreadsheet-data/load-updated-loa-trnsn-ids.py @@ -17,7 +17,7 @@ hour = str(now.hour).rjust(2, ZERO) minute = str(now.minute).rjust(2, ZERO) second = str(now.second).rjust(2, ZERO) -filename = f'{year}{month}{day}{hour}{minute}{second}00_update_loa_trnsn_ids.sql' +filename = f'{year}{month}{day}{hour}{minute}{second}_update_loa_trnsn_ids.sql' secure_migration_filename = ( f'{current_dir}/{destination_directory}/{filename}' ) From 507e285a16b42556b0628680c554bba63e000365 Mon Sep 17 00:00:00 2001 From: Brandon Lenz Date: Thu, 24 Aug 2023 20:59:00 +0000 Subject: [PATCH 096/138] Make sure filename includes 'up', add example migration --- .../load-updated-loa-trnsn-ids.py | 2 +- migrations/app/migrations_manifest.txt | 1 + ...20230824200422_update_loa_trnsn_ids.up.sql | 21 +++++++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 migrations/app/secure/20230824200422_update_loa_trnsn_ids.up.sql diff --git a/cmd/load-spreadsheet-data/load-updated-loa-trnsn-ids.py b/cmd/load-spreadsheet-data/load-updated-loa-trnsn-ids.py index 2959fcd5eaf..ebb0440e5bf 100644 --- a/cmd/load-spreadsheet-data/load-updated-loa-trnsn-ids.py +++ b/cmd/load-spreadsheet-data/load-updated-loa-trnsn-ids.py @@ -17,7 +17,7 @@ hour = str(now.hour).rjust(2, ZERO) minute = str(now.minute).rjust(2, ZERO) second = str(now.second).rjust(2, ZERO) -filename = f'{year}{month}{day}{hour}{minute}{second}_update_loa_trnsn_ids.sql' +filename = f'{year}{month}{day}{hour}{minute}{second}_update_loa_trnsn_ids.up.sql' secure_migration_filename = ( f'{current_dir}/{destination_directory}/{filename}' ) diff --git a/migrations/app/migrations_manifest.txt b/migrations/app/migrations_manifest.txt index 3d6584f7dad..74e2724250f 100644 --- a/migrations/app/migrations_manifest.txt +++ b/migrations/app/migrations_manifest.txt @@ -842,3 +842,4 @@ 20230804161700_import_trdm_part_1.up.sql 20230807175944_import_trdm_part_2.up.sql 20230807180000_import_trdm_part_3.up.sql +20230824200422_update_loa_trnsn_ids.up.sql diff --git a/migrations/app/secure/20230824200422_update_loa_trnsn_ids.up.sql b/migrations/app/secure/20230824200422_update_loa_trnsn_ids.up.sql new file mode 100644 index 00000000000..cb2e75724a6 --- /dev/null +++ b/migrations/app/secure/20230824200422_update_loa_trnsn_ids.up.sql @@ -0,0 +1,21 @@ +-- Local test migration. +-- This will be run on development environments. +-- It should mirror what you intend to apply on loadtest/demo/exp/stg/prd +-- DO NOT include any sensitive data. + +-- Update loa_trnsn_id column constraint +ALTER TABLE lines_of_accounting ALTER COLUMN loa_trnsn_id TYPE char (2); +-- Update lines_of_accounting with updated loa_trnsn_id values, mapped by loa_sys_id +UPDATE lines_of_accounting AS loas SET + loa_trnsn_id = updated.loa_trnsn_id +FROM (VALUES + (10002, NULL), + (10001, 'A1'), + (10003, 'B1'), + (10004, NULL), + (10005, 'C1'), + (10006, 'AB'), + (10007, NULL), + (10008, 'CC') +) AS updated(loa_sys_id, loa_trnsn_id) +WHERE updated.loa_sys_id = loas.loa_sys_id; From dacf771d44d29fe916fac73ac8dd5797094b0174 Mon Sep 17 00:00:00 2001 From: Brandon Lenz Date: Thu, 24 Aug 2023 21:27:27 +0000 Subject: [PATCH 097/138] There is a 3 character loa_trnsn_id so use char (3) --- cmd/load-spreadsheet-data/load-updated-loa-trnsn-ids.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/load-spreadsheet-data/load-updated-loa-trnsn-ids.py b/cmd/load-spreadsheet-data/load-updated-loa-trnsn-ids.py index ebb0440e5bf..7c7f65fdae0 100644 --- a/cmd/load-spreadsheet-data/load-updated-loa-trnsn-ids.py +++ b/cmd/load-spreadsheet-data/load-updated-loa-trnsn-ids.py @@ -28,7 +28,7 @@ with open(secure_migration_filename, "w+") as f: f.write('-- Update loa_trnsn_id column constraint\n') # TODO: Update the Model constraint expectations as well - f.write('ALTER TABLE lines_of_accounting ALTER COLUMN loa_trnsn_id TYPE char (2);\n') # TODO: Confirm nullable char (2) is correct + f.write('ALTER TABLE lines_of_accounting ALTER COLUMN loa_trnsn_id TYPE char (3);\n') # Skip the first and last rows which are just "unclassified" input_file = pd.read_excel(sys.argv[1], skiprows=1, skipfooter=1) From b0c135c343dfcf6c714847e00de1b652bcc71992 Mon Sep 17 00:00:00 2001 From: Brandon Lenz Date: Thu, 24 Aug 2023 21:28:10 +0000 Subject: [PATCH 098/138] Update dummy data to have a 3-digit loa_trnsn_id --- .../app/secure/20230824200422_update_loa_trnsn_ids.up.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/migrations/app/secure/20230824200422_update_loa_trnsn_ids.up.sql b/migrations/app/secure/20230824200422_update_loa_trnsn_ids.up.sql index cb2e75724a6..a0f6c71a232 100644 --- a/migrations/app/secure/20230824200422_update_loa_trnsn_ids.up.sql +++ b/migrations/app/secure/20230824200422_update_loa_trnsn_ids.up.sql @@ -4,7 +4,7 @@ -- DO NOT include any sensitive data. -- Update loa_trnsn_id column constraint -ALTER TABLE lines_of_accounting ALTER COLUMN loa_trnsn_id TYPE char (2); +ALTER TABLE lines_of_accounting ALTER COLUMN loa_trnsn_id TYPE char (3); -- Update lines_of_accounting with updated loa_trnsn_id values, mapped by loa_sys_id UPDATE lines_of_accounting AS loas SET loa_trnsn_id = updated.loa_trnsn_id @@ -16,6 +16,6 @@ FROM (VALUES (10005, 'C1'), (10006, 'AB'), (10007, NULL), - (10008, 'CC') + (10008, 'C12') ) AS updated(loa_sys_id, loa_trnsn_id) WHERE updated.loa_sys_id = loas.loa_sys_id; From e2a8eca5a2b5506fae1323a31986317f50a8b2a3 Mon Sep 17 00:00:00 2001 From: Brandon Lenz Date: Thu, 24 Aug 2023 21:39:33 +0000 Subject: [PATCH 099/138] Update loa factory to create a loa with 3 chars in the loa_trnsn_id field since that is the max --- cmd/load-spreadsheet-data/load-updated-loa-trnsn-ids.py | 2 +- pkg/factory/line_of_accounting_factory.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/load-spreadsheet-data/load-updated-loa-trnsn-ids.py b/cmd/load-spreadsheet-data/load-updated-loa-trnsn-ids.py index 7c7f65fdae0..fd9a8831646 100644 --- a/cmd/load-spreadsheet-data/load-updated-loa-trnsn-ids.py +++ b/cmd/load-spreadsheet-data/load-updated-loa-trnsn-ids.py @@ -27,7 +27,7 @@ os.makedirs(destination_path) with open(secure_migration_filename, "w+") as f: - f.write('-- Update loa_trnsn_id column constraint\n') # TODO: Update the Model constraint expectations as well + f.write('-- Update loa_trnsn_id column constraint\n') f.write('ALTER TABLE lines_of_accounting ALTER COLUMN loa_trnsn_id TYPE char (3);\n') # Skip the first and last rows which are just "unclassified" diff --git a/pkg/factory/line_of_accounting_factory.go b/pkg/factory/line_of_accounting_factory.go index da7c7b1236a..420903af461 100644 --- a/pkg/factory/line_of_accounting_factory.go +++ b/pkg/factory/line_of_accounting_factory.go @@ -77,7 +77,7 @@ func BuildFullLineOfAccounting(db *pop.Connection) models.LineOfAccounting { LoaHsGdsCd: models.StringPointer("12"), OrgGrpDfasCd: models.StringPointer("12"), LoaUic: models.StringPointer("123456"), - LoaTrnsnID: models.StringPointer("LoaTrnsnID"), + LoaTrnsnID: models.StringPointer("123"), LoaSubAcntID: models.StringPointer("123"), LoaBetCd: models.StringPointer("1234"), LoaFndTyFgCd: models.StringPointer("1"), From fbc4d9797b1f342f5f1cfb1b86a4a1feb866e8d0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 25 Aug 2023 11:26:59 +0000 Subject: [PATCH 100/138] Bump actions/checkout from 3.5.3 to 3.6.0 Bumps [actions/checkout](https://github.com/actions/checkout) from 3.5.3 to 3.6.0. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v3.5.3...v3.6.0) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/analyze-bundle.yml | 4 ++-- .github/workflows/front-end-linter.yml | 2 +- .github/workflows/go-auto-approve.yml | 2 +- .github/workflows/happo-tests-main.yml | 2 +- .github/workflows/happo-tests.yml | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/analyze-bundle.yml b/.github/workflows/analyze-bundle.yml index cebc2e9c0a2..a1b1edbbed7 100644 --- a/.github/workflows/analyze-bundle.yml +++ b/.github/workflows/analyze-bundle.yml @@ -46,7 +46,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out branch - uses: actions/checkout@v3.5.3 + uses: actions/checkout@v3.6.0 - name: Set up node uses: actions/setup-node@v3 @@ -78,7 +78,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out base branch - uses: actions/checkout@v3.5.3 + uses: actions/checkout@v3.6.0 with: ref: ${{ github.base_ref }} diff --git a/.github/workflows/front-end-linter.yml b/.github/workflows/front-end-linter.yml index b89dea49e8a..0ac4d90d692 100644 --- a/.github/workflows/front-end-linter.yml +++ b/.github/workflows/front-end-linter.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out repository - uses: actions/checkout@v3.5.3 + uses: actions/checkout@v3.6.0 - name: Set up node uses: actions/setup-node@v3 diff --git a/.github/workflows/go-auto-approve.yml b/.github/workflows/go-auto-approve.yml index 5108c718723..547e2235b0b 100644 --- a/.github/workflows/go-auto-approve.yml +++ b/.github/workflows/go-auto-approve.yml @@ -16,7 +16,7 @@ jobs: runs-on: ubuntu-latest steps: - name: checkout - uses: actions/checkout@v3.5.3 + uses: actions/checkout@v3.6.0 with: fetch-depth: 0 if: github.actor == 'dependabot[bot]' || github.actor == 'dependabot-preview[bot]' diff --git a/.github/workflows/happo-tests-main.yml b/.github/workflows/happo-tests-main.yml index 2553077ea62..2e40cbcbbed 100644 --- a/.github/workflows/happo-tests-main.yml +++ b/.github/workflows/happo-tests-main.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out repository - uses: actions/checkout@v3.5.3 + uses: actions/checkout@v3.6.0 - name: Set up node uses: actions/setup-node@v3 diff --git a/.github/workflows/happo-tests.yml b/.github/workflows/happo-tests.yml index b74ee587872..12d8074a5d3 100644 --- a/.github/workflows/happo-tests.yml +++ b/.github/workflows/happo-tests.yml @@ -26,7 +26,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out repository - uses: actions/checkout@v3.5.3 + uses: actions/checkout@v3.6.0 - name: Set up node uses: actions/setup-node@v3 From 647a1cb990d576bfd0201e4f457342d09b3fd96f Mon Sep 17 00:00:00 2001 From: Michael Mayo Date: Fri, 25 Aug 2023 15:17:53 +0000 Subject: [PATCH 101/138] Created data migration to update ghc domestic transit times table --- migrations/app/migrations_manifest.txt | 1 + ...transit_times_update_data_migration.up.sql | 143 ++++++++++++++++++ 2 files changed, 144 insertions(+) create mode 100644 migrations/app/schema/20230824224954_ghc_domestic_transit_times_update_data_migration.up.sql diff --git a/migrations/app/migrations_manifest.txt b/migrations/app/migrations_manifest.txt index 3d6584f7dad..bbe3168e13f 100644 --- a/migrations/app/migrations_manifest.txt +++ b/migrations/app/migrations_manifest.txt @@ -842,3 +842,4 @@ 20230804161700_import_trdm_part_1.up.sql 20230807175944_import_trdm_part_2.up.sql 20230807180000_import_trdm_part_3.up.sql +20230824224954_ghc_domestic_transit_times_update_data_migration.up.sql diff --git a/migrations/app/schema/20230824224954_ghc_domestic_transit_times_update_data_migration.up.sql b/migrations/app/schema/20230824224954_ghc_domestic_transit_times_update_data_migration.up.sql new file mode 100644 index 00000000000..2cedaaacae4 --- /dev/null +++ b/migrations/app/schema/20230824224954_ghc_domestic_transit_times_update_data_migration.up.sql @@ -0,0 +1,143 @@ +TRUNCATE TABLE "public"."ghc_domestic_transit_times"; + +INSERT INTO "public"."ghc_domestic_transit_times" ("id", "max_days_transit_time", "weight_lbs_lower", "weight_lbs_upper", "distance_miles_lower", "distance_miles_upper") VALUES +('0112b560-1c59-495c-a1e8-17c262f2edd7', '9', '1', '999', '1', '250'), +('03399857-8316-4e89-ae87-78dd6b031013', '8', '1000', '1999', '1', '250'), +('03830e8c-cbfa-4f7d-b112-7dbe776696bb', '7', '2000', '3999', '1', '250'), +('0462b8f2-030d-45f4-9508-ea3ef0fffe1f', '6', '4000', '7999', '1', '250'), +('05fa7acd-c8ec-4d95-a193-c56ac5f87c06', '5', '8000', '0', '1', '250'), +('0cb6de06-fe30-49a6-b46c-8bdc42a04474', '12', '1', '999', '251', '500'), +('0d163eec-933a-4c60-b464-78fe96205d1e', '11', '1000', '1999', '251', '500'), +('0d7239cd-0a73-434d-80dd-05f76218075d', '8', '2000', '3999', '251', '500'), +('15b1488c-2c3f-429c-ad44-501e47c12f64', '7', '4000', '7999', '251', '500'), +('170f040e-0d2a-4a73-bff3-2d3f9eea7a79', '6', '8000', '0', '251', '500'), +('177e797e-d9b6-4cf4-85a6-6c659d83aa59', '15', '1', '999', '501', '750'), +('1a0493a6-d6ed-4244-bc55-93bc0ecb7b84', '13', '1000', '1999', '501', '750'), +('1a7e1caa-976b-4ac3-9d67-4a62c5cec61e', '11', '2000', '3999', '501', '750'), +('1cadc4c1-9bca-46a6-a9d7-7adc22da1327', '10', '4000', '7999', '501', '750'), +('1dad5764-9397-44e2-bf76-71dee1cd0f8f', '8', '8000', '0', '501', '750'), +('1dcea51b-e418-4e11-9a19-cc111ca7fe37', '17', '1', '999', '751', '1000'), +('1e6d0aeb-f7bf-4f91-a19a-caf5e38a0e44', '15', '1000', '1999', '751', '1000'), +('21bbb19e-4ac1-4a52-be19-520aac27db55', '12', '2000', '3999', '751', '1000'), +('22275a7c-e814-40d0-b5b7-f7ee921d4e00', '11', '4000', '7999', '751', '1000'), +('25072113-7e99-450c-9ca9-844f0c6a9177', '9', '8000', '0', '751', '1000'), +('274856a2-d936-4668-8c06-b688d198ca28', '17', '1', '999', '1001', '1250'), +('279a9c04-965d-43a0-926b-eec47a54aab3', '14', '1000', '1999', '1001', '1250'), +('295e21eb-a056-461e-a085-f1fa473ab217', '12', '2000', '3999', '1001', '1250'), +('2980abf8-0e96-4ed7-9503-235c5dc44c3f', '11', '4000', '7999', '1001', '1250'), +('29fcfa96-94f4-41d0-82f3-11268a3d9a3f', '10', '8000', '0', '1001', '1250'), +('2a42d7ef-4e9e-4aaf-9e99-44468b73d669', '18', '1', '999', '1251', '1500'), +('2b45d667-a4a0-4578-a171-010193cb74bf', '15', '1000', '1999', '1251', '1500'), +('2b989e5f-8aad-44d0-93ed-3e42d7951359', '13', '2000', '3999', '1251', '1500'), +('2c22ce21-f2e2-4679-8592-22b739e32245', '12', '4000', '7999', '1251', '1500'), +('315dc7d9-b5a7-4863-aaf9-cc746935d1a4', '11', '8000', '0', '1251', '1500'), +('3b4037be-b415-43af-9ba1-664de5fe266d', '19', '1', '999', '1501', '1750'), +('3b6aeb8f-fa7b-483f-a5c8-d0a014f01e1a', '16', '1000', '1999', '1501', '1750'), +('3c29ba46-6208-4656-993c-61a98ee35dcd', '14', '2000', '3999', '1501', '1750'), +('3ea9039b-8123-4a06-b734-691ae6b2dad8', '13', '4000', '7999', '1501', '1750'), +('3eb1e375-8520-4b0a-9b08-9e24ea7f94e7', '12', '8000', '0', '1501', '1750'), +('3ee7c175-04dc-49df-a7c1-5698094546a6', '19', '1', '999', '1751', '2000'), +('3f4e812f-580f-418e-aab4-1256ac15bbf2', '18', '1000', '1999', '1751', '2000'), +('43264c59-0b3c-47a3-a4a6-27525efe0e00', '15', '2000', '3999', '1751', '2000'), +('45ae8ae0-d230-4d76-9b0c-d9aafaaa605f', '14', '4000', '7999', '1751', '2000'), +('472de745-b92d-45ef-8254-254be7db7ce4', '13', '8000', '0', '1751', '2000'), +('473c3e83-be57-4b24-adfc-26c6fb679252', '20', '1', '999', '2001', '2250'), +('47bd49d4-cf55-45ec-ad8f-bbe6f5e7199e', '19', '1000', '1999', '2001', '2250'), +('4b3c3965-a2b9-4156-8916-62fdbe090f16', '17', '2000', '3999', '2001', '2250'), +('4d8be502-6775-4a2b-94be-e9fcd37b6277', '15', '4000', '7999', '2001', '2250'), +('4da84092-4557-49e3-a58f-b24ab7760902', '14', '8000', '0', '2001', '2250'), +('5436fde9-3847-498c-b9d4-6b1af28a6861', '21', '1', '999', '2251', '2500'), +('552c0837-30a3-44f9-8a1b-34d5720d896b', '19', '1000', '1999', '2251', '2500'), +('5560dae5-80ba-4817-841c-d8d486a561d6', '18', '2000', '3999', '2251', '2500'), +('55c1bdf0-ffdc-44ea-910c-e9b7f9dee609', '16', '4000', '7999', '2251', '2500'), +('583a8674-2338-4089-abb2-5faf3964a346', '15', '8000', '0', '2251', '2500'), +('5d8fb76d-8c1c-48fb-9a35-9eff4d7c9427', '22', '1', '999', '2501', '2750'), +('613cc341-f200-4975-9f2e-9f35c317c40f', '20', '1000', '1999', '2501', '2750'), +('61580524-e306-4b13-ae7c-4e78d8069bc4', '19', '2000', '3999', '2501', '2750'), +('6196d2e0-dcbd-43ec-85fb-eb410ab819a9', '17', '4000', '7999', '2501', '2750'), +('62259ddf-ff99-46fe-abb7-63c1c0e3bf8c', '16', '8000', '0', '2501', '2750'), +('629f1037-466c-40c9-8fbb-b26a3a6a1fb8', '23', '1', '999', '2751', '3000'), +('69c830b5-6936-4631-9e32-ae7317ba668d', '21', '1000', '1999', '2751', '3000'), +('6e1cd911-485a-4e7a-8702-c350738ad3a6', '19', '2000', '3999', '2751', '3000'), +('711ea795-1ab7-414e-908c-fd546d00bc03', '18', '4000', '7999', '2751', '3000'), +('71d3cd38-b62b-4b32-9cbe-5e658447e027', '17', '8000', '0', '2751', '3000'), +('732aeca2-bfce-4052-98ec-0352ec395ca6', '24', '1', '999', '3001', '3250'), +('73f88626-a3a2-4133-882f-cfbc85d14396', '22', '1000', '1999', '3001', '3250'), +('74551d9e-5c3b-482a-9aaf-100a6cb37ce7', '20', '2000', '3999', '3001', '3250'), +('74debd3e-aca4-4faa-a2b7-29439b96338a', '19', '4000', '7999', '3001', '3250'), +('75fad8f1-ce57-4c87-91de-02ac8759f843', '18', '8000', '0', '3001', '3250'), +('7679fe22-0565-4810-9aba-499e816b3535', '25', '1', '999', '3251', '3500'), +('78a12269-2b21-4b7f-8aa2-d5d2a31a6001', '23', '1000', '1999', '3251', '3500'), +('78c4f864-8989-4d1f-b1cf-9907657c5321', '21', '2000', '3999', '3251', '3500'), +('7aa83b7d-4c1a-4e38-b50e-fab494af8128', '19', '4000', '7999', '3251', '3500'), +('7d58bb2d-a044-4dec-9e22-38817aca776d', '19', '8000', '0', '3251', '3500'), +('7e88791f-aa78-4f4f-aee5-a01956ba4480', '26', '1', '999', '3501', '3750'), +('801f90f6-068d-4358-88ae-8ba04315b43c', '24', '1000', '1999', '3501', '3750'), +('82b26561-0ca1-47cc-9bd3-dcd87892d665', '22', '2000', '3999', '3501', '3750'), +('82ef20b3-6b05-4428-85a6-b98b464be4c5', '21', '4000', '7999', '3501', '3750'), +('8562437a-f840-44db-b76f-9f2e8d875e89', '19', '8000', '0', '3501', '3750'), +('85842e02-ab6e-464b-b029-2359d639790d', '27', '1', '999', '3751', '4000'), +('88508cf5-89b4-43b5-9780-6eb8342ca624', '25', '1000', '1999', '3751', '4000'), +('8a9178d9-7e16-4451-946f-dc24bd1d6944', '23', '2000', '3999', '3751', '4000'), +('8c12eb33-5bae-4314-8156-4eaf4357a479', '22', '4000', '7999', '3751', '4000'), +('8c2425fc-98ef-4793-a5b6-a527eb9cbaad', '20', '8000', '0', '3751', '4000'), +('8dc724e6-aa65-454b-ae96-9059090aeea6', '28', '1', '999', '4001', '4250'), +('9d0b2074-658f-4dcb-8663-27705220d12c', '26', '1000', '1999', '4001', '4250'), +('9e5ef6a4-3f0f-4d1f-941f-2839ff910cba', '24', '2000', '3999', '4001', '4250'), +('9e8800e5-c340-4df4-9245-696cd17a7d45', '23', '4000', '7999', '4001', '4250'), +('a15ed9d9-31c1-4f58-844f-39acc70d9f54', '21', '8000', '0', '4001', '4250'), +('a1a73146-bffe-403b-b523-672bfca42bd1', '29', '1', '999', '4251', '4500'), +('a24c1d0c-7190-42c7-9028-ca5e179c8641', '27', '1000', '1999', '4251', '4500'), +('a2d93b11-814a-4c26-ad8d-8e27b2ad7829', '25', '2000', '3999', '4251', '4500'), +('a542e808-93b8-470e-9ba5-3c72f76ad45e', '24', '4000', '7999', '4251', '4500'), +('a5b8a03a-32e0-4a23-bbbd-8191d1b726d0', '22', '8000', '0', '4251', '4500'), +('a805db78-6e74-40c7-be9f-748511cf2b54', '30', '1', '999', '4501', '4750'), +('aabce664-25c1-4144-bd39-6106e68b041e', '28', '1000', '1999', '4501', '4750'), +('acafa56e-306a-417c-bf5e-d5fe58cc47c0', '26', '2000', '3999', '4501', '4750'), +('acbcac9e-a812-4185-83ff-25c433a13df1', '25', '4000', '7999', '4501', '4750'), +('ad632b1d-de47-4472-bbf2-2e5ee5fbea10', '23', '8000', '0', '4501', '4750'), +('ad68cd02-b62b-43f5-b43e-45210d39d271', '31', '1', '999', '4751', '5000'), +('ae6e9e8e-d58e-4b28-beb4-36a410f29b30', '29', '1000', '1999', '4751', '5000'), +('af5aabee-872f-48ba-81cc-5b2366c885e8', '27', '2000', '3999', '4751', '5000'), +('b0fa4588-9050-4001-b22d-17902adbecf7', '26', '4000', '7999', '4751', '5000'), +('b1576b50-dabd-43b1-a582-70dc681fe7ec', '24', '8000', '0', '4751', '5000'), +('b2a48928-d7b8-4587-ab2e-bab50f49305d', '29', '1', '999', '5001', '5250'), +('b56fc986-a729-424b-abfa-6ba79b12e2ad', '27', '1000', '1999', '5001', '5250'), +('b70fcec3-f65b-4143-b799-bc2df28635b8', '25', '2000', '3999', '5001', '5250'), +('b8085372-1da5-47a1-8a53-4c4466f39891', '24', '4000', '7999', '5001', '5250'), +('b93a9274-ad23-4214-b551-53e115ae5c2b', '23', '8000', '0', '5001', '5250'), +('ba2f0e83-4578-4732-afc4-e7f0e9a8f38f', '30', '1', '999', '5251', '5500'), +('ba7b434d-28bd-4bbe-aa43-16bf26b49c82', '28', '1000', '1999', '5251', '5500'), +('bbe14b4d-f7d4-40f3-878c-40030e9ad59e', '26', '2000', '3999', '5251', '5500'), +('bde5e8b6-9694-4f0f-8656-f138eea3adee', '25', '4000', '7999', '5251', '5500'), +('be395e93-b428-49e4-89a4-2d791f4599dc', '24', '8000', '0', '5251', '5500'), +('c18479fc-11bb-4eb6-9dcc-476c180c246e', '21', '1', '999', '5501', '5750'), +('c21a8bf3-e607-4917-9700-b8571b9d007e', '29', '1000', '1999', '5501', '5750'), +('c3c6d2ce-c50d-488c-9eb1-af34bfe0f130', '27', '2000', '3999', '5501', '5750'), +('c407654b-a8dd-4843-9f08-96bb427eac90', '26', '4000', '7999', '5501', '5750'), +('c5e3eb27-27e3-4218-96dd-f2eb0d8cc057', '25', '8000', '0', '5501', '5750'), +('c98f26e4-ffc4-4755-b38b-a8982edcfc14', '31', '1', '999', '5751', '6000'), +('cc08fb75-650e-4aab-891d-3ca86609ee13', '30', '1000', '1999', '5751', '6000'), +('d07344ca-6e3c-41c9-9687-02a767873b63', '28', '2000', '3999', '5751', '6000'), +('d12c64d0-81e2-4aee-892a-028ff2db0fae', '27', '4000', '7999', '5751', '6000'), +('d1748cde-9f71-48bd-81b3-a236904dd60b', '26', '8000', '0', '5751', '6000'), +('d2b87719-5139-4a07-b911-1f77613d00a4', '32', '1', '999', '6001', '6250'), +('d483197a-c684-4ca4-81e7-23b6a7ce7acf', '31', '1000', '1999', '6001', '6250'), +('d90fce74-b1a7-439a-8c16-c8b8e7c50681', '29', '2000', '3999', '6001', '6250'), +('db654308-7503-4e7c-8567-ed1a7a0b8016', '28', '4000', '7999', '6001', '6250'), +('dca80d32-d365-46d7-bd8c-b5f60f996c1f', '27', '8000', '0', '6001', '6250'), +('dd51f4a4-3140-468b-8030-d1d110df9c82', '33', '1', '999', '6251', '6500'), +('e28f9901-23c4-4efd-97ec-eab548431c50', '31', '1000', '1999', '6251', '6500'), +('e36e9d5c-00fe-46a4-82c3-9a2a1a8279c9', '30', '2000', '3999', '6251', '6500'), +('e5cd938a-fa80-4e0a-b77b-6fb3a6632ad4', '29', '4000', '7999', '6251', '6500'), +('e66103f6-ed53-429f-b656-bc8fa9d7a9da', '28', '8000', '0', '6251', '6500'), +('e99cabd5-848a-4284-8270-51f00f75e854', '34', '1', '999', '6501', '6750'), +('ec17e44e-8a60-4595-a780-bd369ea94ec4', '32', '1000', '1999', '6501', '6750'), +('ecd3b0bd-8888-49ef-97c9-3ca815e29b8e', '31', '2000', '3999', '6501', '6750'), +('ef5e2333-d8ae-4729-aa31-38aa1892cffa', '30', '4000', '7999', '6501', '6750'), +('f357c4dc-7353-4aa6-90de-15c39ae6d6af', '29', '8000', '0', '6501', '6750'), +('f3c4e5f2-5f1b-4a05-9eca-96a3071a6c89', '35', '1', '999', '6751', '7000'), +('f62baf2b-a259-4b86-a432-7020abc63d95', '33', '1000', '1999', '6751', '7000'), +('f8c0f43a-2dc6-4ec7-8da7-5f304ecf5bde', '31', '2000', '3999', '6751', '7000'), +('f936c7a1-b85d-4cc7-8e4e-609655336cca', '31', '4000', '7999', '6751', '7000'), +('f9ed9ec2-d3be-499e-baee-f179981ca919', '30', '8000', '0', '6751', '7000'); From 8fd32f97c3522f75b7e9a12542c7f48a50051bfb Mon Sep 17 00:00:00 2001 From: Brandon Lenz Date: Fri, 25 Aug 2023 15:49:35 +0000 Subject: [PATCH 102/138] Use varchar (3) since it can be 2 or 3 characters --- cmd/load-spreadsheet-data/load-updated-loa-trnsn-ids.py | 2 +- .../app/secure/20230824200422_update_loa_trnsn_ids.up.sql | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/load-spreadsheet-data/load-updated-loa-trnsn-ids.py b/cmd/load-spreadsheet-data/load-updated-loa-trnsn-ids.py index fd9a8831646..022e0cec219 100644 --- a/cmd/load-spreadsheet-data/load-updated-loa-trnsn-ids.py +++ b/cmd/load-spreadsheet-data/load-updated-loa-trnsn-ids.py @@ -28,7 +28,7 @@ with open(secure_migration_filename, "w+") as f: f.write('-- Update loa_trnsn_id column constraint\n') - f.write('ALTER TABLE lines_of_accounting ALTER COLUMN loa_trnsn_id TYPE char (3);\n') + f.write('ALTER TABLE lines_of_accounting ALTER COLUMN loa_trnsn_id TYPE varchar (3);\n') # Skip the first and last rows which are just "unclassified" input_file = pd.read_excel(sys.argv[1], skiprows=1, skipfooter=1) diff --git a/migrations/app/secure/20230824200422_update_loa_trnsn_ids.up.sql b/migrations/app/secure/20230824200422_update_loa_trnsn_ids.up.sql index a0f6c71a232..15e1b920105 100644 --- a/migrations/app/secure/20230824200422_update_loa_trnsn_ids.up.sql +++ b/migrations/app/secure/20230824200422_update_loa_trnsn_ids.up.sql @@ -4,7 +4,7 @@ -- DO NOT include any sensitive data. -- Update loa_trnsn_id column constraint -ALTER TABLE lines_of_accounting ALTER COLUMN loa_trnsn_id TYPE char (3); +ALTER TABLE lines_of_accounting ALTER COLUMN loa_trnsn_id TYPE varchar (3); -- Update lines_of_accounting with updated loa_trnsn_id values, mapped by loa_sys_id UPDATE lines_of_accounting AS loas SET loa_trnsn_id = updated.loa_trnsn_id From 3246f01b2bed83355cf750136ce1e09bd3910f25 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 25 Aug 2023 16:29:54 +0000 Subject: [PATCH 103/138] Bump golang.org/x/tools from 0.11.0 to 0.12.0 Bumps [golang.org/x/tools](https://github.com/golang/tools) from 0.11.0 to 0.12.0. - [Release notes](https://github.com/golang/tools/releases) - [Commits](https://github.com/golang/tools/compare/v0.11.0...v0.12.0) --- updated-dependencies: - dependency-name: golang.org/x/tools dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 4 ++-- go.sum | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index a499216dde1..56af9e3d879 100644 --- a/go.mod +++ b/go.mod @@ -51,7 +51,6 @@ require ( github.com/gorilla/csrf v1.7.1 github.com/imdario/mergo v0.3.16 github.com/jackc/pgerrcode v0.0.0-20220416144525-469b46aa5efa - github.com/jackc/pgx/v4 v4.18.1 github.com/jessevdk/go-flags v1.5.0 github.com/jinzhu/copier v0.3.5 github.com/jmoiron/sqlx v1.3.5 @@ -95,7 +94,7 @@ require ( golang.org/x/net v0.14.0 golang.org/x/oauth2 v0.10.0 golang.org/x/text v0.12.0 - golang.org/x/tools v0.11.0 + golang.org/x/tools v0.12.0 google.golang.org/grpc v1.57.0 gopkg.in/dnaeon/go-vcr.v3 v3.1.2 gotest.tools/gotestsum v1.10.1 @@ -180,6 +179,7 @@ require ( github.com/jackc/pgproto3/v2 v2.3.2 // indirect github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect github.com/jackc/pgtype v1.14.0 // indirect + github.com/jackc/pgx/v4 v4.18.1 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/joho/godotenv v1.5.1 // indirect github.com/josharian/intern v1.0.0 // indirect diff --git a/go.sum b/go.sum index c3101dc5569..2714db8fe04 100644 --- a/go.sum +++ b/go.sum @@ -1161,8 +1161,8 @@ golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.11/go.mod h1:SgwaegtQh8clINPpECJMqnxLv9I09HLqnW3RMqW0CA4= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/tools v0.11.0 h1:EMCa6U9S2LtZXLAMoWiR/R8dAQFRqbAitmbJ2UKhoi8= -golang.org/x/tools v0.11.0/go.mod h1:anzJrxPjNtfgiYQYirP2CPGzGLxrH2u2QBhn6Bf3qY8= +golang.org/x/tools v0.12.0 h1:YW6HUoUmYBpwSgyaGaZq1fHjrBjX1rlpZ54T6mu2kss= +golang.org/x/tools v0.12.0/go.mod h1:Sc0INKfu04TlqNoRA1hgpFZbhYXHPr4V5DzpSBTPqQM= golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= From f75c5f5c0852e20e2c62d6755b3c601b674ee5c5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 25 Aug 2023 16:30:06 +0000 Subject: [PATCH 104/138] Bump go.uber.org/zap from 1.24.0 to 1.25.0 Bumps [go.uber.org/zap](https://github.com/uber-go/zap) from 1.24.0 to 1.25.0. - [Release notes](https://github.com/uber-go/zap/releases) - [Changelog](https://github.com/uber-go/zap/blob/master/CHANGELOG.md) - [Commits](https://github.com/uber-go/zap/compare/v1.24.0...v1.25.0) --- updated-dependencies: - dependency-name: go.uber.org/zap dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 5 ++--- go.sum | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index a499216dde1..25dc7e56a9b 100644 --- a/go.mod +++ b/go.mod @@ -51,7 +51,6 @@ require ( github.com/gorilla/csrf v1.7.1 github.com/imdario/mergo v0.3.16 github.com/jackc/pgerrcode v0.0.0-20220416144525-469b46aa5efa - github.com/jackc/pgx/v4 v4.18.1 github.com/jessevdk/go-flags v1.5.0 github.com/jinzhu/copier v0.3.5 github.com/jmoiron/sqlx v1.3.5 @@ -90,7 +89,7 @@ require ( go.opentelemetry.io/otel/sdk v1.16.0 go.opentelemetry.io/otel/sdk/metric v0.39.0 go.opentelemetry.io/otel/trace v1.16.0 - go.uber.org/zap v1.24.0 + go.uber.org/zap v1.25.0 golang.org/x/crypto v0.12.0 golang.org/x/net v0.14.0 golang.org/x/oauth2 v0.10.0 @@ -180,6 +179,7 @@ require ( github.com/jackc/pgproto3/v2 v2.3.2 // indirect github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect github.com/jackc/pgtype v1.14.0 // indirect + github.com/jackc/pgx/v4 v4.18.1 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/joho/godotenv v1.5.1 // indirect github.com/josharian/intern v1.0.0 // indirect @@ -231,7 +231,6 @@ require ( go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.16.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.39.0 // indirect go.opentelemetry.io/proto/otlp v0.19.0 // indirect - go.uber.org/atomic v1.11.0 // indirect go.uber.org/multierr v1.11.0 // indirect golang.org/x/exp v0.0.0-20230212135524-a684f29349b6 // indirect golang.org/x/image v0.5.0 // indirect diff --git a/go.sum b/go.sum index c3101dc5569..bf1ed2d1606 100644 --- a/go.sum +++ b/go.sum @@ -848,8 +848,6 @@ go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE= -go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= @@ -862,8 +860,9 @@ go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9E go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= -go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60= go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg= +go.uber.org/zap v1.25.0 h1:4Hvk6GtkucQ790dqmj7l1eEnRdKm3k3ZUrUMS2d5+5c= +go.uber.org/zap v1.25.0/go.mod h1:JIAUzQIH94IC4fOJQm7gMmBJP5k7wQfdcnYdPoEXJYk= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190411191339-88737f569e3a/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= From 21de17ca4fb482b17a6cd8765fbe231b8d07f866 Mon Sep 17 00:00:00 2001 From: Brandon Lenz Date: Fri, 25 Aug 2023 17:24:41 +0000 Subject: [PATCH 105/138] Update script to filter out rows without a loa_hs_gds_cd value --- .../load-updated-loa-trnsn-ids.py | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/cmd/load-spreadsheet-data/load-updated-loa-trnsn-ids.py b/cmd/load-spreadsheet-data/load-updated-loa-trnsn-ids.py index 022e0cec219..49e2fcb4f91 100644 --- a/cmd/load-spreadsheet-data/load-updated-loa-trnsn-ids.py +++ b/cmd/load-spreadsheet-data/load-updated-loa-trnsn-ids.py @@ -41,25 +41,32 @@ f.write('\tloa_trnsn_id = updated.loa_trnsn_id\n') f.write('FROM (VALUES\n') + has_written_at_least_one_value_to_file = False for index, row in input_file.iterrows(): loa_sys_id = row['LOA_SYS_ID'] + loa_hs_gds_cd = row['LOA_HS_GDS_CD'] + loa_trnsn_id = row['LOA_TRNSN_ID'] # Ignore rows where loa_sys_id is missing if loa_sys_id == 'NULL': continue + # Ignore rows where the loa_hs_gds_cd does not have a value, as we did during the original import + if loa_hs_gds_cd == 'NULL': + continue + # Add single quotes around non-null values, otherwise, just use NULL - loa_trnsn_id = row['LOA_TRNSN_ID'] loa_trnsn_id_write_value = loa_trnsn_id if loa_trnsn_id == 'NULL' else f"'{loa_trnsn_id}'" + if has_written_at_least_one_value_to_file: + # prepend next line with a comma and a newline + f.write(',\n') + f.write(f'\t({loa_sys_id}, {loa_trnsn_id_write_value})') - # only add a comma to rows that are not the last row - if index == len(input_file) - 1: - f.write('\n') - else: - f.write(',\n') + # Now that at least one entry has been added to the file, we know to prepend the rest with `,\n` + has_written_at_least_one_value_to_file = True - f.write(') AS updated(loa_sys_id, loa_trnsn_id)\n') + f.write('\n) AS updated(loa_sys_id, loa_trnsn_id)\n') f.write('WHERE updated.loa_sys_id = loas.loa_sys_id;\n') sys.exit() From aa2f0d3d720381ff6869918dd196a5b444193a82 Mon Sep 17 00:00:00 2001 From: Brandon Lenz Date: Fri, 25 Aug 2023 18:14:23 +0000 Subject: [PATCH 106/138] Greatly simplify filename generation --- .../load-updated-loa-trnsn-ids.py | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/cmd/load-spreadsheet-data/load-updated-loa-trnsn-ids.py b/cmd/load-spreadsheet-data/load-updated-loa-trnsn-ids.py index 49e2fcb4f91..de712353044 100644 --- a/cmd/load-spreadsheet-data/load-updated-loa-trnsn-ids.py +++ b/cmd/load-spreadsheet-data/load-updated-loa-trnsn-ids.py @@ -1,8 +1,6 @@ import os, sys, pandas as pd from datetime import datetime -ZERO = '0' - if len(sys.argv) < 2: sys.exit("Input file required.") @@ -10,14 +8,7 @@ # Generate to gitignored tmp directory to prevent committing secure data current_dir = os.getcwd() destination_directory = 'tmp/generated-secure-migrations' -now = datetime.now() -year = str(now.year).rjust(4, ZERO) -month = str(now.month).rjust(2, ZERO) -day = str(now.day).rjust(2, ZERO) -hour = str(now.hour).rjust(2, ZERO) -minute = str(now.minute).rjust(2, ZERO) -second = str(now.second).rjust(2, ZERO) -filename = f'{year}{month}{day}{hour}{minute}{second}_update_loa_trnsn_ids.up.sql' +filename = f"{datetime.now().strftime('%Y%m%d%H%M%S')}_update_loa_trnsn_ids.up.sql" secure_migration_filename = ( f'{current_dir}/{destination_directory}/{filename}' ) From 2e99fc0dd22bcd5550576fab5ebb3e9c04de115e Mon Sep 17 00:00:00 2001 From: Michael Valdes Date: Fri, 25 Aug 2023 21:58:41 +0000 Subject: [PATCH 107/138] Add linehaul rounding before escalation factoring --- pkg/services/ghcrateengine/pricer_helpers.go | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/pkg/services/ghcrateengine/pricer_helpers.go b/pkg/services/ghcrateengine/pricer_helpers.go index 218c95cc127..337ee18cec1 100644 --- a/pkg/services/ghcrateengine/pricer_helpers.go +++ b/pkg/services/ghcrateengine/pricer_helpers.go @@ -417,22 +417,31 @@ func createPricerGeneratedParams(appCtx appcontext.AppContext, paymentServiceIte // escalatePriceForContractYear calculates the escalated price from the base price, which is provided by the caller/pricer, // and the escalation factor, which is provided by the contract year. The result is rounded to the nearest cent, or to the -// nearest tenth-cent for linehaul prices. The contract year is also returned. +// nearest tenth-cent before and after the escalation factor for linehaul prices. The contract year is also returned. func escalatePriceForContractYear(appCtx appcontext.AppContext, contractID uuid.UUID, referenceDate time.Time, isLinehaul bool, basePrice float64) (float64, models.ReContractYear, error) { contractYear, err := fetchContractYear(appCtx, contractID, referenceDate) if err != nil { return 0, contractYear, fmt.Errorf("could not lookup contract year: %w", err) } - escalatedPrice := basePrice * contractYear.EscalationCompounded + escalatedPrice := basePrice // round escalated price to the nearest cent, or the nearest tenth-of-a-cent if linehaul precision := 0 if isLinehaul { precision = 1 + escalatedPrice = roundToPrecision(escalatedPrice, precision) } - ratio := math.Pow(10, float64(precision)) - escalatedPrice = math.Round(escalatedPrice*ratio) / ratio + escalatedPrice = escalatedPrice * contractYear.EscalationCompounded + + escalatedPrice = roundToPrecision(escalatedPrice, precision) return escalatedPrice, contractYear, nil } + +// roundToPrecision rounds a float64 value to the number of decimal points indicated by the precision. +// TODO: Future cleanup could involve moving this function to a math/utility package with some simple tests +func roundToPrecision(value float64, precision int) float64 { + ratio := math.Pow(10, float64(precision)) + return math.Round(value*ratio) / ratio +} From 064c23a9f682ae86cd9405a9181ff2bcb269995f Mon Sep 17 00:00:00 2001 From: Michael Valdes Date: Fri, 25 Aug 2023 22:00:01 +0000 Subject: [PATCH 108/138] Update linehaul test values so rounding matters --- .../ghcrateengine/domestic_linehaul_pricer_test.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pkg/services/ghcrateengine/domestic_linehaul_pricer_test.go b/pkg/services/ghcrateengine/domestic_linehaul_pricer_test.go index ce3e986f5b5..a7ade6b2f04 100644 --- a/pkg/services/ghcrateengine/domestic_linehaul_pricer_test.go +++ b/pkg/services/ghcrateengine/domestic_linehaul_pricer_test.go @@ -18,12 +18,12 @@ const ( dlhTestWeightUpper = unit.Pound(4999) dlhTestMilesLower = 1001 dlhTestMilesUpper = 1500 - dlhTestBasePriceMillicents = unit.Millicents(5100) + dlhTestBasePriceMillicents = unit.Millicents(5111) dlhTestContractYearName = "DLH Test Year" dlhTestEscalationCompounded = 1.04071 - dlhTestDistance = unit.Miles(1200) - dlhTestWeight = unit.Pound(4000) - dlhPriceCents = unit.Cents(254766) + dlhTestDistance = unit.Miles(1201) + dlhTestWeight = unit.Pound(4001) + dlhPriceCents = unit.Cents(255592) ) var dlhRequestedPickupDate = time.Date(testdatagen.TestYear, time.June, 5, 7, 33, 11, 456, time.UTC) @@ -32,6 +32,7 @@ func (suite *GHCRateEngineServiceSuite) TestPriceDomesticLinehaul() { linehaulServicePricer := NewDomesticLinehaulPricer() suite.Run("success using PaymentServiceItemParams", func() { + // serviceArea := "sa0" suite.setupDomesticLinehaulPrice(dlhTestServiceArea, dlhTestIsPeakPeriod, dlhTestWeightLower, dlhTestWeightUpper, dlhTestMilesLower, dlhTestMilesUpper, dlhTestBasePriceMillicents, dlhTestContractYearName, dlhTestEscalationCompounded) paymentServiceItem := suite.setupDomesticLinehaulServiceItem() priceCents, displayParams, err := linehaulServicePricer.PriceUsingParams(suite.AppContextForTest(), paymentServiceItem.PaymentServiceItemParams) @@ -86,7 +87,7 @@ func (suite *GHCRateEngineServiceSuite) TestPriceDomesticLinehaul() { // < 50 mile distance with PPM priceCents, _, err := linehaulServicePricer.Price(suite.AppContextForTest(), testdatagen.DefaultContractCode, dlhRequestedPickupDate, unit.Miles(49), dlhTestWeight, dlhTestServiceArea, isPPM) suite.NoError(err) - suite.Equal(unit.Cents(10403), priceCents) + suite.Equal(unit.Cents(10428), priceCents) }) suite.Run("successfully finds linehaul price for ppm with distance < 50 miles with PriceUsingParams method", func() { From eeb011780c985408a713e115c7929512451c0bf5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 28 Aug 2023 11:22:47 +0000 Subject: [PATCH 109/138] Bump github.com/DATA-DOG/go-txdb from 0.1.5 to 0.1.7 Bumps [github.com/DATA-DOG/go-txdb](https://github.com/DATA-DOG/go-txdb) from 0.1.5 to 0.1.7. - [Release notes](https://github.com/DATA-DOG/go-txdb/releases) - [Commits](https://github.com/DATA-DOG/go-txdb/compare/v0.1.5...v0.1.7) --- updated-dependencies: - dependency-name: github.com/DATA-DOG/go-txdb dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 4 ++-- go.sum | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index dbbbf57709b..f4a8cac3fa4 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/transcom/mymove go 1.20 require ( - github.com/DATA-DOG/go-txdb v0.1.5 + github.com/DATA-DOG/go-txdb v0.1.7 github.com/XSAM/otelsql v0.23.0 github.com/alexedwards/scs/redisstore v0.0.0-20221223131519-238b052508b6 github.com/alexedwards/scs/v2 v2.5.1 @@ -144,7 +144,7 @@ require ( github.com/go-openapi/jsonreference v0.20.2 // indirect github.com/go-playground/locales v0.14.1 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect - github.com/go-sql-driver/mysql v1.7.0 // indirect + github.com/go-sql-driver/mysql v1.7.1 // indirect github.com/gobuffalo/attrs v1.0.3 // indirect github.com/gobuffalo/genny/v2 v2.1.0 // indirect github.com/gobuffalo/github_flavored_markdown v1.1.4 // indirect diff --git a/go.sum b/go.sum index 2d4fd034c02..ed60fc399e6 100644 --- a/go.sum +++ b/go.sum @@ -48,8 +48,8 @@ github.com/0xAX/notificator v0.0.0-20220220101646-ee9b8921e557 h1:l6surSnJ3RP4qA github.com/0xAX/notificator v0.0.0-20220220101646-ee9b8921e557/go.mod h1:sTrmvD/TxuypdOERsDOS7SndZg0rzzcCi1b6wQMXUYM= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/DATA-DOG/go-txdb v0.1.5 h1:kKzz+LYk9qw1+fMyo8/9yDQiNXrJ2HbfX/TY61HkkB4= -github.com/DATA-DOG/go-txdb v0.1.5/go.mod h1:DhAhxMXZpUJVGnT+p9IbzJoRKvlArO2pkHjnGX7o0n0= +github.com/DATA-DOG/go-txdb v0.1.7 h1:ibr3YvD3SKI4oBPbXbmzsn7eCPlg9oFdDdFtsWCvy7Q= +github.com/DATA-DOG/go-txdb v0.1.7/go.mod h1:l06JaBQdV+y4aWAmDmWj4NwfnJknEXBxg8d4B8sJzXA= github.com/MarvinJWendt/testza v0.1.0/go.mod h1:7AxNvlfeHP7Z/hDQ5JtE3OKYT3XFUeLCDE2DQninSqs= github.com/MarvinJWendt/testza v0.2.1/go.mod h1:God7bhG8n6uQxwdScay+gjm9/LnO4D3kkcZX4hv9Rp8= github.com/MarvinJWendt/testza v0.2.8/go.mod h1:nwIcjmr0Zz+Rcwfh3/4UhBp7ePKVhuBExvZqnKYWlII= @@ -284,8 +284,9 @@ github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91 github.com/go-playground/validator/v10 v10.15.1 h1:BSe8uhN+xQ4r5guV/ywQI4gO59C2raYcGffYWZEjZzM= github.com/go-playground/validator/v10 v10.15.1/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU= github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= -github.com/go-sql-driver/mysql v1.7.0 h1:ueSltNNllEqE3qcWBTD0iQd3IpL/6U+mJxLkazJ7YPc= github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= +github.com/go-sql-driver/mysql v1.7.1 h1:lUIinVbN1DY0xBg0eMOzmmtGoHwWBbvnWubQUrtU8EI= +github.com/go-sql-driver/mysql v1.7.1/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/go-swagger/go-swagger v0.30.5 h1:SQ2+xSonWjjoEMOV5tcOnZJVlfyUfCBhGQGArS1b9+U= github.com/go-swagger/go-swagger v0.30.5/go.mod h1:cWUhSyCNqV7J1wkkxfr5QmbcnCewetCdvEXqgPvbc/Q= From 6b4e6e263ca21db4bea3e4d14bc8586154fd4425 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 28 Aug 2023 11:25:59 +0000 Subject: [PATCH 110/138] Bump github.com/aws/aws-sdk-go-v2/service/ses from 1.15.11 to 1.16.7 Bumps [github.com/aws/aws-sdk-go-v2/service/ses](https://github.com/aws/aws-sdk-go-v2) from 1.15.11 to 1.16.7. - [Release notes](https://github.com/aws/aws-sdk-go-v2/releases) - [Commits](https://github.com/aws/aws-sdk-go-v2/compare/config/v1.15.11...v1.16.7) --- updated-dependencies: - dependency-name: github.com/aws/aws-sdk-go-v2/service/ses dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index dbbbf57709b..eaa030852ba 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,7 @@ require ( github.com/aws/aws-sdk-go-v2/service/ecs v1.27.4 github.com/aws/aws-sdk-go-v2/service/rds v1.45.2 github.com/aws/aws-sdk-go-v2/service/s3 v1.35.0 - github.com/aws/aws-sdk-go-v2/service/ses v1.15.11 + github.com/aws/aws-sdk-go-v2/service/ses v1.16.7 github.com/aws/aws-sdk-go-v2/service/ssm v1.36.6 github.com/aws/aws-sdk-go-v2/service/sts v1.21.5 github.com/aws/smithy-go v1.14.2 diff --git a/go.sum b/go.sum index 2d4fd034c02..b746495a39b 100644 --- a/go.sum +++ b/go.sum @@ -124,8 +124,8 @@ github.com/aws/aws-sdk-go-v2/service/rds v1.45.2 h1:tKZ+n9/BTnNYXZo80nIoFes7QEbO github.com/aws/aws-sdk-go-v2/service/rds v1.45.2/go.mod h1:goBDR4OPrsnKpYyU0GHGcEnlTmL8O+eKGsWeyOAFJ5M= github.com/aws/aws-sdk-go-v2/service/s3 v1.35.0 h1:ya7fmrN2fE7s1P2gaPbNg5MTkERVWfsH8ToP1YC4Z9o= github.com/aws/aws-sdk-go-v2/service/s3 v1.35.0/go.mod h1:aVbf0sko/TsLWHx30c/uVu7c62+0EAJ3vbxaJga0xCw= -github.com/aws/aws-sdk-go-v2/service/ses v1.15.11 h1:7/MtUTSdIdZuW3jRWwDq5kKVihe+VwBGEjWkuZbhlFg= -github.com/aws/aws-sdk-go-v2/service/ses v1.15.11/go.mod h1:iI3tHe16kyXcYA6fcoct3hW1uB/XSoe46w29wupWwho= +github.com/aws/aws-sdk-go-v2/service/ses v1.16.7 h1:yK0opxuSyFWmS3pL+niGStVheVccYwCFTelVrQ2nSAo= +github.com/aws/aws-sdk-go-v2/service/ses v1.16.7/go.mod h1:2DezZ88AkYPNf3Qxf79s8bneDLzATTGVGD4Htjcyw8Y= github.com/aws/aws-sdk-go-v2/service/ssm v1.36.6 h1:/DEPQUCqR6UoJjW4a21gW9AqjFlRSTwyOmciNef19qI= github.com/aws/aws-sdk-go-v2/service/ssm v1.36.6/go.mod h1:NdyMyZH/FzmCaybTrVMBD0nTCGrs1G4cOPKHFywx9Ns= github.com/aws/aws-sdk-go-v2/service/sso v1.12.12/go.mod h1:HuCOxYsF21eKrerARYO6HapNeh9GBNq7fius2AcwodY= From d87399f9238f209ad4295079dd948994996678f4 Mon Sep 17 00:00:00 2001 From: Scott Ries Date: Mon, 28 Aug 2023 14:08:31 +0000 Subject: [PATCH 111/138] Add NS Mayport. --- migrations/app/migrations_manifest.txt | 1 + migrations/app/schema/20230808155723_add_ns_mayport.up.sql | 2 ++ 2 files changed, 3 insertions(+) create mode 100644 migrations/app/schema/20230808155723_add_ns_mayport.up.sql diff --git a/migrations/app/migrations_manifest.txt b/migrations/app/migrations_manifest.txt index 3d6584f7dad..1ce71316d23 100644 --- a/migrations/app/migrations_manifest.txt +++ b/migrations/app/migrations_manifest.txt @@ -842,3 +842,4 @@ 20230804161700_import_trdm_part_1.up.sql 20230807175944_import_trdm_part_2.up.sql 20230807180000_import_trdm_part_3.up.sql +20230808155723_add_ns_mayport.up.sql diff --git a/migrations/app/schema/20230808155723_add_ns_mayport.up.sql b/migrations/app/schema/20230808155723_add_ns_mayport.up.sql new file mode 100644 index 00000000000..2e21d8ac1fe --- /dev/null +++ b/migrations/app/schema/20230808155723_add_ns_mayport.up.sql @@ -0,0 +1,2 @@ +INSERT INTO addresses (id, street_address_1, city, state, postal_code, updated_at, created_at) VALUES ('430c50b4-cc87-42a6-9921-2010aa6d4ed3', 'n/a', 'Mayport', 'FL', '32233', now(), now()); +INSERT INTO duty_locations (id, address_id, name, affiliation, transportation_office_id, updated_at, created_at, provides_services_counseling) VALUES ('3bfe8068-f9d1-4c21-ac19-1c0a60dcd326', '430c50b4-cc87-42a6-9921-2010aa6d4ed3', 'NS Mayport, FL 32233', 'NAVY', 'f5ab88fe-47f8-4b58-99af-41067d6cb60d', now(), now(), 'TRUE'); From 4d3d08e72800163ac15af56517fa98bf2de17760 Mon Sep 17 00:00:00 2001 From: Scott Ries Date: Mon, 28 Aug 2023 14:58:23 +0000 Subject: [PATCH 112/138] Use an update on the address. --- migrations/app/schema/20230808155723_add_ns_mayport.up.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/migrations/app/schema/20230808155723_add_ns_mayport.up.sql b/migrations/app/schema/20230808155723_add_ns_mayport.up.sql index 2e21d8ac1fe..083c946e280 100644 --- a/migrations/app/schema/20230808155723_add_ns_mayport.up.sql +++ b/migrations/app/schema/20230808155723_add_ns_mayport.up.sql @@ -1,2 +1,2 @@ -INSERT INTO addresses (id, street_address_1, city, state, postal_code, updated_at, created_at) VALUES ('430c50b4-cc87-42a6-9921-2010aa6d4ed3', 'n/a', 'Mayport', 'FL', '32233', now(), now()); +UPDATE addresses SET postal_code = '32233' WHERE id = '430c50b4-cc87-42a6-9921-2010aa6d4ed3'; INSERT INTO duty_locations (id, address_id, name, affiliation, transportation_office_id, updated_at, created_at, provides_services_counseling) VALUES ('3bfe8068-f9d1-4c21-ac19-1c0a60dcd326', '430c50b4-cc87-42a6-9921-2010aa6d4ed3', 'NS Mayport, FL 32233', 'NAVY', 'f5ab88fe-47f8-4b58-99af-41067d6cb60d', now(), now(), 'TRUE'); From 13a4800abc0958ab84c31c14804ea57f49f9807c Mon Sep 17 00:00:00 2001 From: Scott Ries Date: Mon, 28 Aug 2023 15:01:13 +0000 Subject: [PATCH 113/138] Move the migration to secure. --- .../app/{schema => secure}/20230808155723_add_ns_mayport.up.sql | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename migrations/app/{schema => secure}/20230808155723_add_ns_mayport.up.sql (100%) diff --git a/migrations/app/schema/20230808155723_add_ns_mayport.up.sql b/migrations/app/secure/20230808155723_add_ns_mayport.up.sql similarity index 100% rename from migrations/app/schema/20230808155723_add_ns_mayport.up.sql rename to migrations/app/secure/20230808155723_add_ns_mayport.up.sql From 72eed438d65bd4f644466cc72ec38e80bb9378df Mon Sep 17 00:00:00 2001 From: Scott Ries Date: Mon, 28 Aug 2023 11:09:27 -0400 Subject: [PATCH 114/138] Update migrations/app/secure/20230808155723_add_ns_mayport.up.sql Co-authored-by: Roger Steve Ruiz --- migrations/app/secure/20230808155723_add_ns_mayport.up.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/migrations/app/secure/20230808155723_add_ns_mayport.up.sql b/migrations/app/secure/20230808155723_add_ns_mayport.up.sql index 083c946e280..d4d90ff2a29 100644 --- a/migrations/app/secure/20230808155723_add_ns_mayport.up.sql +++ b/migrations/app/secure/20230808155723_add_ns_mayport.up.sql @@ -1,2 +1,4 @@ +--- This migration is only expected to run in the STG environment. The other environments have a blank file. + UPDATE addresses SET postal_code = '32233' WHERE id = '430c50b4-cc87-42a6-9921-2010aa6d4ed3'; INSERT INTO duty_locations (id, address_id, name, affiliation, transportation_office_id, updated_at, created_at, provides_services_counseling) VALUES ('3bfe8068-f9d1-4c21-ac19-1c0a60dcd326', '430c50b4-cc87-42a6-9921-2010aa6d4ed3', 'NS Mayport, FL 32233', 'NAVY', 'f5ab88fe-47f8-4b58-99af-41067d6cb60d', now(), now(), 'TRUE'); From a228dfd1ff2547462f938972f51dad5b426690d0 Mon Sep 17 00:00:00 2001 From: Scott Ries Date: Mon, 28 Aug 2023 15:30:01 +0000 Subject: [PATCH 115/138] Update both records. --- migrations/app/secure/20230808155723_add_ns_mayport.up.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/migrations/app/secure/20230808155723_add_ns_mayport.up.sql b/migrations/app/secure/20230808155723_add_ns_mayport.up.sql index d4d90ff2a29..2376a466ee7 100644 --- a/migrations/app/secure/20230808155723_add_ns_mayport.up.sql +++ b/migrations/app/secure/20230808155723_add_ns_mayport.up.sql @@ -1,4 +1,4 @@ --- This migration is only expected to run in the STG environment. The other environments have a blank file. UPDATE addresses SET postal_code = '32233' WHERE id = '430c50b4-cc87-42a6-9921-2010aa6d4ed3'; -INSERT INTO duty_locations (id, address_id, name, affiliation, transportation_office_id, updated_at, created_at, provides_services_counseling) VALUES ('3bfe8068-f9d1-4c21-ac19-1c0a60dcd326', '430c50b4-cc87-42a6-9921-2010aa6d4ed3', 'NS Mayport, FL 32233', 'NAVY', 'f5ab88fe-47f8-4b58-99af-41067d6cb60d', now(), now(), 'TRUE'); +UPDATE duty_locations SET name = 'NS Mayport, FL 32233', provides_services_counseling = 'TRUE' where address_id = '430c50b4-cc87-42a6-9921-2010aa6d4ed3' From 171a7f05a1c7e20be3c3d1538a12221ddcc25ec3 Mon Sep 17 00:00:00 2001 From: Scott Ries Date: Mon, 28 Aug 2023 12:31:18 -0400 Subject: [PATCH 116/138] Update migrations/app/secure/20230808155723_add_ns_mayport.up.sql Co-authored-by: Roger Steve Ruiz --- migrations/app/secure/20230808155723_add_ns_mayport.up.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/migrations/app/secure/20230808155723_add_ns_mayport.up.sql b/migrations/app/secure/20230808155723_add_ns_mayport.up.sql index 2376a466ee7..4be6ec6f79e 100644 --- a/migrations/app/secure/20230808155723_add_ns_mayport.up.sql +++ b/migrations/app/secure/20230808155723_add_ns_mayport.up.sql @@ -1,4 +1,4 @@ --- This migration is only expected to run in the STG environment. The other environments have a blank file. UPDATE addresses SET postal_code = '32233' WHERE id = '430c50b4-cc87-42a6-9921-2010aa6d4ed3'; -UPDATE duty_locations SET name = 'NS Mayport, FL 32233', provides_services_counseling = 'TRUE' where address_id = '430c50b4-cc87-42a6-9921-2010aa6d4ed3' +UPDATE duty_locations SET name = 'NS Mayport, FL 32233', provides_services_counseling = 'TRUE' where address_id = '430c50b4-cc87-42a6-9921-2010aa6d4ed3'; From 5ee6d16f6f89ff94cb2877ccabda9ec153a3e24d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 28 Aug 2023 16:32:29 +0000 Subject: [PATCH 117/138] Bump github.com/aws/aws-sdk-go-v2/service/s3 from 1.35.0 to 1.38.5 Bumps [github.com/aws/aws-sdk-go-v2/service/s3](https://github.com/aws/aws-sdk-go-v2) from 1.35.0 to 1.38.5. - [Release notes](https://github.com/aws/aws-sdk-go-v2/releases) - [Commits](https://github.com/aws/aws-sdk-go-v2/compare/service/s3/v1.35.0...service/s3/v1.38.5) --- updated-dependencies: - dependency-name: github.com/aws/aws-sdk-go-v2/service/s3 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 12 ++++++------ go.sum | 24 ++++++++++++------------ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/go.mod b/go.mod index eaa030852ba..73018ccf3d8 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( github.com/aws/aws-sdk-go-v2/service/ecr v1.18.13 github.com/aws/aws-sdk-go-v2/service/ecs v1.27.4 github.com/aws/aws-sdk-go-v2/service/rds v1.45.2 - github.com/aws/aws-sdk-go-v2/service/s3 v1.35.0 + github.com/aws/aws-sdk-go-v2/service/s3 v1.38.5 github.com/aws/aws-sdk-go-v2/service/ses v1.16.7 github.com/aws/aws-sdk-go-v2/service/ssm v1.36.6 github.com/aws/aws-sdk-go-v2/service/sts v1.21.5 @@ -110,16 +110,16 @@ require ( github.com/Masterminds/semver/v3 v3.2.1 // indirect github.com/Masterminds/sprig/v3 v3.2.3 // indirect github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect - github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.10 // indirect + github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.13 // indirect github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.11 // indirect github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.41 // indirect github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.35 // indirect github.com/aws/aws-sdk-go-v2/internal/ini v1.3.35 // indirect - github.com/aws/aws-sdk-go-v2/internal/v4a v1.0.26 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.11 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.29 // indirect + github.com/aws/aws-sdk-go-v2/internal/v4a v1.1.4 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.14 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.36 // indirect github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.35 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.14.3 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.15.4 // indirect github.com/aws/aws-sdk-go-v2/service/sso v1.13.5 // indirect github.com/aws/aws-sdk-go-v2/service/ssooidc v1.15.5 // indirect github.com/aymerick/douceur v0.2.0 // indirect diff --git a/go.sum b/go.sum index b746495a39b..726b7d91fce 100644 --- a/go.sum +++ b/go.sum @@ -83,8 +83,8 @@ github.com/atomicgo/cursor v0.0.1/go.mod h1:cBON2QmmrysudxNBFthvMtN32r3jxVRIvzkU github.com/aws/aws-sdk-go-v2 v1.18.1/go.mod h1:uzbQtefpm44goOPmdKyAlXSNcwlRgF3ePWVW6EtJvvw= github.com/aws/aws-sdk-go-v2 v1.21.0 h1:gMT0IW+03wtYJhRqTVYn0wLzwdnK9sRMcxmtfGzRdJc= github.com/aws/aws-sdk-go-v2 v1.21.0/go.mod h1:/RfNgGmRxI+iFOB1OeJUyxiU+9s88k3pfHvDagGEp0M= -github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.10 h1:dK82zF6kkPeCo8J1e+tGx4JdvDIQzj7ygIoLg8WMuGs= -github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.10/go.mod h1:VeTZetY5KRJLuD/7fkQXMU6Mw7H5m/KP2J5Iy9osMno= +github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.13 h1:OPLEkmhXf6xFPiz0bLeDArZIDx1NNS4oJyG4nv3Gct0= +github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.13/go.mod h1:gpAbvyDGQFozTEmlTFO8XcQKHzubdq0LzRyJpG6MiXM= github.com/aws/aws-sdk-go-v2/config v1.18.27 h1:Az9uLwmssTE6OGTpsFqOnaGpLnKDqNYOJzWuC6UAYzA= github.com/aws/aws-sdk-go-v2/config v1.18.27/go.mod h1:0My+YgmkGxeqjXZb5BYme5pc4drjTnM+x1GJ3zv42Nw= github.com/aws/aws-sdk-go-v2/credentials v1.13.26/go.mod h1:GoXt2YC8jHUBbA4jr+W3JiemnIbkXOfxSXcisUsZ3os= @@ -103,27 +103,27 @@ github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.35 h1:SijA0mgjV8E+8G45lt github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.35/go.mod h1:SJC1nEVVva1g3pHAIdCp7QsRIkMmLAgoDquQ9Rr8kYw= github.com/aws/aws-sdk-go-v2/internal/ini v1.3.35 h1:LWA+3kDM8ly001vJ1X1waCuLJdtTl48gwkPKWy9sosI= github.com/aws/aws-sdk-go-v2/internal/ini v1.3.35/go.mod h1:0Eg1YjxE0Bhn56lx+SHJwCzhW+2JGtizsrx+lCqrfm0= -github.com/aws/aws-sdk-go-v2/internal/v4a v1.0.26 h1:wscW+pnn3J1OYnanMnza5ZVYXLX4cKk5rAvUAl4Qu+c= -github.com/aws/aws-sdk-go-v2/internal/v4a v1.0.26/go.mod h1:MtYiox5gvyB+OyP0Mr0Sm/yzbEAIPL9eijj/ouHAPw0= +github.com/aws/aws-sdk-go-v2/internal/v4a v1.1.4 h1:6lJvvkQ9HmbHZ4h/IEwclwv2mrTW8Uq1SOB/kXy0mfw= +github.com/aws/aws-sdk-go-v2/internal/v4a v1.1.4/go.mod h1:1PrKYwxTM+zjpw9Y41KFtoJCQrJ34Z47Y4VgVbfndjo= github.com/aws/aws-sdk-go-v2/service/cloudwatchevents v1.15.13 h1:pLQWDntUlaDO4jde6MqxOrCBKrYvlU11PJrIttEQPGA= github.com/aws/aws-sdk-go-v2/service/cloudwatchevents v1.15.13/go.mod h1:N0aDlGD0iO8/Hs1OAQ6cgYmIMz7EoY8BGXGLdv9n8qI= github.com/aws/aws-sdk-go-v2/service/ecr v1.18.13 h1:hF7MUVNjubetjggZDtn3AmqCJzD7EUi//tSdxMYPm7U= github.com/aws/aws-sdk-go-v2/service/ecr v1.18.13/go.mod h1:XwEFO35g0uN/SftK0asWxh8Rk6DOx37R83TmWe2tzEE= github.com/aws/aws-sdk-go-v2/service/ecs v1.27.4 h1:F1N0Eh5EGRRY9QpF+tMTkx8Wb59DkQWE91Xza/9dk1c= github.com/aws/aws-sdk-go-v2/service/ecs v1.27.4/go.mod h1:0irnFofeEZwT7uTjSkNVcSQJbWRqZ9BRoxhKjt1BObM= -github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.11 h1:y2+VQzC6Zh2ojtV2LoC0MNwHWc6qXv/j2vrQtlftkdA= -github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.11/go.mod h1:iV4q2hsqtNECrfmlXyord9u4zyuFEJX9eLgLpSPzWA8= -github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.29 h1:zZSLP3v3riMOP14H7b4XP0uyfREDQOYv2cqIrvTXDNQ= -github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.29/go.mod h1:z7EjRjVwZ6pWcWdI2H64dKttvzaP99jRIj5hphW0M5U= +github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.14 h1:m0QTSI6pZYJTk5WSKx3fm5cNW/DCicVzULBgU/6IyD0= +github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.14/go.mod h1:dDilntgHy9WnHXsh7dDtUPgHKEfTJIBUTHM8OWm0f/0= +github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.36 h1:eev2yZX7esGRjqRbnVk1UxMLw4CyVZDpZXRCcy75oQk= +github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.36/go.mod h1:lGnOkH9NJATw0XEPcAknFBj3zzNTEGRHtSw+CwC1YTg= github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.28/go.mod h1:jj7znCIg05jXlaGBlFMGP8+7UN3VtCkRBG2spnmRQkU= github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.35 h1:CdzPW9kKitgIiLV1+MHobfR5Xg25iYnyzWZhyQuSlDI= github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.35/go.mod h1:QGF2Rs33W5MaN9gYdEQOBBFPLwTZkEhRwI33f7KIG0o= -github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.14.3 h1:dBL3StFxHtpBzJJ/mNEsjXVgfO+7jR0dAIEwLqMapEA= -github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.14.3/go.mod h1:f1QyiAsvIv4B49DmCqrhlXqyaR+0IxMmyX+1P+AnzOM= +github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.15.4 h1:v0jkRigbSD6uOdwcaUQmgEwG1BkPfAPDqaeNt/29ghg= +github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.15.4/go.mod h1:LhTyt8J04LL+9cIt7pYJ5lbS/U98ZmXovLOR/4LUsk8= github.com/aws/aws-sdk-go-v2/service/rds v1.45.2 h1:tKZ+n9/BTnNYXZo80nIoFes7QEbOd/lnbp0EkPbHfUU= github.com/aws/aws-sdk-go-v2/service/rds v1.45.2/go.mod h1:goBDR4OPrsnKpYyU0GHGcEnlTmL8O+eKGsWeyOAFJ5M= -github.com/aws/aws-sdk-go-v2/service/s3 v1.35.0 h1:ya7fmrN2fE7s1P2gaPbNg5MTkERVWfsH8ToP1YC4Z9o= -github.com/aws/aws-sdk-go-v2/service/s3 v1.35.0/go.mod h1:aVbf0sko/TsLWHx30c/uVu7c62+0EAJ3vbxaJga0xCw= +github.com/aws/aws-sdk-go-v2/service/s3 v1.38.5 h1:A42xdtStObqy7NGvzZKpnyNXvoOmm+FENobZ0/ssHWk= +github.com/aws/aws-sdk-go-v2/service/s3 v1.38.5/go.mod h1:rDGMZA7f4pbmTtPOk5v5UM2lmX6UAbRnMDJeDvnH7AM= github.com/aws/aws-sdk-go-v2/service/ses v1.16.7 h1:yK0opxuSyFWmS3pL+niGStVheVccYwCFTelVrQ2nSAo= github.com/aws/aws-sdk-go-v2/service/ses v1.16.7/go.mod h1:2DezZ88AkYPNf3Qxf79s8bneDLzATTGVGD4Htjcyw8Y= github.com/aws/aws-sdk-go-v2/service/ssm v1.36.6 h1:/DEPQUCqR6UoJjW4a21gW9AqjFlRSTwyOmciNef19qI= From b20b5867f0ba2bc82d1c79996cfb23127060c364 Mon Sep 17 00:00:00 2001 From: Scott Ries Date: Mon, 28 Aug 2023 16:43:39 +0000 Subject: [PATCH 118/138] Revert to inserts. --- migrations/app/schema/20230808155723_add_ns_mayport.up.sql | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 migrations/app/schema/20230808155723_add_ns_mayport.up.sql diff --git a/migrations/app/schema/20230808155723_add_ns_mayport.up.sql b/migrations/app/schema/20230808155723_add_ns_mayport.up.sql new file mode 100644 index 00000000000..2e21d8ac1fe --- /dev/null +++ b/migrations/app/schema/20230808155723_add_ns_mayport.up.sql @@ -0,0 +1,2 @@ +INSERT INTO addresses (id, street_address_1, city, state, postal_code, updated_at, created_at) VALUES ('430c50b4-cc87-42a6-9921-2010aa6d4ed3', 'n/a', 'Mayport', 'FL', '32233', now(), now()); +INSERT INTO duty_locations (id, address_id, name, affiliation, transportation_office_id, updated_at, created_at, provides_services_counseling) VALUES ('3bfe8068-f9d1-4c21-ac19-1c0a60dcd326', '430c50b4-cc87-42a6-9921-2010aa6d4ed3', 'NS Mayport, FL 32233', 'NAVY', 'f5ab88fe-47f8-4b58-99af-41067d6cb60d', now(), now(), 'TRUE'); From 15f0083657fd44798e552eadcaa321ef8eaf9d6a Mon Sep 17 00:00:00 2001 From: Scott Ries Date: Mon, 28 Aug 2023 16:54:14 +0000 Subject: [PATCH 119/138] Revert to inserts. --- migrations/app/schema/20230808155723_add_ns_mayport.up.sql | 2 -- migrations/app/secure/20230808155723_add_ns_mayport.up.sql | 6 ++---- 2 files changed, 2 insertions(+), 6 deletions(-) delete mode 100644 migrations/app/schema/20230808155723_add_ns_mayport.up.sql diff --git a/migrations/app/schema/20230808155723_add_ns_mayport.up.sql b/migrations/app/schema/20230808155723_add_ns_mayport.up.sql deleted file mode 100644 index 2e21d8ac1fe..00000000000 --- a/migrations/app/schema/20230808155723_add_ns_mayport.up.sql +++ /dev/null @@ -1,2 +0,0 @@ -INSERT INTO addresses (id, street_address_1, city, state, postal_code, updated_at, created_at) VALUES ('430c50b4-cc87-42a6-9921-2010aa6d4ed3', 'n/a', 'Mayport', 'FL', '32233', now(), now()); -INSERT INTO duty_locations (id, address_id, name, affiliation, transportation_office_id, updated_at, created_at, provides_services_counseling) VALUES ('3bfe8068-f9d1-4c21-ac19-1c0a60dcd326', '430c50b4-cc87-42a6-9921-2010aa6d4ed3', 'NS Mayport, FL 32233', 'NAVY', 'f5ab88fe-47f8-4b58-99af-41067d6cb60d', now(), now(), 'TRUE'); diff --git a/migrations/app/secure/20230808155723_add_ns_mayport.up.sql b/migrations/app/secure/20230808155723_add_ns_mayport.up.sql index 4be6ec6f79e..2e21d8ac1fe 100644 --- a/migrations/app/secure/20230808155723_add_ns_mayport.up.sql +++ b/migrations/app/secure/20230808155723_add_ns_mayport.up.sql @@ -1,4 +1,2 @@ ---- This migration is only expected to run in the STG environment. The other environments have a blank file. - -UPDATE addresses SET postal_code = '32233' WHERE id = '430c50b4-cc87-42a6-9921-2010aa6d4ed3'; -UPDATE duty_locations SET name = 'NS Mayport, FL 32233', provides_services_counseling = 'TRUE' where address_id = '430c50b4-cc87-42a6-9921-2010aa6d4ed3'; +INSERT INTO addresses (id, street_address_1, city, state, postal_code, updated_at, created_at) VALUES ('430c50b4-cc87-42a6-9921-2010aa6d4ed3', 'n/a', 'Mayport', 'FL', '32233', now(), now()); +INSERT INTO duty_locations (id, address_id, name, affiliation, transportation_office_id, updated_at, created_at, provides_services_counseling) VALUES ('3bfe8068-f9d1-4c21-ac19-1c0a60dcd326', '430c50b4-cc87-42a6-9921-2010aa6d4ed3', 'NS Mayport, FL 32233', 'NAVY', 'f5ab88fe-47f8-4b58-99af-41067d6cb60d', now(), now(), 'TRUE'); From 51ce629e1d2ebc6b8db45b97d9a4f20a90167dad Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 28 Aug 2023 17:46:17 +0000 Subject: [PATCH 120/138] Bump github.com/aws/aws-sdk-go-v2/service/ssm from 1.36.6 to 1.37.5 Bumps [github.com/aws/aws-sdk-go-v2/service/ssm](https://github.com/aws/aws-sdk-go-v2) from 1.36.6 to 1.37.5. - [Release notes](https://github.com/aws/aws-sdk-go-v2/releases) - [Commits](https://github.com/aws/aws-sdk-go-v2/compare/service/ssm/v1.36.6...service/ssm/v1.37.5) --- updated-dependencies: - dependency-name: github.com/aws/aws-sdk-go-v2/service/ssm dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 73018ccf3d8..cd0bdd3da00 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,7 @@ require ( github.com/aws/aws-sdk-go-v2/service/rds v1.45.2 github.com/aws/aws-sdk-go-v2/service/s3 v1.38.5 github.com/aws/aws-sdk-go-v2/service/ses v1.16.7 - github.com/aws/aws-sdk-go-v2/service/ssm v1.36.6 + github.com/aws/aws-sdk-go-v2/service/ssm v1.37.5 github.com/aws/aws-sdk-go-v2/service/sts v1.21.5 github.com/aws/smithy-go v1.14.2 github.com/benbjohnson/clock v1.3.5 diff --git a/go.sum b/go.sum index 726b7d91fce..4222ee8dc19 100644 --- a/go.sum +++ b/go.sum @@ -126,8 +126,8 @@ github.com/aws/aws-sdk-go-v2/service/s3 v1.38.5 h1:A42xdtStObqy7NGvzZKpnyNXvoOmm github.com/aws/aws-sdk-go-v2/service/s3 v1.38.5/go.mod h1:rDGMZA7f4pbmTtPOk5v5UM2lmX6UAbRnMDJeDvnH7AM= github.com/aws/aws-sdk-go-v2/service/ses v1.16.7 h1:yK0opxuSyFWmS3pL+niGStVheVccYwCFTelVrQ2nSAo= github.com/aws/aws-sdk-go-v2/service/ses v1.16.7/go.mod h1:2DezZ88AkYPNf3Qxf79s8bneDLzATTGVGD4Htjcyw8Y= -github.com/aws/aws-sdk-go-v2/service/ssm v1.36.6 h1:/DEPQUCqR6UoJjW4a21gW9AqjFlRSTwyOmciNef19qI= -github.com/aws/aws-sdk-go-v2/service/ssm v1.36.6/go.mod h1:NdyMyZH/FzmCaybTrVMBD0nTCGrs1G4cOPKHFywx9Ns= +github.com/aws/aws-sdk-go-v2/service/ssm v1.37.5 h1:s9QR0F1W5+11lq04OJ/mihpRpA2VDFIHmu+ktgAbNfg= +github.com/aws/aws-sdk-go-v2/service/ssm v1.37.5/go.mod h1:JjBzoceyKkpQY3v1GPIdg6kHqUFHRJ7SDlwtwoH0Qh8= github.com/aws/aws-sdk-go-v2/service/sso v1.12.12/go.mod h1:HuCOxYsF21eKrerARYO6HapNeh9GBNq7fius2AcwodY= github.com/aws/aws-sdk-go-v2/service/sso v1.13.5 h1:oCvTFSDi67AX0pOX3PuPdGFewvLRU2zzFSrTsgURNo0= github.com/aws/aws-sdk-go-v2/service/sso v1.13.5/go.mod h1:fIAwKQKBFu90pBxx07BFOMJLpRUGu8VOzLJakeY+0K4= From aa7f1ebf59ea828fe8eb5da0372c4cbf743e9d3f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 28 Aug 2023 17:46:40 +0000 Subject: [PATCH 121/138] Bump github.com/aws/aws-sdk-go-v2/service/ecr from 1.18.13 to 1.19.5 Bumps [github.com/aws/aws-sdk-go-v2/service/ecr](https://github.com/aws/aws-sdk-go-v2) from 1.18.13 to 1.19.5. - [Release notes](https://github.com/aws/aws-sdk-go-v2/releases) - [Commits](https://github.com/aws/aws-sdk-go-v2/compare/config/v1.18.13...service/ecr/v1.19.5) --- updated-dependencies: - dependency-name: github.com/aws/aws-sdk-go-v2/service/ecr dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 73018ccf3d8..d39e9415480 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/aws/aws-sdk-go-v2/credentials v1.13.35 github.com/aws/aws-sdk-go-v2/feature/rds/auth v1.2.12 github.com/aws/aws-sdk-go-v2/service/cloudwatchevents v1.15.13 - github.com/aws/aws-sdk-go-v2/service/ecr v1.18.13 + github.com/aws/aws-sdk-go-v2/service/ecr v1.19.5 github.com/aws/aws-sdk-go-v2/service/ecs v1.27.4 github.com/aws/aws-sdk-go-v2/service/rds v1.45.2 github.com/aws/aws-sdk-go-v2/service/s3 v1.38.5 diff --git a/go.sum b/go.sum index 726b7d91fce..0c980badc8a 100644 --- a/go.sum +++ b/go.sum @@ -107,8 +107,8 @@ github.com/aws/aws-sdk-go-v2/internal/v4a v1.1.4 h1:6lJvvkQ9HmbHZ4h/IEwclwv2mrTW github.com/aws/aws-sdk-go-v2/internal/v4a v1.1.4/go.mod h1:1PrKYwxTM+zjpw9Y41KFtoJCQrJ34Z47Y4VgVbfndjo= github.com/aws/aws-sdk-go-v2/service/cloudwatchevents v1.15.13 h1:pLQWDntUlaDO4jde6MqxOrCBKrYvlU11PJrIttEQPGA= github.com/aws/aws-sdk-go-v2/service/cloudwatchevents v1.15.13/go.mod h1:N0aDlGD0iO8/Hs1OAQ6cgYmIMz7EoY8BGXGLdv9n8qI= -github.com/aws/aws-sdk-go-v2/service/ecr v1.18.13 h1:hF7MUVNjubetjggZDtn3AmqCJzD7EUi//tSdxMYPm7U= -github.com/aws/aws-sdk-go-v2/service/ecr v1.18.13/go.mod h1:XwEFO35g0uN/SftK0asWxh8Rk6DOx37R83TmWe2tzEE= +github.com/aws/aws-sdk-go-v2/service/ecr v1.19.5 h1:hg2/a7rE9dwYr+/DPNzHQ+IsHXLNt1NsQVUecBtA8os= +github.com/aws/aws-sdk-go-v2/service/ecr v1.19.5/go.mod h1:pGwmNL8hN0jpBfKfTbmu+Rl0bJkDhaGl+9PQLrZ4KLo= github.com/aws/aws-sdk-go-v2/service/ecs v1.27.4 h1:F1N0Eh5EGRRY9QpF+tMTkx8Wb59DkQWE91Xza/9dk1c= github.com/aws/aws-sdk-go-v2/service/ecs v1.27.4/go.mod h1:0irnFofeEZwT7uTjSkNVcSQJbWRqZ9BRoxhKjt1BObM= github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.14 h1:m0QTSI6pZYJTk5WSKx3fm5cNW/DCicVzULBgU/6IyD0= From 1eb1b94e4d8181101b9ba4dd4d23e61d726a86f9 Mon Sep 17 00:00:00 2001 From: Scott Ries Date: Mon, 28 Aug 2023 19:06:42 +0000 Subject: [PATCH 122/138] Update Mayport postal code. --- migrations/app/migrations_manifest.txt | 1 + migrations/app/secure/20230828180000_update_mayport_zip.up.sql | 3 +++ 2 files changed, 4 insertions(+) create mode 100644 migrations/app/secure/20230828180000_update_mayport_zip.up.sql diff --git a/migrations/app/migrations_manifest.txt b/migrations/app/migrations_manifest.txt index c34d42a0191..66c4b8f51a3 100644 --- a/migrations/app/migrations_manifest.txt +++ b/migrations/app/migrations_manifest.txt @@ -845,3 +845,4 @@ 20230808155723_add_ns_mayport.up.sql 20230822201206_add_fields_for_sit_to_mto_service_items.up.sql 20230824224954_ghc_domestic_transit_times_update_data_migration.up.sql +20230828180000_update_mayport_zip.up.sql diff --git a/migrations/app/secure/20230828180000_update_mayport_zip.up.sql b/migrations/app/secure/20230828180000_update_mayport_zip.up.sql new file mode 100644 index 00000000000..582feb032bb --- /dev/null +++ b/migrations/app/secure/20230828180000_update_mayport_zip.up.sql @@ -0,0 +1,3 @@ +-- This should only be updated on staging +UPDATE addresses SET postal_code = '32228' WHERE id = '430c50b4-cc87-42a6-9921-2010aa6d4ed3'; +UPDATE duty_locations SET name = 'NS Mayport, FL 32228' WHERE id = '3bfe8068-f9d1-4c21-ac19-1c0a60dcd326'; From 9c7972601594bbb634fd305c0a59d76b5a8cc47e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 28 Aug 2023 19:39:15 +0000 Subject: [PATCH 123/138] Bump github.com/aws/aws-sdk-go-v2/feature/rds/auth from 1.2.12 to 1.2.19 Bumps [github.com/aws/aws-sdk-go-v2/feature/rds/auth](https://github.com/aws/aws-sdk-go-v2) from 1.2.12 to 1.2.19. - [Release notes](https://github.com/aws/aws-sdk-go-v2/releases) - [Commits](https://github.com/aws/aws-sdk-go-v2/compare/service/ssmsap/v1.2.12...feature/rds/auth/v1.2.19) --- updated-dependencies: - dependency-name: github.com/aws/aws-sdk-go-v2/feature/rds/auth dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index d39e9415480..4443413805c 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/aws/aws-sdk-go-v2 v1.21.0 github.com/aws/aws-sdk-go-v2/config v1.18.27 github.com/aws/aws-sdk-go-v2/credentials v1.13.35 - github.com/aws/aws-sdk-go-v2/feature/rds/auth v1.2.12 + github.com/aws/aws-sdk-go-v2/feature/rds/auth v1.2.19 github.com/aws/aws-sdk-go-v2/service/cloudwatchevents v1.15.13 github.com/aws/aws-sdk-go-v2/service/ecr v1.19.5 github.com/aws/aws-sdk-go-v2/service/ecs v1.27.4 diff --git a/go.sum b/go.sum index 0c980badc8a..c7d1a09277c 100644 --- a/go.sum +++ b/go.sum @@ -93,8 +93,8 @@ github.com/aws/aws-sdk-go-v2/credentials v1.13.35/go.mod h1:o7rCaLtvK0hUggAGclf7 github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.4/go.mod h1:E1hLXN/BL2e6YizK1zFlYd8vsfi2GTjbjBazinMmeaM= github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.11 h1:uDZJF1hu0EVT/4bogChk8DyjSF6fof6uL/0Y26Ma7Fg= github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.11/go.mod h1:TEPP4tENqBGO99KwVpV9MlOX4NSrSLP8u3KRy2CDwA8= -github.com/aws/aws-sdk-go-v2/feature/rds/auth v1.2.12 h1:2v4gCEM/SfIMZiMT8luKNmgrngfZo61YPENzedO22n0= -github.com/aws/aws-sdk-go-v2/feature/rds/auth v1.2.12/go.mod h1:G5IqZWpdJ0wIV6URDOeFvpa0qEDz9GTn3uoPKU1EQCA= +github.com/aws/aws-sdk-go-v2/feature/rds/auth v1.2.19 h1:G2Lci4ZUQPyeAnuPSs1QQRx153Tcg4l28Iasnmd8F30= +github.com/aws/aws-sdk-go-v2/feature/rds/auth v1.2.19/go.mod h1:PwSqxzMM8n6tP98Dw/m8bc353aELMyYczvrCDDU6sbY= github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.34/go.mod h1:wZpTEecJe0Btj3IYnDx/VlUzor9wm3fJHyvLpQF0VwY= github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.41 h1:22dGT7PneFMx4+b3pz7lMTRyN8ZKH7M2cW4GP9yUS2g= github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.41/go.mod h1:CrObHAuPneJBlfEJ5T3szXOUkLEThaGfvnhTf33buas= From 3c97230b21b4cfd3f61532c4e735461b07053ac0 Mon Sep 17 00:00:00 2001 From: Scott Ries Date: Mon, 28 Aug 2023 20:46:20 +0000 Subject: [PATCH 124/138] Update SC value. --- migrations/app/migrations_manifest.txt | 1 + .../20230828180001_update_mayport_services_counseling.up.sql | 2 ++ 2 files changed, 3 insertions(+) create mode 100644 migrations/app/secure/20230828180001_update_mayport_services_counseling.up.sql diff --git a/migrations/app/migrations_manifest.txt b/migrations/app/migrations_manifest.txt index 66c4b8f51a3..faf6a4b2ae6 100644 --- a/migrations/app/migrations_manifest.txt +++ b/migrations/app/migrations_manifest.txt @@ -846,3 +846,4 @@ 20230822201206_add_fields_for_sit_to_mto_service_items.up.sql 20230824224954_ghc_domestic_transit_times_update_data_migration.up.sql 20230828180000_update_mayport_zip.up.sql +20230828180001_update_mayport_services_counseling.up.sql diff --git a/migrations/app/secure/20230828180001_update_mayport_services_counseling.up.sql b/migrations/app/secure/20230828180001_update_mayport_services_counseling.up.sql new file mode 100644 index 00000000000..870704cede6 --- /dev/null +++ b/migrations/app/secure/20230828180001_update_mayport_services_counseling.up.sql @@ -0,0 +1,2 @@ +-- This should only be updated on staging +UPDATE duty_locations SET provides_services_counseling = 'FALSE' WHERE id = '3bfe8068-f9d1-4c21-ac19-1c0a60dcd326'; From 08de23dd1e890a79d07008541c72d275ddffcd51 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 29 Aug 2023 11:53:55 +0000 Subject: [PATCH 125/138] Bump go.flipt.io/flipt/sdk/go from 0.3.0 to 0.5.0 Bumps [go.flipt.io/flipt/sdk/go](https://github.com/flipt-io/flipt) from 0.3.0 to 0.5.0. - [Release notes](https://github.com/flipt-io/flipt/releases) - [Changelog](https://github.com/flipt-io/flipt/blob/main/CHANGELOG.md) - [Commits](https://github.com/flipt-io/flipt/compare/v0.3.0...v0.5.0) --- updated-dependencies: - dependency-name: go.flipt.io/flipt/sdk/go dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index ce87b28ddfe..1ed295443c1 100644 --- a/go.mod +++ b/go.mod @@ -72,8 +72,8 @@ require ( github.com/tealeg/xlsx/v3 v3.3.0 github.com/tiaguinho/gosoap v1.4.4 github.com/vektra/mockery/v2 v2.33.0 - go.flipt.io/flipt/rpc/flipt v1.22.0 - go.flipt.io/flipt/sdk/go v0.3.0 + go.flipt.io/flipt/rpc/flipt v1.25.0 + go.flipt.io/flipt/sdk/go v0.5.0 go.mozilla.org/pkcs7 v0.0.0-20210826202110-33d05740a352 go.opentelemetry.io/contrib/detectors/aws/ecs v1.17.0 go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.42.0 diff --git a/go.sum b/go.sum index fc82789d600..211aa94dc34 100644 --- a/go.sum +++ b/go.sum @@ -802,10 +802,10 @@ github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5t github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q= go.flipt.io/flipt/errors v1.19.3 h1:mgQrT3XdambAdu4UykYZ3gm1NG7Ilri5Gt+nLafbJHY= go.flipt.io/flipt/errors v1.19.3/go.mod h1:I2loVwHUoXy+yT7suRx7+pDiSyO1G7CHu6bby9DywyA= -go.flipt.io/flipt/rpc/flipt v1.22.0 h1:SHXMNLKPEmghOV36zM6OHbwHsSdSOafvxPXnDYBZY9E= -go.flipt.io/flipt/rpc/flipt v1.22.0/go.mod h1:H/P7nl/5lMo8uWiXyYGFX5LcOGL0ycWnlcLx3eaxJG4= -go.flipt.io/flipt/sdk/go v0.3.0 h1:6n7HVsLw1ApOi5Kht1Q6Cr5GkOlIJH4uVrh30Qm/n6w= -go.flipt.io/flipt/sdk/go v0.3.0/go.mod h1:4EVLw2+2SzqjqeyTx+NOz2E7a2Fs0+A+ZZKLHs6YvIY= +go.flipt.io/flipt/rpc/flipt v1.25.0 h1:BkIYs3kro8rK1yXK3+jStRXvAzq8eO/7+JeioHNxoq0= +go.flipt.io/flipt/rpc/flipt v1.25.0/go.mod h1:H/P7nl/5lMo8uWiXyYGFX5LcOGL0ycWnlcLx3eaxJG4= +go.flipt.io/flipt/sdk/go v0.5.0 h1:HiFUJ403rMWchlvFjCUyZHrQTgr7x+2ArPiTczAvGk4= +go.flipt.io/flipt/sdk/go v0.5.0/go.mod h1:XF9JWsiK41mNg5aDT3b7bzFxWUsc3Te3Gy5Ok3aijHc= go.mongodb.org/mongo-driver v1.7.3/go.mod h1:NqaYOwnXWr5Pm7AOpO5QFxKJ503nbMse/R79oO62zWg= go.mongodb.org/mongo-driver v1.7.5/go.mod h1:VXEWRZ6URJIkUq2SCAyapmhH0ZLRBP+FT4xhp5Zvxng= go.mongodb.org/mongo-driver v1.10.0/go.mod h1:wsihk0Kdgv8Kqu1Anit4sfK+22vSFbUrAVEYRhCXrA8= From 2c9238d773180bf00b955fcad6572cf01d69ba46 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 29 Aug 2023 11:54:44 +0000 Subject: [PATCH 126/138] Bump github.com/aws/aws-sdk-go-v2/config from 1.18.27 to 1.18.37 Bumps [github.com/aws/aws-sdk-go-v2/config](https://github.com/aws/aws-sdk-go-v2) from 1.18.27 to 1.18.37. - [Release notes](https://github.com/aws/aws-sdk-go-v2/releases) - [Commits](https://github.com/aws/aws-sdk-go-v2/compare/config/v1.18.27...config/v1.18.37) --- updated-dependencies: - dependency-name: github.com/aws/aws-sdk-go-v2/config dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 4 ++-- go.sum | 13 ++++--------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/go.mod b/go.mod index ce87b28ddfe..bcfd73a8480 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/alexedwards/scs/redisstore v0.0.0-20221223131519-238b052508b6 github.com/alexedwards/scs/v2 v2.5.1 github.com/aws/aws-sdk-go-v2 v1.21.0 - github.com/aws/aws-sdk-go-v2/config v1.18.27 + github.com/aws/aws-sdk-go-v2/config v1.18.37 github.com/aws/aws-sdk-go-v2/credentials v1.13.35 github.com/aws/aws-sdk-go-v2/feature/rds/auth v1.2.19 github.com/aws/aws-sdk-go-v2/service/cloudwatchevents v1.15.13 @@ -114,7 +114,7 @@ require ( github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.11 // indirect github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.41 // indirect github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.35 // indirect - github.com/aws/aws-sdk-go-v2/internal/ini v1.3.35 // indirect + github.com/aws/aws-sdk-go-v2/internal/ini v1.3.42 // indirect github.com/aws/aws-sdk-go-v2/internal/v4a v1.1.4 // indirect github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.14 // indirect github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.36 // indirect diff --git a/go.sum b/go.sum index fc82789d600..5c2d0fdce37 100644 --- a/go.sum +++ b/go.sum @@ -85,12 +85,10 @@ github.com/aws/aws-sdk-go-v2 v1.21.0 h1:gMT0IW+03wtYJhRqTVYn0wLzwdnK9sRMcxmtfGzR github.com/aws/aws-sdk-go-v2 v1.21.0/go.mod h1:/RfNgGmRxI+iFOB1OeJUyxiU+9s88k3pfHvDagGEp0M= github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.13 h1:OPLEkmhXf6xFPiz0bLeDArZIDx1NNS4oJyG4nv3Gct0= github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.13/go.mod h1:gpAbvyDGQFozTEmlTFO8XcQKHzubdq0LzRyJpG6MiXM= -github.com/aws/aws-sdk-go-v2/config v1.18.27 h1:Az9uLwmssTE6OGTpsFqOnaGpLnKDqNYOJzWuC6UAYzA= -github.com/aws/aws-sdk-go-v2/config v1.18.27/go.mod h1:0My+YgmkGxeqjXZb5BYme5pc4drjTnM+x1GJ3zv42Nw= -github.com/aws/aws-sdk-go-v2/credentials v1.13.26/go.mod h1:GoXt2YC8jHUBbA4jr+W3JiemnIbkXOfxSXcisUsZ3os= +github.com/aws/aws-sdk-go-v2/config v1.18.37 h1:RNAfbPqw1CstCooHaTPhScz7z1PyocQj0UL+l95CgzI= +github.com/aws/aws-sdk-go-v2/config v1.18.37/go.mod h1:8AnEFxW9/XGKCbjYDCJy7iltVNyEI9Iu9qC21UzhhgQ= github.com/aws/aws-sdk-go-v2/credentials v1.13.35 h1:QpsNitYJu0GgvMBLUIYu9H4yryA5kMksjeIVQfgXrt8= github.com/aws/aws-sdk-go-v2/credentials v1.13.35/go.mod h1:o7rCaLtvK0hUggAGclf76mNGGkaG5a9KWlp+d9IpcV8= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.4/go.mod h1:E1hLXN/BL2e6YizK1zFlYd8vsfi2GTjbjBazinMmeaM= github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.11 h1:uDZJF1hu0EVT/4bogChk8DyjSF6fof6uL/0Y26Ma7Fg= github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.11/go.mod h1:TEPP4tENqBGO99KwVpV9MlOX4NSrSLP8u3KRy2CDwA8= github.com/aws/aws-sdk-go-v2/feature/rds/auth v1.2.19 h1:G2Lci4ZUQPyeAnuPSs1QQRx153Tcg4l28Iasnmd8F30= @@ -101,8 +99,8 @@ github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.41/go.mod h1:CrObHAuPne github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.28/go.mod h1:7VRpKQQedkfIEXb4k52I7swUnZP0wohVajJMRn3vsUw= github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.35 h1:SijA0mgjV8E+8G45ltVHs0fvKpTj8xmZJ3VwhGKtUSI= github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.35/go.mod h1:SJC1nEVVva1g3pHAIdCp7QsRIkMmLAgoDquQ9Rr8kYw= -github.com/aws/aws-sdk-go-v2/internal/ini v1.3.35 h1:LWA+3kDM8ly001vJ1X1waCuLJdtTl48gwkPKWy9sosI= -github.com/aws/aws-sdk-go-v2/internal/ini v1.3.35/go.mod h1:0Eg1YjxE0Bhn56lx+SHJwCzhW+2JGtizsrx+lCqrfm0= +github.com/aws/aws-sdk-go-v2/internal/ini v1.3.42 h1:GPUcE/Yq7Ur8YSUk6lVkoIMWnJNO0HT18GUzCWCgCI0= +github.com/aws/aws-sdk-go-v2/internal/ini v1.3.42/go.mod h1:rzfdUlfA+jdgLDmPKjd3Chq9V7LVLYo1Nz++Wb91aRo= github.com/aws/aws-sdk-go-v2/internal/v4a v1.1.4 h1:6lJvvkQ9HmbHZ4h/IEwclwv2mrTW8Uq1SOB/kXy0mfw= github.com/aws/aws-sdk-go-v2/internal/v4a v1.1.4/go.mod h1:1PrKYwxTM+zjpw9Y41KFtoJCQrJ34Z47Y4VgVbfndjo= github.com/aws/aws-sdk-go-v2/service/cloudwatchevents v1.15.13 h1:pLQWDntUlaDO4jde6MqxOrCBKrYvlU11PJrIttEQPGA= @@ -128,13 +126,10 @@ github.com/aws/aws-sdk-go-v2/service/ses v1.16.7 h1:yK0opxuSyFWmS3pL+niGStVheVcc github.com/aws/aws-sdk-go-v2/service/ses v1.16.7/go.mod h1:2DezZ88AkYPNf3Qxf79s8bneDLzATTGVGD4Htjcyw8Y= github.com/aws/aws-sdk-go-v2/service/ssm v1.37.5 h1:s9QR0F1W5+11lq04OJ/mihpRpA2VDFIHmu+ktgAbNfg= github.com/aws/aws-sdk-go-v2/service/ssm v1.37.5/go.mod h1:JjBzoceyKkpQY3v1GPIdg6kHqUFHRJ7SDlwtwoH0Qh8= -github.com/aws/aws-sdk-go-v2/service/sso v1.12.12/go.mod h1:HuCOxYsF21eKrerARYO6HapNeh9GBNq7fius2AcwodY= github.com/aws/aws-sdk-go-v2/service/sso v1.13.5 h1:oCvTFSDi67AX0pOX3PuPdGFewvLRU2zzFSrTsgURNo0= github.com/aws/aws-sdk-go-v2/service/sso v1.13.5/go.mod h1:fIAwKQKBFu90pBxx07BFOMJLpRUGu8VOzLJakeY+0K4= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.12/go.mod h1:E4VrHCPzmVB/KFXtqBGKb3c8zpbNBgKe3fisDNLAW5w= github.com/aws/aws-sdk-go-v2/service/ssooidc v1.15.5 h1:dnInJb4S0oy8aQuri1mV6ipLlnZPfnsDNB9BGO9PDNY= github.com/aws/aws-sdk-go-v2/service/ssooidc v1.15.5/go.mod h1:yygr8ACQRY2PrEcy3xsUI357stq2AxnFM6DIsR9lij4= -github.com/aws/aws-sdk-go-v2/service/sts v1.19.2/go.mod h1:dp0yLPsLBOi++WTxzCjA/oZqi6NPIhoR+uF7GeMU9eg= github.com/aws/aws-sdk-go-v2/service/sts v1.21.5 h1:CQBFElb0LS8RojMJlxRSo/HXipvTZW2S44Lt9Mk2aYQ= github.com/aws/aws-sdk-go-v2/service/sts v1.21.5/go.mod h1:VC7JDqsqiwXukYEDjoHh9U0fOJtNWh04FPQz4ct4GGU= github.com/aws/smithy-go v1.13.5/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= From e2bfd5c42bdc0b2c89b215024514f496c85343bc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 29 Aug 2023 11:54:51 +0000 Subject: [PATCH 127/138] Bump go.opentelemetry.io/otel/trace from 1.16.0 to 1.17.0 Bumps [go.opentelemetry.io/otel/trace](https://github.com/open-telemetry/opentelemetry-go) from 1.16.0 to 1.17.0. - [Release notes](https://github.com/open-telemetry/opentelemetry-go/releases) - [Changelog](https://github.com/open-telemetry/opentelemetry-go/blob/main/CHANGELOG.md) - [Commits](https://github.com/open-telemetry/opentelemetry-go/compare/v1.16.0...v1.17.0) --- updated-dependencies: - dependency-name: go.opentelemetry.io/otel/trace dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 6 +++--- go.sum | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index ce87b28ddfe..438029b55ac 100644 --- a/go.mod +++ b/go.mod @@ -79,16 +79,16 @@ require ( go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.42.0 go.opentelemetry.io/contrib/instrumentation/runtime v0.42.0 go.opentelemetry.io/contrib/propagators/aws v1.17.0 - go.opentelemetry.io/otel v1.16.0 + go.opentelemetry.io/otel v1.17.0 go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v0.39.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.16.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.16.0 go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v0.39.0 go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.16.0 - go.opentelemetry.io/otel/metric v1.16.0 + go.opentelemetry.io/otel/metric v1.17.0 go.opentelemetry.io/otel/sdk v1.16.0 go.opentelemetry.io/otel/sdk/metric v0.39.0 - go.opentelemetry.io/otel/trace v1.16.0 + go.opentelemetry.io/otel/trace v1.17.0 go.uber.org/zap v1.25.0 golang.org/x/crypto v0.12.0 golang.org/x/net v0.14.0 diff --git a/go.sum b/go.sum index fc82789d600..6a8a4f623a1 100644 --- a/go.sum +++ b/go.sum @@ -827,8 +827,8 @@ go.opentelemetry.io/contrib/instrumentation/runtime v0.42.0 h1:EbmAUG9hEAMXyfWEa go.opentelemetry.io/contrib/instrumentation/runtime v0.42.0/go.mod h1:rD9feqRYP24P14t5kmhNMqsqm1jvKmpx2H2rKVw52V8= go.opentelemetry.io/contrib/propagators/aws v1.17.0 h1:IX8d7l2uRw61BlmZBOTQFaK+y22j6vytMVTs9wFrO+c= go.opentelemetry.io/contrib/propagators/aws v1.17.0/go.mod h1:pAlCYRWff4uGqRXOVn3WP8pDZ5E0K56bEoG7a1VSL4k= -go.opentelemetry.io/otel v1.16.0 h1:Z7GVAX/UkAXPKsy94IU+i6thsQS4nb7LviLpnaNeW8s= -go.opentelemetry.io/otel v1.16.0/go.mod h1:vl0h9NUa1D5s1nv3A5vZOYWn8av4K8Ml6JDeHrT/bx4= +go.opentelemetry.io/otel v1.17.0 h1:MW+phZ6WZ5/uk2nd93ANk/6yJ+dVrvNWUjGhnnFU5jM= +go.opentelemetry.io/otel v1.17.0/go.mod h1:I2vmBGtFaODIVMBSTPVDlJSzBDNf93k60E6Ft0nyjo0= go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.16.0 h1:t4ZwRPU+emrcvM2e9DHd0Fsf0JTPVcbfa/BhTDF03d0= go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.16.0/go.mod h1:vLarbg68dH2Wa77g71zmKQqlQ8+8Rq3GRG31uc0WcWI= go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.39.0 h1:f6BwB2OACc3FCbYVznctQ9V6KK7Vq6CjmYXJ7DeSs4E= @@ -843,14 +843,14 @@ go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v0.39.0 h1:fl2WmyenEf6LYY go.opentelemetry.io/otel/exporters/stdout/stdoutmetric v0.39.0/go.mod h1:csyQxQ0UHHKVA8KApS7eUO/klMO5sd/av5CNZNU4O6w= go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.16.0 h1:+XWJd3jf75RXJq29mxbuXhCXFDG3S3R4vBUeSI2P7tE= go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.16.0/go.mod h1:hqgzBPTf4yONMFgdZvL/bK42R/iinTyVQtiWihs3SZc= -go.opentelemetry.io/otel/metric v1.16.0 h1:RbrpwVG1Hfv85LgnZ7+txXioPDoh6EdbZHo26Q3hqOo= -go.opentelemetry.io/otel/metric v1.16.0/go.mod h1:QE47cpOmkwipPiefDwo2wDzwJrlfxxNYodqc4xnGCo4= +go.opentelemetry.io/otel/metric v1.17.0 h1:iG6LGVz5Gh+IuO0jmgvpTB6YVrCGngi8QGm+pMd8Pdc= +go.opentelemetry.io/otel/metric v1.17.0/go.mod h1:h4skoxdZI17AxwITdmdZjjYJQH5nzijUUjm+wtPph5o= go.opentelemetry.io/otel/sdk v1.16.0 h1:Z1Ok1YsijYL0CSJpHt4cS3wDDh7p572grzNrBMiMWgE= go.opentelemetry.io/otel/sdk v1.16.0/go.mod h1:tMsIuKXuuIWPBAOrH+eHtvhTL+SntFtXF9QD68aP6p4= go.opentelemetry.io/otel/sdk/metric v0.39.0 h1:Kun8i1eYf48kHH83RucG93ffz0zGV1sh46FAScOTuDI= go.opentelemetry.io/otel/sdk/metric v0.39.0/go.mod h1:piDIRgjcK7u0HCL5pCA4e74qpK/jk3NiUoAHATVAmiI= -go.opentelemetry.io/otel/trace v1.16.0 h1:8JRpaObFoW0pxuVPapkgH8UhHQj+bJW8jJsCZEu5MQs= -go.opentelemetry.io/otel/trace v1.16.0/go.mod h1:Yt9vYq1SdNz3xdjZZK7wcXv1qv2pwLkqr2QVwea0ef0= +go.opentelemetry.io/otel/trace v1.17.0 h1:/SWhSRHmDPOImIAetP1QAeMnZYiQXrTy4fMMYOdSKWQ= +go.opentelemetry.io/otel/trace v1.17.0/go.mod h1:I/4vKTgFclIsXRVucpH25X0mpFSczM7aHeaz0ZBLWjY= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.opentelemetry.io/proto/otlp v0.19.0 h1:IVN6GR+mhC4s5yfcTbmzHYODqvWAp3ZedA2SJPI1Nnw= go.opentelemetry.io/proto/otlp v0.19.0/go.mod h1:H7XAot3MsfNsj7EXtrA2q5xSNQ10UqI405h3+duxN4U= From 60d942a6f0562227a2907470a8899d49fcf7f575 Mon Sep 17 00:00:00 2001 From: Andrew Hobson Date: Tue, 29 Aug 2023 12:49:50 +0000 Subject: [PATCH 128/138] Fix another chuck -> chunk reload thinko --- src/utils/retryPageLoading.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/retryPageLoading.js b/src/utils/retryPageLoading.js index 75291e5721c..dd04b2feac2 100644 --- a/src/utils/retryPageLoading.js +++ b/src/utils/retryPageLoading.js @@ -1,7 +1,7 @@ const MilmoveHasBeenForceRefreshed = 'milmove-has-been-force-refreshed'; export const retryPageLoading = (error) => { - // if we see a chuck load error, try to reload the window to get + // if we see a chunk load error, try to reload the window to get // the latest version of the code if (!!error && error.name === 'ChunkLoadError' && !!window) { const pageHasAlreadyBeenForceRefreshed = window.localStorage.getItem(MilmoveHasBeenForceRefreshed) === 'true'; From 4509d65742254f86002a3eb9dc7cb41acdab5d39 Mon Sep 17 00:00:00 2001 From: Michael Valdes Date: Mon, 28 Aug 2023 20:31:04 +0000 Subject: [PATCH 129/138] Standardize messages for escalated price errors --- .../domestic_destination_shuttling_pricer_test.go | 2 +- .../domestic_origin_shuttling_pricer_test.go | 2 +- .../ghcrateengine/domestic_shorthaul_pricer.go | 2 +- .../ghcrateengine/domestic_shorthaul_pricer_test.go | 2 +- pkg/services/ghcrateengine/pricer_helpers.go | 12 ++++++------ pkg/services/ghcrateengine/pricer_helpers_test.go | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/pkg/services/ghcrateengine/domestic_destination_shuttling_pricer_test.go b/pkg/services/ghcrateengine/domestic_destination_shuttling_pricer_test.go index b31f260d279..1f2c7e2de39 100644 --- a/pkg/services/ghcrateengine/domestic_destination_shuttling_pricer_test.go +++ b/pkg/services/ghcrateengine/domestic_destination_shuttling_pricer_test.go @@ -75,7 +75,7 @@ func (suite *GHCRateEngineServiceSuite) TestDomesticDestinationShuttlingPricer() twoYearsLaterPickupDate := ddshutTestRequestedPickupDate.AddDate(2, 0, 0) _, _, err := pricer.Price(suite.AppContextForTest(), testdatagen.DefaultContractCode, twoYearsLaterPickupDate, ddshutTestWeight, ddshutTestServiceSchedule) suite.Error(err) - suite.Contains(err.Error(), "unable to calculate escalated total price") + suite.Contains(err.Error(), "could not calculate escalated price") }) } diff --git a/pkg/services/ghcrateengine/domestic_origin_shuttling_pricer_test.go b/pkg/services/ghcrateengine/domestic_origin_shuttling_pricer_test.go index b8b1ea64313..7ed1540e0fa 100644 --- a/pkg/services/ghcrateengine/domestic_origin_shuttling_pricer_test.go +++ b/pkg/services/ghcrateengine/domestic_origin_shuttling_pricer_test.go @@ -75,7 +75,7 @@ func (suite *GHCRateEngineServiceSuite) TestDomesticOriginShuttlingPricer() { twoYearsLaterPickupDate := doshutTestRequestedPickupDate.AddDate(2, 0, 0) _, _, err := pricer.Price(suite.AppContextForTest(), testdatagen.DefaultContractCode, twoYearsLaterPickupDate, doshutTestWeight, doshutTestServiceSchedule) suite.Error(err) - suite.Contains(err.Error(), "unable to calculate escalated total price: could not lookup contract year") + suite.Contains(err.Error(), "could not calculate escalated price") }) } diff --git a/pkg/services/ghcrateengine/domestic_shorthaul_pricer.go b/pkg/services/ghcrateengine/domestic_shorthaul_pricer.go index 3882d55dcef..80846b04718 100644 --- a/pkg/services/ghcrateengine/domestic_shorthaul_pricer.go +++ b/pkg/services/ghcrateengine/domestic_shorthaul_pricer.go @@ -57,7 +57,7 @@ func (p domesticShorthaulPricer) Price(appCtx appcontext.AppContext, contractCod basePrice := domServiceAreaPrice.PriceCents.Float64() * distance.Float64() * weight.ToCWTFloat64() escalatedPrice, contractYear, err := escalatePriceForContractYear(appCtx, domServiceAreaPrice.ContractID, referenceDate, false, basePrice) if err != nil { - return 0, nil, fmt.Errorf("could not look up escalated price: %w", err) + return 0, nil, fmt.Errorf("could not calculate escalated price: %w", err) } totalCost = unit.Cents(math.Round(escalatedPrice)) diff --git a/pkg/services/ghcrateengine/domestic_shorthaul_pricer_test.go b/pkg/services/ghcrateengine/domestic_shorthaul_pricer_test.go index 853d359803c..8ecbdb14d75 100644 --- a/pkg/services/ghcrateengine/domestic_shorthaul_pricer_test.go +++ b/pkg/services/ghcrateengine/domestic_shorthaul_pricer_test.go @@ -198,7 +198,7 @@ func (suite *GHCRateEngineServiceSuite) TestPriceDomesticShorthaul() { suite.Error(err) suite.Nil(rateEngineParams) - suite.Contains(err.Error(), "could not look up escalated price") + suite.Contains(err.Error(), "could not calculate escalated price") }) suite.Run("weight below minimum", func() { diff --git a/pkg/services/ghcrateengine/pricer_helpers.go b/pkg/services/ghcrateengine/pricer_helpers.go index 337ee18cec1..1df9484286a 100644 --- a/pkg/services/ghcrateengine/pricer_helpers.go +++ b/pkg/services/ghcrateengine/pricer_helpers.go @@ -54,7 +54,7 @@ func priceDomesticPackUnpack(appCtx appcontext.AppContext, packUnpackCode models basePrice := domOtherPrice.PriceCents.Float64() * finalWeight.ToCWTFloat64() escalatedPrice, contractYear, err := escalatePriceForContractYear(appCtx, domOtherPrice.ContractID, referenceDate, false, basePrice) if err != nil { - return 0, nil, fmt.Errorf("unable to calculate escalated total price: %w", err) + return 0, nil, fmt.Errorf("could not calculate escalated price: %w", err) } displayParams := services.PricingDisplayParams{ @@ -122,7 +122,7 @@ func priceDomesticFirstDaySIT(appCtx appcontext.AppContext, firstDaySITCode mode baseTotalPrice := serviceAreaPrice.PriceCents.Float64() * weight.ToCWTFloat64() escalatedPrice, contractYear, err := escalatePriceForContractYear(appCtx, serviceAreaPrice.ContractID, referenceDate, false, baseTotalPrice) if err != nil { - return 0, nil, fmt.Errorf("unable to calculate escalated total price: %w", err) + return 0, nil, fmt.Errorf("could not calculate escalated price: %w", err) } totalPriceCents := unit.Cents(math.Round(escalatedPrice)) @@ -159,7 +159,7 @@ func priceDomesticAdditionalDaysSIT(appCtx appcontext.AppContext, additionalDayS baseTotalPrice := serviceAreaPrice.PriceCents.Float64() * weight.ToCWTFloat64() escalatedTotalPrice, contractYear, err := escalatePriceForContractYear(appCtx, serviceAreaPrice.ContractID, referenceDate, false, baseTotalPrice) if err != nil { - return 0, nil, fmt.Errorf("unable to calculate escalated total price: %w", err) + return 0, nil, fmt.Errorf("could not calculate escalated price: %w", err) } totalForNumberOfDaysPrice := escalatedTotalPrice * float64(numberOfDaysInSIT) @@ -260,7 +260,7 @@ func priceDomesticPickupDeliverySIT(appCtx appcontext.AppContext, pickupDelivery baseTotalPrice := domOtherPrice.PriceCents.Float64() * weight.ToCWTFloat64() escalatedTotalPrice, contractYear, err := escalatePriceForContractYear(appCtx, domOtherPrice.ContractID, referenceDate, false, baseTotalPrice) if err != nil { - return 0, nil, fmt.Errorf("unable to calculate escalated total price: %w", err) + return 0, nil, fmt.Errorf("could not calculate escalated price: %w", err) } totalPriceCents := unit.Cents(math.Round(escalatedTotalPrice)) @@ -313,7 +313,7 @@ func priceDomesticShuttling(appCtx appcontext.AppContext, shuttlingCode models.R basePrice := domAccessorialPrice.PerUnitCents.Float64() * weight.ToCWTFloat64() escalatedPrice, contractYear, err := escalatePriceForContractYear(appCtx, domAccessorialPrice.ContractID, referenceDate, false, basePrice) if err != nil { - return 0, nil, fmt.Errorf("unable to calculate escalated total price: %w", err) + return 0, nil, fmt.Errorf("could not calculate escalated price: %w", err) } totalCost := unit.Cents(math.Round(escalatedPrice)) @@ -350,7 +350,7 @@ func priceDomesticCrating(appCtx appcontext.AppContext, code models.ReServiceCod basePrice := domAccessorialPrice.PerUnitCents.Float64() * float64(billedCubicFeet) escalatedPrice, contractYear, err := escalatePriceForContractYear(appCtx, domAccessorialPrice.ContractID, referenceDate, false, basePrice) if err != nil { - return 0, nil, fmt.Errorf("unable to calculate escalated total price: %w", err) + return 0, nil, fmt.Errorf("could not calculate escalated price: %w", err) } totalCost := unit.Cents(math.Round(escalatedPrice)) diff --git a/pkg/services/ghcrateengine/pricer_helpers_test.go b/pkg/services/ghcrateengine/pricer_helpers_test.go index b3054a5e265..389535de055 100644 --- a/pkg/services/ghcrateengine/pricer_helpers_test.go +++ b/pkg/services/ghcrateengine/pricer_helpers_test.go @@ -553,7 +553,7 @@ func (suite *GHCRateEngineServiceSuite) Test_priceDomesticShuttling() { _, _, err := priceDomesticShuttling(suite.AppContextForTest(), models.ReServiceCodeDDSHUT, testdatagen.DefaultContractCode, twoYearsLaterPickupDate, ddshutTestWeight, ddshutTestServiceSchedule) suite.Error(err) - suite.Contains(err.Error(), "unable to calculate escalated total price: could not lookup contract year") + suite.Contains(err.Error(), "could not calculate escalated price: could not lookup contract year") }) } func (suite *GHCRateEngineServiceSuite) Test_priceDomesticCrating() { From f013be9f992c617ff2dc601ca37d3650871a101d Mon Sep 17 00:00:00 2001 From: Michael Valdes Date: Tue, 29 Aug 2023 15:20:22 +0000 Subject: [PATCH 130/138] Finish standardizing escalate price error messages --- pkg/services/ghcrateengine/domestic_destination_pricer.go | 2 +- pkg/services/ghcrateengine/domestic_destination_pricer_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/services/ghcrateengine/domestic_destination_pricer.go b/pkg/services/ghcrateengine/domestic_destination_pricer.go index 10d1db3395b..0bbfb8fbcef 100644 --- a/pkg/services/ghcrateengine/domestic_destination_pricer.go +++ b/pkg/services/ghcrateengine/domestic_destination_pricer.go @@ -53,7 +53,7 @@ func (p domesticDestinationPricer) Price(appCtx appcontext.AppContext, contractC basePrice := domServiceAreaPrice.PriceCents.Float64() * finalWeight.ToCWTFloat64() escalatedPrice, contractYear, err := escalatePriceForContractYear(appCtx, domServiceAreaPrice.ContractID, referenceDate, false, basePrice) if err != nil { - return 0, nil, fmt.Errorf("unable to calculate escalated total price: %w", err) + return 0, nil, fmt.Errorf("could not calculate escalated price: %w", err) } totalCost := unit.Cents(math.Round(escalatedPrice)) diff --git a/pkg/services/ghcrateengine/domestic_destination_pricer_test.go b/pkg/services/ghcrateengine/domestic_destination_pricer_test.go index 38c2d90516e..175892481fb 100644 --- a/pkg/services/ghcrateengine/domestic_destination_pricer_test.go +++ b/pkg/services/ghcrateengine/domestic_destination_pricer_test.go @@ -226,7 +226,7 @@ func (suite *GHCRateEngineServiceSuite) TestPriceDomesticDestination() { ) suite.Error(err) - suite.Contains(err.Error(), "unable to calculate escalated total price") + suite.Contains(err.Error(), "could not calculate escalated price") }) From ffc1077d266ef54c693db9558a2655b0382bbfba Mon Sep 17 00:00:00 2001 From: PDickeyTruss Date: Mon, 28 Aug 2023 20:38:40 +0000 Subject: [PATCH 131/138] Add different zip same base point city testharness move --- pkg/testdatagen/testharness/dispatch.go | 3 + pkg/testdatagen/testharness/make_move.go | 118 +++++++++++++++++++++++ 2 files changed, 121 insertions(+) diff --git a/pkg/testdatagen/testharness/dispatch.go b/pkg/testdatagen/testharness/dispatch.go index dcb65d372bd..13d8b723116 100644 --- a/pkg/testdatagen/testharness/dispatch.go +++ b/pkg/testdatagen/testharness/dispatch.go @@ -119,6 +119,9 @@ var actionDispatcher = map[string]actionFunc{ "PrimeSimulatorMoveNeedsShipmentUpdate": func(appCtx appcontext.AppContext) testHarnessResponse { return MakePrimeSimulatorMoveNeedsShipmentUpdate(appCtx) }, + "MakePrimeSimulatorMoveSameBasePointCity": func(appCtx appcontext.AppContext) testHarnessResponse { + return MakePrimeSimulatorMoveSameBasePointCity(appCtx) + }, "NeedsOrdersUser": func(appCtx appcontext.AppContext) testHarnessResponse { return MakeNeedsOrdersUser(appCtx.DB()) }, diff --git a/pkg/testdatagen/testharness/make_move.go b/pkg/testdatagen/testharness/make_move.go index 1326094cb2a..3710e1178e7 100644 --- a/pkg/testdatagen/testharness/make_move.go +++ b/pkg/testdatagen/testharness/make_move.go @@ -760,6 +760,124 @@ func MakePrimeSimulatorMoveNeedsShipmentUpdate(appCtx appcontext.AppContext) mod return *newmove } +func MakePrimeSimulatorMoveSameBasePointCity(appCtx appcontext.AppContext) models.Move { + now := time.Now() + move := factory.BuildMove(appCtx.DB(), []factory.Customization{ + { + Model: models.Move{ + Status: models.MoveStatusAPPROVED, + AvailableToPrimeAt: &now, + ApprovalsRequestedAt: &now, + SubmittedAt: &now, + }, + }, + }, nil) + factory.BuildMTOServiceItemBasic(appCtx.DB(), []factory.Customization{ + { + Model: models.MTOServiceItem{ + Status: models.MTOServiceItemStatusApproved, + }, + }, + { + Model: move, + LinkOnly: true, + }, + { + Model: models.ReService{ + Code: models.ReServiceCodeMS, + }, + }, + }, nil) + + requestedPickupDate := time.Now().AddDate(0, 3, 0) + requestedDeliveryDate := requestedPickupDate.AddDate(0, 1, 0) + pickupAddress := factory.BuildAddress(appCtx.DB(), []factory.Customization{ + { + Model: models.Address{ + ID: uuid.Must(uuid.NewV4()), + StreetAddress1: "1 First St", + StreetAddress2: models.StringPointer("Apt 1"), + City: "Miami Gardens", + State: "FL", + PostalCode: "33169", + Country: models.StringPointer("US"), + }, + }, + }, nil) + destinationAddress := factory.BuildAddress(appCtx.DB(), []factory.Customization{ + { + Model: models.Address{ + ID: uuid.Must(uuid.NewV4()), + StreetAddress1: "2 Second St", + StreetAddress2: models.StringPointer("Bldg 2"), + City: "Key West", + State: "FL", + PostalCode: "33040", + Country: models.StringPointer("US"), + }, + }, + }, nil) + + estimatedWeight := unit.Pound(1400) + actualWeight := unit.Pound(2000) + shipmentFields := models.MTOShipment{ + PrimeEstimatedWeight: &estimatedWeight, + PrimeActualWeight: &actualWeight, + Status: models.MTOShipmentStatusApproved, + RequestedPickupDate: &requestedPickupDate, + RequestedDeliveryDate: &requestedDeliveryDate, + } + + firstShipment := factory.BuildMTOShipmentMinimal(appCtx.DB(), []factory.Customization{ + { + Model: move, + LinkOnly: true, + }, + { + Model: shipmentFields, + }, + { + Model: pickupAddress, + LinkOnly: true, + Type: &factory.Addresses.PickupAddress, + }, + { + Model: destinationAddress, + LinkOnly: true, + Type: &factory.Addresses.DeliveryAddress, + }, + }, nil) + + factory.BuildMTOServiceItem(appCtx.DB(), []factory.Customization{ + { + Model: models.MTOServiceItem{ + Status: models.MTOServiceItemStatusApproved, + }, + }, + { + Model: models.ReService{ + Code: models.ReServiceCodeDLH, + }, + }, + { + Model: firstShipment, + LinkOnly: true, + }, + { + Model: move, + LinkOnly: true, + }, + }, nil) + + // 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 +} + // MakeHHGMoveWithNTSAndNeedsSC is similar to old shared.createUserWithLocatorAndDODID func MakeHHGMoveWithNTSAndNeedsSC(appCtx appcontext.AppContext) models.Move { From b2f81df629370cfd823419df82161ea4bc6db662 Mon Sep 17 00:00:00 2001 From: PDickeyTruss Date: Mon, 28 Aug 2023 21:00:42 +0000 Subject: [PATCH 132/138] Add func to fetch reZip3 from db by zip3 --- pkg/models/re_zip3s.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pkg/models/re_zip3s.go b/pkg/models/re_zip3s.go index 282b46b7a24..a389ea58123 100644 --- a/pkg/models/re_zip3s.go +++ b/pkg/models/re_zip3s.go @@ -45,3 +45,17 @@ func (r *ReZip3) Validate(_ *pop.Connection) (*validate.Errors, error) { &validators.UUIDIsPresent{Field: r.DomesticServiceAreaID, Name: "DomesticServiceAreaID"}, ), nil } + +// FetchReZip3Item returns an reZip3 for a given zip3 +func FetchReZip3Item(tx *pop.Connection, zip3 string) (*ReZip3, error) { + var reZip3 ReZip3 + err := tx. + Where("zip3 = $1", zip3). + First(&reZip3) + + if err != nil { + return nil, err + } + + return &reZip3, err +} From 0638574125936a56c484a180c141139d92436b80 Mon Sep 17 00:00:00 2001 From: PDickeyTruss Date: Tue, 29 Aug 2023 16:04:10 +0000 Subject: [PATCH 133/138] Update hhg planner to use dtod when zip3s differ within same base point city --- pkg/route/hhg_planner.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkg/route/hhg_planner.go b/pkg/route/hhg_planner.go index de4ac14b44b..3dece111d7c 100644 --- a/pkg/route/hhg_planner.go +++ b/pkg/route/hhg_planner.go @@ -63,6 +63,16 @@ func (p *hhgPlanner) ZipTransitDistance(appCtx appcontext.AppContext, source str return p.dtodPlannerMileage.DTODZip5Distance(appCtx, source, destination) } + // Get reZip3s for origin and destination to compair base point cities. + // Dont worry about errors, if we dont find them, we'll just use randMcNallyZip3Distance + sourceReZip3, _ := models.FetchReZip3Item(appCtx.DB(), sourceZip3) + destinationReZip3, _ := models.FetchReZip3Item(appCtx.DB(), destZip3) + + // Different zip3, same base point city, use DTOD + if sourceReZip3 != nil && destinationReZip3 != nil && sourceReZip3.BasePointCity == destinationReZip3.BasePointCity { + return p.dtodPlannerMileage.DTODZip5Distance(appCtx, source, destination) + } + return randMcNallyZip3Distance(appCtx, sourceZip3, destZip3) } From c9ae279b3e62753b93e635c6f5863c83dad55a54 Mon Sep 17 00:00:00 2001 From: PDickeyTruss Date: Tue, 29 Aug 2023 16:34:18 +0000 Subject: [PATCH 134/138] Add unit tests for hhg_planner and reZip3 changes --- pkg/models/re_zip3s_test.go | 14 +++++++++++++ pkg/route/hhg_planner_test.go | 38 +++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/pkg/models/re_zip3s_test.go b/pkg/models/re_zip3s_test.go index 7b823d7243b..3395842216d 100644 --- a/pkg/models/re_zip3s_test.go +++ b/pkg/models/re_zip3s_test.go @@ -4,6 +4,7 @@ import ( "github.com/gofrs/uuid" "github.com/transcom/mymove/pkg/models" + "github.com/transcom/mymove/pkg/testdatagen" ) func (suite *ModelSuite) TestReZip3Validations() { @@ -44,4 +45,17 @@ func (suite *ModelSuite) TestReZip3Validations() { } suite.verifyValidationErrors(&invalidReZip3, expErrors) }) + + suite.Run("test FetchReZip3Item", func() { + zip3 := "606" + testdatagen.MakeReZip3(suite.DB(), testdatagen.Assertions{ + ReZip3: models.ReZip3{ + Zip3: zip3, + }, + }) + + reZip3, err := models.FetchReZip3Item(suite.DB(), zip3) + suite.Nil(err) + suite.Equal(zip3, reZip3.Zip3) + }) } diff --git a/pkg/route/hhg_planner_test.go b/pkg/route/hhg_planner_test.go index 78988f3f62c..e9639c0e8ff 100644 --- a/pkg/route/hhg_planner_test.go +++ b/pkg/route/hhg_planner_test.go @@ -104,6 +104,44 @@ func (suite *GHCTestSuite) TestHHGZipTransitDistance() { suite.Equal(1, distance) }) + suite.Run("Uses DTOD for distance when origin/dest zips differ but are in the same base point city", func() { + // Mock DTOD distance response + testSoapClient := &ghcmocks.SoapCaller{} + testSoapClient.On("Call", + mock.Anything, + mock.Anything, + ).Return(soapResponseForDistance("166"), nil) + + // Create two zip3s in the same base point city (Miami) + testdatagen.MakeReZip3(suite.DB(), testdatagen.Assertions{ + ReZip3: models.ReZip3{ + Zip3: "330", + BasePointCity: "Miami", + State: "FL", + }, + }) + testdatagen.MakeReZip3(suite.DB(), testdatagen.Assertions{ + ReZip3: models.ReZip3{ + Zip3: "331", + BasePointCity: "Miami", + State: "FL", + }, + ReDomesticServiceArea: models.ReDomesticServiceArea{ + ServiceArea: "005", + }, + }) + + plannerMileage := NewDTODZip5Distance(fakeUsername, fakePassword, testSoapClient) + planner := NewHHGPlanner(plannerMileage) + + // Get distance between two zips in the same base point city + distance, err := planner.ZipTransitDistance(suite.AppContextForTest(), "33169", "33040") + suite.NoError(err) + + // Ensure DTOD was used for distance + suite.Equal(166, distance) + }) + suite.Run("fake DTOD returns an error", func() { testSoapClient := &ghcmocks.SoapCaller{} testSoapClient.On("Call", From f6e55c598624793c221478acb73e29b3f184a1e4 Mon Sep 17 00:00:00 2001 From: Joshua Sarnovsky Date: Tue, 29 Aug 2023 19:45:23 +0000 Subject: [PATCH 135/138] update exp cert --- config/tls/api.exp.dp3.us.chain.der.p7b | Bin 3021 -> 3019 bytes config/tls/api.exp.dp3.us.crt | 64 ++++++++++++------------ 2 files changed, 33 insertions(+), 31 deletions(-) diff --git a/config/tls/api.exp.dp3.us.chain.der.p7b b/config/tls/api.exp.dp3.us.chain.der.p7b index 7c4fcc693cb1f30171548a632065f229c639e1d1..8e90d3ed5da696e491e982182ff16036eb2a37b6 100644 GIT binary patch delta 35 qcmX>rep+1Ipo#l98>d#AN85K^Ms}tJP24+xLR&V9Z{lV$WB>rsX$uPg delta 37 scmX>tepX!Epo#k=8>d#AN85K^Ms}tJP29VHLfbZqZ{lWI$Y96-0O}D7v;Y7A diff --git a/config/tls/api.exp.dp3.us.crt b/config/tls/api.exp.dp3.us.crt index a491d3a32dc..94410d76dba 100644 --- a/config/tls/api.exp.dp3.us.crt +++ b/config/tls/api.exp.dp3.us.crt @@ -1,33 +1,35 @@ -----BEGIN CERTIFICATE----- -MIIFrDCCBJSgAwIBAgIQY5O3DBUKQmj8fdDkgfjuPTANBgkqhkiG9w0BAQsFADCB -jzELMAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4G -A1UEBxMHU2FsZm9yZDEYMBYGA1UEChMPU2VjdGlnbyBMaW1pdGVkMTcwNQYDVQQD -Ey5TZWN0aWdvIFJTQSBEb21haW4gVmFsaWRhdGlvbiBTZWN1cmUgU2VydmVyIENB -MB4XDTIzMDgxNjAwMDAwMFoXDTIzMDkyMzIzNTk1OVowGTEXMBUGA1UEAxMOYXBp -LmV4cC5kcDMudXMwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDAGT7Y -MsWEQ4NAPjszIB9wqUwJn2/8ykCePtQYJsfeBu95nKRynPHgajHGi/BgB1rNMNWV -rxfsKbtwamps5PkaeLh3M18PMolFJ/rXW+VRKO0ELIUdvOAUqx88glfEhk7f0X9o -ZK5EtNlr+qIhecg4HuyIs36HbN9sBvvspZAIuND/8JM8OHnWPbBrkrjkZdQVwKPI -oTGaBBBgc2wRlL0mYUtNGTFw8JhqdtSQtJy0cjmgqnGSuG0iGAOE+YVSrD9Tam5/ -wHvUWN9fSBSaWk+EOK3bQGFxvJbZOB4YSK8iD24rQcKLRlu1TQFxoibKOellv7hU -baphs6DNJWXQlTZXAgMBAAGjggJ3MIICczAfBgNVHSMEGDAWgBSNjF7EVK2K4Xfp -m/mbBeG4AY1h4TAdBgNVHQ4EFgQUYQsWnsAmKfIe3wOZ+w8K1AXZOkIwDgYDVR0P -AQH/BAQDAgWgMAwGA1UdEwEB/wQCMAAwHQYDVR0lBBYwFAYIKwYBBQUHAwEGCCsG -AQUFBwMCMEkGA1UdIARCMEAwNAYLKwYBBAGyMQECAgcwJTAjBggrBgEFBQcCARYX -aHR0cHM6Ly9zZWN0aWdvLmNvbS9DUFMwCAYGZ4EMAQIBMIGEBggrBgEFBQcBAQR4 -MHYwTwYIKwYBBQUHMAKGQ2h0dHA6Ly9jcnQuc2VjdGlnby5jb20vU2VjdGlnb1JT -QURvbWFpblZhbGlkYXRpb25TZWN1cmVTZXJ2ZXJDQS5jcnQwIwYIKwYBBQUHMAGG -F2h0dHA6Ly9vY3NwLnNlY3RpZ28uY29tMBkGA1UdEQQSMBCCDmFwaS5leHAuZHAz -LnVzMIIBBQYKKwYBBAHWeQIEAgSB9gSB8wDxAHYArfe++nz/EMiLnT2cHj4YarRn -KV3PsQwkyoWGNOvcgooAAAGJ/56GTgAABAMARzBFAiBvXgzKBkSZ+d+QL5mKdSSR -omM7sBvCF60TBspxebUoWwIhAPz6UfNZgLEQ0jNFQIjWdgNFj2AeWmmvdlRVAbH/ -5Au1AHcAejKMVNi3LbYg6jjgUh7phBZwMhOFTTvSK8E6V6NS61IAAAGJ/56GpAAA -BAMASDBGAiEA2ZJhgP//nZDuKl0yhq8dqEThD8Wi1MoMewQeZy5BVikCIQD92/V7 -sTtr3Xwo2w/DXXPNqxh8g7DqwyWY357j/zh53zANBgkqhkiG9w0BAQsFAAOCAQEA -oLDWLRi4VsKrZbMW8rzpRaj5n5NSaT/SozqvNFYc+CLXZg9tw5Sht+0ES7oN4jnj -NkX5FfGMmjDChKdwZnlJqQlk0lfr5MwOwUFbFhd2QCdb9DIgMdKIxtA69eDsoClC -wLa4H7iwneqrJqdBoazEFIfgLx2eVDLFvd1CMTOz17NcOhQfu6e3sowVEE8w1k7b -6BbDgaof1RH6D2orCCR+5Lt/HLGHqCIkCLE29+I6OMy98XjDuFRiuOmCEs/XnvRs -sCHTOar8AhS0mfhTwDM65NoH73YGu0x9yrue63ggEQFxyEwLAkYkDBZzflBDxGs/ -2yHosMRiVcZdsf4MnAOlZA== +MIIGJzCCBQ+gAwIBAgIRAJnYZ2WO1CLAL7Jyc6GFkaYwDQYJKoZIhvcNAQELBQAw +gY8xCzAJBgNVBAYTAkdCMRswGQYDVQQIExJHcmVhdGVyIE1hbmNoZXN0ZXIxEDAO +BgNVBAcTB1NhbGZvcmQxGDAWBgNVBAoTD1NlY3RpZ28gTGltaXRlZDE3MDUGA1UE +AxMuU2VjdGlnbyBSU0EgRG9tYWluIFZhbGlkYXRpb24gU2VjdXJlIFNlcnZlciBD +QTAeFw0yMzA4MjUwMDAwMDBaFw0yNDA5MjMyMzU5NTlaMBkxFzAVBgNVBAMTDmFw +aS5leHAuZHAzLnVzMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwBk+ +2DLFhEODQD47MyAfcKlMCZ9v/MpAnj7UGCbH3gbveZykcpzx4GoxxovwYAdazTDV +la8X7Cm7cGpqbOT5Gni4dzNfDzKJRSf611vlUSjtBCyFHbzgFKsfPIJXxIZO39F/ +aGSuRLTZa/qiIXnIOB7siLN+h2zfbAb77KWQCLjQ//CTPDh51j2wa5K45GXUFcCj +yKExmgQQYHNsEZS9JmFLTRkxcPCYanbUkLSctHI5oKpxkrhtIhgDhPmFUqw/U2pu +f8B71FjfX0gUmlpPhDit20BhcbyW2TgeGEivIg9uK0HCi0ZbtU0BcaImyjnpZb+4 +VG2qYbOgzSVl0JU2VwIDAQABo4IC8TCCAu0wHwYDVR0jBBgwFoAUjYxexFStiuF3 +6Zv5mwXhuAGNYeEwHQYDVR0OBBYEFGELFp7AJinyHt8DmfsPCtQF2TpCMA4GA1Ud +DwEB/wQEAwIFoDAMBgNVHRMBAf8EAjAAMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggr +BgEFBQcDAjBJBgNVHSAEQjBAMDQGCysGAQQBsjEBAgIHMCUwIwYIKwYBBQUHAgEW +F2h0dHBzOi8vc2VjdGlnby5jb20vQ1BTMAgGBmeBDAECATCBhAYIKwYBBQUHAQEE +eDB2ME8GCCsGAQUFBzAChkNodHRwOi8vY3J0LnNlY3RpZ28uY29tL1NlY3RpZ29S +U0FEb21haW5WYWxpZGF0aW9uU2VjdXJlU2VydmVyQ0EuY3J0MCMGCCsGAQUFBzAB +hhdodHRwOi8vb2NzcC5zZWN0aWdvLmNvbTAZBgNVHREEEjAQgg5hcGkuZXhwLmRw +My51czCCAX8GCisGAQQB1nkCBAIEggFvBIIBawFpAHUAdv+IPwq2+5VRwmHM9Ye6 +NLSkzbsp3GhCCp/mZ0xaOnQAAAGKKg5KNQAABAMARjBEAiA9H/mNZeEsJkfgZpmS +CcwbpSM66uNB4ucavhWhfxuFnQIgZ4IF9XyIIxvjg1S/Xt0cbhkIWhRErlaE1FME +nMvlMuoAdwDatr9rP7W2Ip+bwrtca+hwkXFsu1GEhTS9pD0wSNf7qwAAAYoqDkqF +AAAEAwBIMEYCIQCG+ADYuRQqVwkVSWK+vLoTfnqiToRGb4Ldnug3v6/LPAIhAIt0 +nS6CvRvnUkaCABua5iTL11PLaAVXA0b2+TDIvvSPAHcA7s3QZNXbGs7FXLedtM0T +ojKHRny87N7DUUhZRnEftZsAAAGKKg5KWwAABAMASDBGAiEA2oKWPOxwiao9+frp +eWum121dFJJS9bYbYoReuttH0H4CIQCOmzDdVIgOROhYAT84NT2qNEZEx+B/Au2g ++3aQglpf+jANBgkqhkiG9w0BAQsFAAOCAQEAv6+uGv+Jwip9QqmNfgiY7wZWtZSP +HAi3fzjsgVoWTry6XwPdwud7Vi1YHaK1e9TA3sMMibzbsNiezsFUTk/05Bruh6lk +2F6jIxVhRTZzRE0qMz//t8x5hBxQgH9A+9KaQhZXc/zAhZGsbsz0CmBnNFsyULJj +DBVrZkjAjL41iIwO2iMcDvIRd0mWnSbd9TPPKyn6z79f4nVVDNbr1t/+dSnuKI22 +Y2GT0DMMtthe1zSRnbXdu1zfdNI3iGq2i6MGtWOoUY1ROYuyOP5bUH1k1ftnm+Oo +KqiuYXKdvu+seL14OHYaP5TDZTce7OGn8iZD4ZY6nLLA919Cfz0zt9T3YA== -----END CERTIFICATE----- From b259a5bf951f44c39763771efd7aaf5e9386fe35 Mon Sep 17 00:00:00 2001 From: Joshua Sarnovsky Date: Tue, 29 Aug 2023 21:08:36 +0000 Subject: [PATCH 136/138] update loadtest certs --- config/tls/api.loadtest.dp3.us.chain.der.p7b | Bin 3021 -> 3019 bytes config/tls/api.loadtest.dp3.us.crt | 68 +++++++++---------- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/config/tls/api.loadtest.dp3.us.chain.der.p7b b/config/tls/api.loadtest.dp3.us.chain.der.p7b index 7c4fcc693cb1f30171548a632065f229c639e1d1..8e90d3ed5da696e491e982182ff16036eb2a37b6 100644 GIT binary patch delta 35 qcmX>rep+1Ipo#l98>d#AN85K^Ms}tJP24+xLR&V9Z{lV$WB>rsX$uPg delta 37 scmX>tepX!Epo#k=8>d#AN85K^Ms}tJP29VHLfbZqZ{lWI$Y96-0O}D7v;Y7A diff --git a/config/tls/api.loadtest.dp3.us.crt b/config/tls/api.loadtest.dp3.us.crt index 3d142c4f506..721026c6f42 100644 --- a/config/tls/api.loadtest.dp3.us.crt +++ b/config/tls/api.loadtest.dp3.us.crt @@ -1,36 +1,36 @@ -----BEGIN CERTIFICATE----- -MIIGLTCCBRWgAwIBAgIQbKZa26vVIPynjPDPxS+9mDANBgkqhkiG9w0BAQsFADCB -jzELMAkGA1UEBhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4G -A1UEBxMHU2FsZm9yZDEYMBYGA1UEChMPU2VjdGlnbyBMaW1pdGVkMTcwNQYDVQQD -Ey5TZWN0aWdvIFJTQSBEb21haW4gVmFsaWRhdGlvbiBTZWN1cmUgU2VydmVyIENB -MB4XDTIzMDEwNjAwMDAwMFoXDTIzMDkyMjIzNTk1OVowHjEcMBoGA1UEAxMTYXBp -LmxvYWR0ZXN0LmRwMy51czCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB -ALMUQbd0XxvhzWMmTUsL0hwCQRP8tzn0zK1m34k7oxD8QtFtqcDtMBdJIKdcZoJM -cTN+uPIAKFzeLeG0GlP2tQId6iPwtxHNmqvntpdhY8XAM3Tbnd6kJE7TC8ocanvi -LWyEz+yjaX67FjnMv7izzr7vja3dt8vHOTnrObkGOzrUSNR0TdxX0Jp1h0fkiv0L -DzHyAwIa3eE7A376nT4ILHAiGlJWlGz0CS35JRTtBwDZZvu1nRtQXn87aNzhR5CQ -01Z6wLhnUU1JFsi90Hrrna4Ns5AQ2oqnzwXVHJ28A4EOevOr6VWm/C9Rkky1RnqM -zxEpqkveqvI4yHmIu35epcMCAwEAAaOCAvMwggLvMB8GA1UdIwQYMBaAFI2MXsRU -rYrhd+mb+ZsF4bgBjWHhMB0GA1UdDgQWBBSQx3Kn2vf9NyJzNGu5So/Qq8LvDDAO -BgNVHQ8BAf8EBAMCBaAwDAYDVR0TAQH/BAIwADAdBgNVHSUEFjAUBggrBgEFBQcD -AQYIKwYBBQUHAwIwSQYDVR0gBEIwQDA0BgsrBgEEAbIxAQICBzAlMCMGCCsGAQUF -BwIBFhdodHRwczovL3NlY3RpZ28uY29tL0NQUzAIBgZngQwBAgEwgYQGCCsGAQUF -BwEBBHgwdjBPBggrBgEFBQcwAoZDaHR0cDovL2NydC5zZWN0aWdvLmNvbS9TZWN0 -aWdvUlNBRG9tYWluVmFsaWRhdGlvblNlY3VyZVNlcnZlckNBLmNydDAjBggrBgEF -BQcwAYYXaHR0cDovL29jc3Auc2VjdGlnby5jb20wHgYDVR0RBBcwFYITYXBpLmxv -YWR0ZXN0LmRwMy51czCCAXwGCisGAQQB1nkCBAIEggFsBIIBaAFmAHYArfe++nz/ -EMiLnT2cHj4YarRnKV3PsQwkyoWGNOvcgooAAAGFiKPcggAABAMARzBFAiEAll7N -CypOd/TEEpXsxsTeAfKMcnWthQGDaw6TKBdGwAACIG/oarTEPEXD6fYL8V9FgBAT -FUTfU79vgE+8KfqmIeqkAHUAejKMVNi3LbYg6jjgUh7phBZwMhOFTTvSK8E6V6NS -61IAAAGFiKPcdQAABAMARjBEAiBwU60fnC680c80zae9SUnYoMqBywK2hmfucIXf -Jo2SVAIgeiFb15Awef4Kf2MwBeDHhB85Ev2v6Zdlu2nJE22/1XQAdQDoPtDaPvUG -NTLnVyi8iWvJA9PL0RFr7Otp4Xd9bQa9bgAAAYWIo9w6AAAEAwBGMEQCIGRHjXrC -i4yhkHW6/8NUc9ez/SxdqE3NANCVhCdZaIRqAiBgdC/bnsw6uf7cynS1nCt9B5AG -L5xeYOVtu6fgB4JERzANBgkqhkiG9w0BAQsFAAOCAQEASiG9H47kMcEaT6M39ELK -JtI0Sz9Y6wkKcPvuGN0T6nEaPAgjRS+ZG3NGsXjhjrLnQrs3PxWEduKdLj47xAq8 -Gr3j+LLv+EeSU3wIsey8FM8FxmN2HC9NKNQtcIuhSUO12+d5a8EcNQBtLA7ncHa9 -diT7h2ZfkYv3nsq8lGSlY//PtduwSsvYM+V0RQz+Dq0TZrygBOABiH+f7E4ZKQlj -KTCbEhFC5jDbm4IE88zBbE29naidgWAttJD6jAdvQ+7lY3yhX2q5z7HcmAAMVxGh -9aaR4FLkc3clgwvr+j0IIqQgtic56PhX6NsC8xXhesuPRWOOVH6b+3FqI0SSMh2h -Ag== +MIIGMTCCBRmgAwIBAgIRAObSiatB91zjrlkLzaI42EgwDQYJKoZIhvcNAQELBQAw +gY8xCzAJBgNVBAYTAkdCMRswGQYDVQQIExJHcmVhdGVyIE1hbmNoZXN0ZXIxEDAO +BgNVBAcTB1NhbGZvcmQxGDAWBgNVBAoTD1NlY3RpZ28gTGltaXRlZDE3MDUGA1UE +AxMuU2VjdGlnbyBSU0EgRG9tYWluIFZhbGlkYXRpb24gU2VjdXJlIFNlcnZlciBD +QTAeFw0yMzA4MjQwMDAwMDBaFw0yNDA5MjIyMzU5NTlaMB4xHDAaBgNVBAMTE2Fw +aS5sb2FkdGVzdC5kcDMudXMwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIB +AQCzFEG3dF8b4c1jJk1LC9IcAkET/Lc59MytZt+JO6MQ/ELRbanA7TAXSSCnXGaC +THEzfrjyAChc3i3htBpT9rUCHeoj8LcRzZqr57aXYWPFwDN0253epCRO0wvKHGp7 +4i1shM/so2l+uxY5zL+4s86+742t3bfLxzk56zm5Bjs61EjUdE3cV9CadYdH5Ir9 +Cw8x8gMCGt3hOwN++p0+CCxwIhpSVpRs9Akt+SUU7QcA2Wb7tZ0bUF5/O2jc4UeQ +kNNWesC4Z1FNSRbIvdB6652uDbOQENqKp88F1RydvAOBDnrzq+lVpvwvUZJMtUZ6 +jM8RKapL3qryOMh5iLt+XqXDAgMBAAGjggL2MIIC8jAfBgNVHSMEGDAWgBSNjF7E +VK2K4Xfpm/mbBeG4AY1h4TAdBgNVHQ4EFgQUkMdyp9r3/TciczRruUqP0KvC7www +DgYDVR0PAQH/BAQDAgWgMAwGA1UdEwEB/wQCMAAwHQYDVR0lBBYwFAYIKwYBBQUH +AwEGCCsGAQUFBwMCMEkGA1UdIARCMEAwNAYLKwYBBAGyMQECAgcwJTAjBggrBgEF +BQcCARYXaHR0cHM6Ly9zZWN0aWdvLmNvbS9DUFMwCAYGZ4EMAQIBMIGEBggrBgEF +BQcBAQR4MHYwTwYIKwYBBQUHMAKGQ2h0dHA6Ly9jcnQuc2VjdGlnby5jb20vU2Vj +dGlnb1JTQURvbWFpblZhbGlkYXRpb25TZWN1cmVTZXJ2ZXJDQS5jcnQwIwYIKwYB +BQUHMAGGF2h0dHA6Ly9vY3NwLnNlY3RpZ28uY29tMB4GA1UdEQQXMBWCE2FwaS5s +b2FkdGVzdC5kcDMudXMwggF/BgorBgEEAdZ5AgQCBIIBbwSCAWsBaQB3AHb/iD8K +tvuVUcJhzPWHujS0pM27KdxoQgqf5mdMWjp0AAABiiTn6VQAAAQDAEgwRgIhAMZs +IwyQArMxkQ8Etk0qHpc5TQPa83xrUIFqrgRX6hf2AiEAis9+SX2fuFCYTSwfsLLP +a7F2aifKyrQSPSzZVQx60QUAdgDatr9rP7W2Ip+bwrtca+hwkXFsu1GEhTS9pD0w +SNf7qwAAAYok5+mmAAAEAwBHMEUCICWFyZh0szQKM6Golr0s4eHXBaXAf4lXGGLE +CPP/qqkcAiEA6i5BknyCyI77pV1TvOZtnKUflh6ciXFCa5YpxbP9SssAdgDuzdBk +1dsazsVct520zROiModGfLzs3sNRSFlGcR+1mwAAAYok5+mBAAAEAwBHMEUCIGVc +4duwRf7mYB0fPNmDfY3A99wMdwaUHIVjjqe2kXtQAiEAh13YuzUs2Tv2zY5yxaR7 +dNX3P5so0npliQEaJhauDsEwDQYJKoZIhvcNAQELBQADggEBAH0mHBtGdQcBaY+k +s42T/QZUgiIyALY7B79pCNSIBTK4x5DhXbbCezhnhU2oB/5xqhbhMAy/q80OE1GB +e8YWIjM8i5DG+st/8SxPMcouHsMPz1A5yQ2Lql+JGDn+5Ht6HrU9SjXVQA0ByoOP +iPrNOUZ8hnNkN+zB9N4CmfkHtJo39MKw+V2mCWZWgPmaRdI27CeVU9kkDVZ2C93k +0VbirQCQF18h9AQ1tVtBOvlj5shiIiJ0DAqlkNKRDT1uvjFhtIt/wUV+qrb6lGtu +BYhyP8QJgl12e9qzYS3gT75CJU+hVROGSZz+01XNJONsTpXL2kzj+/iLgBkdD26l +Dk5VUhk= -----END CERTIFICATE----- From b070f8c160862524a3f933bfdb832b5d3c5d52da Mon Sep 17 00:00:00 2001 From: PDickeyTruss Date: Wed, 30 Aug 2023 15:52:52 +0000 Subject: [PATCH 137/138] Fix spelling error --- pkg/route/hhg_planner.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/route/hhg_planner.go b/pkg/route/hhg_planner.go index 3dece111d7c..cf6e0ccaabe 100644 --- a/pkg/route/hhg_planner.go +++ b/pkg/route/hhg_planner.go @@ -63,7 +63,7 @@ func (p *hhgPlanner) ZipTransitDistance(appCtx appcontext.AppContext, source str return p.dtodPlannerMileage.DTODZip5Distance(appCtx, source, destination) } - // Get reZip3s for origin and destination to compair base point cities. + // Get reZip3s for origin and destination to compare base point cities. // Dont worry about errors, if we dont find them, we'll just use randMcNallyZip3Distance sourceReZip3, _ := models.FetchReZip3Item(appCtx.DB(), sourceZip3) destinationReZip3, _ := models.FetchReZip3Item(appCtx.DB(), destZip3) From ccc513148d17fb1fa9181fb1ee12dcd44eb03ab9 Mon Sep 17 00:00:00 2001 From: PDickeyTruss Date: Wed, 30 Aug 2023 16:03:07 +0000 Subject: [PATCH 138/138] Log errors when fetching reZip3s --- pkg/route/hhg_planner.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/pkg/route/hhg_planner.go b/pkg/route/hhg_planner.go index cf6e0ccaabe..544d8f5eed7 100644 --- a/pkg/route/hhg_planner.go +++ b/pkg/route/hhg_planner.go @@ -3,6 +3,8 @@ package route import ( "fmt" + "go.uber.org/zap" + "github.com/transcom/mymove/pkg/appcontext" "github.com/transcom/mymove/pkg/models" ) @@ -64,9 +66,15 @@ func (p *hhgPlanner) ZipTransitDistance(appCtx appcontext.AppContext, source str } // Get reZip3s for origin and destination to compare base point cities. - // Dont worry about errors, if we dont find them, we'll just use randMcNallyZip3Distance - sourceReZip3, _ := models.FetchReZip3Item(appCtx.DB(), sourceZip3) - destinationReZip3, _ := models.FetchReZip3Item(appCtx.DB(), destZip3) + // Dont throw/return errors from this. If we dont find them, we'll just use randMcNallyZip3Distance + sourceReZip3, sErr := models.FetchReZip3Item(appCtx.DB(), sourceZip3) + if sErr != nil { + appCtx.Logger().Error("Failed to fetch the reZip3 item for sourceZip3", zap.Error(sErr)) + } + destinationReZip3, dErr := models.FetchReZip3Item(appCtx.DB(), destZip3) + if dErr != nil { + appCtx.Logger().Error("Failed to fetch the reZip3 item for destinationZip3", zap.Error(dErr)) + } // Different zip3, same base point city, use DTOD if sourceReZip3 != nil && destinationReZip3 != nil && sourceReZip3.BasePointCity == destinationReZip3.BasePointCity {