Add multi-series charts and enhance dashboard functionality

This commit is contained in:
2026-10-19 15:51:39 +05:30
parent 2d6723a040
commit 3c75f9786e
5 changed files with 621 additions and 215 deletions
+38
View File
@@ -159,3 +159,41 @@ export const productReports = {
summary: (params?: Pick<ProductReportParams, 'brandId' | 'categoryId' | 'warehouseId' | 'from' | 'to'>) =>
api.get<ProductReportSummary>('/reports/products/summary', { params }).then(r => r.data),
}
export interface SalesKpis {
grossSales: number
returnValue: number
netSales: number
orders: number
averageOrderValue: number
grossProfit: number
grossProfitMarginPercent: number | null
}
export interface DashboardSalesSummary {
from: string
to: string
granularity: 'day' | 'month'
kpis: { current: SalesKpis; previous: SalesKpis; previousFrom: string; previousTo: string }
trend: Array<{ period: string; sales: number; returns: number }>
byCategory: Array<{ id: string | null; name: string; amount: number }>
byRegion: Array<{ id: string | null; name: string; amount: number }>
byRep: Array<{ id: string | null; name: string; amount: number }>
}
export interface DashboardInventorySummary {
from: string
to: string
granularity: 'day' | 'month'
valueByCategory: Array<{ category: string; quantity: number; value: number }>
byWarehouse: Array<{ warehouseId: string; name: string; quantity: number; value: number }>
movementTrend: Array<{ period: string; received: number; issued: number; net: number }>
}
export const dashboardReports = {
sales: (params?: { from?: string; to?: string; regionId?: string; categoryId?: string }) =>
api.get<DashboardSalesSummary>('/reports/dashboard/sales', { params }).then(r => r.data),
inventory: (params?: { from?: string; to?: string; warehouseId?: string; categoryId?: string }) =>
api.get<DashboardInventorySummary>('/reports/dashboard/inventory', { params }).then(r => r.data),
}