From ba9a744aef534f2b90a74c023489662551de421d Mon Sep 17 00:00:00 2001 From: M_Kececi Date: Wed, 19 Aug 2026 01:06:55 +0300 Subject: [PATCH] Fix product performance grouped JSON build --- .../ProductionProductCostingHasCostDetail.vue | 53 +++++++++++++++++-- 1 file changed, 50 insertions(+), 3 deletions(-) diff --git a/ui/src/pages/ProductionProductCostingHasCostDetail.vue b/ui/src/pages/ProductionProductCostingHasCostDetail.vue index 1b3593a..250e6a9 100644 --- a/ui/src/pages/ProductionProductCostingHasCostDetail.vue +++ b/ui/src/pages/ProductionProductCostingHasCostDetail.vue @@ -2934,21 +2934,68 @@ function resolveGroupRowUSDAmount (row) { // olarak her degisiklikte yeniden toplanir. const detailGroupsWithTotals = computed(() => ( detailGroups.value.map(group => { - const totals = (Array.isArray(group?.items) ? group.items : []).reduce((acc, row) => { + const items = Array.isArray(group?.items) ? group.items : [] + const totals = items.reduce((acc, row) => { + acc.rawTryTotal += parseMoneyInput(row?.lTutar) + acc.liveTryTotal += resolveRowTRYTutar(row) if (!shouldIncludeRowInGroupTotal(group, row)) return acc + acc.includedCount += 1 acc.tryTotal += resolveGroupRowTRYAmount(row) acc.usdTotal += resolveGroupRowUSDAmount(row) return acc - }, { tryTotal: 0, usdTotal: 0 }) + }, { tryTotal: 0, usdTotal: 0, rawTryTotal: 0, liveTryTotal: 0, includedCount: 0 }) return { ...group, tryTotal: totals.tryTotal, - usdTotal: totals.usdTotal + usdTotal: totals.usdTotal, + rawTryTotal: totals.rawTryTotal, + liveTryTotal: totals.liveTryTotal, + rowCount: items.length, + includedCount: totals.includedCount, + firstTryAmount: items.length > 0 ? resolveGroupRowTRYAmount(items[0]) : 0 } }) )) +watch( + detailGroupsWithTotals, + groups => { + const timestamp = new Date().toISOString() + console.groupCollapsed(`[PCD-GROUP-TOTALS] ${timestamp}`) + console.table((Array.isArray(groups) ? groups : []).map(group => ({ + grup: String(group?.sAciklama3 || 'TANIMSIZ'), + satir: group?.rowCount || 0, + dahil: group?.includedCount || 0, + hamTRY: group?.rawTryTotal || 0, + canliTRY: group?.liveTryTotal || 0, + toplamTRY: group?.tryTotal || 0, + toplamUSD: group?.usdTotal || 0 + }))) + + ;(Array.isArray(groups) ? groups : []).forEach(group => { + console.groupCollapsed(`[PCD-GROUP-ROWS] ${String(group?.sAciklama3 || 'TANIMSIZ')}`) + console.table((Array.isArray(group?.items) ? group.items : []).map(row => ({ + key: row?.__rowKey, + kod: row?.sKodu, + dahil: shouldIncludeRowInGroupTotal(group, row), + miktarInput: row?.miktarInput, + lMiktar: row?.lMiktar, + inputPrice: row?.inputPrice, + paraBirimi: row?.inputPricePrBr, + lFiyat: row?.lFiyat, + lTutar: row?.lTutar, + hesapTRY: resolveGroupRowTRYAmount(row), + usdTutar: row?.usdTutar, + hesapUSD: resolveGroupRowUSDAmount(row) + }))) + console.groupEnd() + }) + console.groupEnd() + }, + { deep: true, immediate: true, flush: 'post' } +) + function resolveGroupQuantity (grp) { return (Array.isArray(grp?.items) ? grp.items : []).reduce((total, row) => ( total + resolveNumericRowQuantity(row)