lib

Core libraries for Radroots
git clone https://radroots.dev/git/lib.git
Log | Files | Refs | README | LICENSE

order_economics.rs (4872B)


      1 #![forbid(unsafe_code)]
      2 
      3 #[cfg(not(feature = "std"))]
      4 use alloc::{string::String, vec::Vec};
      5 
      6 use radroots_core::{
      7     RadrootsCoreCurrency, RadrootsCoreDecimal, RadrootsCoreMoney, RadrootsCoreUnit,
      8 };
      9 
     10 use crate::ids::{RadrootsInventoryBinId, RadrootsOrderQuoteId};
     11 
     12 #[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))]
     13 #[cfg_attr(feature = "dto-bindgen", dto(ts(name = "RadrootsOrderItem")))]
     14 #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
     15 #[derive(Clone, Debug, PartialEq, Eq)]
     16 pub struct RadrootsOrderItem {
     17     pub bin_id: RadrootsInventoryBinId,
     18     pub bin_count: u32,
     19 }
     20 
     21 #[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))]
     22 #[cfg_attr(feature = "dto-bindgen", dto(ts(name = "RadrootsOrderPricingBasis")))]
     23 #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
     24 #[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
     25 #[derive(Clone, Copy, Debug, PartialEq, Eq)]
     26 pub enum RadrootsOrderPricingBasis {
     27     #[cfg_attr(feature = "serde", serde(rename = "listing_event"))]
     28     ListingEvent,
     29 }
     30 
     31 #[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))]
     32 #[cfg_attr(
     33     feature = "dto-bindgen",
     34     dto(ts(name = "RadrootsOrderEconomicLineKind"))
     35 )]
     36 #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
     37 #[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
     38 #[derive(Clone, Copy, Debug, PartialEq, Eq)]
     39 pub enum RadrootsOrderEconomicLineKind {
     40     #[cfg_attr(feature = "serde", serde(rename = "listing_discount"))]
     41     ListingDiscount,
     42     #[cfg_attr(feature = "serde", serde(rename = "basket_adjustment"))]
     43     BasketAdjustment,
     44     #[cfg_attr(feature = "serde", serde(rename = "revision_adjustment"))]
     45     RevisionAdjustment,
     46 }
     47 
     48 #[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))]
     49 #[cfg_attr(feature = "dto-bindgen", dto(ts(name = "RadrootsOrderEconomicActor")))]
     50 #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
     51 #[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
     52 #[derive(Clone, Copy, Debug, PartialEq, Eq)]
     53 pub enum RadrootsOrderEconomicActor {
     54     #[cfg_attr(feature = "serde", serde(rename = "buyer"))]
     55     Buyer,
     56     #[cfg_attr(feature = "serde", serde(rename = "seller"))]
     57     Seller,
     58 }
     59 
     60 #[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))]
     61 #[cfg_attr(feature = "dto-bindgen", dto(ts(name = "RadrootsOrderEconomicEffect")))]
     62 #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
     63 #[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
     64 #[derive(Clone, Copy, Debug, PartialEq, Eq)]
     65 pub enum RadrootsOrderEconomicEffect {
     66     #[cfg_attr(feature = "serde", serde(rename = "increase"))]
     67     Increase,
     68     #[cfg_attr(feature = "serde", serde(rename = "decrease"))]
     69     Decrease,
     70 }
     71 
     72 #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
     73 #[derive(Clone, Debug, PartialEq, Eq)]
     74 pub struct RadrootsOrderEconomicItem {
     75     pub bin_id: RadrootsInventoryBinId,
     76     pub bin_count: u32,
     77     pub quantity_amount: RadrootsCoreDecimal,
     78     pub quantity_unit: RadrootsCoreUnit,
     79     pub unit_price_amount: RadrootsCoreDecimal,
     80     pub unit_price_currency: RadrootsCoreCurrency,
     81     pub line_subtotal: RadrootsCoreMoney,
     82 }
     83 
     84 #[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))]
     85 #[cfg_attr(
     86     feature = "dto-bindgen",
     87     dto(ts(name = "RadrootsOrderEconomicLine"))
     88 )]
     89 #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
     90 #[derive(Clone, Debug, PartialEq, Eq)]
     91 pub struct RadrootsOrderEconomicLine {
     92     pub id: String,
     93     pub kind: RadrootsOrderEconomicLineKind,
     94     pub actor: RadrootsOrderEconomicActor,
     95     pub effect: RadrootsOrderEconomicEffect,
     96     pub amount: RadrootsCoreMoney,
     97     pub reason: String,
     98 }
     99 
    100 #[cfg_attr(feature = "dto-bindgen", derive(dto_bindgen::Dto))]
    101 #[cfg_attr(
    102     feature = "dto-bindgen",
    103     dto(ts(name = "RadrootsOrderEconomicTotals"))
    104 )]
    105 #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
    106 #[derive(Clone, Debug, PartialEq, Eq)]
    107 pub struct RadrootsOrderEconomicTotals {
    108     pub subtotal: RadrootsCoreMoney,
    109     pub discount_total: RadrootsCoreMoney,
    110     pub adjustment_total: RadrootsCoreMoney,
    111     pub total: RadrootsCoreMoney,
    112 }
    113 
    114 #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
    115 #[derive(Clone, Debug, PartialEq, Eq)]
    116 pub struct RadrootsOrderEconomics {
    117     pub quote_id: RadrootsOrderQuoteId,
    118     pub quote_version: u32,
    119     pub pricing_basis: RadrootsOrderPricingBasis,
    120     pub currency: RadrootsCoreCurrency,
    121     pub items: Vec<RadrootsOrderEconomicItem>,
    122     pub discounts: Vec<RadrootsOrderEconomicLine>,
    123     pub adjustments: Vec<RadrootsOrderEconomicLine>,
    124     pub subtotal: RadrootsCoreMoney,
    125     pub discount_total: RadrootsCoreMoney,
    126     pub adjustment_total: RadrootsCoreMoney,
    127     pub total: RadrootsCoreMoney,
    128 }