diff --git a/ui/src/pages/ProductionProductCostingHasCostDetail.vue b/ui/src/pages/ProductionProductCostingHasCostDetail.vue
index 613c685..178de85 100644
--- a/ui/src/pages/ProductionProductCostingHasCostDetail.vue
+++ b/ui/src/pages/ProductionProductCostingHasCostDetail.vue
@@ -631,7 +631,7 @@
-
-
- {{ formatMoney(props.value) }}
- {{ captureRenderedGroupAmount(gi, grp, props.row, 'try', props.value) }}
-
-
-
-
-
- {{ formatMoney(props.value) }}
- {{ captureRenderedGroupAmount(gi, grp, props.row, 'usd', props.value) }}
-
-
-
{{ props.value }}
@@ -2861,9 +2847,22 @@ function recalculateAllDetailRows () {
...grp,
items: (Array.isArray(grp?.items) ? grp.items : []).map(row => recalculateDetailRow({ ...row }, { preserveInputs: true }))
}))
+ refreshLiveGroupTotals()
}
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)
}
@@ -2887,7 +2886,7 @@ function resolveRowUSDTutar (row) {
resolveExchangeRateValue('GBP')
) * quantity
- if (Number.isFinite(liveAmount) && inputPrice > 0 && quantity > 0) return liveAmount
+ if (Number.isFinite(liveAmount) && inputPrice > 0) return liveAmount
const rawUSDAmount = row?.usdTutar
if (rawUSDAmount !== undefined && rawUSDAmount !== null && String(rawUSDAmount).trim() !== '') {
@@ -2912,6 +2911,25 @@ function shouldIncludeRowInGroupTotal (grp, row) {
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()
let renderedAmountFlushScheduled = false
@@ -2966,22 +2984,16 @@ function resolveRenderedGroupRowCount (groupIndex) {
function resolveGroupTRYTutar (groupIndex, _revision) {
const grp = detailGroups.value[groupIndex]
- return (Array.isArray(grp?.items) ? grp.items : []).reduce((total, row) => (
- total + (shouldIncludeRowInGroupTotal(grp, row) ? parseMoneyInput(row?.lTutar) : 0)
- ), 0)
+ return parseMoneyInput(grp?.liveTryTotal)
}
function resolveGroupUSDTutar (groupIndex, _revision) {
const grp = detailGroups.value[groupIndex]
- return (Array.isArray(grp?.items) ? grp.items : []).reduce((total, row) => (
- total + (shouldIncludeRowInGroupTotal(grp, row) ? parseMoneyInput(row?.usdTutar ?? row?.lTutarUSD) : 0)
- ), 0)
+ return parseMoneyInput(grp?.liveUsdTotal)
}
function resolveGroupQuantity (grp) {
- return (Array.isArray(grp?.items) ? grp.items : []).reduce((total, row) => (
- total + resolveNumericRowQuantity(row)
- ), 0)
+ return parseMoneyInput(grp?.liveQuantity)
}
function groupKey (grp, gi) {
@@ -3359,7 +3371,7 @@ function onRowQuantityInput (row, value) {
}
function triggerUIUpdate () {
- groupTotalsRevision.value += 1
+ refreshLiveGroupTotals()
}
function normalizeRowQuantityDisplay (row) {