Skip to content

Commit

Permalink
Merge pull request #13617 from transcom/B-20942-SSW-Label
Browse files Browse the repository at this point in the history
B 20942 ssw label
  • Loading branch information
r-mettler authored Sep 5, 2024
2 parents 889f7f4 + e84ecdc commit 258daa4
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 120 deletions.
Binary file modified pkg/assets/paperwork/formtemplates/SSWPDFTemplate.pdf
Binary file not shown.
100 changes: 38 additions & 62 deletions pkg/services/shipment_summary_worksheet/shipment_summary_worksheet.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,23 +81,19 @@ type textField struct {

var newline = "\n\n"

// WorkSheetShipments is an object representing shipment line items on Shipment Summary Worksheet
type WorkSheetShipments struct {
// WorkSheetShipment is an object representing specific shipment items on Shipment Summary Worksheet
type WorkSheetShipment struct {
EstimatedIncentive string
MaxAdvance string
FinalIncentive string
AdvanceAmountReceived string
ShipmentNumberAndTypes string
PickUpDates string
ShipmentWeights string
ShipmentWeightForObligation string
CurrentShipmentStatuses string
}

// WorkSheetShipment is an object representing specific shipment items on Shipment Summary Worksheet
type WorkSheetShipment struct {
EstimatedIncentive string
MaxAdvance string
FinalIncentive string
AdvanceAmountReceived string
}

// WorkSheetSIT is an object representing SIT on the Shipment Summary Worksheet
type WorkSheetSIT struct {
NumberAndTypes string
Expand Down Expand Up @@ -239,16 +235,15 @@ func FormatValuesShipmentSummaryWorksheetFormPage1(data services.ShipmentSummary
page1.WeightAllotmentProgearSpouse = FormatWeights(data.WeightAllotment.SpouseProGear)
page1.TotalWeightAllotment = FormatWeights(data.WeightAllotment.TotalWeight)

formattedShipments := FormatAllShipments(data.PPMShipments)
page1.ShipmentNumberAndTypes = formattedShipments.ShipmentNumberAndTypes
page1.ShipmentPickUpDates = formattedShipments.PickUpDates
page1.ShipmentCurrentShipmentStatuses = formattedShipments.CurrentShipmentStatuses
formattedShipment := FormatShipment(data.PPMShipment, isPaymentPacket)
page1.ShipmentNumberAndTypes = formattedShipment.ShipmentNumberAndTypes
page1.ShipmentPickUpDates = formattedShipment.PickUpDates
page1.ShipmentCurrentShipmentStatuses = formattedShipment.CurrentShipmentStatuses
formattedSIT := FormatAllSITS(data.PPMShipments)
formattedShipment := FormatCurrentShipment(data.PPMShipment)
page1.SITDaysInStorage = formattedSIT.DaysInStorage
page1.SITEntryDates = formattedSIT.EntryDates
page1.SITEndDates = formattedSIT.EndDates
page1.SITNumberAndTypes = formattedShipments.ShipmentNumberAndTypes
page1.SITNumberAndTypes = formattedShipment.ShipmentNumberAndTypes
// Shipment weights for Payment Packet are actual, for AOA Packet are estimated.
if isPaymentPacket {
finalPPMWeight := FormatPPMWeightFinal(data.PPMShipmentFinalWeight)
Expand All @@ -259,8 +254,8 @@ func FormatValuesShipmentSummaryWorksheetFormPage1(data services.ShipmentSummary
return page1, err
}
} else {
page1.ShipmentWeights = formattedShipments.ShipmentWeights
page1.ActualObligationGCC100 = formattedShipments.ShipmentWeightForObligation + " - Estimated lbs; " + formattedShipment.FinalIncentive
page1.ShipmentWeights = formattedShipment.ShipmentWeights
page1.ActualObligationGCC100 = formattedShipment.ShipmentWeightForObligation + " - Estimated lbs; " + formattedShipment.FinalIncentive
page1.PreparationDate1 = formatAOADate(data.SignedCertifications, data.PPMShipment.ID)
}
page1.MaxObligationGCC100 = FormatWeights(data.WeightAllotment.TotalWeight) + " lbs; " + formattedShipment.EstimatedIncentive
Expand All @@ -278,7 +273,7 @@ func FormatValuesShipmentSummaryWorksheetFormPage2(data services.ShipmentSummary
var err error
expensesMap := SubTotalExpenses(data.MovingExpenses)
certificationInfo := formatSignedCertifications(data.SignedCertifications, data.PPMShipment.ID)
formattedShipments := FormatAllShipments(data.PPMShipments)
formattedShipments := FormatShipment(data.PPMShipment, isPaymentPacket)

page2 := services.Page2Values{}
page2.CUIBanner = controlledUnclassifiedInformationText
Expand Down Expand Up @@ -489,7 +484,7 @@ func FormatServiceMemberFullName(serviceMember models.ServiceMember) string {
return strings.TrimSpace(fmt.Sprintf("%s, %s %s", lastName, firstName, middleName))
}

func FormatCurrentShipment(ppm models.PPMShipment) WorkSheetShipment {
func FormatShipment(ppm models.PPMShipment, isPaymentPacket bool) WorkSheetShipment {
formattedShipment := WorkSheetShipment{}

if ppm.FinalIncentive != nil {
Expand All @@ -509,38 +504,33 @@ func FormatCurrentShipment(ppm models.PPMShipment) WorkSheetShipment {
} else {
formattedShipment.AdvanceAmountReceived = "No advance received."
}

return formattedShipment
}

// FormatAllShipments formats Shipment line items for the Shipment Summary Worksheet
func FormatAllShipments(ppms models.PPMShipments) WorkSheetShipments {
totalShipments := len(ppms)
formattedShipments := WorkSheetShipments{}
formattedNumberAndTypes := make([]string, totalShipments)
formattedPickUpDates := make([]string, totalShipments)
formattedShipmentWeights := make([]string, totalShipments)
formattedShipmentStatuses := make([]string, totalShipments)
formattedShipmentTotalWeights := unit.Pound(0)
var shipmentNumber int
formattedNumberAndTypes := ppm.Shipment.ShipmentLocator
formattedShipmentWeights := FormatPPMWeightEstimated(ppm)
formattedShipmentStatuses := FormatCurrentPPMStatus(ppm)
if ppm.EstimatedWeight != nil {
formattedShipmentTotalWeights += *ppm.EstimatedWeight
}

for _, ppm := range ppms {
formattedNumberAndTypes[shipmentNumber] = FormatPPMNumberAndType(shipmentNumber)
formattedPickUpDates[shipmentNumber] = FormatPPMPickupDate(ppm)
formattedShipmentWeights[shipmentNumber] = FormatPPMWeightEstimated(ppm)
formattedShipmentStatuses[shipmentNumber] = FormatCurrentPPMStatus(ppm)
if ppm.EstimatedWeight != nil {
formattedShipmentTotalWeights += *ppm.EstimatedWeight
formattedPickUpDates := FormatDate(ppm.ExpectedDepartureDate)
if isPaymentPacket {
formattedPickUpDates = "N/A"
if ppm.ActualMoveDate != nil {
formattedPickUpDates = FormatDate(*ppm.ActualMoveDate)
}
shipmentNumber++
}
// Last resort in case any dates are stored incorrectly
if formattedPickUpDates == "01-Jan-0001" {
formattedPickUpDates = "N/A"
}

formattedShipment.ShipmentNumberAndTypes = *formattedNumberAndTypes
formattedShipment.PickUpDates = formattedPickUpDates
formattedShipment.ShipmentWeights = formattedShipmentWeights
formattedShipment.ShipmentWeightForObligation = FormatWeights(formattedShipmentTotalWeights)
formattedShipment.CurrentShipmentStatuses = formattedShipmentStatuses

formattedShipments.ShipmentNumberAndTypes = strings.Join(formattedNumberAndTypes, newline)
formattedShipments.PickUpDates = strings.Join(formattedPickUpDates, newline)
formattedShipments.ShipmentWeights = strings.Join(formattedShipmentWeights, newline)
formattedShipments.ShipmentWeightForObligation = FormatWeights(formattedShipmentTotalWeights)
formattedShipments.CurrentShipmentStatuses = strings.Join(formattedShipmentStatuses, newline)
return formattedShipments
return formattedShipment
}

// FormatAllSITs formats SIT line items for the Shipment Summary Worksheet
Expand Down Expand Up @@ -624,11 +614,6 @@ func FormatCurrentPPMStatus(ppm models.PPMShipment) string {
return FormatEnum(string(ppm.Status), " ")
}

// FormatPPMNumberAndType formats FormatShipmentNumberAndType for the Shipment Summary Worksheet
func FormatPPMNumberAndType(i int) string {
return fmt.Sprintf("%02d - PPM", i+1)
}

// FormatSITNumberAndType formats FormatSITNumberAndType for the Shipment Summary Worksheet
func FormatSITNumberAndType(i int) string {
return fmt.Sprintf("%02d - SIT", i+1)
Expand All @@ -649,15 +634,6 @@ func FormatPPMWeightFinal(weight unit.Pound) string {
return fmt.Sprintf("%s lbs - Actual", wtg)
}

// FormatPPMPickupDate formats a shipments ActualPickupDate for the Shipment Summary Worksheet
func FormatPPMPickupDate(ppm models.PPMShipment) string {
// nil check just incase of bad ppm state. if so return not available.
if ppm.ActualMoveDate == nil {
return "N/A"
}
return FormatDate(*ppm.ActualMoveDate)
}

// FormatSITEntryDate formats a SIT EstimatedEntryDate for the Shipment Summary Worksheet
func FormatSITEntryDate(ppm models.PPMShipment) string {
if ppm.SITEstimatedEntryDate == nil {
Expand Down Expand Up @@ -913,7 +889,7 @@ func (SSWPPMGenerator *SSWPPMGenerator) FillSSWPDFForm(Page1Values services.Page
var sswHeader = header{
Source: "SSWPDFTemplate.pdf",
Version: "pdfcpu v0.8.0 dev",
Creation: "2024-08-21 19:31:01 UTC",
Creation: "2024-08-27 16:39:37 UTC",
Producer: "macOS Version 13.5 (Build 22G74) Quartz PDFContext, AppendMode 1.1",
}

Expand Down
Loading

0 comments on commit 258daa4

Please sign in to comment.