Sum of sales by saletype (REST API)

Hi,

I'm trying to get sum of sales by saletype using REST API. I've been trying with this kind of request:

/api/v1/Agents/Archive/GetArchiveListByColumns2

{
"ProviderName": "findsale",
"Columns": "GroupBy(saletype):Header,sum(amount):HideDetail:Footer",
"Restrictions": "saleid > 0",
"Entities": "sale",
"Page": 0,
"PageSize": 500
}

But problem is it doesn't return saletypes, only some sums. Like this:

"ColumnData": {
  "GroupBy(saletype):Header": {
    "DisplayValue": "",
    "TooltipHint": "",
    "LinkHint": ""
  },
  "sum(amount):HideDetail:Footer": {
    "DisplayValue": "[F:123]",
    "TooltipHint": "",
    "LinkHint": ""
  }
},

Also is there any simple way to parse DisplayValue-fields in Javascript?

RE: Sum of sales by saletype (REST API)

H Mikko,

I think what you want is something more like this:

{
"ProviderName": "findsale",
"Columns": "GroupBy(saleType):Header:HideDetail,Sum(amount):HideDetail",
"Restrictions": "saleId gt 0",
"Entities": "sale",
"Page": 0,
"PageSize": 500
}

Unless you are certain they are all the same, you really should take into account sale currency. For help, search/scan the Archive Providers article for currency for help.

I'm unaware of any JavaScript variant of the CultureDataFormatter class.

Best regards.

By: Tony Yates 4 Nov 2020

RE: Sum of sales by saletype (REST API)

Thanks a lot! That seems to be working. I'll have to read again your article on "Netserver Archive Providers" :-)

By: Mikko Tillikainen 5 Nov 2020