tktax-amazon 0.2.2

High-performance crate for parsing, fusing, and exporting Amazon transaction data for financial recordkeeping.
Documentation
// ---------------- [ File: tktax-amazon/src/amazon_tx.rs ]
crate::ix!();

#[derive(Getters,Builder,Clone,Debug,Serialize,Deserialize)]
#[getset(get="pub")]
#[builder(setter(into))]
pub struct AmazonTx {
    quantity:     i32,
    unit_price:   MonetaryAmount,
    order_date:   NaiveDate,
    product_name: String,
}

impl From<&AmazonTx1> for AmazonTx {

    fn from(x: &AmazonTx1) -> Self {

        let order_date = NaiveDate::parse_from_str(&x.order_date(), "%m/%d/%Y").unwrap();

        Self {
            quantity:     x.quantity().parse::<i32>().unwrap(),
            unit_price:   parse_price(&x.purchase_price_per_unit()).unwrap(),
            order_date,
            product_name: x.title().clone(),
        }
    }
}

impl From<&AmazonTx2> for AmazonTx {

    fn from(x: &AmazonTx2) -> Self {

        let order_date 
            = NaiveDateTime::parse_from_str(&x.order_date(), "%m/%d/%Y %H:%M:%S").unwrap().date();

        Self {
            quantity:     x.quantity().parse::<i32>().unwrap(),
            unit_price:   parse_price(&x.unit_price()).unwrap(),
            order_date,
            product_name: x.product_name().clone(),
        }
    }
}