Skip to main content

mcp_procurement/
types.rs

1use serde::{Deserialize, Serialize};
2use serde_json::Value;
3
4#[derive(Clone, Debug, Serialize, Deserialize)]
5pub struct Supplier {
6    pub id: String,
7    pub name: String,
8    pub category: String,
9    pub contact_email: Option<String>,
10    pub contact_phone: Option<String>,
11    pub country: String,
12    pub currency: String,
13    pub payment_terms: String, // net30, net60, cod
14    pub rating: f64, // 0-5
15    pub status: String, // active, suspended, blacklisted
16    pub metadata: Value,
17}
18
19#[derive(Clone, Debug, Serialize, Deserialize)]
20pub struct PurchaseOrder {
21    pub id: String,
22    pub supplier_id: String,
23    pub status: String, // draft, pending_approval, approved, sent, partially_received, received, cancelled
24    pub lines: Vec<PoLine>,
25    pub currency: String,
26    pub subtotal: f64,
27    pub tax: f64,
28    pub total: f64,
29    pub payment_terms: String,
30    pub delivery_date: Option<String>,
31    pub notes: Option<String>,
32    pub created_by: String,
33    pub approved_by: Option<String>,
34    pub created_at: String,
35}
36
37#[derive(Clone, Debug, Serialize, Deserialize)]
38pub struct PoLine {
39    pub sku: String,
40    pub description: String,
41    pub quantity: f64,
42    pub unit_price: f64,
43    pub total: f64,
44    pub received_qty: f64,
45}
46
47#[derive(Clone, Debug, Serialize, Deserialize)]
48pub struct Rfq {
49    pub id: String,
50    pub title: String,
51    pub status: String, // open, closed, awarded
52    pub items: Vec<RfqItem>,
53    pub supplier_ids: Vec<String>,
54    pub responses: Vec<RfqResponse>,
55    pub deadline: String,
56    pub created_by: String,
57    pub created_at: String,
58}
59
60#[derive(Clone, Debug, Serialize, Deserialize)]
61pub struct RfqItem {
62    pub description: String,
63    pub quantity: f64,
64    pub unit: String,
65    pub specs: Option<String>,
66}
67
68#[derive(Clone, Debug, Serialize, Deserialize)]
69pub struct RfqResponse {
70    pub supplier_id: String,
71    pub supplier_name: String,
72    pub unit_prices: Vec<f64>,
73    pub total: f64,
74    pub lead_time_days: u32,
75    pub notes: Option<String>,
76    pub submitted_at: String,
77}
78
79#[derive(Clone, Debug, Serialize, Deserialize)]
80pub struct GoodsReceipt {
81    pub id: String,
82    pub po_id: String,
83    pub lines: Vec<ReceiptLine>,
84    pub received_by: String,
85    pub received_at: String,
86    pub notes: Option<String>,
87}
88
89#[derive(Clone, Debug, Serialize, Deserialize)]
90pub struct ReceiptLine {
91    pub sku: String,
92    pub quantity_received: f64,
93    pub quantity_rejected: f64,
94    pub rejection_reason: Option<String>,
95}
96
97#[derive(Clone, Debug, Serialize, Deserialize)]
98pub struct Contract {
99    pub id: String,
100    pub supplier_id: String,
101    pub title: String,
102    pub contract_type: String, // fixed_price, time_materials, blanket, framework
103    pub value: f64,
104    pub currency: String,
105    pub start_date: String,
106    pub end_date: String,
107    pub auto_renew: bool,
108    pub terms: String,
109    pub status: String, // draft, active, expired, terminated
110    pub created_at: String,
111}
112
113#[derive(Clone, Debug, Serialize, Deserialize)]
114pub struct Invoice {
115    pub id: String,
116    pub po_id: String,
117    pub supplier_id: String,
118    pub invoice_number: String,
119    pub amount: f64,
120    pub currency: String,
121    pub status: String, // pending, matched, disputed, paid
122    pub received_at: String,
123}
124
125#[derive(Clone, Debug, Serialize, Deserialize)]
126pub struct Budget {
127    pub id: String,
128    pub department: String,
129    pub category: String,
130    pub allocated: f64,
131    pub spent: f64,
132    pub currency: String,
133    pub period: String, // 2026-Q2, 2026
134}
135
136#[derive(Clone, Debug, Serialize, Deserialize)]
137pub struct SupplierDiversity {
138    pub supplier_id: String,
139    pub certifications: Vec<String>, // minority_owned, women_owned, veteran_owned, small_business, disabled_owned, lgbtq_owned
140    pub certified_by: Option<String>,
141    pub expiry_date: Option<String>,
142}
143
144#[derive(Clone, Debug, Serialize, Deserialize)]
145pub struct CatalogItem {
146    pub id: String,
147    pub supplier_id: String,
148    pub sku: String,
149    pub description: String,
150    pub unit_price: f64,
151    pub currency: String,
152    pub lead_time_days: u32,
153    pub min_order_qty: f64,
154}