quickbooks_types/models/
payment.rs

1use chrono::NaiveDate;
2use serde::{Deserialize, Serialize};
3use serde_with::skip_serializing_none;
4
5use super::common::{CreditCardPayment, MetaData, NtRef};
6#[cfg(feature = "builder")]
7use crate::error::QBTypeError;
8use crate::{
9    LineField, QBCreatable, QBDeletable, QBFullUpdatable, QBItem, QBPDFable, QBSendable, QBVoidable,
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/// Payment
22///
23/// Represents receipt or application of funds against customer balances or invoices.
24///
25/// API reference:
26/// <https://developer.intuit.com/app/developer/qbo/docs/api/accounting/all-entities/payment>
27pub struct Payment {
28    /// The unique ID of the entity
29    pub id: Option<String>,
30    /// The unique sync token of the entity, used for concurrency control
31    pub sync_token: Option<String>,
32    /// Metadata about the entity
33    #[serde(skip_serializing)]
34    pub meta_data: Option<MetaData>,
35    /// Total amount of the payment
36    pub total_amt: Option<f64>,
37    /// Reference to the customer for the payment
38    pub customer_ref: Option<NtRef>,
39    /// Reference to the currency for the payment
40    pub currency_ref: Option<NtRef>,
41    /// Private note for the payment
42    pub private_note: Option<String>,
43    /// Reference to the payment method
44    pub payment_method_ref: Option<NtRef>,
45    /// Unapplied amount of the payment
46    pub unapplied_amt: Option<f64>,
47    /// Reference to the account where the payment is deposited
48    pub deposit_to_account_ref: Option<NtRef>,
49    /// Exchange rate for the payment
50    pub exchange_rate: Option<f64>,
51    /// Line items for the payment
52    pub line: Option<LineField>,
53    /// Source of the transaction
54    pub txn_source: Option<String>,
55    /// Reference to the accounts receivable account
56    #[serde(rename = "ARAccountRef")]
57    pub ar_account_ref: Option<NtRef>,
58    /// Date of the transaction in YYYY-MM-DD format
59    pub txn_date: Option<NaiveDate>,
60    /// Information about a credit card payment for the transaction
61    pub credit_card_payment: Option<CreditCardPayment>,
62    /// Type of location for the transaction
63    pub transaction_location_type: Option<String>,
64    /// Reference number for the payment
65    pub payment_ref_num: Option<String>,
66    /// Reference to the tax exemption for the payment
67    pub tax_exemption_ref: Option<NtRef>,
68}
69
70impl QBCreatable for Payment {
71    fn can_create(&self) -> bool {
72        self.total_amt.is_some() && self.customer_ref.is_some()
73    }
74}
75
76impl QBDeletable for Payment {}
77impl QBVoidable for Payment {}
78impl QBFullUpdatable for Payment {
79    fn can_full_update(&self) -> bool {
80        self.has_read() && self.can_create()
81    }
82}
83
84impl QBSendable for Payment {}
85impl QBPDFable for Payment {}