Fix product performance grouped JSON build
This commit is contained in:
@@ -469,7 +469,7 @@
|
||||
</span>
|
||||
</div>
|
||||
<div class="sub-right pcd-sub-right-clickable" @click="toggleGroup(grp, gi)">
|
||||
Grup Toplami TRY: {{ formatBarMoney(groupLiveTotals[gi]?.tryTotal) }} | USD: {{ formatBarMoney(groupLiveTotals[gi]?.usdTotal) }}
|
||||
Grup Toplami TRY: {{ formatBarMoney(groupTotals[gi]?.tryTotal) }} | USD: {{ formatBarMoney(groupTotals[gi]?.usdTotal) }}
|
||||
<q-icon
|
||||
:name="isGroupOpen(grp, gi) ? 'expand_less' : 'expand_more'"
|
||||
size="18px"
|
||||
@@ -1116,6 +1116,7 @@ const canReadOrder = canRead('order')
|
||||
const detailLoading = ref(false)
|
||||
const detailError = ref('')
|
||||
const detailGroups = ref([])
|
||||
const groupTotals = ref([])
|
||||
const detailHeader = ref(null)
|
||||
const costDate = ref('')
|
||||
const exchangeRates = ref(createEmptyExchangeRates())
|
||||
@@ -1577,15 +1578,6 @@ const toolbarSummary = computed(() => 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()
|
||||
|
||||
Reference in New Issue
Block a user