Update Auto Generate SKU

This commit is contained in:
2025-06-27 13:34:54 +07:00
parent f8798a53a4
commit 9b1f58d783
5 changed files with 62 additions and 2 deletions
@@ -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
}