diff --git a/svc/product_series_auto_scheduler.go b/svc/product_series_auto_scheduler.go index cd44224..e888fce 100644 --- a/svc/product_series_auto_scheduler.go +++ b/svc/product_series_auto_scheduler.go @@ -695,13 +695,19 @@ ORDER BY d.id, r.priority DESC, r.id } out := make([]productSeriesAutoRule, 0, len(byID)) for _, r := range byID { - if len(r.Ratio) == 0 { - for _, part := range strings.Split(r.Title, "-") { - size := normalizeProductSeriesSize(part) - if size != "" { - r.Ratio[size] = 1 - } + // Always augment ratio map from the dfgrp.title tokens. + // mk_product_series_rule can be partially populated (or manually edited), which would allow + // a "subset" rule (e.g. only M+XL) to match stock and incorrectly assign a series like + // "XS-S-M-L-XL-2XL". Title tokens are the canonical definition of a series in this setup. + for _, part := range strings.Split(r.Title, "-") { + size := normalizeProductSeriesSize(part) + if size == "" { + continue } + if _, ok := r.Ratio[size]; ok { + continue + } + r.Ratio[size] = 1 } if len(r.Ratio) > 0 { out = append(out, *r)