Credith exposes three dedicated report endpoints that give business owners a detailed view of operational performance across their retail network. The Products report shows per-product sales volume, current inventory, and gross/net gain broken down by store. The Stores report provides a monthly snapshot of a single branch — including revenue and staff roster. The Companies report aggregates monthly gross and net gain across all active stores under a company. All three endpoints run optimised raw SQL queries against theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/RoyGeova07/Credith/llms.txt
Use this file to discover all available pages before exploring further.
cd PostgreSQL schema and are accessible only to users with the OWNER role (and ADMIN for the stores report).
In the Credith React frontend (
ManagerReportsPage.jsx), report controls are only rendered for users whose session cookie contains role: "OWNER". Non-owner roles are redirected away from the reports section entirely. Ensure the authenticated user was assigned the Owner role via POST /api/roles/associate-user before using these endpoints.Report Types
- Products
- Stores
- Companies
GET /api/reports/products
Returns product-level performance for a given company, optionally scoped to a specific store and/or calendar month. Results are paginated and sorted alphabetically by product name.Query Parameters| Parameter | Required | Description |
|---|---|---|
companyId | ✅ | UUID of the company to scope the report to |
storeId | — | UUID of a specific store; filters both sales and inventory data |
month | — | Month to filter. Accepts YYYY-MM format (e.g. 2025-06) or a numeric 1–12 alongside year |
year | — | Required when month is passed as a number (e.g. month=6&year=2025) |
limit | — | Max products to return (default 10, max 100) |
offset | — | Pagination offset (default 0) |
month nor year is provided, the report returns historical data (all time). The period.type field in the response will be "historical".Example RequestquantitySold— total units sold during the period across all stores (or the filtered store)inStock— current inventory units availablegrossGain—(sellPrice − buyPrice) × quantitysummed over all matching bill detailsnetGain—(lineTotal − buyPrice × quantity)summed, accounting for line-item discountsstores— per-store breakdown of the same metrics
Exporting Reports
TheManagerReportsPage in the React frontend provides a Exportar CSV button for each report section. The export is entirely client-side — the page calls downloadCsv() which converts the in-memory report JSON into CSV rows and triggers a browser download without any additional API call.
| Report | CSV filename pattern |
|---|---|
| Company | company-report-{name}.csv |
| Store | store-report-{storeId}.csv |
| Products | product-report.csv |
Dashboard Revenue Charts
TheDashboardHomePage uses the GET /api/reports/stores/range endpoint to power a Recharts AreaChart that visualises the last 6 months of revenue for the current store. The frontend computes the startDate as 6 months before today and endDate as today, passes the authenticated user’s storeId from the session cookie, and maps the returned daily { date, grossGain, netGain } array directly into the chart data prop. This gives store admins an at-a-glance revenue trend without navigating to the full reports page.
Role Requirements
| Endpoint | Required role |
|---|---|
GET /api/reports/products | OWNER |
GET /api/reports/stores | OWNER or ADMIN |
GET /api/reports/stores/range | OWNER or ADMIN |
GET /api/reports/companies | OWNER |
authMiddleware (requires a valid JWT cookie) and roleMiddleware (checks req.user.role against the allowed roles). A request from an ADMIN user to GET /api/reports/companies will be rejected with 403.