Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

INT-B-22196 ppm sit cost defect #14576

Merged
merged 11 commits into from
Jan 15, 2025
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ func SSWGetEntitlement(grade internalmessages.OrderPayGrade, hasDependents bool,
}

// Calculates cost for the Remaining PPM Incentive (pre-tax) field on page 2 of SSW form.
func CalculateRemainingPPMEntitlement(finalIncentive *unit.Cents, sitMemberPaid float64, sitGTCCPaid float64, aoa *unit.Cents) float64 {
func CalculateRemainingPPMEntitlement(finalIncentive *unit.Cents, aoa *unit.Cents) float64 {
// FinalIncentive
var finalIncentiveFloat float64 = 0
if finalIncentive != nil {
Expand All @@ -223,7 +223,7 @@ func CalculateRemainingPPMEntitlement(finalIncentive *unit.Cents, sitMemberPaid
// This costing is computed by taking the Actual Obligations 100% GCC plus the
// SIT cost calculated (if SIT was approved and accepted) minus any Advance
// Operating Allowance (AOA) the customer identified as receiving in the Document upload process
return (finalIncentiveFloat + sitMemberPaid + sitGTCCPaid) - aoaFloat
return finalIncentiveFloat - aoaFloat
}

const (
Expand Down Expand Up @@ -328,15 +328,23 @@ func (s *SSWPPMComputer) FormatValuesShipmentSummaryWorksheetFormPage2(data mode
if data.IsActualExpenseReimbursement {
data.PPMRemainingEntitlement = 0.0
} else {
data.PPMRemainingEntitlement = CalculateRemainingPPMEntitlement(data.PPMShipment.FinalIncentive, expensesMap["StorageMemberPaid"], expensesMap["StorageGTCCPaid"], data.PPMShipment.AdvanceAmountReceived)
data.PPMRemainingEntitlement = CalculateRemainingPPMEntitlement(data.PPMShipment.FinalIncentive, data.PPMShipment.AdvanceAmountReceived)
}

page2.PPMRemainingEntitlement = FormatDollars(data.PPMRemainingEntitlement)
page2.PreparationDate2, err = formatSSWDate(data.SignedCertifications, data.PPMShipment.ID)
if err != nil {
return page2, err
}
page2.Disbursement = formatDisbursement(expensesMap, data.PPMRemainingEntitlement)
var finalIncentiveFloat float64 = 0
if data.PPMShipment.FinalIncentive != nil {
finalIncentiveFloat = float64(*data.PPMShipment.FinalIncentive) / 100
}
var aoaFloat float64 = 0
if data.PPMShipment.AdvanceAmountReceived != nil {
aoaFloat = float64(*data.PPMShipment.AdvanceAmountReceived) / 100
}
page2.Disbursement = formatDisbursement(expensesMap, finalIncentiveFloat-aoaFloat)
} else {
page2.PreparationDate2 = formatAOADate(data.SignedCertifications, data.PPMShipment.ID)
page2.Disbursement = "N/A"
Expand Down Expand Up @@ -950,7 +958,7 @@ func formatDisbursement(expensesMap map[string]float64, ppmRemainingEntitlement
disbursementGTCC = 0
} else {
// Disbursement Member is remaining entitlement plus member SIT minus GTCC Disbursement, not less than 0.
disbursementMember = ppmRemainingEntitlement + expensesMap["StorageMemberPaid"] - disbursementGTCC
disbursementMember = ppmRemainingEntitlement + expensesMap["StorageMemberPaid"]
}

// Return formatted values in string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ import (
"github.com/transcom/mymove/pkg/uploader"
)

// Helper function to format disbursement field for equal checks
var expectedDisbursementString = func(expectedGTCC int, expectedMember int) string {
return "GTCC: " + FormatDollars((models.CentPointer(unit.Cents(expectedGTCC)).ToMillicents().ToDollarFloat())) + "\nMember: " + FormatDollars(models.CentPointer(unit.Cents(expectedMember)).ToMillicents().ToDollarFloat())
}

func (suite *ShipmentSummaryWorksheetServiceSuite) TestFetchDataShipmentSummaryWorksheet() {
//advanceID, _ := uuid.NewV4()
ordersType := internalmessages.OrdersTypePERMANENTCHANGEOFSTATION
Expand Down Expand Up @@ -693,7 +698,8 @@ func (suite *ShipmentSummaryWorksheetServiceSuite) TestMemberPaidRemainingPPMEnt
sswPPMComputer := NewSSWPPMComputer(mockPPMCloseoutFetcher)
expensesMap := SubTotalExpenses(ssd.MovingExpenses)
sswPage2, _ := sswPPMComputer.FormatValuesShipmentSummaryWorksheetFormPage2(ssd, true, expensesMap)
suite.Equal("$4.00", sswPage2.PPMRemainingEntitlement)
suite.Equal("$3.00", sswPage2.PPMRemainingEntitlement)
suite.Equal(expectedDisbursementString(0, 400), sswPage2.Disbursement)
}

func (suite *ShipmentSummaryWorksheetServiceSuite) TestAOAPacketPPMEntitlementFormatValuesShipmentSummaryWorksheetFormPage2() {
Expand Down Expand Up @@ -777,7 +783,8 @@ func (suite *ShipmentSummaryWorksheetServiceSuite) TestNullCheckForFinalIncentiv
sswPPMComputer := NewSSWPPMComputer(mockPPMCloseoutFetcher)
expensesMap := SubTotalExpenses(ssd.MovingExpenses)
sswPage2, _ := sswPPMComputer.FormatValuesShipmentSummaryWorksheetFormPage2(ssd, true, expensesMap)
suite.Equal("$1.00", sswPage2.PPMRemainingEntitlement)
suite.Equal("$0.00", sswPage2.PPMRemainingEntitlement)
suite.Equal(expectedDisbursementString(0, 100), sswPage2.Disbursement)
}

func (suite *ShipmentSummaryWorksheetServiceSuite) TestGTCCPaidRemainingPPMEntitlementFormatValuesShipmentSummaryWorksheetFormPage2() {
Expand Down Expand Up @@ -827,7 +834,8 @@ func (suite *ShipmentSummaryWorksheetServiceSuite) TestGTCCPaidRemainingPPMEntit
mockPPMCloseoutFetcher := &mocks.PPMCloseoutFetcher{}
sswPPMComputer := NewSSWPPMComputer(mockPPMCloseoutFetcher)
sswPage2, _ := sswPPMComputer.FormatValuesShipmentSummaryWorksheetFormPage2(ssd, true, expensesMap)
suite.Equal("$105.00", sswPage2.PPMRemainingEntitlement)
suite.Equal("$5.00", sswPage2.PPMRemainingEntitlement)
suite.Equal(expectedDisbursementString(500, 500), sswPage2.Disbursement)
}
func (suite *ShipmentSummaryWorksheetServiceSuite) TestGroupExpenses() {
paidWithGTCC := false
Expand Down Expand Up @@ -1320,11 +1328,6 @@ func (suite *ShipmentSummaryWorksheetServiceSuite) TestFillSSWPDFForm() {

func (suite *ShipmentSummaryWorksheetServiceSuite) TestActualExpenseReimbursementCalculations() {

// Helper function to format disbursement field for equal checks
expectedDisbursementString := func(expectedGTCC int, expectedMember int) string {
return "GTCC: " + FormatDollars((models.CentPointer(unit.Cents(expectedGTCC)).ToMillicents().ToDollarFloat())) + "\nMember: " + FormatDollars(models.CentPointer(unit.Cents(expectedMember)).ToMillicents().ToDollarFloat())
}

fakeS3 := storageTest.NewFakeS3Storage(true)
userUploader, uploaderErr := uploader.NewUserUploader(fakeS3, 25*uploader.MB)
suite.FatalNoError(uploaderErr)
Expand Down Expand Up @@ -1950,23 +1953,23 @@ func (suite *ShipmentSummaryWorksheetServiceSuite) TestFormatDisbursement() {

// Test case 1: GTCC calculation B is less than GTCC calculation A
// Additionally, Member should not be less than 0
expectedResult := "GTCC: " + FormatDollars(100.00) + "\nMember: " + FormatDollars(0)
expectedResult := "GTCC: " + FormatDollars(100.00) + "\nMember: " + FormatDollars(100.00)
expensesMap["TotalGTCCPaid"] = 200.00
expensesMap["StorageGTCCPaid"] = 300.00
ppmRemainingEntitlement := 60.00
expensesMap["StorageMemberPaid"] = 40.00
result := formatDisbursement(expensesMap, ppmRemainingEntitlement)
suite.Equal(result, expectedResult)
suite.Equal(expectedResult, result)

// Test case 2: GTCC calculation A is less than GTCC calculation B
expectedResult = "GTCC: " + FormatDollars(100.00) + "\nMember: " + FormatDollars(400.00)
expectedResult = "GTCC: " + FormatDollars(100.00) + "\nMember: " + FormatDollars(500.00)
expensesMap = make(map[string]float64)
expensesMap["TotalGTCCPaid"] = 60.00
expensesMap["StorageGTCCPaid"] = 40.00
ppmRemainingEntitlement = 300.00
expensesMap["StorageMemberPaid"] = 200.00
result = formatDisbursement(expensesMap, ppmRemainingEntitlement)
suite.Equal(result, expectedResult)
suite.Equal(expectedResult, result)

// Test case 3: GTCC calculation is less than 0
expectedResult = "GTCC: " + FormatDollars(0) + "\nMember: " + FormatDollars(-250.00)
Expand All @@ -1976,5 +1979,5 @@ func (suite *ShipmentSummaryWorksheetServiceSuite) TestFormatDisbursement() {
ppmRemainingEntitlement = -300.00
expensesMap["StorageMemberPaid"] = 50.00
result = formatDisbursement(expensesMap, ppmRemainingEntitlement)
suite.Equal(result, expectedResult)
suite.Equal(expectedResult, result)
}
Loading