diff --git a/ui/src/pages/ProductionProductCostingHasCostDetail.vue b/ui/src/pages/ProductionProductCostingHasCostDetail.vue
index 87f5c74..0f859db 100644
--- a/ui/src/pages/ProductionProductCostingHasCostDetail.vue
+++ b/ui/src/pages/ProductionProductCostingHasCostDetail.vue
@@ -469,7 +469,7 @@
- Grup Toplami TRY: {{ formatBarMoney(groupLiveTotals[gi]?.tryTotal) }} | USD: {{ formatBarMoney(groupLiveTotals[gi]?.usdTotal) }}
+ Grup Toplami TRY: {{ formatBarMoney(groupTotals[gi]?.tryTotal) }} | USD: {{ formatBarMoney(groupTotals[gi]?.usdTotal) }}
flatDetailRows.value.reduce((acc, row) =>
gbpTotal: 0
}))
-const groupLiveTotals = computed(() => detailGroups.value.map(group => (
- (Array.isArray(group?.items) ? group.items : []).reduce((acc, row) => {
- acc.tryTotal += resolveRowTRYTutar(row)
- acc.usdTotal += resolveRowUSDTutar(row)
- acc.quantity += resolveNumericRowQuantity(row)
- return acc
- }, { tryTotal: 0, usdTotal: 0, quantity: 0 })
-)))
-
const summaryOpen = ref(false)
function makeEmptySummaryRow (part) {
@@ -2836,7 +2828,6 @@ function recalculateAllDetailRows () {
...grp,
items: (Array.isArray(grp?.items) ? grp.items : []).map(row => recalculateDetailRow({ ...row }, { preserveInputs: true }))
}))
- refreshLiveGroupTotals()
}
function resolveRowTRYTutar (row) {
@@ -2887,34 +2878,30 @@ function resolveRowUSDTutar (row) {
return Number.isFinite(calc) ? calc : 0
}
-function shouldIncludeRowInGroupTotal (_grp, row) {
- // Sub-headers show the gross amount entered in that group. Inclusion in the
- // actual costing is shown separately by the page header and checkbox.
- return Boolean(row)
+function shouldIncludeRowInGroupTotal (grp, row) {
+ if (!row) return false
+
+ // CM1/CM2 sub-headers always show their full group value. For every other
+ // group, the explicit "Maliyete Dahil" selection controls the subtotal.
+ if (isCMGroupName(grp?.sAciklama3 || row?.sAciklama3)) return true
+ return normalizeBooleanFlag(row?.maliyeteDahil ?? row?.maliyete_dahil ?? row?.Maliyete_dahil)
}
-function refreshLiveGroupTotals () {
- detailGroups.value = detailGroups.value.map(group => {
- const totals = (Array.isArray(group?.items) ? group.items : []).reduce((acc, row) => {
+function syncGroupTotals () {
+ groupTotals.value = detailGroups.value.map(group => (
+ (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
- }
- })
+ ))
}
function resolveGroupQuantity (grp) {
const groupIndex = detailGroups.value.indexOf(grp)
- return groupIndex >= 0 ? parseMoneyInput(groupLiveTotals.value[groupIndex]?.quantity) : 0
+ return groupIndex >= 0 ? parseMoneyInput(groupTotals.value[groupIndex]?.quantity) : 0
}
function groupKey (grp, gi) {
@@ -3290,7 +3277,7 @@ function onRowQuantityInput (row, value) {
}
function triggerUIUpdate () {
- refreshLiveGroupTotals()
+ syncGroupTotals()
}
function normalizeRowQuantityDisplay (row) {
@@ -5229,6 +5216,18 @@ watch(
}
)
+watch(
+ [detailGroups, exchangeRates],
+ () => {
+ syncGroupTotals()
+ },
+ {
+ deep: true,
+ flush: 'sync',
+ immediate: true
+ }
+)
+
onMounted(() => {
if (!canReadOrder.value) return
fetchDetail()