23 lines
477 B
Go
23 lines
477 B
Go
package service
|
|
|
|
import (
|
|
"BE-MiniERP/modules/inventory/models"
|
|
"fmt"
|
|
)
|
|
|
|
func GenerateSKU(product *models.Product) (string, error) {
|
|
if product.Collection.Code == "" ||
|
|
product.Category.Code == "" ||
|
|
product.Colour.Code == "" ||
|
|
product.Size.Code == "" {
|
|
return "", fmt.Errorf("missing code from one or more components")
|
|
}
|
|
|
|
return fmt.Sprintf("%s-%s-%s-%s",
|
|
product.Collection.Code,
|
|
product.Category.Code,
|
|
product.Colour.Code,
|
|
product.Size.Code,
|
|
), nil
|
|
}
|