quickbooks_types/models/
sales_receipt.rs

1use chrono::NaiveDate;
2use serde::{Deserialize, Serialize};
3use serde_with::skip_serializing_none;
4
5use super::{
6    common::{
7        Addr, CreditCardPayment, CustomField, DeliveryInfo, Email, GlobalTaxCalculation, LinkedTxn,
8        MetaData, NtRef, PrintStatus, TxnTaxDetail,
9    },
10    LineField,
11};
12#[cfg(feature = "builder")]
13use crate::error::QBTypeError;
14use crate::{QBCreatable, QBFullUpdatable, QBPDFable, QBSendable, QBSparseUpdateable, QBVoidable};
15
16#[skip_serializing_none]
17#[derive(Clone, Debug, Deserialize, PartialEq, Serialize, Default)]
18#[serde(rename_all = "PascalCase", default)]
19#[cfg_attr(
20    feature = "builder",
21    derive(Builder),
22    builder(default, build_fn(error = "QBTypeError"), setter(into, strip_option))
23)]
24
25/// `SalesReceipt`
26///
27/// Represents a finalized sale where payment is received at the time of purchase. Unlike an invoice, it does not create an accounts receivable balance.
28///
29/// API reference:
30/// <https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/salesreceipt>
31pub struct SalesReceipt {
32    /// The unique ID of the entity
33    pub id: Option<String>,
34    /// Line items for the transaction
35    pub line: Option<LineField>,
36    /// Reference to the customer for the transaction
37    pub customer_ref: Option<NtRef>,
38    /// The unique sync token of the entity, used for concurrency control
39    pub sync_token: Option<String>,
40    /// Reference to the currency for the transaction
41    pub currency_ref: Option<NtRef>,
42    /// Email address for billing
43    pub bill_email: Option<Email>,
44    /// Address from which the items are shipped
45    pub ship_from_addr: Option<Addr>,
46    /// Custom fields for the entity
47    pub custom_field: Option<Vec<CustomField>>,
48    /// Date when the items are shipped
49    pub ship_date: Option<NaiveDate>,
50    /// Tracking number for the shipment
51    pub tracking_num: Option<String>,
52    /// Reference to the class for the transaction
53    pub class_ref: Option<NtRef>,
54    /// Print status of the sales receipt
55    pub print_status: Option<PrintStatus>,
56    /// Reference number for the payment
57    pub payment_ref_num: Option<String>,
58    /// Source of the transaction
59    pub txn_source: Option<String>,
60    /// Linked transactions
61    pub linked_txn: Option<Vec<LinkedTxn>>,
62    /// Global tax calculation method
63    pub global_tax_calculation: Option<GlobalTaxCalculation>,
64    /// Indicates if tax is applied after discount
65    pub apply_tax_after_discount: Option<bool>,
66    /// Document number for the sales receipt
67    pub doc_number: Option<String>,
68    /// Private note for the transaction
69    pub private_note: Option<String>,
70    /// Reference to the account where the deposit is made
71    pub deposit_to_account_ref: Option<NtRef>,
72    /// Memo for the customer
73    pub customer_memo: Option<NtRef>,
74    /// Information about a credit card payment for the transaction
75    pub credit_card_payment: Option<CreditCardPayment>,
76    /// Tax details for the transaction
77    pub txn_tax_detail: Option<TxnTaxDetail>,
78    /// Reference to the payment method for the transaction
79    pub payment_method_ref: Option<NtRef>,
80    /// Exchange rate for the transaction
81    pub exchange_rate: Option<f64>,
82    /// Address to which the items are shipped
83    pub ship_addr: Option<Addr>,
84    /// Indicates if the transaction is a sparse object
85    #[serde(rename = "sparse")]
86    pub sparse: Option<bool>,
87    /// Reference to the department for the transaction
88    pub department_ref: Option<NtRef>,
89    /// Reference to the shipping method for the transaction
90    pub ship_method_ref: Option<NtRef>,
91    /// Address for billing
92    pub bill_addr: Option<Addr>,
93    /// Metadata about the transaction
94    #[serde(skip_serializing)]
95    pub meta_data: Option<MetaData>,
96    /// Home balance for the transaction
97    pub home_balance: Option<f64>,
98    /// Delivery information for the transaction
99    pub delivery_info: Option<DeliveryInfo>,
100    /// Reference to the recurring data for the transaction
101    pub recur_data_ref: Option<NtRef>,
102    /// Total amount of the transaction
103    pub total_amt: Option<f64>,
104    /// Balance for the transaction
105    pub balance: Option<f64>,
106    /// Indicates if the address is a free-form address
107    pub free_form_address: Option<bool>,
108    /// Date of the transaction in YYYY-MM-DD format
109    pub txn_date: Option<NaiveDate>,
110}
111
112impl QBCreatable for SalesReceipt {
113    fn can_create(&self) -> bool {
114        self.line.can_create()
115    }
116}
117
118impl QBVoidable for SalesReceipt {}
119impl QBFullUpdatable for SalesReceipt {
120    fn can_full_update(&self) -> bool {
121        self.can_create()
122    }
123}
124
125impl QBSparseUpdateable for SalesReceipt {
126    fn can_sparse_update(&self) -> bool {
127        self.can_full_update() && self.sparse.is_some_and(|x| x)
128    }
129}
130
131impl QBSendable for SalesReceipt {}
132impl QBPDFable for SalesReceipt {}