quickbooks_types/models/
payment.rs1use 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
21pub struct Payment {
28 pub id: Option<String>,
30 pub sync_token: Option<String>,
32 #[serde(skip_serializing)]
34 pub meta_data: Option<MetaData>,
35 pub total_amt: Option<f64>,
37 pub customer_ref: Option<NtRef>,
39 pub currency_ref: Option<NtRef>,
41 pub private_note: Option<String>,
43 pub payment_method_ref: Option<NtRef>,
45 pub unapplied_amt: Option<f64>,
47 pub deposit_to_account_ref: Option<NtRef>,
49 pub exchange_rate: Option<f64>,
51 pub line: Option<LineField>,
53 pub txn_source: Option<String>,
55 #[serde(rename = "ARAccountRef")]
57 pub ar_account_ref: Option<NtRef>,
58 pub txn_date: Option<NaiveDate>,
60 pub credit_card_payment: Option<CreditCardPayment>,
62 pub transaction_location_type: Option<String>,
64 pub payment_ref_num: Option<String>,
66 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 {}