...
Code Block | ||
---|---|---|
| ||
import net.pricefx.common.api.FieldFormatType
import static net.pricefx.server.dto.calculation.ResultMatrixGrouping.AggregateFunctionType
import static net.pricefx.server.dto.calculation.ResultMatrixGrouping.AggregateFunctionType.SUM
def listPriceItems = null
def filter = [
Filter.equal("name", "ListPrice"),
]
List<String> fields = ["ProductId", "ListPrice", "Currency"]
def listPriceItems = api.find("PX3", 0, api.getMaxFindResultsLimit(), "ProductId", fields, *filter)
def rows = listPriceItems
def columnFormats = [
"ProductId": FieldFormatType.TEXT,
"ListPrice": FieldFormatType.MONEY,
"Currency" : FieldFormatType.MONEY,
]
def resultMatrix = api.newMatrix()
.withEnableClientFilter(true)
.withColumnFormats(columnFormats)
.withRows(rows)
.withGroupBy(['Currency'])
.withColumnAggregation('ListPrice', SUM)
.calculateGroupByData()
return resultMatrix |
...