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 a generic “no static resource” 404 that looks like a routing problem rather than a typo in the path.

See Applet Reports API for authentication.


Request fields

FieldTypeDefaultNotes
date_from, date_toZonedDateTimenow
branch_guidsSet<UUID>emptySend this or one of the four below — not several at once; the applet’s Group By control decides which.
gl_dimension_guidsSet<UUID>empty
segment_guidsSet<UUID>empty
profit_center_guidsSet<UUID>empty
project_guidsSet<UUID>empty
company_guidsSet<UUID>emptyNever sent by the applet under any Group By choice.
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.

Sending more than one of the five group-by guid sets is not something the applet does and has not been tested; sending none of them at all also has not been tested — always send exactly one, matching the applet.


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": ["3f2a7c10-9b4e-4d61-8a22-1c5e7f9d0b33", "6b8d1f42-7e35-4c09-ad81-1d4e8b2c5a70"],
    "date_from": "2026-08-01T00:00:00+08:00",
    "date_to": "2026-09-30T23:59:59+08:00",
    "cost_type": "cogs_wa"
  }'

Related

Last updated on