pub struct OrderItem {
pub id: OrderItemId,
pub order_id: OrderId,
pub product_id: ProductId,
pub variant_id: Option<Uuid>,
pub sku: String,
pub name: String,
pub quantity: i32,
pub unit_price: Decimal,
pub discount: Decimal,
pub tax_amount: Decimal,
pub total: Decimal,
}Expand description
Order line item
Fields§
§id: OrderItemId§order_id: OrderId§product_id: ProductId§variant_id: Option<Uuid>§sku: String§name: String§quantity: i32§unit_price: Decimal§discount: Decimal§tax_amount: Decimal§total: DecimalImplementations§
Source§impl OrderItem
impl OrderItem
Sourcepub fn calculate_total(
quantity: i32,
unit_price: Decimal,
discount: Decimal,
tax: Decimal,
) -> Decimal
pub fn calculate_total( quantity: i32, unit_price: Decimal, discount: Decimal, tax: Decimal, ) -> Decimal
Calculate a line item’s money total, rounded to the currency minor unit.
The result is rounded to MONEY_SCALE (2) decimal places so the stored
line total is a real money amount and an order’s total_amount (the sum
of these line totals) foots exactly to its line items. All order-creation
paths on both backends route through this function so they agree to the
cent.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for OrderItem
impl<'de> Deserialize<'de> for OrderItem
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<OrderItem, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<OrderItem, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for OrderItem
Source§impl Serialize for OrderItem
impl Serialize for OrderItem
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl StructuralPartialEq for OrderItem
Auto Trait Implementations§
impl Freeze for OrderItem
impl RefUnwindSafe for OrderItem
impl Send for OrderItem
impl Sync for OrderItem
impl Unpin for OrderItem
impl UnsafeUnpin for OrderItem
impl UnwindSafe for OrderItem
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more