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