Fix product performance grouped JSON build
This commit is contained in:
@@ -469,7 +469,7 @@
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="sub-right pcd-sub-right-clickable" @click="toggleGroup(grp, gi)">
|
<div class="sub-right pcd-sub-right-clickable" @click="toggleGroup(grp, gi)">
|
||||||
Grup Toplami TRY: {{ formatBarMoney(resolveGroupTRYTutar(grp)) }} | USD: {{ formatBarMoney(resolveGroupUSDTutar(grp)) }}
|
Grup Toplami TRY: {{ formatBarMoney(grp.liveTryTotal) }} | USD: {{ formatBarMoney(grp.liveUsdTotal) }}
|
||||||
<q-icon
|
<q-icon
|
||||||
:name="isGroupOpen(grp, gi) ? 'expand_less' : 'expand_more'"
|
:name="isGroupOpen(grp, gi) ? 'expand_less' : 'expand_more'"
|
||||||
size="18px"
|
size="18px"
|
||||||
@@ -2827,6 +2827,7 @@ function recalculateAllDetailRows () {
|
|||||||
...grp,
|
...grp,
|
||||||
items: (Array.isArray(grp?.items) ? grp.items : []).map(row => recalculateDetailRow({ ...row }, { preserveInputs: true }))
|
items: (Array.isArray(grp?.items) ? grp.items : []).map(row => recalculateDetailRow({ ...row }, { preserveInputs: true }))
|
||||||
}))
|
}))
|
||||||
|
refreshLiveGroupTotals()
|
||||||
}
|
}
|
||||||
|
|
||||||
function resolveRowTRYTutar (row) {
|
function resolveRowTRYTutar (row) {
|
||||||
@@ -2883,40 +2884,27 @@ function shouldIncludeRowInGroupTotal (_grp, row) {
|
|||||||
return Boolean(row)
|
return Boolean(row)
|
||||||
}
|
}
|
||||||
|
|
||||||
const groupTotalsByName = computed(() => {
|
function refreshLiveGroupTotals () {
|
||||||
const totals = new Map()
|
detailGroups.value = detailGroups.value.map(group => {
|
||||||
for (const group of detailGroups.value) {
|
const totals = (Array.isArray(group?.items) ? group.items : []).reduce((acc, row) => {
|
||||||
const name = normalizeGroupName(group?.sAciklama3)
|
if (!shouldIncludeRowInGroupTotal(group, row)) return acc
|
||||||
const current = totals.get(name) || { tryTotal: 0, usdTotal: 0, quantity: 0 }
|
acc.tryTotal += resolveRowTRYTutar(row)
|
||||||
for (const row of (Array.isArray(group?.items) ? group.items : [])) {
|
acc.usdTotal += resolveRowUSDTutar(row)
|
||||||
if (!shouldIncludeRowInGroupTotal(group, row)) continue
|
acc.quantity += resolveNumericRowQuantity(row)
|
||||||
current.tryTotal += resolveRowTRYTutar(row)
|
return acc
|
||||||
current.usdTotal += resolveRowUSDTutar(row)
|
}, { tryTotal: 0, usdTotal: 0, quantity: 0 })
|
||||||
current.quantity += resolveNumericRowQuantity(row)
|
|
||||||
|
return {
|
||||||
|
...group,
|
||||||
|
liveTryTotal: totals.tryTotal,
|
||||||
|
liveUsdTotal: totals.usdTotal,
|
||||||
|
liveQuantity: totals.quantity
|
||||||
}
|
}
|
||||||
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) {
|
|
||||||
return resolveGroupTotals(grp).tryTotal
|
|
||||||
}
|
|
||||||
|
|
||||||
function resolveGroupUSDTutar (grp) {
|
|
||||||
return resolveGroupTotals(grp).usdTotal
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function resolveGroupQuantity (grp) {
|
function resolveGroupQuantity (grp) {
|
||||||
return resolveGroupTotals(grp).quantity
|
return parseMoneyInput(grp?.liveQuantity)
|
||||||
}
|
}
|
||||||
|
|
||||||
function groupKey (grp, gi) {
|
function groupKey (grp, gi) {
|
||||||
@@ -3292,7 +3280,7 @@ function onRowQuantityInput (row, value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function triggerUIUpdate () {
|
function triggerUIUpdate () {
|
||||||
detailGroups.value = [...detailGroups.value]
|
refreshLiveGroupTotals()
|
||||||
}
|
}
|
||||||
|
|
||||||
function normalizeRowQuantityDisplay (row) {
|
function normalizeRowQuantityDisplay (row) {
|
||||||
|
|||||||
Reference in New Issue
Block a user