diff --git a/pkg/services/shipment_summary_worksheet/shipment_summary_worksheet.go b/pkg/services/shipment_summary_worksheet/shipment_summary_worksheet.go index bfa0f85b458..1864166585d 100644 --- a/pkg/services/shipment_summary_worksheet/shipment_summary_worksheet.go +++ b/pkg/services/shipment_summary_worksheet/shipment_summary_worksheet.go @@ -779,6 +779,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 ace5be1ccc7..d6acd8a6db9 100644 --- a/pkg/services/shipment_summary_worksheet/shipment_summary_worksheet_test.go +++ b/pkg/services/shipment_summary_worksheet/shipment_summary_worksheet_test.go @@ -483,6 +483,102 @@ 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) + locator := "ABCDEF-01" + singlePPM := models.PPMShipment{ + Shipment: models.MTOShipment{ + ShipmentLocator: &locator, + }, + } + 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 := models.ShipmentSummaryFormData{ + Order: order, + MovingExpenses: movingExpenses, + PPMShipment: singlePPM, + } + + mockPPMCloseoutFetcher := &mocks.PPMCloseoutFetcher{} + sswPPMComputer := NewSSWPPMComputer(mockPPMCloseoutFetcher) + sswPage2, err := sswPPMComputer.FormatValuesShipmentSummaryWorksheetFormPage2(ssd, false) + suite.NoError(err) + 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) TestFormatValuesShipmentSummaryWorksheetFormPage3() { yuma := factory.FetchOrBuildCurrentDutyLocation(suite.DB()) fortGordon := factory.FetchOrBuildOrdersDutyLocation(suite.DB())