pub struct Invoice {Show 24 fields
pub document_format: DocumentFormat,
pub invoice_type: InvoiceType,
pub invoice_number: Option<String>,
pub account_name: Option<String>,
pub customer_id: Option<String>,
pub billing_period: Option<String>,
pub invoice_date: Option<NaiveDate>,
pub due_date: Option<NaiveDate>,
pub currency: Currency,
pub vendor: Party,
pub customer: Party,
pub line_items: Vec<LineItem>,
pub subtotal: Option<f64>,
pub discount_amount: Option<f64>,
pub discount_rate: Option<f64>,
pub tax_summaries: Vec<TaxSummary>,
pub total_tax: Option<f64>,
pub total_amount: f64,
pub amount_paid: Option<f64>,
pub amount_due: Option<f64>,
pub payment_info: Option<PaymentInfo>,
pub notes: Option<String>,
pub raw_text: Option<String>,
pub metadata: HashMap<String, String>,
}Expand description
发票主结构体
包含发票的所有核心信息,支持多种发票格式的解析结果存储
Fields§
§document_format: DocumentFormat§invoice_type: InvoiceType§invoice_number: Option<String>发票号码
account_name: Option<String>账户名称/项目别名(如 AWS Account No 后括号内的名称)
customer_id: Option<String>客户ID
billing_period: Option<String>账单年月(格式:YYYY-MM,如 2025-01)
invoice_date: Option<NaiveDate>发票日期
due_date: Option<NaiveDate>付款截止日期
currency: Currency货币类型
vendor: Party供应商/卖方信息
customer: Party客户/买方信息
line_items: Vec<LineItem>行项目列表(商品/服务明细)
subtotal: Option<f64>小计金额(税前)
discount_amount: Option<f64>折扣金额(负数表示折扣)
discount_rate: Option<f64>折扣比例(百分比,如 5.0 表示 5%)
tax_summaries: Vec<TaxSummary>税务汇总列表
total_tax: Option<f64>总税额
total_amount: f64总金额(含税)
amount_paid: Option<f64>已付金额
amount_due: Option<f64>应付金额(未付余额)
payment_info: Option<PaymentInfo>付款信息
notes: Option<String>备注/附注
raw_text: Option<String>原始文本(PDF提取的原文)
metadata: HashMap<String, String>元数据(扩展字段,如账单周期等)
Implementations§
Source§impl Invoice
impl Invoice
Sourcepub fn to_json_compact(&self) -> Result<String, Error>
pub fn to_json_compact(&self) -> Result<String, Error>
序列化为紧凑的 JSON 字符串
Sourcepub fn calculate_subtotal(&self) -> f64
pub fn calculate_subtotal(&self) -> f64
根据行项目计算小计金额
Sourcepub fn calculate_total_tax(&self) -> f64
pub fn calculate_total_tax(&self) -> f64
根据税务汇总计算总税额
pub fn validate_line_items(&self) -> InvoiceValidation
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Invoice
impl<'de> Deserialize<'de> for Invoice
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 Invoice
impl RefUnwindSafe for Invoice
impl Send for Invoice
impl Sync for Invoice
impl Unpin for Invoice
impl UnsafeUnpin for Invoice
impl UnwindSafe for Invoice
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