Profit Loss Report
profit-loss-report is the query behind the Financial Report applet’s top-level Profit and Loss Report menu item — not the “Financial Report” menu’s own P&L view, a different screen entirely. Unlike the other two pages in this section, this endpoint does not return raw GL rows: it builds the full statement structure — subtotals, GROSS PROFIT, margins and all — server-side, because the applet normally does that assembly in the browser and an external integration needs it done for it.
Path: POST /core2/tnt/dm/erp/fi/financial-reports/profit-loss-report/etl-ep
Request body: FinancialReportInputDto as JSON
Response envelope: ApiResponse — {"code": "OK_RESPONSE", "data": [ … ], "message": ""}, no paging fields. See the family page.
fi/ segment that the other two reports in this section don’t. SalesReportController and StockReportController sit under .../erp/reports/...; this one sits under .../erp/fi/financial-reports/.... Leaving out fi/ returns 417 SERVER_GENERAL_UNKNOWN_ERROR with a message beginning No static resource: the path matched no route, and the API has no 404 for that (When it goes wrong).See Applet Reports API for authentication.
The fast path:
POST /core2/tnt/dm/erp/fi/financial-reports/profit-loss-report/etl-ep; without thefi/segment it returns417(no route).- Send
date_from, anddate_toas midnight at the start of the last day you want: omit them and you get an empty statement. - Send exactly one dimension set. Only the first non-empty one counts, in the order branch, GL dimension, profit centre, segment, project; send none and the call fails with HTTP 417. GL dimension, profit centre, segment and project each leave untagged journal lines out.
- Choose
cost_typefor cost of goods sold, which is recomputed from final sales invoices, cash bills and sales returns (skipping those with a base-document link) rather than read from the journal. Sort and group the rows byindex, and with several branches or values pivotbranch_codeinto columns, to rebuild the statement (the response).
Request fields
The date window works like the other reports in this section: date_from is inclusive and the route adds one day to date_to, so send date_to as midnight at the start of the last day you want. Both default to now — omit them and you get an empty statement, not an error.
Pick exactly one dimension. The five GUID sets are not filters you can combine; each is a different way of cutting the same journal, and the route reads only the first non-empty one in this order: branch, GL dimension, profit centre, segment, project. Send branches and projects together and the projects are ignored without a message. Send none and the generated query has nothing after its WHERE, so the call fails with an error (HTTP 417) rather than returning the whole company.
| Field | Type | Default | What it cuts by, and what falls out |
|---|---|---|---|
branch_guids | Set<UUID> | empty | The branch stamped on each journal line. One block of 16 lines per branch code. |
gl_dimension_guids | Set<UUID> | empty | The GL dimension on each journal line. Lines posted without a dimension are left out — the statement only covers what was tagged, so its total can be lower than the branch view of the same period. |
profit_center_guids | Set<UUID> | empty | The profit centre on each journal line; untagged lines are left out, as above. |
segment_guids | Set<UUID> | empty | The segment on each journal line; untagged lines are left out. |
project_guids | Set<UUID> | empty | The project on each journal line; untagged lines are left out. |
company_guids | Set<UUID> | empty | Ignored. The query never reads it, and the applet never sends it. |
cost_type | enum string | cogs | One of cogs (MA), cogs_wa (WA), cogs_fifo (FIFO), cogs_lifo (LIFO), cogs_replacement (Replacement), cogs_manual (Manual) — the applet’s own label-to-value mapping. |
Where the two halves of the statement come from. Revenue and expenses are journal lines — only from journal headers of type TXN, so journals of other types do not appear. Cost of goods sold is not read from the journal: it is recomputed from final sales invoices, cash bills and sales returns — quantity times the cost price stored on each line for the method you chose in cost_type, skipping documents that carry a base-document link (base_doc_guid). That is why switching cost_type changes gross profit without changing a single journal, and why this figure can differ from the cost-of-sales balance in your trial balance.
Filter dropdowns
The five group-by dropdowns:
POST /core2/tnt/dm/erp/drop-down/branch/etl-ep
POST /core2/tnt/dm/erp/drop-down/gl-dimension/etl-ep
POST /core2/tnt/dm/erp/drop-down/segment/etl-ep
POST /core2/tnt/dm/erp/drop-down/profit-center/etl-ep
POST /core2/tnt/dm/erp/drop-down/project/etl-epBody and response shape: see Applet Reports API → dropdowns.
Response: a pre-built statement, not raw GL rows
The raw GL rows this query reads (gl_section, gl_category, gl_code, gl_code_descr, debit, credit, code — the branch or dimension code, guid_branch, glcode_guid) are transformed server-side into 16 ordered line items per branch/dimension code, matching exactly what constructDataRow in the applet builds client-side: purchases and purchases returns GL categories are dropped entirely before anything else happens, the remaining rows are grouped by code, and each group produces the 16 lines below.
{
"index": 3,
"glSection": "Net Sales",
"glCategory": "Net Sales",
"glCode": "Net Sales",
"descr": "",
"amount": 412650.00,
"branch_code": "GS-KV-01",
"guid_branch": null,
"glcode_guid": null
}index gives the applet’s display order — sort/group by it to reconstruct the statement in the right sequence:
index | Line | Kind | Sign convention |
|---|---|---|---|
| 1 | Sales Revenue lines | raw GL | credit − debit |
| 2 | Sales Expenses lines | raw GL | credit − debit |
| 3 | Net Sales | computed subtotal | sum of 1 + 2 |
| 4 | Cost Of Goods Sold lines | raw GL | debit − credit |
| 5 | Cost of Goods Sold – Gains lines | raw GL | debit − credit |
| 6 | Cost of Goods Sold – Expenses lines | raw GL | debit − credit |
| 7 | Total Cost of Goods Sold | computed subtotal | sum of 4 + 5 + 6, sign flipped |
| 8 | GROSS PROFIT/(LOSS) | computed subtotal | 1 + 2 + 4 + 5 + 6, credit − debit convention |
| 9 | GROSS MARGIN | computed % | line 8 ÷ line 3 × 100 |
| 10 | General Expenses lines | raw GL | credit − debit |
| 11 | Other Revenues lines | raw GL | credit − debit |
| 12 | Other Expenses lines | raw GL | credit − debit |
| 13 | PROFIT BEFORE TAXES | computed subtotal | lines 1+2+4+5+6+10+11+12 |
| 14 | Tax Expenses lines | raw GL | credit − debit |
| 15 | NET PROFIT/(LOSS) | computed subtotal | lines 1+2+4+5+6+10+11+12+14 |
| 16 | PROFIT MARGIN | computed % | line 15 ÷ line 3 × 100 |
Raw-GL rows (indices 1, 2, 4, 5, 6, 10, 11, 12, 14) carry real glCategory, glCode, guid_branch and glcode_guid values, one row per GL code with activity in the period. Computed rows (3, 7, 8, 9, 13, 15, 16) carry the label in all three of glSection/glCategory/glCode and null for both GUID fields — filter on whether guid_branch is null if you need to separate the two kinds programmatically rather than matching on index.
To render a pivot table with branch (or dimension) codes as columns, the way the applet’s own grid does, group by (index, glSection, glCategory, glCode) and pivot branch_code into columns of amount.
branch_code in the response is enough to identify the row without it. Mentioned here only so its absence from this endpoint’s response isn’t mistaken for a gap.Example
curl -X POST "https://api-etl.akaun.com/core2/tnt/dm/erp/fi/financial-reports/profit-loss-report/etl-ep" \
-H "AccessId: YOUR_ACCESS_ID" \
-H "AccessKey: YOUR_ACCESS_KEY" \
-H "tenantCode: YOUR_TENANT_CODE" \
-H "Content-Type: application/json" \
-d '{
"branch_guids": ["a4d3e7b1-9c52-4f86-8e0d-3b6a2f9c5e17"],
"date_from": "2026-08-01T00:00:00+08:00",
"date_to": "2026-09-30T00:00:00+08:00",
"cost_type": "cogs_wa"
}'date_to is midnight at the start of 30 September because the route adds a day to it, so this asks for
August and September and nothing of October. The answer is the statement as rows, raw GL rows and
computed rows together, for the one branch asked for. Shortened:
{
"code": "OK_RESPONSE",
"message": "",
"data": [
{
"index": 1,
"glSection": "Sales Revenue",
"glCategory": "Sales",
"glCode": "SALES-SMARTPHONE",
"descr": "Sales - smartphones",
"amount": 48210.0,
"branch_code": "GS-KV-01",
"guid_branch": "a4d3e7b1-9c52-4f86-8e0d-3b6a2f9c5e17",
"glcode_guid": "5f1c8a39-2e64-4b07-9d83-7a2e4c6b1f95"
},
{
"index": 3,
"glSection": "Net Sales",
"glCategory": "Net Sales",
"glCode": "Net Sales",
"descr": "",
"amount": 51980.0,
"branch_code": "GS-KV-01",
"guid_branch": null,
"glcode_guid": null
}
]
}Raw GL rows appear only for codes with activity in the period; the seven computed rows (3, 7, 8, 9, 13, 15, 16) come back for every branch, even at zero.
Related
- Applet Reports API — shared auth, envelope shapes, dropdowns
- Authentication
- Data API — hosts, headers, limits shared by every
etl-epcall