Add products with a product reference number
A product reference number is only assigned (and the central counter incremented) if the product has no product reference number attached. Fixes #14
This commit is contained in:
parent
0a14f56ddb
commit
4b2dda8301
2 changed files with 9 additions and 3 deletions
2
ferag.go
2
ferag.go
|
@ -84,8 +84,10 @@ func (fs *FeragString) PrintOut() string {
|
||||||
// AddProductReference adds a Product Reference instance to the list
|
// AddProductReference adds a Product Reference instance to the list
|
||||||
// of product references of the FeragString
|
// of product references of the FeragString
|
||||||
func (fs *FeragString) AddProductReference(pr *ProductReference) error {
|
func (fs *FeragString) AddProductReference(pr *ProductReference) error {
|
||||||
|
if pr.productReferenceNumber == 0 {
|
||||||
fs.ProductReferencesNr++
|
fs.ProductReferencesNr++
|
||||||
pr.SetProductReferenceNumber(fs.ProductReferencesNr)
|
pr.SetProductReferenceNumber(fs.ProductReferencesNr)
|
||||||
|
}
|
||||||
if pr.productReferenceNumber == 1 && pr.productUsageType == 0 {
|
if pr.productReferenceNumber == 1 && pr.productUsageType == 0 {
|
||||||
pr.SetProductUsageType(1)
|
pr.SetProductUsageType(1)
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,13 +119,17 @@ func (pr *ProductReference) SetProductName(productName string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pr *ProductReference) ProductReferenceNumber() string {
|
func (pr *ProductReference) ProductReferenceNumber() string {
|
||||||
return fmt.Sprintf("+41%02d", pr.productReferenceNumber)
|
return fmt.Sprintf("+99141%03d", pr.productReferenceNumber)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pr *ProductReference) SetProductReferenceNumber(productReferenceNumber int) {
|
func (pr *ProductReference) SetProductReferenceNumber(productReferenceNumber int) {
|
||||||
pr.productReferenceNumber = productReferenceNumber
|
pr.productReferenceNumber = productReferenceNumber
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (pr *ProductReference) GetProductReferenceNumber() int {
|
||||||
|
return pr.productReferenceNumber
|
||||||
|
}
|
||||||
|
|
||||||
func NewProductReference() *ProductReference {
|
func NewProductReference() *ProductReference {
|
||||||
pr := ProductReference{
|
pr := ProductReference{
|
||||||
FeragMessage: FeragMessage{"2450", "!"},
|
FeragMessage: FeragMessage{"2450", "!"},
|
||||||
|
|
Loading…
Reference in a new issue