Fix product performance grouped JSON build
This commit is contained in:
@@ -2934,21 +2934,68 @@ function resolveGroupRowUSDAmount (row) {
|
|||||||
// olarak her degisiklikte yeniden toplanir.
|
// olarak her degisiklikte yeniden toplanir.
|
||||||
const detailGroupsWithTotals = computed(() => (
|
const detailGroupsWithTotals = computed(() => (
|
||||||
detailGroups.value.map(group => {
|
detailGroups.value.map(group => {
|
||||||
const totals = (Array.isArray(group?.items) ? group.items : []).reduce((acc, row) => {
|
const items = Array.isArray(group?.items) ? group.items : []
|
||||||
|
const totals = items.reduce((acc, row) => {
|
||||||
|
acc.rawTryTotal += parseMoneyInput(row?.lTutar)
|
||||||
|
acc.liveTryTotal += resolveRowTRYTutar(row)
|
||||||
if (!shouldIncludeRowInGroupTotal(group, row)) return acc
|
if (!shouldIncludeRowInGroupTotal(group, row)) return acc
|
||||||
|
acc.includedCount += 1
|
||||||
acc.tryTotal += resolveGroupRowTRYAmount(row)
|
acc.tryTotal += resolveGroupRowTRYAmount(row)
|
||||||
acc.usdTotal += resolveGroupRowUSDAmount(row)
|
acc.usdTotal += resolveGroupRowUSDAmount(row)
|
||||||
return acc
|
return acc
|
||||||
}, { tryTotal: 0, usdTotal: 0 })
|
}, { tryTotal: 0, usdTotal: 0, rawTryTotal: 0, liveTryTotal: 0, includedCount: 0 })
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...group,
|
...group,
|
||||||
tryTotal: totals.tryTotal,
|
tryTotal: totals.tryTotal,
|
||||||
usdTotal: totals.usdTotal
|
usdTotal: totals.usdTotal,
|
||||||
|
rawTryTotal: totals.rawTryTotal,
|
||||||
|
liveTryTotal: totals.liveTryTotal,
|
||||||
|
rowCount: items.length,
|
||||||
|
includedCount: totals.includedCount,
|
||||||
|
firstTryAmount: items.length > 0 ? resolveGroupRowTRYAmount(items[0]) : 0
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
))
|
))
|
||||||
|
|
||||||
|
watch(
|
||||||
|
detailGroupsWithTotals,
|
||||||
|
groups => {
|
||||||
|
const timestamp = new Date().toISOString()
|
||||||
|
console.groupCollapsed(`[PCD-GROUP-TOTALS] ${timestamp}`)
|
||||||
|
console.table((Array.isArray(groups) ? groups : []).map(group => ({
|
||||||
|
grup: String(group?.sAciklama3 || 'TANIMSIZ'),
|
||||||
|
satir: group?.rowCount || 0,
|
||||||
|
dahil: group?.includedCount || 0,
|
||||||
|
hamTRY: group?.rawTryTotal || 0,
|
||||||
|
canliTRY: group?.liveTryTotal || 0,
|
||||||
|
toplamTRY: group?.tryTotal || 0,
|
||||||
|
toplamUSD: group?.usdTotal || 0
|
||||||
|
})))
|
||||||
|
|
||||||
|
;(Array.isArray(groups) ? groups : []).forEach(group => {
|
||||||
|
console.groupCollapsed(`[PCD-GROUP-ROWS] ${String(group?.sAciklama3 || 'TANIMSIZ')}`)
|
||||||
|
console.table((Array.isArray(group?.items) ? group.items : []).map(row => ({
|
||||||
|
key: row?.__rowKey,
|
||||||
|
kod: row?.sKodu,
|
||||||
|
dahil: shouldIncludeRowInGroupTotal(group, row),
|
||||||
|
miktarInput: row?.miktarInput,
|
||||||
|
lMiktar: row?.lMiktar,
|
||||||
|
inputPrice: row?.inputPrice,
|
||||||
|
paraBirimi: row?.inputPricePrBr,
|
||||||
|
lFiyat: row?.lFiyat,
|
||||||
|
lTutar: row?.lTutar,
|
||||||
|
hesapTRY: resolveGroupRowTRYAmount(row),
|
||||||
|
usdTutar: row?.usdTutar,
|
||||||
|
hesapUSD: resolveGroupRowUSDAmount(row)
|
||||||
|
})))
|
||||||
|
console.groupEnd()
|
||||||
|
})
|
||||||
|
console.groupEnd()
|
||||||
|
},
|
||||||
|
{ deep: true, immediate: true, flush: 'post' }
|
||||||
|
)
|
||||||
|
|
||||||
function resolveGroupQuantity (grp) {
|
function resolveGroupQuantity (grp) {
|
||||||
return (Array.isArray(grp?.items) ? grp.items : []).reduce((total, row) => (
|
return (Array.isArray(grp?.items) ? grp.items : []).reduce((total, row) => (
|
||||||
total + resolveNumericRowQuantity(row)
|
total + resolveNumericRowQuantity(row)
|
||||||
|
|||||||
Reference in New Issue
Block a user