Update Auto Generate SKU
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user