backbone_inventory/domain/event/
declared.rs1use backbone_core::write_hooks::DeclaredEvent;
14use serde::{Deserialize, Serialize};
15
16#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
19pub struct StockReceived {
20 pub receipt_id: serde_json::Value,
21 pub company_id: serde_json::Value,
22 pub warehouse_id: serde_json::Value,
23 pub source_po_id: serde_json::Value,
24 pub total_value: serde_json::Value,
25}
26
27impl DeclaredEvent for StockReceived {
28 const NAME: &'static str = "StockReceived";
29 const VERSION: i32 = 1;
30 const AGGREGATE: &'static str = "";
31}
32
33#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
36pub struct StockDelivered {
37 pub delivery_id: serde_json::Value,
38 pub company_id: serde_json::Value,
39 pub warehouse_id: serde_json::Value,
40 pub source_so_id: serde_json::Value,
41 pub total_cogs: serde_json::Value,
42}
43
44impl DeclaredEvent for StockDelivered {
45 const NAME: &'static str = "StockDelivered";
46 const VERSION: i32 = 1;
47 const AGGREGATE: &'static str = "";
48}
49
50#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
53pub struct StockMoved {
54 pub entry_id: serde_json::Value,
55 pub company_id: serde_json::Value,
56 pub from_warehouse_id: serde_json::Value,
57 pub to_warehouse_id: serde_json::Value,
58}
59
60impl DeclaredEvent for StockMoved {
61 const NAME: &'static str = "StockMoved";
62 const VERSION: i32 = 1;
63 const AGGREGATE: &'static str = "";
64}
65
66#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
69pub struct StockReconciled {
70 pub reconciliation_id: serde_json::Value,
71 pub company_id: serde_json::Value,
72 pub warehouse_id: serde_json::Value,
73 pub net_difference: serde_json::Value,
74}
75
76impl DeclaredEvent for StockReconciled {
77 const NAME: &'static str = "StockReconciled";
78 const VERSION: i32 = 1;
79 const AGGREGATE: &'static str = "";
80}
81
82#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
85pub struct LandedCostValidated {
86 pub lc_id: serde_json::Value,
87 pub company_id: serde_json::Value,
88 pub target_receipt_id: serde_json::Value,
89 pub amount_total: serde_json::Value,
90 pub revalued_value: serde_json::Value,
91}
92
93impl DeclaredEvent for LandedCostValidated {
94 const NAME: &'static str = "LandedCostValidated";
95 const VERSION: i32 = 1;
96 const AGGREGATE: &'static str = "";
97}
98
99#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
102pub struct MoveConfirmed {
103 pub move_id: serde_json::Value,
104 pub company_id: serde_json::Value,
105 pub item_id: serde_json::Value,
106 pub demand_qty: serde_json::Value,
107 pub picking_id: serde_json::Value,
108}
109
110impl DeclaredEvent for MoveConfirmed {
111 const NAME: &'static str = "MoveConfirmed";
112 const VERSION: i32 = 1;
113 const AGGREGATE: &'static str = "";
114}
115
116#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
119pub struct MoveAssigned {
120 pub move_id: serde_json::Value,
121 pub company_id: serde_json::Value,
122 pub picking_id: serde_json::Value,
123}
124
125impl DeclaredEvent for MoveAssigned {
126 const NAME: &'static str = "MoveAssigned";
127 const VERSION: i32 = 1;
128 const AGGREGATE: &'static str = "";
129}
130
131#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
134pub struct MoveDone {
135 pub move_id: serde_json::Value,
136 pub company_id: serde_json::Value,
137 pub item_id: serde_json::Value,
138 pub quantity: serde_json::Value,
139 pub price_unit: serde_json::Value,
140 pub is_inventory: serde_json::Value,
141}
142
143impl DeclaredEvent for MoveDone {
144 const NAME: &'static str = "MoveDone";
145 const VERSION: i32 = 1;
146 const AGGREGATE: &'static str = "";
147}
148
149#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
152pub struct MoveCancelled {
153 pub move_id: serde_json::Value,
154 pub company_id: serde_json::Value,
155 pub released_qty: serde_json::Value,
156}
157
158impl DeclaredEvent for MoveCancelled {
159 const NAME: &'static str = "MoveCancelled";
160 const VERSION: i32 = 1;
161 const AGGREGATE: &'static str = "";
162}
163
164#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
167pub struct TransferProjected {
168 pub transfer_id: serde_json::Value,
169 pub company_id: serde_json::Value,
170 pub state: serde_json::Value,
171 pub previous_state: serde_json::Value,
172}
173
174impl DeclaredEvent for TransferProjected {
175 const NAME: &'static str = "TransferProjected";
176 const VERSION: i32 = 1;
177 const AGGREGATE: &'static str = "";
178}
179
180#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
183pub struct BackorderCreated {
184 pub backorder_id: serde_json::Value,
185 pub company_id: serde_json::Value,
186 pub origin_id: serde_json::Value,
187}
188
189impl DeclaredEvent for BackorderCreated {
190 const NAME: &'static str = "BackorderCreated";
191 const VERSION: i32 = 1;
192 const AGGREGATE: &'static str = "";
193}
194
195#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
198pub struct OrderpointTriggered {
199 pub orderpoint_id: serde_json::Value,
200 pub company_id: serde_json::Value,
201 pub item_id: serde_json::Value,
202 pub qty_to_order: serde_json::Value,
203 pub forecast_qty: serde_json::Value,
204}
205
206impl DeclaredEvent for OrderpointTriggered {
207 const NAME: &'static str = "OrderpointTriggered";
208 const VERSION: i32 = 1;
209 const AGGREGATE: &'static str = "";
210}
211
212pub const OUTBOX_SCHEMAS: &[&str] = &[];
214
215pub async fn migrate_outbox(pool: &backbone_orm::PgPool) -> anyhow::Result<()> {
219 for schema in OUTBOX_SCHEMAS {
220 backbone_core::write_hooks::migrate_outbox(pool, schema).await?;
221 }
222 Ok(())
223}