From 20f5fea2e8e94b612b8b7df4e665ae4db05dd444 Mon Sep 17 00:00:00 2001 From: M_Kececi Date: Tue, 18 Aug 2026 22:35:20 +0300 Subject: [PATCH] Fix product performance grouped JSON build --- .../ProductionProductCostingHasCostDetail.vue | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/ui/src/pages/ProductionProductCostingHasCostDetail.vue b/ui/src/pages/ProductionProductCostingHasCostDetail.vue index 4f7116f..d97a0c2 100644 --- a/ui/src/pages/ProductionProductCostingHasCostDetail.vue +++ b/ui/src/pages/ProductionProductCostingHasCostDetail.vue @@ -2685,7 +2685,15 @@ function resolveAutoOrICodeHighlightClass (row) { } function resolveNumericRowQuantity (row) { - return parseMoneyInput(row?.miktarInput ?? row?.lMiktar) + const editableQuantity = parseMoneyInput(row?.miktarInput) + const storedQuantity = parseMoneyInput(row?.lMiktar) + + // Some detail payloads/local drafts contain miktarInput=0 even though the + // recipe quantity in lMiktar is populated. Nullish coalescing selected that + // zero and consequently every amount was calculated as zero. + if (editableQuantity > 0) return editableQuantity + if (storedQuantity > 0) return storedQuantity + return 0 } function resolveNumericRowInputPrice (row) { @@ -2867,15 +2875,22 @@ function resolveRowTRYTutar (row) { const quantity = resolveNumericRowQuantity(row) const inputPrice = resolveNumericRowInputPrice(row) const inputCurrency = resolveInputCurrency(row) - const liveAmount = resolveTRYUnitPriceByInput( + const calculatedUnitPrice = resolveTRYUnitPriceByInput( inputPrice, inputCurrency, resolveExchangeRateValue('USD'), resolveExchangeRateValue('EUR'), resolveExchangeRateValue('GBP') - ) * quantity + ) + // lFiyat is already the TRY unit price rendered in the table. Keep it as a + // fallback for hydrated/autofilled rows whose original input fields lag one + // render behind. + const unitPrice = calculatedUnitPrice > 0 + ? calculatedUnitPrice + : parseMoneyInput(row?.lFiyat) + const liveAmount = unitPrice * quantity - if (Number.isFinite(liveAmount) && inputPrice > 0) return liveAmount + if (Number.isFinite(liveAmount) && unitPrice > 0 && quantity > 0) return liveAmount return parseMoneyInput(row?.lTutar) } @@ -2899,7 +2914,7 @@ function resolveRowUSDTutar (row) { resolveExchangeRateValue('GBP') ) * quantity - if (Number.isFinite(liveAmount) && inputPrice > 0) return liveAmount + if (Number.isFinite(liveAmount) && inputPrice > 0 && quantity > 0) return liveAmount const rawUSDAmount = row?.usdTutar if (rawUSDAmount !== undefined && rawUSDAmount !== null && String(rawUSDAmount).trim() !== '') {