Skip to content
PharmaFlow Knowledgebase
Esc
↑↓navigate↵open⌘Jpreview

Report on sales

Admin and branch manager. Returns revenue, VAT, day and payment splits, top sellers, sales. Gross profit uses the cost frozen on each line, so a later cost change never rewrites it.

GET/api/v1/reports/sales
Authorization
AuthorizationBearer token (JWT) · headerrequired

JWT from POST /api/v1/auth/login sent as Authorization Bearer.

Query parameters
from_datestring

First day of the window, YYYY-MM-DD. Defaults to thirty days ago.

to_datestring

Last day of the window, YYYY-MM-DD. Defaults to today.

branch_idstring

Scope the report to one branch. Empty reports every branch together.

Responses
200

The sales report

from_datestringrequired
to_datestringrequired
total_revenuestringrequired
total_vatstringrequired
total_countintegerrequired
min -9007199254740991 · max 9007199254740991
by_dayobject[]required
Show properties
Array of object
daystringrequired
totalstringrequired
countintegerrequired
min -9007199254740991 · max 9007199254740991
by_paymentobject[]required
Show properties
Array of object
methodstringrequired
countintegerrequired
min -9007199254740991 · max 9007199254740991
totalstringrequired
top_sellingobject[]required
Show properties
Array of object
medicine_idstringrequired
medicine_namestringrequired
units_soldintegerrequired
min -9007199254740991 · max 9007199254740991
revenuestringrequired
total_coststringrequired
gross_profitstringrequired
margin_pctnumberrequired
recentobject[]required
Show properties
Array of object
idstringrequired
invoice_numberstringrequired
total_amountstringrequired
vat_amountstringrequired
payment_methodstringrequired
sold_atstringrequired
pharmacist_namestringrequired
400

from_date or to_date is not a valid YYYY-MM-DD date, or from_date is after to_date

detailstringrequired
401

Not authenticated

detailstringrequired
403

Caller is not an admin, branch manager, or auditor

detailstringrequired
Try it
Server
Authorization
Parameters
Request
curl -X GET 'http://localhost:8000/api/v1/reports/sales' \
  -H 'Authorization: Bearer YOUR_TOKEN'
Response
{
  "from_date": "string",
  "to_date": "string",
  "total_revenue": "string",
  "total_vat": "string",
  "total_count": -9007199254740991,
  "by_day": [
    {
      "day": "string",
      "total": "string",
      "count": -9007199254740991
    }
  ],
  "by_payment": [
    {
      "method": "string",
      "count": -9007199254740991,
      "total": "string"
    }
  ],
  "top_selling": [
    {
      "medicine_id": "string",
      "medicine_name": "string",
      "units_sold": -9007199254740991,
      "revenue": "string",
      "total_cost": "string",
      "gross_profit": "string",
      "margin_pct": 0
    }
  ],
  "recent": [
    {
      "id": "string",
      "invoice_number": "string",
      "total_amount": "string",
      "vat_amount": "string",
      "payment_method": "string",
      "sold_at": "string",
      "pharmacist_name": "string"
    }
  ]
}