Skip to content

Commit

Permalink
fix: compute subtotals/totals for boolean types (DHIS2-9155)
Browse files Browse the repository at this point in the history
  • Loading branch information
edoardo committed Aug 21, 2024
1 parent 59f717e commit ed4fa5d
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/modules/pivotTable/PivotTableEngine.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ import {
} from '../dataTypes.js'
import { DIMENSION_ID_ORGUNIT } from '../predefinedDimensions.js'
import { renderValue } from '../renderValue.js'
import { VALUE_TYPE_NUMBER, VALUE_TYPE_TEXT } from '../valueTypes.js'
import {
VALUE_TYPE_NUMBER,
VALUE_TYPE_TEXT,
isBooleanValueType,
isNumericValueType,
} from '../valueTypes.js'
import { AdaptiveClippingController } from './AdaptiveClippingController.js'
import { addToTotalIfNumber } from './addToTotalIfNumber.js'
import { parseValue } from './parseValue.js'
Expand Down Expand Up @@ -744,7 +749,15 @@ export class PivotTableEngine {
totalCell.valueType = currentValueType
}

if (dxDimension?.valueType === VALUE_TYPE_NUMBER) {
// compute subtotals and totals for all numeric and boolean value types
// in that case, force value type of subtotal and total cells to NUMBER to format them correctly
// (see DHIS2-9155)
if (
isNumericValueType(dxDimension?.valueType) ||
isBooleanValueType(dxDimension?.valueType)
) {
totalCell.valueType = VALUE_TYPE_NUMBER

dataFields.forEach((field) => {
const headerIndex = this.dimensionLookup.dataHeaders[field]
const value = parseValue(dataRow[headerIndex])
Expand Down

0 comments on commit ed4fa5d

Please sign in to comment.