Added product reference numbers to production drops. Fixes #13

This commit is contained in:
Oliver Jakoubek 2023-03-24 08:55:06 +01:00
parent 9c4df123df
commit 0a14f56ddb
2 changed files with 22 additions and 5 deletions

View file

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4"> <module type="WEB_MODULE" version="4">
<component name="Go" enabled="true" />
<component name="NewModuleRootManager"> <component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" /> <content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" /> <orderEntry type="inheritedJdk" />

View file

@ -11,6 +11,7 @@ type ProductionDrop struct {
ControlCharacters ControlCharacterSet ControlCharacters ControlCharacterSet
dontProduce bool dontProduce bool
topsheetData string topsheetData string
productReferenceNumbers []int
} }
// TopsheetData returns the formatted topsheet data segment // TopsheetData returns the formatted topsheet data segment
@ -38,6 +39,20 @@ func (pd *ProductionDrop) SetTopsheetData(topsheetData string) {
pd.topsheetData = topsheetData 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 // NumberOfCopies returns the formatted number of copies in the route
func (pd *ProductionDrop) NumberOfCopies() string { func (pd *ProductionDrop) NumberOfCopies() string {
return fmt.Sprintf("+13%05d", pd.numberOfCopies) return fmt.Sprintf("+13%05d", pd.numberOfCopies)
@ -77,6 +92,7 @@ func (pd *ProductionDrop) Payload() string {
data := pd.AgentName() data := pd.AgentName()
data += pd.NumberOfCopies() data += pd.NumberOfCopies()
data += pd.ControlCharacters.GetControlCharactersMessage() data += pd.ControlCharacters.GetControlCharactersMessage()
data += pd.ProductReferenceNumbers()
return data return data
} }