serial numbers
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
// Item tracking endpoints — pickers (/tracking), serial register (/serials), warranty register
|
||||
// (/warranties) and batch stock (/stock/batches). docs/ITEM_TRACKING_PLAN.md.
|
||||
import { apiRequest, buildQuery } from "@/lib/api-client"
|
||||
import { PagedResponse } from "@/types/common"
|
||||
import {
|
||||
AvailableBatch,
|
||||
AvailableSerial,
|
||||
BatchStock,
|
||||
BatchSuggestion,
|
||||
SerialDetail,
|
||||
SerialStatus,
|
||||
SerialSummary,
|
||||
TrackingSettings,
|
||||
WarrantyRegistration,
|
||||
WarrantyStatus,
|
||||
} from "@/types/tracking"
|
||||
|
||||
export interface SerialListParams {
|
||||
q?: string
|
||||
itemId?: number
|
||||
warehouseId?: number
|
||||
status?: SerialStatus
|
||||
page?: number
|
||||
pageSize?: number
|
||||
}
|
||||
|
||||
export interface WarrantyListParams {
|
||||
q?: string
|
||||
customerId?: number
|
||||
itemId?: number
|
||||
serialNo?: string
|
||||
status?: WarrantyStatus
|
||||
expiringWithinDays?: number
|
||||
expired?: boolean
|
||||
page?: number
|
||||
pageSize?: number
|
||||
}
|
||||
|
||||
export interface BatchStockParams {
|
||||
q?: string
|
||||
itemId?: number
|
||||
warehouseId?: number
|
||||
expiringWithinDays?: number
|
||||
page?: number
|
||||
pageSize?: number
|
||||
}
|
||||
|
||||
export const trackingApi = {
|
||||
settings() {
|
||||
return apiRequest<TrackingSettings>("/tracking/settings")
|
||||
},
|
||||
|
||||
/** Next free serial numbers for an item under a prefix (auto-generate on GRN). */
|
||||
nextSerialNumbers(itemId: number, prefix: string, count: number) {
|
||||
return apiRequest<string[]>(`/tracking/serials/next-numbers${buildQuery({ itemId, prefix, count })}`)
|
||||
},
|
||||
|
||||
availableSerials(itemId: number, warehouseId: number, q?: string) {
|
||||
return apiRequest<AvailableSerial[]>(`/tracking/serials/available${buildQuery({ itemId, warehouseId, q })}`)
|
||||
},
|
||||
|
||||
availableBatches(itemId: number, warehouseId: number) {
|
||||
return apiRequest<AvailableBatch[]>(`/tracking/batches/available${buildQuery({ itemId, warehouseId })}`)
|
||||
},
|
||||
|
||||
suggestBatches(itemId: number, warehouseId: number, qty: number) {
|
||||
return apiRequest<BatchSuggestion[]>(`/tracking/batches/suggest${buildQuery({ itemId, warehouseId, qty })}`)
|
||||
},
|
||||
|
||||
listSerials(params: SerialListParams = {}) {
|
||||
return apiRequest<PagedResponse<SerialSummary>>(`/serials${buildQuery(params)}`)
|
||||
},
|
||||
|
||||
getSerial(serialId: number) {
|
||||
return apiRequest<SerialDetail>(`/serials/${serialId}`)
|
||||
},
|
||||
|
||||
lookupSerial(serialNo: string) {
|
||||
return apiRequest<SerialDetail[]>(`/serials/lookup${buildQuery({ serialNo })}`)
|
||||
},
|
||||
|
||||
listWarranties(params: WarrantyListParams = {}) {
|
||||
return apiRequest<PagedResponse<WarrantyRegistration>>(`/warranties${buildQuery(params)}`)
|
||||
},
|
||||
|
||||
listBatchStock(params: BatchStockParams = {}) {
|
||||
return apiRequest<PagedResponse<BatchStock>>(`/stock/batches${buildQuery(params)}`)
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user