Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | 1x 1x 1x | import type { ApiClient, BusinessId } from "./api";
export interface StockSummary {
skuId: BusinessId;
onHand: number;
reserved: number;
available: number;
}
export interface Warehouse {
id: BusinessId;
code: string;
name: string;
status: string;
version: number;
}
export interface StockPosition extends StockSummary {
warehouseId: BusinessId;
version: number;
}
export interface AdjustStockInput {
movementNo: string;
warehouseId: BusinessId;
skuId: BusinessId;
quantityDelta: number;
reason: string;
}
export interface InventoryApi {
stock(skuId: BusinessId): Promise<StockSummary>;
warehouses(): Promise<Warehouse[]>;
createWarehouse(code: string, name: string): Promise<Warehouse>;
stockPosition(warehouseId: BusinessId, skuId: BusinessId): Promise<StockPosition>;
adjustStock(input: AdjustStockInput): Promise<StockPosition>;
}
export function createInventoryApi(client: ApiClient): InventoryApi {
return {
stock(skuId) {
return client.request<StockSummary>(
`/api/v1/inventory/stocks/${encodeURIComponent(skuId)}`,
);
},
warehouses() {
return client.request<Warehouse[]>("/api/v1/inventory/admin/warehouses");
},
createWarehouse(code, name) {
return client.request<Warehouse>("/api/v1/inventory/admin/warehouses", {
method: "POST",
body: JSON.stringify({ code, name }),
});
},
stockPosition(warehouseId, skuId) {
return client.request<StockPosition>(
`/api/v1/inventory/admin/warehouses/${encodeURIComponent(warehouseId)}`
+ `/stocks/${encodeURIComponent(skuId)}`,
);
},
adjustStock(input) {
return client.request<StockPosition>("/api/v1/inventory/admin/stocks/adjustments", {
method: "POST",
body: JSON.stringify(input),
});
},
};
}
|