From 51cd23bdced4978c741bd3ca485bab12314c9cd9 Mon Sep 17 00:00:00 2001 From: Maria Traskowsky Date: Wed, 28 Aug 2024 17:55:43 +0000 Subject: [PATCH 1/3] excluded rejected or excluded expenses from SSW total expenses --- .../shipment_summary_worksheet.go | 4 + .../shipment_summary_worksheet_test.go | 87 +++++++++++++++++++ 2 files changed, 91 insertions(+) diff --git a/pkg/services/shipment_summary_worksheet/shipment_summary_worksheet.go b/pkg/services/shipment_summary_worksheet/shipment_summary_worksheet.go index 0a5c3109a63..bae2a49020b 100644 --- a/pkg/services/shipment_summary_worksheet/shipment_summary_worksheet.go +++ b/pkg/services/shipment_summary_worksheet/shipment_summary_worksheet.go @@ -545,6 +545,10 @@ func SubTotalExpenses(expenseDocuments models.MovingExpenses) map[string]float64 if expense.MovingExpenseType == nil || expense.Amount == nil { continue } // Added quick nil check to ensure SSW returns while moving expenses are being added still + var nilPPMDocumentStatus *models.PPMDocumentStatus + if expense.Status != nilPPMDocumentStatus && (*expense.Status == models.PPMDocumentStatusRejected || *expense.Status == models.PPMDocumentStatusExcluded) { + continue + } expenseType, addToTotal := getExpenseType(expense) expenseDollarAmt := expense.Amount.ToDollarFloatNoRound() diff --git a/pkg/services/shipment_summary_worksheet/shipment_summary_worksheet_test.go b/pkg/services/shipment_summary_worksheet/shipment_summary_worksheet_test.go index 705b0700d62..1782e2e36c9 100644 --- a/pkg/services/shipment_summary_worksheet/shipment_summary_worksheet_test.go +++ b/pkg/services/shipment_summary_worksheet/shipment_summary_worksheet_test.go @@ -475,6 +475,93 @@ func (suite *ShipmentSummaryWorksheetServiceSuite) TestFormatValuesShipmentSumma suite.Equal("SAC", sswPage2.SAC) } +func (suite *ShipmentSummaryWorksheetServiceSuite) TestFormatValuesShipmentSummaryWorksheetFormPage2ExcludeRejectedOrExcludedExpensesFromTotal() { + fortGordon := factory.FetchOrBuildOrdersDutyLocation(suite.DB()) + orderIssueDate := time.Date(2018, time.December, 23, 0, 0, 0, 0, time.UTC) + + order := models.Order{ + IssueDate: orderIssueDate, + OrdersType: internalmessages.OrdersTypePERMANENTCHANGEOFSTATION, + OrdersNumber: models.StringPointer("012346"), + NewDutyLocationID: fortGordon.ID, + TAC: models.StringPointer("NTA4"), + SAC: models.StringPointer("SAC"), + HasDependents: true, + SpouseHasProGear: true, + } + paidWithGTCCFalse := false + paidWithGTCCTrue := true + tollExpense := models.MovingExpenseReceiptTypeTolls + oilExpense := models.MovingExpenseReceiptTypeOil + approvedStatus := models.PPMDocumentStatusApproved + excludedStatus := models.PPMDocumentStatusExcluded + rejectedStatus := models.PPMDocumentStatusRejected + amount := unit.Cents(10000) + smallerAmount := unit.Cents(5000) + movingExpenses := models.MovingExpenses{ + // APPROVED + { + MovingExpenseType: &tollExpense, + Amount: &amount, + PaidWithGTCC: &paidWithGTCCFalse, + Status: &approvedStatus, + }, + { + MovingExpenseType: &oilExpense, + Amount: &smallerAmount, + PaidWithGTCC: &paidWithGTCCTrue, + Status: &approvedStatus, + }, + // EXCLUDED + { + MovingExpenseType: &tollExpense, + Amount: &amount, + PaidWithGTCC: &paidWithGTCCTrue, + Status: &excludedStatus, + }, + { + MovingExpenseType: &tollExpense, + Amount: &amount, + PaidWithGTCC: &paidWithGTCCFalse, + Status: &excludedStatus, + }, + { + MovingExpenseType: &oilExpense, + Amount: &smallerAmount, + PaidWithGTCC: &paidWithGTCCFalse, + Status: &excludedStatus, + }, + // REJECTED + { + MovingExpenseType: &oilExpense, + Amount: &amount, + PaidWithGTCC: &paidWithGTCCFalse, + Status: &rejectedStatus, + }, + { + MovingExpenseType: &tollExpense, + Amount: &amount, + PaidWithGTCC: &paidWithGTCCTrue, + Status: &rejectedStatus, + }, + } + + ssd := services.ShipmentSummaryFormData{ + Order: order, + MovingExpenses: movingExpenses, + } + + sswPage2 := FormatValuesShipmentSummaryWorksheetFormPage2(ssd, false) + suite.Equal("$0.00", sswPage2.TollsGTCCPaid) + suite.Equal("$100.00", sswPage2.TollsMemberPaid) + suite.Equal("$0.00", sswPage2.OilMemberPaid) + suite.Equal("$50.00", sswPage2.OilGTCCPaid) + suite.Equal("$50.00", sswPage2.TotalGTCCPaid) + suite.Equal("$100.00", sswPage2.TotalMemberPaid) + suite.Equal("NTA4", sswPage2.TAC) + suite.Equal("SAC", sswPage2.SAC) +} + func (suite *ShipmentSummaryWorksheetServiceSuite) TestGroupExpenses() { paidWithGTCC := false tollExpense := models.MovingExpenseReceiptTypeTolls From a19618e5094190880c093be03aa0ebb70e7b30d6 Mon Sep 17 00:00:00 2001 From: Maria Traskowsky Date: Thu, 12 Sep 2024 15:29:59 +0000 Subject: [PATCH 2/3] update to return two vals from func --- .../shipment_summary_worksheet_test.go | 3 ++- scripts/run-server-test | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pkg/services/shipment_summary_worksheet/shipment_summary_worksheet_test.go b/pkg/services/shipment_summary_worksheet/shipment_summary_worksheet_test.go index 1802234ef43..314f018e863 100644 --- a/pkg/services/shipment_summary_worksheet/shipment_summary_worksheet_test.go +++ b/pkg/services/shipment_summary_worksheet/shipment_summary_worksheet_test.go @@ -550,7 +550,8 @@ func (suite *ShipmentSummaryWorksheetServiceSuite) TestFormatValuesShipmentSumma MovingExpenses: movingExpenses, } - sswPage2 := FormatValuesShipmentSummaryWorksheetFormPage2(ssd, false) + sswPage2, err := FormatValuesShipmentSummaryWorksheetFormPage2(ssd, false) + suite.NoError(err) suite.Equal("$0.00", sswPage2.TollsGTCCPaid) suite.Equal("$100.00", sswPage2.TollsMemberPaid) suite.Equal("$0.00", sswPage2.OilMemberPaid) diff --git a/scripts/run-server-test b/scripts/run-server-test index 0ead8674b81..1fd1e90764b 100755 --- a/scripts/run-server-test +++ b/scripts/run-server-test @@ -53,9 +53,9 @@ fi # Check if the operating system is macOS before running command # this uses the classic linker when running make server_test aka go test # this addresses issues we were having with the default linker on macOS -if [[ "$(uname)" == "Darwin" ]]; then - gotest_args+=("-ldflags=-extldflags=-Wl,-ld_classic") -fi +# if [[ "$(uname)" == "Darwin" ]]; then +# gotest_args+=("-ldflags=-extldflags=-Wl,-ld_classic") +# fi # Try to compile tests, but don't run them. if [[ "${DRY_RUN:-}" == "1" ]]; then From 409262bb289f8b2845fea78a2c949eaf8dfa2fd1 Mon Sep 17 00:00:00 2001 From: Maria Traskowsky Date: Thu, 12 Sep 2024 15:33:03 +0000 Subject: [PATCH 3/3] uncomment ldclassic --- scripts/run-server-test | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/run-server-test b/scripts/run-server-test index 1fd1e90764b..0ead8674b81 100755 --- a/scripts/run-server-test +++ b/scripts/run-server-test @@ -53,9 +53,9 @@ fi # Check if the operating system is macOS before running command # this uses the classic linker when running make server_test aka go test # this addresses issues we were having with the default linker on macOS -# if [[ "$(uname)" == "Darwin" ]]; then -# gotest_args+=("-ldflags=-extldflags=-Wl,-ld_classic") -# fi +if [[ "$(uname)" == "Darwin" ]]; then + gotest_args+=("-ldflags=-extldflags=-Wl,-ld_classic") +fi # Try to compile tests, but don't run them. if [[ "${DRY_RUN:-}" == "1" ]]; then