Sales Reports & Analytics
Comprehensive sales analytics and reporting endpoints covering revenue analysis, customer insights, product performance, aging, and conversion funnels.
API Endpoints
| Method | Endpoint | Description |
|---|---|---|
GET | /api/sales/reports/summary | Overall sales summary |
GET | /api/sales/reports/by-product | Revenue & profit per product |
GET | /api/sales/reports/by-customer | Revenue & outstanding per customer |
GET | /api/sales/reports/by-salesperson | Revenue per salesperson |
GET | /api/sales/reports/by-category | Revenue per product category |
GET | /api/sales/reports/trends | Time-series invoice & return data |
GET | /api/sales/reports/overdue-invoices | Overdue invoices with aging buckets |
GET | /api/sales/reports/payment-collection | Payments by period & method |
GET | /api/sales/reports/conversion-funnel | Quotation→Order→Invoice rates |
GET | /api/sales/reports/profit-by-product | Gross profit & margin per product |
Common Query Parameters
Most report endpoints accept these filters:
| Parameter | Type | Description |
|---|---|---|
date_from | date | Start date filter (YYYY-MM-DD) |
date_to | date | End date filter (must be ≥ date_from) |
branch_id | integer | Filter by branch |
Summary Report
Returns aggregated totals for quotations, orders, invoices (posted), and returns (posted).
curl -s -X GET "$API/sales/reports/summary?date_from=2026-01-01&date_to=2026-12-31" \
-H "Authorization: Bearer $TOKEN"final res = await http.get(
Uri.parse('$api/sales/reports/summary?date_from=2026-01-01&date_to=2026-12-31'),
headers: {'Authorization': 'Bearer $token'},
);Response:
{
"data": {
"quotations": { "count": 25, "value": 12500.000 },
"orders": { "count": 18, "value": 9800.000 },
"invoices": { "count": 15, "value": 8500.000 },
"returns": { "count": 2, "value": 500.000 },
"net_sales": 8000.000,
"amount_collected": 6000.000,
"amount_outstanding": 2500.000,
"average_invoice_value": 566.667
}
}Sales by Product
Revenue, quantity sold, discounts, COGS, and gross profit per product from posted invoices.
| Parameter | Type | Description |
|---|---|---|
category_id | integer | Filter by product category |
sort_by | string | gross_revenue, quantity_sold, gross_profit, net_revenue |
limit | integer | Max results (default 50, max 200) |
Sales by Customer
Invoice count, gross revenue, outstanding balance, and last invoice date per customer.
| Parameter | Type | Description |
|---|---|---|
salesperson_id | integer | Filter by salesperson |
limit | integer | Max results (default 50, max 200) |
Sales Trends
Time-series data grouped by day, week, or month. Returns invoice count, revenue, returns, and net per period.
| Parameter | Type | Description |
|---|---|---|
group_by | string | day, week, month (default: month) |
Overdue Invoices & Aging
Lists posted invoices with balance_due > 0 past their due date, with aging buckets.
| Parameter | Type | Description |
|---|---|---|
partner_id | integer | Filter by customer |
as_of_date | date | Calculate aging as of date (default: today) |
Aging Buckets: current, 1_30, 31_60, 61_90, 90_plus
Payment Collection
Payments received grouped by period, broken down by payment method.
| Parameter | Type | Description |
|---|---|---|
payment_method | string | cash, bank_transfer, check, credit_card |
group_by | string | day, month (default: month) |
Conversion Funnel
Tracks quotation→order→invoice conversion rates.
| Parameter | Type | Description |
|---|---|---|
salesperson_id | integer | Filter by salesperson |
Response includes: quotations_created, converted_to_orders, conversion_rate_to_order, converted_to_invoices, conversion_rate_to_invoice
Profit by Product
Gross profit and margin percentage per product.
| Parameter | Type | Description |
|---|---|---|
category_id | integer | Filter by product category |
warehouse_id | integer | Filter by warehouse |
limit | integer | Max results (default 50, max 200) |
Permissions
| Permission | Description |
|---|---|
sales.reports.view | Access all report endpoints |
All report endpoints require the sales.reports.view permission. Granted to owner and manager roles by default.