Fix product performance grouped JSON build
This commit is contained in:
@@ -2883,19 +2883,40 @@ function shouldIncludeRowInGroupTotal (_grp, row) {
|
||||
return Boolean(row)
|
||||
}
|
||||
|
||||
const groupTotalsByName = computed(() => {
|
||||
const totals = new Map()
|
||||
for (const group of detailGroups.value) {
|
||||
const name = normalizeGroupName(group?.sAciklama3)
|
||||
const current = totals.get(name) || { tryTotal: 0, usdTotal: 0, quantity: 0 }
|
||||
for (const row of (Array.isArray(group?.items) ? group.items : [])) {
|
||||
if (!shouldIncludeRowInGroupTotal(group, row)) continue
|
||||
current.tryTotal += resolveRowTRYTutar(row)
|
||||
current.usdTotal += resolveRowUSDTutar(row)
|
||||
current.quantity += resolveNumericRowQuantity(row)
|
||||
}
|
||||
totals.set(name, current)
|
||||
}
|
||||
return totals
|
||||
})
|
||||
|
||||
function resolveGroupTotals (grp) {
|
||||
return groupTotalsByName.value.get(normalizeGroupName(grp?.sAciklama3)) || {
|
||||
tryTotal: 0,
|
||||
usdTotal: 0,
|
||||
quantity: 0
|
||||
}
|
||||
}
|
||||
|
||||
function resolveGroupTRYTutar (grp) {
|
||||
const items = Array.isArray(grp?.items) ? grp.items : []
|
||||
return items.reduce((acc, row) => acc + (shouldIncludeRowInGroupTotal(grp, row) ? resolveRowTRYTutar(row) : 0), 0)
|
||||
return resolveGroupTotals(grp).tryTotal
|
||||
}
|
||||
|
||||
function resolveGroupUSDTutar (grp) {
|
||||
const items = Array.isArray(grp?.items) ? grp.items : []
|
||||
return items.reduce((acc, row) => acc + (shouldIncludeRowInGroupTotal(grp, row) ? resolveRowUSDTutar(row) : 0), 0)
|
||||
return resolveGroupTotals(grp).usdTotal
|
||||
}
|
||||
|
||||
function resolveGroupQuantity (grp) {
|
||||
const items = Array.isArray(grp?.items) ? grp.items : []
|
||||
return items.reduce((acc, row) => acc + resolveNumericRowQuantity(row), 0)
|
||||
return resolveGroupTotals(grp).quantity
|
||||
}
|
||||
|
||||
function groupKey (grp, gi) {
|
||||
|
||||
Reference in New Issue
Block a user