quickbooks_types/models/
estimate.rs1use chrono::NaiveDate;
2use serde::{Deserialize, Serialize};
3use serde_with::skip_serializing_none;
4
5use super::common::{Addr, CustomField, Email, LinkedTxn, MetaData, NtRef, TxnTaxDetail};
6#[cfg(feature = "builder")]
7use crate::error::QBTypeError;
8use crate::{
9 common::EmailStatus, LineField, QBCreatable, QBDeletable, QBFullUpdatable, QBItem, QBPDFable,
10 QBSendable, QBSparseUpdateable,
11};
12
13#[skip_serializing_none]
14#[derive(Clone, Debug, Deserialize, PartialEq, Serialize, Default)]
15#[serde(rename_all = "PascalCase", default)]
16#[cfg_attr(
17 feature = "builder",
18 derive(Builder),
19 builder(default, build_fn(error = "QBTypeError"), setter(into, strip_option))
20)]
21
22pub struct Estimate {
30 pub id: Option<String>,
32 pub sync_token: Option<String>,
34 #[serde(skip_serializing)]
36 pub meta_data: Option<MetaData>,
37 pub customer_ref: Option<NtRef>,
39 pub currency_ref: Option<NtRef>,
41 pub bill_email: Option<Email>,
43 pub txn_date: Option<NaiveDate>,
45 pub ship_from_addr: Option<Addr>,
47 pub ship_date: Option<NaiveDate>,
49 pub class_ref: Option<NtRef>,
51 pub custom_field: Option<Vec<CustomField>>,
53 pub print_status: Option<String>,
55 #[serde(rename = "sparse")]
57 pub sparse: Option<bool>,
58 pub sales_term_ref: Option<NtRef>,
60 pub txn_status: Option<String>,
62 pub global_tax_calculation: Option<String>,
64 pub accepted_date: Option<NaiveDate>,
66 pub expiration_date: Option<NaiveDate>,
68 pub due_date: Option<NaiveDate>,
70 pub doc_number: Option<String>,
72 pub private_note: Option<String>,
74 pub customer_memo: Option<NtRef>,
76 pub email_status: Option<EmailStatus>,
78 pub txn_tax_detail: Option<TxnTaxDetail>,
80 pub line: Option<LineField>,
82 pub linked_txn: Option<Vec<LinkedTxn>>,
84 pub accepted_by: Option<String>,
86 pub exchange_rate: Option<f64>,
88 pub ship_addr: Option<Addr>,
90 pub department_ref: Option<NtRef>,
92 pub ship_method_ref: Option<NtRef>,
94 pub bill_addr: Option<Addr>,
96 pub apply_tax_after_discount: Option<bool>,
98 pub total_amt: Option<f64>,
100 pub recur_data_ref: Option<NtRef>,
102 pub tax_exemption_ref: Option<NtRef>,
104 pub home_total_amt: Option<f64>,
106 pub free_form_address: Option<bool>,
108}
109
110impl QBCreatable for Estimate {
111 fn can_create(&self) -> bool {
112 self.line.is_some() && self.customer_ref.is_some()
113 }
114}
115
116impl QBDeletable for Estimate {}
117
118impl QBFullUpdatable for Estimate {
119 fn can_full_update(&self) -> bool {
120 if !self.has_read() || self.customer_ref.is_none() {
121 false
122 } else if let Some(EmailStatus::NeedToSend) = self.email_status.as_ref() {
123 self.bill_email.is_some()
124 } else {
125 true
126 }
127 }
128}
129
130impl QBSparseUpdateable for Estimate {
131 fn can_sparse_update(&self) -> bool {
132 self.can_full_update() && self.sparse.is_some_and(|x| x)
133 }
134}
135
136impl QBSendable for Estimate {}
137impl QBPDFable for Estimate {}