Fix product performance grouped JSON build

This commit is contained in:
M_Kececi
2026-08-18 23:32:39 +03:00
parent 0c51729f7a
commit 25ef023df5
@@ -631,7 +631,7 @@
<template #body-cell-lMiktar="props"> <template #body-cell-lMiktar="props">
<q-td :props="props"> <q-td :props="props">
<q-input <q-input
:model-value="props.row.miktarInput" v-model="props.row.miktarInput"
class="pcd-inline-input pcd-entry-input" class="pcd-inline-input pcd-entry-input"
color="primary" color="primary"
dense dense
@@ -648,7 +648,7 @@
<template #body-cell-inputPrice="props"> <template #body-cell-inputPrice="props">
<q-td :props="props"> <q-td :props="props">
<q-input <q-input
:model-value="props.row.inputPrice" v-model="props.row.inputPrice"
class="pcd-inline-input pcd-entry-input" class="pcd-inline-input pcd-entry-input"
color="primary" color="primary"
dense dense
@@ -665,7 +665,7 @@
<template #body-cell-inputPricePrBr="props"> <template #body-cell-inputPricePrBr="props">
<q-td :props="props"> <q-td :props="props">
<q-select <q-select
:model-value="props.row.inputPricePrBr" v-model="props.row.inputPricePrBr"
class="pcd-inline-input pcd-entry-input" class="pcd-inline-input pcd-entry-input"
:options="priceCurrencyOptions" :options="priceCurrencyOptions"
color="primary" color="primary"
@@ -679,20 +679,6 @@
</q-td> </q-td>
</template> </template>
<template #body-cell-lTutar="props">
<q-td :props="props">
{{ formatMoney(props.value) }}
<span class="hidden">{{ captureRenderedGroupAmount(gi, grp, props.row, 'try', props.value) }}</span>
</q-td>
</template>
<template #body-cell-usdTutar="props">
<q-td :props="props">
{{ formatMoney(props.value) }}
<span class="hidden">{{ captureRenderedGroupAmount(gi, grp, props.row, 'usd', props.value) }}</span>
</q-td>
</template>
<template #body-cell-sBirim="props"> <template #body-cell-sBirim="props">
<q-td :props="props"> <q-td :props="props">
<span>{{ props.value }}</span> <span>{{ props.value }}</span>
@@ -2861,9 +2847,22 @@ 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) {
const quantity = resolveNumericRowQuantity(row)
const inputPrice = resolveNumericRowInputPrice(row)
const inputCurrency = resolveInputCurrency(row)
const liveAmount = resolveTRYUnitPriceByInput(
inputPrice,
inputCurrency,
resolveExchangeRateValue('USD'),
resolveExchangeRateValue('EUR'),
resolveExchangeRateValue('GBP')
) * quantity
if (Number.isFinite(liveAmount) && inputPrice > 0) return liveAmount
return parseMoneyInput(row?.lTutar) return parseMoneyInput(row?.lTutar)
} }
@@ -2887,7 +2886,7 @@ function resolveRowUSDTutar (row) {
resolveExchangeRateValue('GBP') resolveExchangeRateValue('GBP')
) * quantity ) * quantity
if (Number.isFinite(liveAmount) && inputPrice > 0 && quantity > 0) return liveAmount if (Number.isFinite(liveAmount) && inputPrice > 0) return liveAmount
const rawUSDAmount = row?.usdTutar const rawUSDAmount = row?.usdTutar
if (rawUSDAmount !== undefined && rawUSDAmount !== null && String(rawUSDAmount).trim() !== '') { if (rawUSDAmount !== undefined && rawUSDAmount !== null && String(rawUSDAmount).trim() !== '') {
@@ -2912,6 +2911,25 @@ function shouldIncludeRowInGroupTotal (grp, row) {
return normalizedValue !== '0' && normalizedValue !== 'false' && normalizedValue !== 'hayir' return normalizedValue !== '0' && normalizedValue !== 'false' && normalizedValue !== 'hayir'
} }
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 })
return {
...group,
liveTryTotal: totals.tryTotal,
liveUsdTotal: totals.usdTotal,
liveQuantity: totals.quantity
}
})
}
const pendingRenderedAmounts = new Map() const pendingRenderedAmounts = new Map()
let renderedAmountFlushScheduled = false let renderedAmountFlushScheduled = false
@@ -2966,22 +2984,16 @@ function resolveRenderedGroupRowCount (groupIndex) {
function resolveGroupTRYTutar (groupIndex, _revision) { function resolveGroupTRYTutar (groupIndex, _revision) {
const grp = detailGroups.value[groupIndex] const grp = detailGroups.value[groupIndex]
return (Array.isArray(grp?.items) ? grp.items : []).reduce((total, row) => ( return parseMoneyInput(grp?.liveTryTotal)
total + (shouldIncludeRowInGroupTotal(grp, row) ? parseMoneyInput(row?.lTutar) : 0)
), 0)
} }
function resolveGroupUSDTutar (groupIndex, _revision) { function resolveGroupUSDTutar (groupIndex, _revision) {
const grp = detailGroups.value[groupIndex] const grp = detailGroups.value[groupIndex]
return (Array.isArray(grp?.items) ? grp.items : []).reduce((total, row) => ( return parseMoneyInput(grp?.liveUsdTotal)
total + (shouldIncludeRowInGroupTotal(grp, row) ? parseMoneyInput(row?.usdTutar ?? row?.lTutarUSD) : 0)
), 0)
} }
function resolveGroupQuantity (grp) { function resolveGroupQuantity (grp) {
return (Array.isArray(grp?.items) ? grp.items : []).reduce((total, row) => ( return parseMoneyInput(grp?.liveQuantity)
total + resolveNumericRowQuantity(row)
), 0)
} }
function groupKey (grp, gi) { function groupKey (grp, gi) {
@@ -3359,7 +3371,7 @@ function onRowQuantityInput (row, value) {
} }
function triggerUIUpdate () { function triggerUIUpdate () {
groupTotalsRevision.value += 1 refreshLiveGroupTotals()
} }
function normalizeRowQuantityDisplay (row) { function normalizeRowQuantityDisplay (row) {