Skip to content

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.

The path has an extra 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:

  1. POST /core2/tnt/dm/erp/fi/financial-reports/profit-loss-report/etl-ep; without the fi/ segment it returns 417 (no route).
  2. Send date_from, and date_to as midnight at the start of the last day you want: omit them and you get an empty statement.
  3. 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.
  4. Choose cost_type for 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 by index, and with several branches or values pivot branch_code into 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.

FieldTypeDefaultWhat it cuts by, and what falls out
branch_guidsSet<UUID>emptyThe branch stamped on each journal line. One block of 16 lines per branch code.
gl_dimension_guidsSet<UUID>emptyThe 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_guidsSet<UUID>emptyThe profit centre on each journal line; untagged lines are left out, as above.
segment_guidsSet<UUID>emptyThe segment on each journal line; untagged lines are left out.
project_guidsSet<UUID>emptyThe project on each journal line; untagged lines are left out.
company_guidsSet<UUID>emptyIgnored. The query never reads it, and the applet never sends it.
cost_typeenum stringcogsOne 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-ep

Body 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:

indexLineKindSign convention
1Sales Revenue linesraw GLcredit − debit
2Sales Expenses linesraw GLcredit − debit
3Net Salescomputed subtotalsum of 1 + 2
4Cost Of Goods Sold linesraw GLdebit − credit
5Cost of Goods Sold – Gains linesraw GLdebit − credit
6Cost of Goods Sold – Expenses linesraw GLdebit − credit
7Total Cost of Goods Soldcomputed subtotalsum of 4 + 5 + 6, sign flipped
8GROSS PROFIT/(LOSS)computed subtotal1 + 2 + 4 + 5 + 6, credit − debit convention
9GROSS MARGINcomputed %line 8 ÷ line 3 × 100
10General Expenses linesraw GLcredit − debit
11Other Revenues linesraw GLcredit − debit
12Other Expenses linesraw GLcredit − debit
13PROFIT BEFORE TAXEScomputed subtotallines 1+2+4+5+6+10+11+12
14Tax Expenses linesraw GLcredit − debit
15NET PROFIT/(LOSS)computed subtotallines 1+2+4+5+6+10+11+12+14
16PROFIT MARGINcomputed %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.

When grouping by Branch specifically, the applet makes a second call to resolve each branch’s parent company code (a dropdown-style lookup, used only to build a display label — “Profit Loss Report by Branch” with the company shown alongside). This endpoint does not need or make that second call; the 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

Last updated on