Custom reports
This page will show you how to set up custom reports
Custom reports are creating using the Tabs API. A tab is a collection of Events (see here for an explanation of Events).
This page explains how to setup and download custom reports and it has the following sections:
Creating a tab
A tab can be created like this:
curl {baseURL}/tabs
-H "Authorization:your-api-key"
-H "Content-type: application/json"
-X POST
-d '{
"name": "Jones & Sons rebate",
"tabFilter": "#order.sellerId == 'supplier-trader-id' and #order.status == 'COMPLETED'",
"tabFormula": "#order.orderAmountInCents * 0.02",
"type": "REBATE",
"currency": "GBP"
}'
This particular tab calculates a 1% rebate on all payments to a particular supplier.
You can give the tab any name and type you want.
The tabFilter specifies which Events are included in the tab. In this case the filter specifies the supplier and order status. You can include any field of the order or event using #order or #event followed by the field name.
The tabFormula specifies what value to calculate. Just as for the tabFilter, you can use any field of the order or event. You can also use the + - * and / mathematical operators and brackets.
The response will look like this:
{
"name": "Jones & Sons rebate",
"tabFilter": "#order.sellerId == 'supplier-trader-id' and #order.status == 'COMPLETED'",
"tabFormula": "#order.orderAmountInCents * 0.02",
"type": "REBATE",
"status": "OPEN",
"traderId": "your-trader-id",
"results": [
{
"currency": "GBP",
"currencyComponent": 2,
"amountInCents": 8964338,
"formulaAmountInCents": 25000,
"events": [
{
"orderId": "order-id",
"eventId": "event-id"
}
]
}
}
Let's break that down. The first few fields are what you provided plus a status and traderId:
"name": "Jones & Sons rebate",
"tabFilter": "#order.sellerId == 'supplier-trader-id' and #order.status == 'COMPLETED'",
"tabFormula": "#order.orderAmountInCents * 0.02",
"type": "REBATE",
"status": "OPEN",
"traderId": "your-trader-id",
The status can either be FILLING (we are still filling the tab), OPEN or CLOSED.
The results include all events and our calculations:
"results": [
{
"currency": "GBP",
"currencyComponent": 2,
"amountInCents": 8964338,
"formulaAmountInCents": 25000,
"events": [
{
"orderId": "order-id",
"eventId": "event-id"
}
]
}
When a tab is OPEN we will constantly add new events to the tab and recalculate the values and list of events in the results.
The amountInCents is the sum of the payments for all events. The formulaAmountInCents is the result of the formula you provided which in this example was 1% of the total value of all payments to this supplier.
Getting tabs
To get a list of tabs, you can call the following API:
curl {baseURL}/tabs?type=REBATE
-H "Authorization:your-api-key"
-X GET
You can also call this API without the type filter in which case you get a list of all tabs
To get an individual tab, you can call this API:
curl {baseURL}/tabs/tab-id
-H "Authorization:your-api-key"
-X GET
Updated over 1 year ago