wb_cache/test/simulation/scriptwriter/entity/
inventory.rs

1use fieldx::fxstruct;
2use serde::Deserialize;
3use serde::Serialize;
4
5#[derive(Clone, Debug)]
6#[fxstruct(no_new, builder, get(copy))]
7pub struct InventoryRecord {
8    product_id:    i32,
9    #[fieldx(get_mut)]
10    stock:         i64,
11    handling_days: i16,
12}
13
14impl InventoryRecord {
15    pub fn new(product_id: i32, stock: i64, handling_days: i16) -> Self {
16        Self {
17            product_id,
18            stock,
19            handling_days,
20        }
21    }
22}
23
24impl From<InventoryRecord> for crate::test::simulation::db::entity::InventoryRecord {
25    fn from(record: InventoryRecord) -> Self {
26        Self {
27            product_id:    record.product_id,
28            stock:         record.stock,
29            handling_days: record.handling_days,
30        }
31    }
32}
33
34#[derive(Clone, Debug, Serialize, Deserialize)]
35#[serde(deny_unknown_fields)]
36pub struct IncomingShipment {
37    #[serde(rename = "p")]
38    pub product_id: i32,
39    #[serde(rename = "b")]
40    pub batch_size: i32,
41}
42
43#[derive(Clone, Debug, Serialize, Deserialize)]
44#[serde(deny_unknown_fields)]
45pub struct InventoryCheck {
46    #[serde(rename = "p")]
47    pub product_id: i32,
48    #[serde(rename = "s")]
49    pub stock:      i64,
50    #[serde(rename = "c")]
51    pub comment:    String,
52}
53
54impl InventoryCheck {
55    pub fn new<S: ToString>(product_id: i32, stock: i64, comment: S) -> Self {
56        Self {
57            product_id,
58            stock,
59            comment: comment.to_string(),
60        }
61    }
62}