import { api } from '@/lib/api' import type { PaginatedResponse } from '@/types/api' import type { PageParams } from './master' export interface ProductStockRow { itemId: string sku: string name: string brand: string | null category: string subCategory: string | null uom: string salePrice: number | null costPrice: number | null reorderLevel: number | null warehouseQty: number vehicleQty: number totalQty: number stockValue: number isLowStock: boolean isActive: boolean } export interface ProductSalesRow { itemId: string sku: string name: string orders: number stores: number qtyOrdered: number qtyFulfilled: number salesValue: number costValue: number | null margin: number | null marginPercent: number | null } export interface ProductReturnRow { itemId: string sku: string name: string returnedQty: number returnedValue: number soldQty: number returnPercent: number | null qtyByReason: Record } export interface ProductReportSummary { itemCount: number totalQty: number totalValue: number totalSales: number } export interface ProductReportParams extends PageParams { brandId?: string categoryId?: string subCategoryId?: string warehouseId?: string regionId?: string routeId?: string storeId?: string from?: string to?: string search?: string } export interface ProductStockParams extends ProductReportParams { activeOnly?: boolean lowStockOnly?: boolean } export const productReports = { stock: (params?: ProductStockParams) => api.get>('/reports/products/stock', { params }).then(r => r.data), sales: (params?: ProductReportParams) => api.get>('/reports/products/sales', { params }).then(r => r.data), returns: (params?: ProductReportParams) => api.get>('/reports/products/returns', { params }).then(r => r.data), summary: (params?: Pick) => api.get('/reports/products/summary', { params }).then(r => r.data), }