diff --git a/ui/src/pages/ProductionProductCostingHasCostDetail.vue b/ui/src/pages/ProductionProductCostingHasCostDetail.vue index 54532f9..834b783 100644 --- a/ui/src/pages/ProductionProductCostingHasCostDetail.vue +++ b/ui/src/pages/ProductionProductCostingHasCostDetail.vue @@ -469,7 +469,7 @@
- Grup Toplami TRY: {{ formatBarMoney(resolveGroupTRYTutar(grp)) }} | USD: {{ formatBarMoney(resolveGroupUSDTutar(grp)) }} + Grup Toplami TRY: {{ formatBarMoney(grp.liveTryTotal) }} | USD: {{ formatBarMoney(grp.liveUsdTotal) }} 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) +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 } - 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) { - 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) {