diff --git a/.idea/feragstring.iml b/.idea/feragstring.iml index c956989..5e764c4 100644 --- a/.idea/feragstring.iml +++ b/.idea/feragstring.iml @@ -1,5 +1,6 @@ + diff --git a/production_drop.go b/production_drop.go index cdf38de..6bdbb4a 100644 --- a/production_drop.go +++ b/production_drop.go @@ -6,11 +6,12 @@ import "fmt" // underneath a route type ProductionDrop struct { FeragMessage - agentName string - numberOfCopies int - ControlCharacters ControlCharacterSet - dontProduce bool - topsheetData string + agentName string + numberOfCopies int + ControlCharacters ControlCharacterSet + dontProduce bool + topsheetData string + productReferenceNumbers []int } // TopsheetData returns the formatted topsheet data segment @@ -38,6 +39,20 @@ func (pd *ProductionDrop) SetTopsheetData(topsheetData string) { pd.topsheetData = topsheetData } +// ProductReferenceNumbers returns the string of TSL-formatted ProductReferenceNumbers +func (pd *ProductionDrop) ProductReferenceNumbers() string { + var prreffmt string + for _, pr := range pd.productReferenceNumbers { + prreffmt += fmt.Sprintf("+99141%03d", pr) + } + return prreffmt +} + +// AddProductReferenceNumber adds a numeric ProductReferenceNumber to the production drop +func (pd *ProductionDrop) AddProductReferenceNumber(productReferenceNumber int) { + pd.productReferenceNumbers = append(pd.productReferenceNumbers, productReferenceNumber) +} + // NumberOfCopies returns the formatted number of copies in the route func (pd *ProductionDrop) NumberOfCopies() string { return fmt.Sprintf("+13%05d", pd.numberOfCopies) @@ -77,6 +92,7 @@ func (pd *ProductionDrop) Payload() string { data := pd.AgentName() data += pd.NumberOfCopies() data += pd.ControlCharacters.GetControlCharactersMessage() + data += pd.ProductReferenceNumbers() return data }