Merge remote-tracking branch 'origin/master'

This commit is contained in:
M_Kececi
2026-06-23 17:37:54 +03:00
parent 0f9b7549ec
commit c2e2c6a295
2 changed files with 18 additions and 16 deletions

View File

@@ -565,18 +565,12 @@ func productSeriesRuleFitsGroup(group string, rule productSeriesAutoRule) bool {
if rule.GroupKey != "" && rule.GroupKey != group {
return false
}
groupSizes := map[string]struct{}{}
for _, size := range productSeriesSizeGroups[group] {
groupSizes[normalizeProductSeriesSize(size)] = struct{}{}
}
if len(groupSizes) == 0 {
return true
}
for size := range rule.Ratio {
if _, ok := groupSizes[size]; !ok {
return false
}
}
// NOTE: In this installation, Nebim ItemDim1Code (size_code) can be numeric tokens that do not match the
// hardcoded group size lists (e.g. "XS/S/M..."). Enforcing those lists causes valid rules to be rejected
// and series assignment to stay blank across many products.
//
// We therefore rely only on explicit rule.GroupKey when provided, and otherwise allow the rule to compete
// based on actual stock consumption.
return true
}

View File

@@ -373,12 +373,20 @@ LIMIT 1
row.MappingWarning = "PG urun veya varyant token eslesmesi bulunamadi"
}
assignKey := assignmentKey(row.ProductCode, row.Dim1ID, row.Dim3ID)
for _, id := range existing[assignKey] {
if d, ok := defByID[id]; ok {
row.SeriesIDs = append(row.SeriesIDs, id)
row.Series = append(row.Series, d)
appendSeries := func(key string) {
for _, id := range existing[key] {
if d, ok := defByID[id]; ok {
row.SeriesIDs = append(row.SeriesIDs, id)
row.Series = append(row.Series, d)
}
}
}
appendSeries(assignKey)
// Fallback: if we couldn't match dim3-specific assignments (dim3 token ambiguity / missing),
// show the default (dim3 NULL) assignments for the same product+color.
if len(row.SeriesIDs) == 0 && row.Dim3Code != "" && row.Dim1ID > 0 {
appendSeries(assignmentKey(row.ProductCode, row.Dim1ID, 0))
}
sort.Slice(row.Series, func(i, j int) bool { return row.Series[i].Code < row.Series[j].Code })
sort.Slice(row.SeriesIDs, func(i, j int) bool { return row.SeriesIDs[i] < row.SeriesIDs[j] })
out = append(out, *row)