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

Report on purchase spend

Admin, branch manager, or auditor. Returns batch spend grouped by supplier and medicine. The window defaults to the last thirty days, and a branch_id scopes it to one branch.

GET/api/v1/reports/purchases
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 purchase report

from_datestringrequired
to_datestringrequired
total_spendstringrequired
by_supplierobject[]required
Show properties
Array of object
supplier_namestring | nullrequired
batch_countintegerrequired
min -9007199254740991 · max 9007199254740991
total_spendstringrequired
by_medicineobject[]required
Show properties
Array of object
medicine_namestring | nullrequired
batch_countintegerrequired
min -9007199254740991 · max 9007199254740991
total_unitsintegerrequired
min -9007199254740991 · max 9007199254740991
total_spendstringrequired
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/purchases' \
  -H 'Authorization: Bearer YOUR_TOKEN'
Response
{
  "from_date": "string",
  "to_date": "string",
  "total_spend": "string",
  "by_supplier": [
    {
      "supplier_name": "string",
      "batch_count": -9007199254740991,
      "total_spend": "string"
    }
  ],
  "by_medicine": [
    {
      "medicine_name": "string",
      "batch_count": -9007199254740991,
      "total_units": -9007199254740991,
      "total_spend": "string"
    }
  ]
}