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
/*!
 * Commodity definition
 * 
 * commodity.cc
 */

#[derive(Debug, PartialEq)]
pub struct Commodity {
    pub symbol: String,
    // graph_index: Option
    // precision
    // name: Option<String>
    // note: Option<String>
    // smaller: Option
    // larger: Option
    // value_expr: Option

    // commodity_pool
    // annotated_commodity
    // parent
    // qualified_symbol: Option<String>
    // annotated: bool
}

impl Commodity {
    pub fn new(symbol: &str) -> Self {
        Self { symbol: symbol.to_owned() }
    }

    // pub fn parse(symbol: &str) -> Option<Self> {
    //     if symbol.is_empty() {
    //         return None;
    //     }
    //     Some(Commodity::new(symbol))
    // }
}

// struct PricePoint {
//     when: NaiveDateTime,
//     price: Amount
// }

#[cfg(test)]
mod tests {
    use super::Commodity;

    #[test]
    fn test_comparison() {
        let c1 = Commodity::new("EUR");
        let c2 = Commodity::new("EUR");

        assert!(c1 == c2);
    }

    #[test]
    fn test_comparison_ne() {
        let c1 = Commodity::new("EUR");
        let c2 = Commodity::new("GBP");

        assert!(c1 != c2);
    }

}