Skip to content

Commit

Permalink
Merge pull request #13662 from transcom/B-20940-INT
Browse files Browse the repository at this point in the history
B 20940 int 2
  • Loading branch information
antgmann authored Sep 10, 2024
2 parents 0a933bd + a55f53c commit 0e6df3f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -867,15 +867,21 @@ func FormatSITDaysInStorage(entryDate *time.Time, departureDate *time.Time) stri
func formatDisbursement(expensesMap map[string]float64, ppmRemainingEntitlement float64) string {
disbursementGTCC := expensesMap["TotalGTCCPaid"] + expensesMap["StorageGTCCPaid"]
disbursementGTCCB := ppmRemainingEntitlement + expensesMap["StorageMemberPaid"]
var disbursementMember float64
// Disbursement GTCC is the lowest value of the above 2 calculations
if disbursementGTCCB < disbursementGTCC {
disbursementGTCC = disbursementGTCCB
}
// Disbursement Member is remaining entitlement plus member SIT minus GTCC Disbursement, not less than 0.
disbursementMember := ppmRemainingEntitlement + expensesMap["StorageMemberPaid"] - disbursementGTCC
if disbursementMember < 0 {
disbursementMember = 0
if disbursementGTCC < 0 {
// The only way this can happen is if the member overdrafted on their advance, resulting in negative GTCCB. In this case, the
// disbursement member value will be liable for the negative difference, meaning they owe this money to the govt.
disbursementMember = disbursementGTCC
disbursementGTCC = 0
} else {
// Disbursement Member is remaining entitlement plus member SIT minus GTCC Disbursement, not less than 0.
disbursementMember = ppmRemainingEntitlement + expensesMap["StorageMemberPaid"] - disbursementGTCC
}

// Return formatted values in string
disbursementString := "GTCC: " + FormatDollars(disbursementGTCC) + "\nMember: " + FormatDollars(disbursementMember)
return disbursementString
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1414,6 +1414,17 @@ func (suite *ShipmentSummaryWorksheetServiceSuite) TestFormatDisbursement() {
expensesMap["StorageMemberPaid"] = 200.00
result = formatDisbursement(expensesMap, ppmRemainingEntitlement)
suite.Equal(result, expectedResult)

// Test case 3: GTCC calculation is less than 0
expectedResult = "GTCC: " + FormatDollars(0) + "\nMember: " + FormatDollars(-250.00)
expensesMap = make(map[string]float64)
expensesMap["TotalGTCCPaid"] = 0
expensesMap["StorageGTCCPaid"] = 0
ppmRemainingEntitlement = -300.00
expensesMap["StorageMemberPaid"] = 50.00
result = formatDisbursement(expensesMap, ppmRemainingEntitlement)
suite.Equal(result, expectedResult)

}

func (suite *ShipmentSummaryWorksheetServiceSuite) TestFormatAdditionalShipments() {
Expand Down

0 comments on commit 0e6df3f

Please sign in to comment.