Merge remote-tracking branch 'origin/master'

This commit is contained in:
M_Kececi
2026-03-31 14:54:19 +03:00
parent afe77171f4
commit 7b1de24dfb
4 changed files with 97 additions and 16 deletions

View File

@@ -512,10 +512,28 @@ func ValidateItemVariant(tx *sql.Tx, ln models.OrderDetail) error {
SELECT 1 SELECT 1
FROM BAGGI_V3.dbo.prItemVariant V WITH (NOLOCK) FROM BAGGI_V3.dbo.prItemVariant V WITH (NOLOCK)
WHERE ISNULL(LTRIM(RTRIM(V.ItemCode)),'') = @p1 WHERE ISNULL(LTRIM(RTRIM(V.ItemCode)),'') = @p1
AND ISNULL(LTRIM(RTRIM(V.ColorCode)),'') = @p2 AND (
AND UPPER(REPLACE(REPLACE(REPLACE(ISNULL(LTRIM(RTRIM(V.ItemDim1Code)),'') ,' ', ''), 'YAS', ''), 'Y', '')) (
ISNULL(LTRIM(RTRIM(V.ColorCode)),'') = @p2
AND (
ISNULL(LTRIM(RTRIM(@p4)),'') = ''
OR ISNULL(LTRIM(RTRIM(V.ItemDim2Code)),'') = @p4
)
)
OR (
ISNULL(LTRIM(RTRIM(@p4)),'') = ''
AND ISNULL(LTRIM(RTRIM(V.ItemDim2Code)),'') = @p2
)
)
AND (
UPPER(REPLACE(REPLACE(REPLACE(ISNULL(LTRIM(RTRIM(V.ItemDim1Code)),'') ,' ', ''), 'YAS', ''), 'Y', ''))
= UPPER(REPLACE(REPLACE(REPLACE(ISNULL(LTRIM(RTRIM(@p3)),'') ,' ', ''), 'YAS', ''), 'Y', '')) = UPPER(REPLACE(REPLACE(REPLACE(ISNULL(LTRIM(RTRIM(@p3)),'') ,' ', ''), 'YAS', ''), 'Y', ''))
AND ISNULL(LTRIM(RTRIM(V.ItemDim2Code)),'') = @p4 OR (
TRY_CONVERT(INT, NULLIF(UPPER(REPLACE(REPLACE(REPLACE(ISNULL(LTRIM(RTRIM(V.ItemDim1Code)),'') ,' ', ''), 'YAS', ''), 'Y', '')), ''))
= TRY_CONVERT(INT, NULLIF(UPPER(REPLACE(REPLACE(REPLACE(ISNULL(LTRIM(RTRIM(@p3)),'') ,' ', ''), 'YAS', ''), 'Y', '')), ''))
AND TRY_CONVERT(INT, NULLIF(UPPER(REPLACE(REPLACE(REPLACE(ISNULL(LTRIM(RTRIM(@p3)),'') ,' ', ''), 'YAS', ''), 'Y', '')), '')) IS NOT NULL
)
)
) THEN 1 ELSE 0 END ) THEN 1 ELSE 0 END
`, item, color, dim1, dim2).Scan(&exists) `, item, color, dim1, dim2).Scan(&exists)
@@ -555,10 +573,28 @@ func ValidateOrderVariants(db *sql.DB, lines []models.OrderDetail) ([]models.Inv
SELECT 1 SELECT 1
FROM BAGGI_V3.dbo.prItemVariant V WITH (NOLOCK) FROM BAGGI_V3.dbo.prItemVariant V WITH (NOLOCK)
WHERE ISNULL(LTRIM(RTRIM(V.ItemCode)),'') = @p1 WHERE ISNULL(LTRIM(RTRIM(V.ItemCode)),'') = @p1
AND ISNULL(LTRIM(RTRIM(V.ColorCode)),'') = @p2 AND (
AND UPPER(REPLACE(REPLACE(REPLACE(ISNULL(LTRIM(RTRIM(V.ItemDim1Code)),'') ,' ', ''), 'YAS', ''), 'Y', '')) (
ISNULL(LTRIM(RTRIM(V.ColorCode)),'') = @p2
AND (
ISNULL(LTRIM(RTRIM(@p4)),'') = ''
OR ISNULL(LTRIM(RTRIM(V.ItemDim2Code)),'') = @p4
)
)
OR (
ISNULL(LTRIM(RTRIM(@p4)),'') = ''
AND ISNULL(LTRIM(RTRIM(V.ItemDim2Code)),'') = @p2
)
)
AND (
UPPER(REPLACE(REPLACE(REPLACE(ISNULL(LTRIM(RTRIM(V.ItemDim1Code)),'') ,' ', ''), 'YAS', ''), 'Y', ''))
= UPPER(REPLACE(REPLACE(REPLACE(ISNULL(LTRIM(RTRIM(@p3)),'') ,' ', ''), 'YAS', ''), 'Y', '')) = UPPER(REPLACE(REPLACE(REPLACE(ISNULL(LTRIM(RTRIM(@p3)),'') ,' ', ''), 'YAS', ''), 'Y', ''))
AND ISNULL(LTRIM(RTRIM(V.ItemDim2Code)),'') = @p4 OR (
TRY_CONVERT(INT, NULLIF(UPPER(REPLACE(REPLACE(REPLACE(ISNULL(LTRIM(RTRIM(V.ItemDim1Code)),'') ,' ', ''), 'YAS', ''), 'Y', '')), ''))
= TRY_CONVERT(INT, NULLIF(UPPER(REPLACE(REPLACE(REPLACE(ISNULL(LTRIM(RTRIM(@p3)),'') ,' ', ''), 'YAS', ''), 'Y', '')), ''))
AND TRY_CONVERT(INT, NULLIF(UPPER(REPLACE(REPLACE(REPLACE(ISNULL(LTRIM(RTRIM(@p3)),'') ,' ', ''), 'YAS', ''), 'Y', '')), '')) IS NOT NULL
)
)
) THEN 1 ELSE 0 END ) THEN 1 ELSE 0 END
`) `)
if err != nil { if err != nil {

View File

@@ -20,5 +20,5 @@ GROUP BY
prItemVariant.ItemDim2Code, prItemVariant.ItemDim2Code,
prItemVariant.ColorCode, prItemVariant.ColorCode,
ColorDesc.ColorDescription ColorDesc.ColorDescription
ORDER BY ItemDim2Code ORDER BY prItemVariant.ItemDim2Code
` `

View File

@@ -2970,6 +2970,20 @@ async function onColor2Change(colorCode2) {
=========================================================== */ =========================================================== */
const bedenStock = ref([]) // Görsel tablo için stok listesi const bedenStock = ref([]) // Görsel tablo için stok listesi
const stockMap = ref({}) // { "48": 12, "50": 7, ... } şeklinde key-value map const stockMap = ref({}) // { "48": 12, "50": 7, ... } şeklinde key-value map
function warnIfSecondColorMissing() {
const hasSecondColorOptions = Array.isArray(renkOptions2.value) && renkOptions2.value.length > 0
const secondColorEmpty = !String(form.renk2 || '').trim()
if (hasSecondColorOptions && secondColorEmpty) {
$q.notify({
type: 'warning',
message: 'Bu model/renk için 2. renk seçimi önerilir.',
position: 'top-right'
})
}
}
const onSaveOrUpdateRow = async () => { const onSaveOrUpdateRow = async () => {
if (!hasRowMutationPermission()) { if (!hasRowMutationPermission()) {
notifyNoPermission( notifyNoPermission(
@@ -2980,6 +2994,8 @@ const onSaveOrUpdateRow = async () => {
return return
} }
warnIfSecondColorMissing()
await orderStore.saveOrUpdateRowUnified({ await orderStore.saveOrUpdateRowUnified({
form, form,
@@ -3033,6 +3049,8 @@ const onSaveAndNextColor = async () => {
return return
} }
warnIfSecondColorMissing()
const ok = await orderStore.saveOrUpdateRowUnified({ const ok = await orderStore.saveOrUpdateRowUnified({
form, form,
recalcVat: typeof recalcVat === 'function' ? recalcVat : null, recalcVat: typeof recalcVat === 'function' ? recalcVat : null,

View File

@@ -3069,20 +3069,22 @@ export const useOrderEntryStore = defineStore('orderentry', {
} }
// ======================================================= // =======================================================
// 🧪 PRE-VALIDATE — prItemVariant ön kontrol // 🧪 PRE-VALIDATE — prItemVariant ön kontrol (NEW + EDIT)
// - invalid varsa CREATE/UPDATE ÇALIŞMAZ // - invalid varsa CREATE/UPDATE çalışmaz
// ======================================================= // =======================================================
if (!isNew) { const linesToValidate = lines.filter(l =>
const linesToValidate = lines.filter( Number(l?.Qty1 || 0) > 0 &&
l => l._deleteSignal === true || l._dirty === true || !l.OrderLineID l?._deleteSignal !== true &&
String(l?.ItemCode || '').trim() !== ''
) )
if (linesToValidate.length > 0) {
const v = await api.post('/order/validate', { header, lines: linesToValidate }) const v = await api.post('/order/validate', { header, lines: linesToValidate })
const invalid = v?.data?.invalid || [] const invalid = v?.data?.invalid || []
if (invalid.length > 0) { if (invalid.length > 0) {
await this.showInvalidVariantDialog?.($q, invalid) await this.showInvalidVariantDialog?.($q, invalid)
return // ❌ update ÇALIŞMAZ return // ❌ create/update ÇALIŞMAZ
} }
} }
@@ -3245,6 +3247,31 @@ export const useOrderEntryStore = defineStore('orderentry', {
} catch (err) { } catch (err) {
console.error('❌ submitAllReal:', err) console.error('❌ submitAllReal:', err)
const data = err?.response?.data || {}
const status = Number(err?.response?.status || 0)
if (err?.response?.status === 400 && data?.code === 'INVALID_ITEM_VARIANT') {
const oneInvalid = [{
clientKey: data?.clientKey || '',
itemCode: data?.itemCode || '',
colorCode: data?.colorCode || '',
dim1: data?.dim1 || '',
dim2: data?.dim2 || '',
qty1: 0,
reason: data?.message || 'Tanımsız ürün kombinasyonu'
}]
await this.showInvalidVariantDialog?.($q, oneInvalid)
return
}
if (status === 524) {
$q.notify({
type: 'warning',
timeout: 36000,
message: 'Sunucu zaman aşımına uğradı (524). Sipariş kısmen kaydedilmiş olabilir; önce listeden kontrol edin, sonra tekrar deneyin.'
})
return
}
$q.notify({ $q.notify({
type: 'negative', type: 'negative',
message: message: