quickbooks_types/models/
vendor.rs

1use serde::{Deserialize, Serialize};
2use serde_with::skip_serializing_none;
3
4use super::common::{Addr, Email, MetaData, NtRef, PhoneNumber, WebAddr};
5#[cfg(feature = "builder")]
6use crate::error::QBTypeError;
7use crate::{QBCreatable, QBFullUpdatable, QBItem};
8
9#[skip_serializing_none]
10#[derive(Clone, Debug, Deserialize, PartialEq, Serialize, Default)]
11#[serde(rename_all = "PascalCase", default)]
12#[cfg_attr(
13    feature = "builder",
14    derive(Builder),
15    builder(default, build_fn(error = "QBTypeError"), setter(into, strip_option))
16)]
17/// Vendor
18///
19/// Represents a supplier/payee from whom goods or services are purchased and to whom bills are owed in `QuickBooks` Online.
20///
21/// API reference:
22/// <https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/vendor>
23pub struct Vendor {
24    /// The unique ID of the entity
25    pub id: Option<String>,
26    /// The unique sync token of the entity, used for concurrency control
27    pub sync_token: Option<String>,
28    /// Metadata about the entity
29    #[serde(skip_serializing)]
30    pub meta_data: Option<MetaData>,
31    /// Title of the vendor
32    pub title: Option<String>,
33    /// Given name of the vendor
34    pub given_name: Option<String>,
35    /// Middle name of the vendor
36    pub middle_name: Option<String>,
37    /// Suffix of the vendor's name
38    pub suffix: Option<String>,
39    /// Family name of the vendor
40    pub family_name: Option<String>,
41    /// Primary email address of the vendor
42    pub primary_email_addr: Option<Email>,
43    /// Display name of the vendor
44    pub display_name: Option<String>,
45    /// Other contact information for the vendor
46    pub other_contact_info: Option<ContactInfo>,
47    /// Accounts Payable account reference
48    #[serde(rename = "APAccountRef")]
49    pub ap_account_ref: Option<NtRef>,
50    /// Term reference for the vendor
51    pub term_ref: Option<NtRef>,
52    /// Source of the vendor information
53    ///
54    /// DEPRECATED: as of 9/15/2025
55    pub source: Option<String>,
56    /// GSTIN of the vendor
57    #[serde(rename = "GSTIN")]
58    pub gstin: Option<String>,
59    /// Indicates if the vendor is T4A eligible
60    #[serde(rename = "T4AEligible")]
61    pub t4a_eligible: Option<bool>,
62    /// Fax number of the vendor
63    pub fax: Option<PhoneNumber>,
64    /// Business number of the vendor
65    pub business_number: Option<String>,
66    /// Currency reference for the vendor
67    pub currency_ref: Option<NtRef>,
68    /// Indicates if the vendor has TPAR
69    #[serde(rename = "HasTPAR")]
70    pub has_tpar: Option<bool>,
71    /// Tax reporting basis for the vendor
72    pub tax_reporting_basis: Option<String>,
73    /// Mobile phone number of the vendor
74    pub mobile: Option<PhoneNumber>,
75    /// Primary phone number of the vendor
76    pub primary_phone: Option<PhoneNumber>,
77    /// Indicates if the vendor is active
78    pub active: Option<bool>,
79    /// Alternate phone number of the vendor
80    pub alternate_phone: Option<PhoneNumber>,
81    /// Indicates if the vendor is 1099 eligible
82    pub vendor_1099: Option<bool>,
83    /// Cost rate for the vendor
84    pub cost_rate: Option<f64>,
85    /// Bill rate for the vendor
86    pub bill_rate: Option<f64>,
87    /// Web address of the vendor
88    pub web_addr: Option<WebAddr>,
89    /// Indicates if the vendor is T5018 eligible
90    pub t5018_eligible: Option<bool>,
91    /// Company name of the vendor
92    pub company_name: Option<String>,
93    /// Bank details for vendor payment
94    pub vendor_payment_bank_detail: Option<VendorPaymentBankDetail>,
95    /// Tax identifier for the vendor
96    pub tax_identifier: Option<String>,
97    /// Account number for the vendor
98    pub acct_num: Option<String>,
99    /// GST registration type for the vendor
100    #[serde(rename = "GSTRegistrationType")]
101    pub gst_registration_type: Option<String>,
102    /// Name to print on checks for the vendor
103    pub print_check_on_name: Option<String>,
104    /// Billing address of the vendor
105    pub bill_addr: Option<Addr>,
106    /// Balance for the vendor
107    pub balance: Option<f64>,
108}
109
110/// Contact Information
111///
112/// Represents additional contact information for a vendor in `QuickBooks` Online.
113#[skip_serializing_none]
114#[derive(Clone, Debug, Deserialize, PartialEq, Serialize, Default)]
115#[serde(rename_all = "PascalCase", default)]
116pub struct ContactInfo {
117    #[serde(rename = "Type")]
118    contact_type: Option<String>,
119    telephone: Option<PhoneNumber>,
120}
121
122/// Vendor Payment Bank Detail
123///
124/// Represents the bank details used for vendor payments in `QuickBooks` Online.
125#[skip_serializing_none]
126#[derive(Clone, Debug, Deserialize, PartialEq, Serialize, Default)]
127#[serde(rename_all = "PascalCase", default)]
128pub struct VendorPaymentBankDetail {
129    bank_account_name: Option<String>,
130    bank_branch_identifier: Option<String>,
131    bank_account_number: Option<String>,
132    statement_text: Option<String>,
133}
134
135impl QBCreatable for Vendor {
136    fn can_create(&self) -> bool {
137        self.display_name.is_some()
138            || self.suffix.is_some()
139            || self.title.is_some()
140            || self.middle_name.is_some()
141            || self.family_name.is_some()
142            || self.given_name.is_some()
143    }
144}
145
146impl QBFullUpdatable for Vendor {
147    fn can_full_update(&self) -> bool {
148        self.has_read() && self.can_create()
149    }
150}