feat: add dashboard overview stats endpoint and UI integration
- Implemented `GET /dashboard/stats` in `DashboardController` to provide aggregate counts for stock, GRN, and procurement. - Created `DashboardStatsDto` and `WarehouseValuationDto` to structure the response data. - Developed `DashboardService` to fetch and compute necessary statistics from the database. - Added `IDashboardService` interface for service abstraction. - Introduced API client methods in `dashboard.ts` for frontend consumption of the new endpoint. - Defined TypeScript types for dashboard data in `dashboard.ts` to ensure type safety in the frontend. - Updated UI components in the frontend to reflect changes in the dashboard, including styling adjustments and removal of unused icons.
This commit is contained in:
@@ -713,6 +713,28 @@ Items at/below ROP (FR-STK-10); computed on read, no stored entity.
|
||||
```
|
||||
`POST /stock/reorder-alerts/{itemId}/requisition?warehouseId=1` → creates a draft requisition for the suggested qty.
|
||||
|
||||
### 5.8 Dashboard overview (added 2026-07-28)
|
||||
#### `GET /dashboard/stats`
|
||||
Cross-domain aggregate counts for the dashboard UI — a single computed-on-read object, not a stored entity or a `PagedResponse<T>` list (same posture as reorder alerts, §5.7). `lowStockAlerts` reuses `IReorderService.GetAlertsAsync` rather than re-deriving the FIFO-available-vs-reorder-point comparison; `onHandTotal`/`onHandWarehouses`/`stockValuationTotal`/`stockValuationByWarehouse` are SQL-side `SUM`/`GROUP BY` over `StockLayer` (cheap — unlike reorder alerts, they need no per-item live lookup).
|
||||
```json
|
||||
{
|
||||
"lowStockAlerts": 6,
|
||||
"onHandTotal": 15420,
|
||||
"onHandWarehouses": 3,
|
||||
"stockValuationTotal": 4820500.00,
|
||||
"stockValuationByWarehouse": [
|
||||
{ "warehouseId": 1, "total": 3120000.00 },
|
||||
{ "warehouseId": 2, "total": 1700500.00 }
|
||||
],
|
||||
"pendingApprovalPurchaseOrders": 2,
|
||||
"pendingGrns": 4,
|
||||
"openRequisitions": 5,
|
||||
"pendingCounts": 1,
|
||||
"openRfqs": 3
|
||||
}
|
||||
```
|
||||
`pendingApprovalPurchaseOrders` = PO status `PendingApproval`; `pendingGrns` = GRN status `Draft`; `openRequisitions` = Requisition status `Submitted`; `pendingCounts` = StockCount status `Counted` (counted but not yet posted); `openRfqs` = RFQ status `Open`. **Not covered here:** GRN inspection-hold counts (`HoldStatus` lives on GRN lines, no list/count endpoint exposes it yet) and recent stock movements (just call `GET /stock/ledger` directly with a small `pageSize` — no aggregation needed).
|
||||
|
||||
---
|
||||
|
||||
## 6. Reference Data
|
||||
|
||||
Reference in New Issue
Block a user