Fe changes

This commit is contained in:
2026-10-16 15:47:23 +05:30
parent 09d86835a2
commit c5a0992b5d
23 changed files with 2715 additions and 89 deletions
+9
View File
@@ -12,6 +12,8 @@ import type {
RouteVisitResponse,
VehicleResponse,
WarehouseResponse,
WarehouseDashboardResponse,
VehicleDashboardResponse,
VehicleType,
WarehouseType,
} from '@/types/api'
@@ -199,6 +201,10 @@ export const vehicles = {
get: (id: string) =>
api.get<VehicleResponse>(`/vehicles/${id}`).then(r => normalizeVehicle(r.data)),
dashboard: (id: string, params?: { from?: string; to?: string }) =>
api.get<VehicleDashboardResponse>(`/vehicles/${id}/dashboard`, { params })
.then(r => ({ ...r.data, vehicle: normalizeVehicle(r.data.vehicle) })),
create: (body: VehicleBody) =>
api.post<VehicleResponse>('/vehicles', serializeVehicleBody(body)).then(r => normalizeVehicle(r.data)),
@@ -226,6 +232,9 @@ export const warehouses = {
get: (id: string) =>
api.get<WarehouseResponse>(`/warehouses/${id}`).then(r => r.data),
dashboard: (id: string, params?: { from?: string; to?: string; deadStockDays?: number }) =>
api.get<WarehouseDashboardResponse>(`/warehouses/${id}/dashboard`, { params }).then(r => r.data),
create: (body: WarehouseBody) =>
api.post<WarehouseResponse>('/warehouses', body).then(r => r.data),
+74
View File
@@ -72,6 +72,80 @@ export interface ProductStockParams extends ProductReportParams {
lowStockOnly?: boolean
}
export interface StockOverview {
totalSkus: number
totalQty: number
totalValue: number
lowStockCount: number
outOfStockCount: number
expiringSoonCount: number
expiredCount: number
}
export type StockLedgerStatus = 'OK' | 'Low' | 'Out'
export interface StockLedgerRow {
itemId: string
sku: string
name: string
brand: string | null
category: string
uom: string
openingQty: number
qtyIn: number
qtyOut: number
closingQty: number
currentQty: number
costPrice: number | null
stockValue: number
reorderLevel: number | null
status: StockLedgerStatus
}
export interface StockExpiryRow {
itemId: string
sku: string
name: string
batchId: string
batchNumber: string | null
expiryDate: string
daysLeft: number
quantity: number
costPrice: number | null
value: number
locationId: string
locationType: string
locationName: string
}
export interface StockLedgerParams extends PageParams {
locationId?: string
categoryId?: string
brandId?: string
from?: string
to?: string
status?: 'low' | 'out'
activeOnly?: boolean
search?: string
}
export interface StockExpiryParams extends PageParams {
locationId?: string
days?: number
search?: string
}
export const stockReports = {
overview: (params?: { locationId?: string; expiryDays?: number }) =>
api.get<StockOverview>('/reports/stock/overview', { params }).then(r => r.data),
ledger: (params?: StockLedgerParams) =>
api.get<PaginatedResponse<StockLedgerRow>>('/reports/stock/ledger', { params }).then(r => r.data),
expiry: (params?: StockExpiryParams) =>
api.get<PaginatedResponse<StockExpiryRow>>('/reports/stock/expiry', { params }).then(r => r.data),
}
export const productReports = {
stock: (params?: ProductStockParams) =>
api.get<PaginatedResponse<ProductStockRow>>('/reports/products/stock', { params }).then(r => r.data),