Fix product performance grouped JSON build

This commit is contained in:
M_Kececi
2026-08-18 20:58:29 +03:00
parent 12ce3a3eca
commit 03287d4850
@@ -469,7 +469,7 @@
</span>
</div>
<div class="sub-right pcd-sub-right-clickable" @click="toggleGroup(grp, gi)">
Grup Toplami TRY: {{ formatBarMoney(groupTotals[gi]?.tryTotal) }} | USD: {{ formatBarMoney(groupTotals[gi]?.usdTotal) }}
Grup Toplami TRY: {{ formatBarMoney(groupLiveTotals[gi]?.tryTotal) }} | USD: {{ formatBarMoney(groupLiveTotals[gi]?.usdTotal) }}
<q-icon
:name="isGroupOpen(grp, gi) ? 'expand_less' : 'expand_more'"
size="18px"
@@ -1116,7 +1116,7 @@ const canReadOrder = canRead('order')
const detailLoading = ref(false)
const detailError = ref('')
const detailGroups = ref([])
const groupTotals = ref([])
const groupTotalsRevision = ref(0)
const detailHeader = ref(null)
const costDate = ref('')
const exchangeRates = ref(createEmptyExchangeRates())
@@ -1578,6 +1578,21 @@ const toolbarSummary = computed(() => flatDetailRows.value.reduce((acc, row) =>
gbpTotal: 0
}))
const groupLiveTotals = computed(() => {
// Explicitly depend on inline-edit events as QTable can update a row without
// invalidating computations owned by the parent component.
void groupTotalsRevision.value
return detailGroups.value.map(group => (
(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 })
))
})
const summaryOpen = ref(false)
function makeEmptySummaryRow (part) {
@@ -2887,22 +2902,9 @@ function shouldIncludeRowInGroupTotal (grp, row) {
return normalizeBooleanFlag(row?.maliyeteDahil ?? row?.maliyete_dahil ?? row?.Maliyete_dahil)
}
function syncGroupTotals () {
groupTotals.value = detailGroups.value.map(group => (
(Array.isArray(group?.items) ? group.items : []).reduce((acc, row) => {
if (!shouldIncludeRowInGroupTotal(group, row)) return acc
// Sub-header must mirror the amounts already rendered in the row.
acc.tryTotal += parseMoneyInput(row?.lTutar)
acc.usdTotal += parseMoneyInput(row?.usdTutar ?? row?.lTutarUSD)
acc.quantity += resolveNumericRowQuantity(row)
return acc
}, { tryTotal: 0, usdTotal: 0, quantity: 0 })
))
}
function resolveGroupQuantity (grp) {
const groupIndex = detailGroups.value.indexOf(grp)
return groupIndex >= 0 ? parseMoneyInput(groupTotals.value[groupIndex]?.quantity) : 0
return groupIndex >= 0 ? parseMoneyInput(groupLiveTotals.value[groupIndex]?.quantity) : 0
}
function groupKey (grp, gi) {
@@ -3278,10 +3280,7 @@ function onRowQuantityInput (row, value) {
}
function triggerUIUpdate () {
syncGroupTotals()
nextTick(() => {
syncGroupTotals()
})
groupTotalsRevision.value += 1
}
function normalizeRowQuantityDisplay (row) {
@@ -5220,18 +5219,6 @@ watch(
}
)
watch(
[detailGroups, exchangeRates],
() => {
syncGroupTotals()
},
{
deep: true,
flush: 'sync',
immediate: true
}
)
onMounted(() => {
if (!canReadOrder.value) return
fetchDetail()