quickbooks_types/models/
preferences.rs

1use chrono::NaiveDate;
2use serde::{Deserialize, Serialize};
3use serde_with::skip_serializing_none;
4
5#[cfg(feature = "builder")]
6use crate::error::QBTypeError;
7use crate::{
8    common::{Email, MetaData, NtRef},
9    QBFullUpdatable, QBItem,
10};
11
12#[skip_serializing_none]
13#[derive(Clone, Debug, Deserialize, PartialEq, Serialize, Default)]
14#[serde(rename_all = "PascalCase", default)]
15#[cfg_attr(
16    feature = "builder",
17    derive(Builder),
18    builder(default, build_fn(error = "QBTypeError"), setter(into, strip_option))
19)]
20
21/// Preferences
22///
23/// Represents company-wide configuration that controls behavior of sales forms,
24/// purchasing, accounting, taxes, time tracking, currency handling, and various
25/// messaging options in `QuickBooks` Online.
26///
27/// API reference:
28/// <https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/preferences>
29pub struct Preferences {
30    /// The unique ID of the entity
31    pub id: Option<String>,
32    /// The unique sync token of the entity, used for concurrency control
33    pub sync_token: Option<String>,
34    /// Metadata about the entity
35    #[serde(skip_serializing)]
36    pub meta_data: Option<MetaData>,
37    /// Preferences for email messages
38    pub email_message_prefs: Option<EmailMessagePrefs>,
39    /// Preferences for products and services
40    pub product_and_services_prefs: Option<ProductAndServicesPrefs>,
41    /// Preferences for reports
42    pub report_prefs: Option<ReportPrefs>,
43    /// Preferences for accounting information
44    pub accounting_info_prefs: Option<AccountingInfoPrefs>,
45    /// Preferences for sales forms
46    pub sales_forms_prefs: Option<SalesFormsPrefs>,
47    /// Preferences for vendors and purchases
48    pub vendor_and_purchases_prefs: Option<VendorAndPurchasesPrefs>,
49    /// Preferences for taxes
50    pub tax_prefs: Option<TaxPrefs>,
51    /// Other miscellaneous preferences
52    pub other_prefs: Option<OtherPrefs>,
53    /// Preferences for time tracking
54    pub time_tracking_prefs: Option<TimeTrackingPrefs>,
55    /// Preferences for currency
56    pub currency_prefs: Option<CurrencyPrefs>,
57}
58
59/// Email Message Preferences
60#[skip_serializing_none]
61#[derive(Clone, Debug, Deserialize, PartialEq, Serialize, Default)]
62#[serde(rename_all = "PascalCase", default)]
63pub struct EmailMessagePrefs {
64    pub invoice_message: Option<EmailMessageType>,
65    pub estimate_message: Option<EmailMessageType>,
66    pub sales_receipt_message: Option<EmailMessageType>,
67    pub statement_message: Option<EmailMessageType>,
68}
69
70/// Email Message Type
71#[skip_serializing_none]
72#[derive(Clone, Debug, Deserialize, PartialEq, Serialize, Default)]
73#[serde(rename_all = "PascalCase", default)]
74pub struct EmailMessageType {
75    pub message: Option<String>,
76    pub subject: Option<String>,
77}
78
79/// Product and Services Preferences
80#[skip_serializing_none]
81#[derive(Clone, Debug, Deserialize, PartialEq, Serialize, Default)]
82#[serde(rename_all = "PascalCase", default)]
83pub struct ProductAndServicesPrefs {
84    pub revenue_recognition_enabled: Option<bool>,
85    pub recognition_frequency_type: Option<String>,
86    pub for_sales: Option<bool>,
87    pub quantity_on_hand: Option<bool>,
88    pub quantity_with_price_and_rate: Option<bool>,
89    pub for_purchase: Option<bool>,
90}
91
92/// Report Preferences
93#[skip_serializing_none]
94#[derive(Clone, Debug, Deserialize, PartialEq, Serialize, Default)]
95#[serde(rename_all = "PascalCase", default)]
96pub struct ReportPrefs {
97    pub report_basis: Option<String>,
98    pub calc_aging_report_from_txn_date: Option<bool>,
99}
100
101/// Accounting Info Preferences
102#[skip_serializing_none]
103#[derive(Clone, Debug, Deserialize, PartialEq, Serialize, Default)]
104#[serde(rename_all = "PascalCase", default)]
105pub struct AccountingInfoPrefs {
106    pub first_month_of_fiscal_year: Option<String>,
107    pub use_account_numbers: Option<bool>,
108    pub tax_year_month: Option<String>,
109    pub class_tracking_per_txn: Option<bool>,
110    pub track_departments: Option<bool>,
111    pub tax_form: Option<String>,
112    pub customer_terminology: Option<String>,
113    pub book_close_date: Option<NaiveDate>,
114    pub department_terminology: Option<String>,
115    pub class_tracking_per_txn_line: Option<bool>,
116}
117
118#[skip_serializing_none]
119#[derive(Clone, Debug, Deserialize, PartialEq, Serialize, Default)]
120#[serde(rename_all = "PascalCase", default)]
121/// Sales Forms Preferences
122///
123/// Represents the preferences for sales forms in `QuickBooks`.
124pub struct SalesFormsPrefs {
125    /// BCC email address for sales forms.
126    pub sales_emaill_bcc: Option<Email>,
127    /// CC email address for sales forms.
128    pub sales_email_cc: Option<Email>,
129    /// Indicates if progress invoicing is being used.
130    pub using_progress_invoicing: Option<bool>,
131    /// Custom field for sales forms.
132    pub custom_field: Option<String>, // TODO
133    /// Indicates if service date is allowed on sales forms.
134    pub allow_service_date: Option<bool>,
135    /// Default message for estimates.
136    pub estimate_message: Option<String>,
137    /// Indicates if a copy of the email should be sent to the company.
138    pub email_copy_to_company: Option<bool>,
139    /// Default customer message for sales forms.
140    pub default_customer_message: Option<String>,
141    /// Indicates if shipping is allowed on sales forms.
142    pub allow_shipping: Option<bool>,
143    /// Indicates if the default discount account is enabled.
144    pub default_discount_account: Option<bool>,
145    /// Indicates if IPN support is enabled.
146    #[serde(rename = "IPNSupportEnabled")]
147    pub ipn_support_enabled: Option<bool>,
148    /// Indicates if e-transaction payment is enabled.
149    pub e_transaction_payment_enabled: Option<bool>,
150    /// Default terms for sales forms.
151    pub default_terms: Option<NtRef>,
152    /// Indicates if deposits are allowed on sales forms.
153    pub allow_deposit: Option<bool>,
154    /// Indicates if price levels are being used.
155    pub using_price_levels: Option<bool>,
156    /// Indicates if the default shipping account is enabled.
157    pub default_shipping_account: Option<bool>,
158    /// Indicates if e-transaction PDF attachment is enabled.
159    #[serde(rename = "ETransactionAttachPDF")]
160    pub e_transaction_attach_pdf: Option<bool>,
161    /// Indicates if custom transaction numbers are allowed.
162    pub custom_txn_numbers: Option<bool>,
163    /// Status of e-transaction enabled.
164    pub e_transaction_enabled_status: Option<String>,
165    /// Indicates if estimates are allowed.
166    pub allow_estimates: Option<bool>,
167    /// Indicates if discounts are allowed.
168    pub allow_discount: Option<bool>,
169    /// Indicates if auto-apply credit is enabled.
170    pub auto_apply_credit: Option<bool>,
171}
172
173#[skip_serializing_none]
174#[derive(Clone, Debug, Deserialize, PartialEq, Serialize, Default)]
175#[serde(rename_all = "PascalCase", default)]
176/// Vendor and Purchases Preferences
177///
178/// Represents the preferences related to vendors and purchases.
179pub struct VendorAndPurchasesPrefs {
180    /// Custom field for purchase orders
181    #[serde(rename = "POCustomField")]
182    pub po_custom_field: Option<String>, // TODO
183    /// Reference to the default markup account
184    pub default_markup_account: Option<NtRef>,
185    /// Indicates if tracking by customer is enabled
186    pub tracking_by_customer: Option<bool>,
187    /// Reference to the default terms
188    pub default_terms: Option<NtRef>,
189    /// Indicates if billable expense tracking is enabled
190    pub billable_expense_tracking: Option<bool>,
191    /// Default markup value
192    pub default_markup: Option<f64>,
193    /// Indicates if TPAR (Taxable Payments Annual Report) is enabled
194    #[serde(rename = "TPAREnabled")]
195    pub tpar_enabled: Option<bool>,
196}
197
198/// Tax Preferences
199#[skip_serializing_none]
200#[derive(Clone, Debug, Deserialize, PartialEq, Serialize, Default)]
201#[serde(rename_all = "PascalCase", default)]
202pub struct TaxPrefs {
203    pub partner_tax_enabled: Option<bool>,
204    pub tax_group_code_ref: Option<String>,
205    pub using_sales_tax: Option<bool>,
206}
207
208/// Miscellaneous Other Preferences
209#[skip_serializing_none]
210#[derive(Clone, Debug, Deserialize, PartialEq, Serialize, Default)]
211#[serde(rename_all = "PascalCase", default)]
212pub struct OtherPrefs {
213    pub name_value: Option<Vec<NtRef>>,
214}
215
216#[skip_serializing_none]
217#[derive(Clone, Debug, Deserialize, PartialEq, Serialize, Default)]
218#[serde(rename_all = "PascalCase", default)]
219/// Time Tracking Preferences
220///
221/// Represents the preferences for time tracking in `QuickBooks`.
222pub struct TimeTrackingPrefs {
223    /// The start date of the work week.
224    pub work_week_start_date: Option<String>,
225    /// Indicates if time entries should be marked as billable.
226    pub mark_time_entries_billable: Option<bool>,
227    /// Indicates if the bill rate should be shown to all users.
228    pub show_bill_rate_to_all: Option<bool>,
229    /// Indicates if sales tax is being used.
230    pub using_sales_tax: Option<bool>,
231    /// Indicates if customers should be billed.
232    pub bill_customers: Option<bool>,
233}
234
235/// Currency Preferences
236///
237/// Represents the preferences related to currency handling in `QuickBooks`.
238#[skip_serializing_none]
239#[derive(Clone, Debug, Deserialize, PartialEq, Serialize, Default)]
240#[serde(rename_all = "PascalCase", default)]
241pub struct CurrencyPrefs {
242    pub home_currency: Option<NtRef>,
243    pub multi_currency_enabled: Option<bool>,
244}
245
246impl QBFullUpdatable for Preferences {
247    fn can_full_update(&self) -> bool {
248        self.has_read()
249    }
250}