Skip to content

Commit 26068be

Browse files
authored
Fix: Sumary Report (PanJiaChen#2649)
* Fix: Sumary Report * Fix: Sumary Report * Fix: Sumary Report * Fix: Sumary Report
1 parent 0d97532 commit 26068be

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

src/components/ADempiere/Report/Data/DataReport.vue

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ import DataCells from '@/components/ADempiere/Report/Data/DataCells.vue'
9090
// Utility functions
9191
import { isEmptyValue } from '@/utils/ADempiere/valueUtils.js'
9292
import { isNumberField, isDateField, isBooleanField, isDecimalField } from '@/utils/ADempiere/references'
93+
import {
94+
formatQuantity
95+
} from '@/utils/ADempiere/formatValue/numberFormat'
9396
export default defineComponent({
9497
name: 'DataReport',
9598
components: {
@@ -339,22 +342,25 @@ export default defineComponent({
339342
sums[index] = 'Total'
340343
return
341344
}
345+
let sum = 0
342346
data.forEach((data) => {
343-
Object.values(data.cells).forEach((dataCell) => {
344-
if (dataCell && 'sum_value' in dataCell && isNumberField(column.display_type)) {
345-
sums[index] = dataCell.value.value
346-
nextTick(() => {
347-
const footerCells = document.querySelectorAll('.el-table__footer-wrapper td.el-table__cell')
348-
footerCells.forEach((cell) => {
349-
const num = parseFloat(cell.textContent)
350-
if (!isEmptyValue(num) && num < 0) {
351-
cell.style.color = 'red'
352-
}
353-
})
354-
return
355-
})
347+
const dataCell = data.cells[column.code]
348+
if (!isEmptyValue(dataCell) && dataCell.sum_value) {
349+
const { value } = dataCell
350+
if (!isEmptyValue(value) && value.value) {
351+
sum += parseFloat(value.value)
356352
}
357-
})
353+
}
354+
})
355+
sums[index] = sum === 0 ? '' : formatQuantity({ value: sum })
356+
})
357+
nextTick(() => {
358+
const footerCells = document.querySelectorAll('.el-table__footer-wrapper td.el-table__cell')
359+
footerCells.forEach((cell) => {
360+
const num = parseFloat(cell.textContent)
361+
if (!isEmptyValue(num) && num < 0) {
362+
cell.style.color = 'red'
363+
}
358364
})
359365
})
360366
}

0 commit comments

Comments
 (0)