Skip to content

Commit

Permalink
Merge pull request #13633 from transcom/B-20943
Browse files Browse the repository at this point in the history
B 20943
  • Loading branch information
r-mettler authored Sep 12, 2024
2 parents 402f356 + 6b89307 commit dad17c3
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ type textField struct {
Locked bool `json:"locked"`
}

var newline = "\n\n"

// WorkSheetShipment is an object representing specific shipment items on Shipment Summary Worksheet
type WorkSheetShipment struct {
EstimatedIncentive string
Expand Down Expand Up @@ -235,17 +233,17 @@ func FormatValuesShipmentSummaryWorksheetFormPage1(data services.ShipmentSummary
page1.WeightAllotmentProgearSpouse = FormatWeights(data.WeightAllotment.SpouseProGear)
page1.TotalWeightAllotment = FormatWeights(data.WeightAllotment.TotalWeight)

formattedSIT := WorkSheetSIT{}

formattedShipment := FormatShipment(data.PPMShipment, isPaymentPacket)
page1.ShipmentNumberAndTypes = formattedShipment.ShipmentNumberAndTypes
page1.ShipmentPickUpDates = formattedShipment.PickUpDates
page1.ShipmentCurrentShipmentStatuses = formattedShipment.CurrentShipmentStatuses
formattedSIT := FormatAllSITS(data.PPMShipments)
page1.SITDaysInStorage = formattedSIT.DaysInStorage
page1.SITEntryDates = formattedSIT.EntryDates
page1.SITEndDates = formattedSIT.EndDates
page1.SITNumberAndTypes = formattedShipment.ShipmentNumberAndTypes

// Shipment weights for Payment Packet are actual, for AOA Packet are estimated.
if isPaymentPacket {
formattedSIT = FormatAllSITSForPaymentPacket(data.MovingExpenses)

finalPPMWeight := FormatPPMWeightFinal(data.PPMShipmentFinalWeight)
page1.ShipmentWeights = finalPPMWeight
page1.ActualObligationGCC100 = finalPPMWeight + "; " + formattedShipment.FinalIncentive
Expand All @@ -254,10 +252,19 @@ func FormatValuesShipmentSummaryWorksheetFormPage1(data services.ShipmentSummary
return page1, err
}
} else {
formattedSIT = FormatAllSITSForAOAPacket(data.PPMShipment)

page1.ShipmentWeights = formattedShipment.ShipmentWeights
page1.ActualObligationGCC100 = formattedShipment.ShipmentWeightForObligation + " - Estimated lbs; " + formattedShipment.FinalIncentive

page1.PreparationDate1 = formatAOADate(data.SignedCertifications, data.PPMShipment.ID)
}

page1.SITDaysInStorage = formattedSIT.DaysInStorage
page1.SITEntryDates = formattedSIT.EntryDates
page1.SITEndDates = formattedSIT.EndDates
page1.SITNumberAndTypes = formattedShipment.ShipmentNumberAndTypes

page1.MaxObligationGCC100 = FormatWeights(data.WeightAllotment.Entitlement) + " lbs; " + formattedShipment.EstimatedIncentive
page1.MaxObligationGCCMaxAdvance = formattedShipment.MaxAdvance
page1.ActualObligationAdvance = formattedShipment.AdvanceAmountReceived
Expand Down Expand Up @@ -540,28 +547,31 @@ func FormatShipment(ppm models.PPMShipment, isPaymentPacket bool) WorkSheetShipm
return formattedShipment
}

// FormatAllSITs formats SIT line items for the Shipment Summary Worksheet
func FormatAllSITS(ppms models.PPMShipments) WorkSheetSIT {
totalSITS := len(ppms)
// FormatAllSITs formats SIT line items for the Shipment Summary Worksheet Payment Packet
func FormatAllSITSForPaymentPacket(expenseDocuments models.MovingExpenses) WorkSheetSIT {
formattedSIT := WorkSheetSIT{}
formattedSITNumberAndTypes := make([]string, totalSITS)
formattedSITEntryDates := make([]string, totalSITS)
formattedSITEndDates := make([]string, totalSITS)
formattedSITDaysInStorage := make([]string, totalSITS)
var sitNumber int

for _, ppm := range ppms {
// formattedSITNumberAndTypes[sitNumber] = FormatPPMNumberAndType(sitNumber)
formattedSITEntryDates[sitNumber] = FormatSITEntryDate(ppm)
formattedSITEndDates[sitNumber] = FormatSITEndDate(ppm)
formattedSITDaysInStorage[sitNumber] = FormatSITDaysInStorage(ppm)
for _, expense := range expenseDocuments {
if *expense.MovingExpenseType == models.MovingExpenseReceiptTypeStorage {
formattedSIT.EntryDates = FormatSITDate(expense.SITStartDate)
formattedSIT.EndDates = FormatSITDate(expense.SubmittedSITEndDate)
formattedSIT.DaysInStorage = FormatSITDaysInStorage(expense.SITStartDate, expense.SubmittedSITEndDate)
return formattedSIT
}
}

return formattedSIT
}

// FormatAllSITs formats SIT line items for the Shipment Summary Worksheet AOA Packet
func FormatAllSITSForAOAPacket(ppm models.PPMShipment) WorkSheetSIT {
formattedSIT := WorkSheetSIT{}

sitNumber++
if ppm.SITEstimatedEntryDate != nil && ppm.SITEstimatedDepartureDate != nil {
formattedSIT.EntryDates = FormatSITDate(ppm.SITEstimatedEntryDate)
formattedSIT.EndDates = FormatSITDate(ppm.SITEstimatedDepartureDate)
formattedSIT.DaysInStorage = FormatSITDaysInStorage(ppm.SITEstimatedEntryDate, ppm.SITEstimatedDepartureDate)
}
formattedSIT.NumberAndTypes = strings.Join(formattedSITNumberAndTypes, newline)
formattedSIT.EntryDates = strings.Join(formattedSITEntryDates, newline)
formattedSIT.EndDates = strings.Join(formattedSITEndDates, newline)
formattedSIT.DaysInStorage = strings.Join(formattedSITDaysInStorage, newline)

return formattedSIT
}
Expand Down Expand Up @@ -641,29 +651,21 @@ func FormatPPMWeightFinal(weight unit.Pound) string {
return fmt.Sprintf("%s lbs - Actual", wtg)
}

// FormatSITEntryDate formats a SIT EstimatedEntryDate for the Shipment Summary Worksheet
func FormatSITEntryDate(ppm models.PPMShipment) string {
if ppm.SITEstimatedEntryDate == nil {
return "No Entry Data" // Return string if no SIT attached
}
return FormatDate(*ppm.SITEstimatedEntryDate)
}

// FormatSITEndDate formats a SIT EstimatedPickupDate for the Shipment Summary Worksheet
func FormatSITEndDate(ppm models.PPMShipment) string {
if ppm.SITEstimatedDepartureDate == nil {
return "No Departure Data" // Return string if no SIT attached
// FormatSITDate formats a SIT Date for the Shipment Summary Worksheet
func FormatSITDate(sitDate *time.Time) string {
if sitDate == nil {
return "No SIT date" // Return string if no date found
}
return FormatDate(*ppm.SITEstimatedDepartureDate)
return FormatDate(*sitDate)
}

// FormatSITDaysInStorage formats a SIT DaysInStorage for the Shipment Summary Worksheet
func FormatSITDaysInStorage(ppm models.PPMShipment) string {
if ppm.SITEstimatedEntryDate == nil || ppm.SITEstimatedDepartureDate == nil {
func FormatSITDaysInStorage(entryDate *time.Time, departureDate *time.Time) string {
if entryDate == nil || departureDate == nil {
return "No Entry/Departure Data" // Return string if no SIT attached
}
firstDate := ppm.SITEstimatedDepartureDate
secondDate := *ppm.SITEstimatedEntryDate
firstDate := *departureDate
secondDate := *entryDate
difference := firstDate.Sub(secondDate)
formattedDifference := fmt.Sprintf("Days: %d\n", int64(difference.Hours()/24)+1)
return formattedDifference
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -892,6 +892,16 @@ func (suite *ShipmentSummaryWorksheetServiceSuite) TestFillSSWPDFForm() {
},
}, nil)

storageExpenseType := models.MovingExpenseReceiptTypeStorage
movingExpense := models.MovingExpense{
MovingExpenseType: &storageExpenseType,
Amount: models.CentPointer(unit.Cents(67899)),
SITStartDate: models.TimePointer(time.Now()),
SITEndDate: models.TimePointer(time.Now()),
}

factory.AddMovingExpenseToPPMShipment(suite.DB(), &ppmShipment, nil, &movingExpense)

ppmShipmentID := ppmShipment.ID

serviceMemberID := ppmShipment.Shipment.MoveTaskOrder.Orders.ServiceMemberID
Expand Down

0 comments on commit dad17c3

Please sign in to comment.