Merge remote-tracking branch 'origin/master'

This commit is contained in:
M_Kececi
2026-03-05 09:53:48 +03:00
parent 94244b194a
commit 431781e765
6 changed files with 3787 additions and 1814 deletions

View File

@@ -422,7 +422,7 @@ export const useOrderEntryStore = defineStore('orderentry', {
const detail = await extractApiErrorDetail(err)
const orderId = id || this.header?.OrderHeaderID || '-'
const status = err?.status || err?.response?.status || '-'
console.error(`? PDF a<EFBFBD>ma hatas<EFBFBD> [${status}] order=${orderId}: ${detail}`)
console.error(`? PDF a<>ma hatas<61> [${status}] order=${orderId}: ${detail}`)
throw new Error(detail)
}
}
@@ -1702,15 +1702,15 @@ export const useOrderEntryStore = defineStore('orderentry', {
: {}
/* ===== SAME COMBO → UPDATE ===== */
if (sameCombo) {
rows[idx] = {
...prev,
...newRow,
_dirty: true,
id: prev.id,
OrderLineID: prev.OrderLineID || null,
lineIdMap: preservedLineIdMap
}
if (sameCombo) {
rows[idx] = {
...prev,
...newRow,
_dirty: true,
id: prev.id,
OrderLineID: prev.OrderLineID || null,
lineIdMap: preservedLineIdMap
}
this.summaryRows = rows
this.orders = rows
@@ -1763,13 +1763,13 @@ export const useOrderEntryStore = defineStore('orderentry', {
comboLineIds: { ...(prev.comboLineIds || {}) }
}
const insertedRow = {
...newRow,
_dirty: true,
id: crypto.randomUUID(),
OrderLineID: null,
lineIdMap: {}
}
const insertedRow = {
...newRow,
_dirty: true,
id: crypto.randomUUID(),
OrderLineID: null,
lineIdMap: {}
}
rows.splice(idx, 1, insertedRow)
@@ -1838,14 +1838,14 @@ export const useOrderEntryStore = defineStore('orderentry', {
const price = Number(newRow?.fiyat ?? prev?.fiyat ?? 0)
const totalTutar = Number((totalAdet * price).toFixed(2))
rows[dupIdx] = {
...prev,
...newRow,
_dirty: true,
rows[dupIdx] = {
...prev,
...newRow,
_dirty: true,
// kritik korumalar
id: prev.id,
OrderLineID: prev.OrderLineID || null,
// kritik korumalar
id: prev.id,
OrderLineID: prev.OrderLineID || null,
lineIdMap: { ...(prev.lineIdMap || {}) },
// MERGED bedenMap
@@ -1873,13 +1873,13 @@ export const useOrderEntryStore = defineStore('orderentry', {
}
// dup yoksa (veya dup delete satırıydı) → yeni satır
rows.push({
...newRow,
_dirty: true,
id: newRow.id || crypto.randomUUID(),
OrderLineID: null,
lineIdMap: { ...(newRow.lineIdMap || {}) }
})
rows.push({
...newRow,
_dirty: true,
id: newRow.id || crypto.randomUUID(),
OrderLineID: null,
lineIdMap: { ...(newRow.lineIdMap || {}) }
})
this.summaryRows = rows
this.orders = rows
@@ -2206,8 +2206,33 @@ export const useOrderEntryStore = defineStore('orderentry', {
// ❗ BEDEN YOK → bu SADECE üst seviye grup anahtarı
const modelKey = `${model}||${renk}||${renk2}`
const grpKey = raw.grpKey || 'tak'
const srcMap = raw.bedenMap[grpKey] || {}
// grouped map: { [grpKey]: { beden: qty } } or flat map: { beden: qty }
const groupedKey =
raw.grpKey ||
(raw.bedenMap && typeof raw.bedenMap === 'object'
? Object.keys(raw.bedenMap).find(k => raw.bedenMap[k] && typeof raw.bedenMap[k] === 'object')
: null)
const srcMap =
groupedKey && raw.bedenMap?.[groupedKey] && typeof raw.bedenMap[groupedKey] === 'object'
? raw.bedenMap[groupedKey]
: raw.bedenMap
const grpKey =
groupedKey ||
detectBedenGroup(
Object.keys(srcMap || {}),
raw.urunAnaGrubu || raw.UrunAnaGrubu || '',
raw.kategori || raw.Kategori || raw.urunAltGrubu || raw.UrunAltGrubu || '',
raw.yetiskinGarson ||
raw.YETISKIN_GARSON ||
raw.YetiskinGarson ||
raw.AskiliYan ||
raw.ASKILIYAN ||
raw.askiliyan ||
''
) ||
'tak'
const adet = Object.values(srcMap).reduce((a, b) => a + (Number(b) || 0), 0)
const fiyat = Number(raw.fiyat || 0)
@@ -2264,7 +2289,16 @@ export const useOrderEntryStore = defineStore('orderentry', {
urunAnaGrubu: raw.UrunAnaGrubu || 'GENEL',
urunAltGrubu: raw.UrunAltGrubu || '',
kategori: raw.Kategori || '',
kategori: raw.Kategori || raw.UrunAltGrubu || '',
urunAltGrubu: raw.UrunAltGrubu || '',
yetiskinGarson:
raw.YETISKIN_GARSON ||
raw.YetiskinGarson ||
raw.yetiskinGarson ||
raw.AskiliYan ||
raw.ASKILIYAN ||
raw.askiliyan ||
'',
aciklama: raw.LineDescription || '',
fiyat: Number(raw.Price || 0),
@@ -2321,7 +2355,8 @@ export const useOrderEntryStore = defineStore('orderentry', {
const grpKey = detectBedenGroup(
bedenList,
row.urunAnaGrubu,
row.kategori
row.kategori || row.urunAltGrubu,
row.yetiskinGarson
)
const cleanedMap = { ...row.__tmpMap }
@@ -2516,7 +2551,7 @@ export const useOrderEntryStore = defineStore('orderentry', {
return detectBedenGroup(
null,
row?.urunAnaGrubu || '',
row?.kategori || '',
row?.kategori || row?.urunAltGrubu || '',
row?.YETISKIN_GARSON || row?.yetiskinGarson || ''
)
},
@@ -3055,12 +3090,12 @@ export const useOrderEntryStore = defineStore('orderentry', {
// ComboKey stabil kalsın diye bedenKey kullan
const comboKey = buildComboKey(row, bedenKey)
const makeLine = () => ({
OrderLineID: orderLineId || '',
ClientKey: makeLineClientKey(row, grpKey, bedenKey),
ComboKey: comboKey,
_dirty: row?._dirty === true,
_deleteSignal: isDeleteSignal === true,
const makeLine = () => ({
OrderLineID: orderLineId || '',
ClientKey: makeLineClientKey(row, grpKey, bedenKey),
ComboKey: comboKey,
_dirty: row?._dirty === true,
_deleteSignal: isDeleteSignal === true,
SortOrder: 0,
ItemTypeCode: 1,
@@ -3128,30 +3163,30 @@ export const useOrderEntryStore = defineStore('orderentry', {
DOVCode: ''
})
const existing = lineByCombo.get(comboKey)
const existing = lineByCombo.get(comboKey)
if (!existing) {
const ln = makeLine()
lineByCombo.set(comboKey, ln)
lines.push(ln)
return
}
if (!existing) {
const ln = makeLine()
lineByCombo.set(comboKey, ln)
lines.push(ln)
return
}
/* DELETE */
if (isDeleteSignal) {
if (orderLineId && !existing.OrderLineID) {
existing.OrderLineID = orderLineId
}
existing._deleteSignal = true
existing.Qty1 = 0
return
if (isDeleteSignal) {
if (orderLineId && !existing.OrderLineID) {
existing.OrderLineID = orderLineId
}
existing._deleteSignal = true
existing.Qty1 = 0
return
}
/* MERGE */
existing.Qty1 += qty
if (row?._dirty === true) {
existing._dirty = true
}
/* MERGE */
existing.Qty1 += qty
if (row?._dirty === true) {
existing._dirty = true
}
if (this.mode === 'edit' && orderLineId && !existing.OrderLineID) {
existing.OrderLineID = orderLineId
@@ -3442,6 +3477,15 @@ export function detectBedenGroup(bedenList, urunAnaGrubu = '', urunKategori = ''
? bedenList.map(v => (v || '').toString().trim().toUpperCase())
: [' ']
// Beden seti çocuk yaş formatındaysa metadata beklemeden "yas" aç.
// Örn: 2,4,6,8,10,12,14 veya 2Y,4Y,6Y...
const yasNums = new Set(['2', '4', '6', '8', '10', '12', '14'])
const yasParsed = list
.map(v => v.replace(/\s+/g, '').replace(/YAS$/i, '').replace(/Y$/i, ''))
if (yasParsed.length > 0 && yasParsed.every(v => yasNums.has(v))) {
return 'yas'
}
const rawAna = normalizeTextForMatch(urunAnaGrubu || '')
const rawKat = normalizeTextForMatch(urunKategori || '')
const rawYetiskinGarson = normalizeTextForMatch(yetiskinGarson || '')