Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
`)
|
||||
|
||||
Reference in New Issue
Block a user