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 {
35 pub id: Option<String>,
37 pub sync_token: Option<String>,
39 #[serde(skip_serializing)]
41 pub meta_data: Option<MetaData>,
42 pub total_amt: Option<f64>,
44 pub customer_ref: Option<NtRef>,
46 pub currency_ref: Option<NtRef>,
48 pub private_note: Option<String>,
50 pub payment_method_ref: Option<NtRef>,
52 pub unapplied_amt: Option<f64>,
54 pub deposit_to_account_ref: Option<NtRef>,
56 pub exchange_rate: Option<f64>,
58 pub line: Option<LineField>,
60 pub txn_source: Option<String>,
62 #[serde(rename = "ARAccountRef")]
64 pub ar_account_ref: Option<NtRef>,
65 pub txn_date: Option<NaiveDate>,
67 pub credit_card_payment: Option<CreditCardPayment>,
69 pub transaction_location_type: Option<String>,
71 pub payment_ref_num: Option<String>,
73 pub tax_exemption_ref: Option<NtRef>,
75}
76
77impl QBCreatable for Payment {
78 fn can_create(&self) -> bool {
79 self.total_amt.is_some() && self.customer_ref.is_some()
80 }
81}
82
83impl QBDeletable for Payment {}
84impl QBVoidable for Payment {}
85impl QBFullUpdatable for Payment {
86 fn can_full_update(&self) -> bool {
87 self.has_read() && self.can_create()
88 }
89}
90
91impl QBSendable for Payment {}
92impl QBPDFable for Payment {}