Fix product performance grouped JSON build
This commit is contained in:
@@ -469,7 +469,7 @@
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="sub-right pcd-sub-right-clickable" @click="toggleGroup(grp, gi)">
|
<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
|
<q-icon
|
||||||
:name="isGroupOpen(grp, gi) ? 'expand_less' : 'expand_more'"
|
:name="isGroupOpen(grp, gi) ? 'expand_less' : 'expand_more'"
|
||||||
size="18px"
|
size="18px"
|
||||||
@@ -1116,6 +1116,7 @@ const canReadOrder = canRead('order')
|
|||||||
const detailLoading = ref(false)
|
const detailLoading = ref(false)
|
||||||
const detailError = ref('')
|
const detailError = ref('')
|
||||||
const detailGroups = ref([])
|
const detailGroups = ref([])
|
||||||
|
const groupTotals = ref([])
|
||||||
const detailHeader = ref(null)
|
const detailHeader = ref(null)
|
||||||
const costDate = ref('')
|
const costDate = ref('')
|
||||||
const exchangeRates = ref(createEmptyExchangeRates())
|
const exchangeRates = ref(createEmptyExchangeRates())
|
||||||
@@ -1577,15 +1578,6 @@ const toolbarSummary = computed(() => flatDetailRows.value.reduce((acc, row) =>
|
|||||||
gbpTotal: 0
|
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)
|
const summaryOpen = ref(false)
|
||||||
|
|
||||||
function makeEmptySummaryRow (part) {
|
function makeEmptySummaryRow (part) {
|
||||||
@@ -2836,7 +2828,6 @@ function recalculateAllDetailRows () {
|
|||||||
...grp,
|
...grp,
|
||||||
items: (Array.isArray(grp?.items) ? grp.items : []).map(row => recalculateDetailRow({ ...row }, { preserveInputs: true }))
|
items: (Array.isArray(grp?.items) ? grp.items : []).map(row => recalculateDetailRow({ ...row }, { preserveInputs: true }))
|
||||||
}))
|
}))
|
||||||
refreshLiveGroupTotals()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function resolveRowTRYTutar (row) {
|
function resolveRowTRYTutar (row) {
|
||||||
@@ -2887,34 +2878,30 @@ function resolveRowUSDTutar (row) {
|
|||||||
return Number.isFinite(calc) ? calc : 0
|
return Number.isFinite(calc) ? calc : 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function shouldIncludeRowInGroupTotal (_grp, row) {
|
function shouldIncludeRowInGroupTotal (grp, row) {
|
||||||
// Sub-headers show the gross amount entered in that group. Inclusion in the
|
if (!row) return false
|
||||||
// actual costing is shown separately by the page header and checkbox.
|
|
||||||
return Boolean(row)
|
// 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 () {
|
function syncGroupTotals () {
|
||||||
detailGroups.value = detailGroups.value.map(group => {
|
groupTotals.value = detailGroups.value.map(group => (
|
||||||
const totals = (Array.isArray(group?.items) ? group.items : []).reduce((acc, row) => {
|
(Array.isArray(group?.items) ? group.items : []).reduce((acc, row) => {
|
||||||
if (!shouldIncludeRowInGroupTotal(group, row)) return acc
|
if (!shouldIncludeRowInGroupTotal(group, row)) return acc
|
||||||
acc.tryTotal += resolveRowTRYTutar(row)
|
acc.tryTotal += resolveRowTRYTutar(row)
|
||||||
acc.usdTotal += resolveRowUSDTutar(row)
|
acc.usdTotal += resolveRowUSDTutar(row)
|
||||||
acc.quantity += resolveNumericRowQuantity(row)
|
acc.quantity += resolveNumericRowQuantity(row)
|
||||||
return acc
|
return acc
|
||||||
}, { tryTotal: 0, usdTotal: 0, quantity: 0 })
|
}, { tryTotal: 0, usdTotal: 0, quantity: 0 })
|
||||||
|
))
|
||||||
return {
|
|
||||||
...group,
|
|
||||||
liveTryTotal: totals.tryTotal,
|
|
||||||
liveUsdTotal: totals.usdTotal,
|
|
||||||
liveQuantity: totals.quantity
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function resolveGroupQuantity (grp) {
|
function resolveGroupQuantity (grp) {
|
||||||
const groupIndex = detailGroups.value.indexOf(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) {
|
function groupKey (grp, gi) {
|
||||||
@@ -3290,7 +3277,7 @@ function onRowQuantityInput (row, value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function triggerUIUpdate () {
|
function triggerUIUpdate () {
|
||||||
refreshLiveGroupTotals()
|
syncGroupTotals()
|
||||||
}
|
}
|
||||||
|
|
||||||
function normalizeRowQuantityDisplay (row) {
|
function normalizeRowQuantityDisplay (row) {
|
||||||
@@ -5229,6 +5216,18 @@ watch(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
watch(
|
||||||
|
[detailGroups, exchangeRates],
|
||||||
|
() => {
|
||||||
|
syncGroupTotals()
|
||||||
|
},
|
||||||
|
{
|
||||||
|
deep: true,
|
||||||
|
flush: 'sync',
|
||||||
|
immediate: true
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
if (!canReadOrder.value) return
|
if (!canReadOrder.value) return
|
||||||
fetchDetail()
|
fetchDetail()
|
||||||
|
|||||||
Reference in New Issue
Block a user