quickbooks_types/models/
bill.rs

1use chrono::NaiveDate;
2use serde::{Deserialize, Serialize};
3use serde_with::skip_serializing_none;
4
5use super::common::{LinkedTxn, MetaData, NtRef};
6#[cfg(feature = "builder")]
7use crate::error::QBTypeError;
8use crate::{LineField, QBCreatable, QBDeletable, QBFullUpdatable, QBItem};
9
10#[skip_serializing_none]
11#[derive(Clone, Debug, Deserialize, PartialEq, Serialize, Default)]
12#[serde(rename_all = "PascalCase", default)]
13#[cfg_attr(
14    feature = "builder",
15    derive(Builder),
16    builder(default, build_fn(error = "QBTypeError"), setter(into, strip_option))
17)]
18
19/// Bill
20///
21/// Represents an accounts payable bill received from a vendor.
22/// Records amounts owed to vendors; line items specify products/services and their costs.
23///
24/// API reference:
25/// <https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/bill>
26pub struct Bill {
27    /// The unique ID of the entity
28    pub id: Option<String>,
29    /// The unique sync token of the entity, used for concurrency control
30    pub sync_token: Option<String>,
31    /// Metadata about the entity
32    #[serde(skip_serializing)]
33    pub meta_data: Option<MetaData>,
34    /// Domain of the transaction. `QBO` for `QuickBooks` Online.
35    pub domain: Option<String>,
36    /// Reference to the Accounts Payable account for the transaction
37    #[serde(rename = "APAccountRef")]
38    pub ap_account_ref: Option<NtRef>,
39    /// Reference to the vendor for the transaction
40    pub vendor_ref: Option<NtRef>,
41    /// Date of the transaction in YYYY-MM-DD format
42    pub txn_date: Option<NaiveDate>,
43    /// Total amount of the transaction
44    pub total_amt: Option<f64>,
45    /// Reference to the currency for the transaction
46    pub currency_ref: Option<NtRef>,
47    /// List of transactions linked to this bill
48    pub linked_txn: Option<Vec<LinkedTxn>>,
49    /// Reference to the sales terms for the transaction
50    pub sales_term_ref: Option<NtRef>,
51    /// Due date of the bill in YYYY-MM-DD format
52    pub due_date: Option<NaiveDate>,
53    /// Indicates if the transaction is a sparse object
54    pub sparse: Option<bool>,
55    /// Line items for the transaction
56    pub line: Option<LineField>,
57    /// Remaining balance on the bill
58    pub balance: Option<f64>,
59    /// Document number for the bill
60    pub doc_number: Option<String>,
61    /// Private note for the transaction
62    pub private_note: Option<String>,
63    /// Exchange rate for the transaction
64    pub exchange_rate: Option<f64>,
65    /// Reference to the department for the transaction
66    pub department_ref: Option<NtRef>,
67    /// Home currency balance for the transaction
68    pub home_balance: Option<f64>,
69    /// Reference to recurring schedule information
70    pub recur_data_ref: Option<NtRef>,
71}
72
73impl QBCreatable for Bill {
74    fn can_create(&self) -> bool {
75        self.vendor_ref.is_some() && self.line.is_some()
76    }
77}
78
79impl QBDeletable for Bill {}
80impl QBFullUpdatable for Bill {
81    fn can_full_update(&self) -> bool {
82        self.has_read() && self.vendor_ref.is_some() && self.line.is_some()
83    }
84}