Skip to main content

mcp_inventory/
types.rs

1use serde::{Deserialize, Serialize};
2use serde_json::Value;
3
4#[derive(Clone, Debug, Serialize, Deserialize)]
5pub struct Item {
6    pub sku: String,
7    pub name: String,
8    pub category: String,
9    pub unit: String, // each, kg, litre, box, pallet
10    pub reorder_point: f64,
11    pub reorder_qty: f64,
12    pub cost: f64,
13    pub currency: String,
14    pub attributes: Value,
15}
16
17#[derive(Clone, Debug, Serialize, Deserialize)]
18pub struct Location {
19    pub id: String,
20    pub name: String,
21    pub location_type: String, // warehouse, zone, aisle, rack, bin, staging, dock
22    pub parent_id: Option<String>,
23    pub address: Option<String>,
24    pub capacity_units: Option<f64>,   // max units this location can hold
25    pub capacity_weight_kg: Option<f64>, // max weight
26    pub capacity_volume_m3: Option<f64>, // max volume
27    pub used_units: f64,
28    pub used_weight_kg: f64,
29    pub used_volume_m3: f64,
30}
31
32#[derive(Clone, Debug, Serialize, Deserialize)]
33pub struct PickOrder {
34    pub id: String,
35    pub status: String, // pending, picking, packed, shipped, cancelled
36    pub order_reference: String,
37    pub lines: Vec<PickLine>,
38    pub assigned_to: Option<String>,
39    pub wave_id: Option<String>,
40    pub created_at: String,
41    pub updated_at: String,
42}
43
44#[derive(Clone, Debug, Serialize, Deserialize)]
45pub struct PickLine {
46    pub sku: String,
47    pub quantity: f64,
48    pub from_location: String,
49    pub picked_qty: f64,
50    pub status: String, // pending, picked, short
51}
52
53#[derive(Clone, Debug, Serialize, Deserialize)]
54pub struct PutawayRule {
55    pub id: String,
56    pub category: String,       // item category this rule applies to
57    pub target_zone: String,    // preferred zone/location
58    pub priority: i32,
59}
60
61#[derive(Clone, Debug, Serialize, Deserialize)]
62pub struct CycleCount {
63    pub id: String,
64    pub location_id: String,
65    pub status: String, // scheduled, in_progress, completed
66    pub scheduled_date: String,
67    pub counted_by: Option<String>,
68    pub discrepancies: Vec<Value>,
69    pub completed_at: Option<String>,
70}
71
72#[derive(Clone, Debug, Serialize, Deserialize)]
73pub struct Wave {
74    pub id: String,
75    pub name: String,
76    pub status: String, // planning, released, in_progress, completed
77    pub pick_ids: Vec<String>,
78    pub priority: String,
79    pub created_at: String,
80    pub released_at: Option<String>,
81    pub completed_at: Option<String>,
82}
83
84#[derive(Clone, Debug, Serialize, Deserialize)]
85pub struct BarcodeLabel {
86    pub id: String,
87    pub barcode_type: String, // sku, location, lot, shipment, receipt, serial, rfid
88    pub entity_id: String,
89    pub barcode_format: String, // code128, ean13, qr, datamatrix, rfid_epc
90    pub barcode_value: String,
91    pub label_text: Vec<String>,
92    pub generated_at: String,
93}
94
95#[derive(Clone, Debug, Serialize, Deserialize)]
96pub struct SerializedItem {
97    pub serial_number: String,
98    pub sku: String,
99    pub status: String, // in_stock, reserved, shipped, returned, scrapped
100    pub location_id: String,
101    pub lot_number: Option<String>,
102    pub manufacture_date: Option<String>,
103    pub expiry_date: Option<String>,
104    pub rfid_tag: Option<String>,
105    pub qr_code: Option<String>,
106    pub history: Vec<SerialEvent>,
107    pub metadata: Value,
108}
109
110#[derive(Clone, Debug, Serialize, Deserialize)]
111pub struct SerialEvent {
112    pub event_type: String, // received, moved, picked, shipped, returned, scrapped
113    pub location: String,
114    pub actor: String,
115    pub timestamp: String,
116    pub reference: Option<String>,
117}
118
119#[derive(Clone, Debug, Serialize, Deserialize)]
120pub struct RfidTag {
121    pub epc: String, // Electronic Product Code (96-bit hex)
122    pub serial_number: Option<String>,
123    pub sku: Option<String>,
124    pub location_id: String,
125    pub last_read_at: String,
126    pub read_count: u32,
127    pub status: String, // active, lost, decommissioned
128}
129
130#[derive(Clone, Debug, Serialize, Deserialize)]
131pub struct StockLevel {
132    pub sku: String,
133    pub location_id: String,
134    pub quantity: f64,
135    pub reserved: f64,
136    pub lot_number: Option<String>,
137    pub expiry_date: Option<String>,
138    pub updated_at: String,
139}
140
141#[derive(Clone, Debug, Serialize, Deserialize)]
142pub struct StockMovement {
143    pub id: String,
144    pub movement_type: String, // receive, issue, transfer, adjust, return
145    pub sku: String,
146    pub quantity: f64,
147    pub from_location: Option<String>,
148    pub to_location: Option<String>,
149    pub reference: String,
150    pub actor: String,
151    pub lot_number: Option<String>,
152    pub timestamp: String,
153}
154
155#[derive(Clone, Debug, Serialize, Deserialize)]
156pub struct BomEntry {
157    pub parent_sku: String,
158    pub component_sku: String,
159    pub quantity: f64,
160}
161
162#[derive(Clone, Debug, Serialize, Deserialize)]
163pub struct Reservation {
164    pub id: String,
165    pub sku: String,
166    pub location_id: String,
167    pub quantity: f64,
168    pub reference: String, // order_id, work_order_id
169    pub expires_at: Option<String>,
170    pub created_at: String,
171}