Merge remote-tracking branch 'origin/master'

This commit is contained in:
M_Kececi
2026-06-23 18:12:52 +03:00
parent 750444b9c8
commit f6cf6bb4cc
2 changed files with 16 additions and 1 deletions

View File

@@ -104,7 +104,8 @@ func productSeriesFallbackAutoCreateEnabled() bool {
func productSeriesFallbackCode() string {
code := strings.TrimSpace(os.Getenv("PRODUCT_SERIES_FALLBACK_SERIES_CODE"))
if code == "" {
code = "1-"
// In this installation, the default series code is "1" (not "1-").
code = "1"
}
return code
}

View File

@@ -76,12 +76,26 @@ CREATE TABLE IF NOT EXISTS mk_product_series_job_log (
return err
}
}
// Ensure a default fallback series exists for "stok var ama seri secilemedi" cases.
// The scheduler may apply it when no other rule matches. We create only the definition;
// we intentionally do NOT auto-seed mk_product_series_rule from its title.
// Default code for this installation is "1".
_, _ = pg.Exec(`
INSERT INTO dfgrp (code, title, is_active, typ, master, parent_filter, sort_order, is_required, notes)
SELECT '1', '', TRUE, 'opt', 'zbggseri', '', 0, FALSE, 'auto-created fallback series'
WHERE NOT EXISTS (
SELECT 1 FROM dfgrp WHERE master='zbggseri' AND code='1'
)
`)
_, err := pg.Exec(`
INSERT INTO mk_product_series_rule (series_id, size_group, size_code, ratio_qty, priority, source, notes)
SELECT d.id, '', BTRIM(x.size_code), 1, 0, 'dfgrp_title', 'auto-seeded from dfgrp.title'
FROM dfgrp d
CROSS JOIN LATERAL regexp_split_to_table(COALESCE(d.title, ''), '-') AS x(size_code)
WHERE d.master='zbggseri'
AND COALESCE(d.code,'') <> '1'
AND BTRIM(x.size_code) <> ''
ON CONFLICT (series_id, size_group, size_code) DO NOTHING
`)