Merge remote-tracking branch 'origin/master'

This commit is contained in:
M_Kececi
2026-03-13 14:40:48 +03:00
parent 706f530315
commit e341489d6e

View File

@@ -150,9 +150,16 @@ WHERE b.typ = 'img'
AND (
-- exact code match (spaces ignored)
UPPER(REPLACE(COALESCE(i.code,''), ' ', '')) = UPPER(REPLACE(COALESCE($1,''), ' ', ''))
-- or exact core-code match after last '-' (e.g. S901-DMY18252 -> DMY18252)
OR UPPER(REPLACE(REGEXP_REPLACE(COALESCE(i.code,''), '^.*-', ''), ' ', '')) =
UPPER(REPLACE(REGEXP_REPLACE(COALESCE($1,''), '^.*-', ''), ' ', ''))
-- core-code fallback only when there is no exact item code for the input
OR (
NOT EXISTS (
SELECT 1
FROM mmitem ix
WHERE UPPER(REPLACE(COALESCE(ix.code,''), ' ', '')) = UPPER(REPLACE(COALESCE($1,''), ' ', ''))
)
AND UPPER(REPLACE(REGEXP_REPLACE(COALESCE(i.code,''), '^.*-', ''), ' ', '')) =
UPPER(REPLACE(REGEXP_REPLACE(COALESCE($1,''), '^.*-', ''), ' ', ''))
)
)
ORDER BY
COALESCE(b.sort_order,999999),