pub struct LineItem {
pub line_number: Option<u32>,
pub service_name: Option<String>,
pub description: String,
pub quantity: Option<f64>,
pub unit: Option<String>,
pub unit_price: Option<f64>,
pub discount: Option<f64>,
pub tax_rate: Option<f64>,
pub tax_amount: Option<f64>,
pub amount: f64,
}Expand description
发票行项目结构体(单个商品/服务明细)
Fields§
§line_number: Option<u32>行号
service_name: Option<String>服务/项目名称(如:Amazon CloudFront)
description: String使用类型/描述(如:US-Requests-Tier2-HTTPS)
quantity: Option<f64>数量
unit: Option<String>单位(如:个、件、小时等)
unit_price: Option<f64>单价
discount: Option<f64>折扣金额
tax_rate: Option<f64>税率(百分比)
tax_amount: Option<f64>税额
amount: f64金额(数量 × 单价 - 折扣 + 税额)
Implementations§
Source§impl LineItem
impl LineItem
Sourcepub fn calculate_amount(&self) -> f64
pub fn calculate_amount(&self) -> f64
计算行项目金额:数量 × 单价 - 折扣 + 税额
Sourcepub fn validate_amount(&self) -> LineItemValidation
pub fn validate_amount(&self) -> LineItemValidation
验证单价×数量是否等于金额 返回 (是否有效, 计算值, 差异值)
Trait Implementations§
Source§impl<'de> Deserialize<'de> for LineItem
impl<'de> Deserialize<'de> for LineItem
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for LineItem
impl RefUnwindSafe for LineItem
impl Send for LineItem
impl Sync for LineItem
impl Unpin for LineItem
impl UnsafeUnpin for LineItem
impl UnwindSafe for LineItem
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more