quickbooks_types/models/
bill_payment.rs1use serde::{Deserialize, Serialize};
2use serde_with::skip_serializing_none;
3
4#[cfg(feature = "builder")]
5use crate::error::QBTypeError;
6use crate::{
7 common::{MetaData, NtRef},
8 LineField, QBCreatable, QBDeletable, QBFullUpdatable, QBItem, QBVoidable,
9};
10
11#[skip_serializing_none]
12#[derive(Clone, Debug, Deserialize, PartialEq, Serialize, Default)]
13#[serde(rename_all = "PascalCase", default)]
14#[cfg_attr(
15 feature = "builder",
16 derive(Builder),
17 builder(default, build_fn(error = "QBTypeError"), setter(into, strip_option))
18)]
19
20pub struct BillPayment {
27 pub sync_token: Option<String>,
29 pub domain: Option<String>,
31 pub vendor_ref: Option<NtRef>,
33 pub txn_date: Option<String>,
35 pub total_amt: Option<f64>,
37 pub pay_type: Option<PayType>,
39 pub private_note: Option<String>,
41 pub sparse: Option<bool>,
43 pub line: Option<LineField>,
45 pub id: Option<String>,
47 pub check_payment: Option<CheckBillPayment>,
49 pub credit_card_payment: Option<CreditCardBillPayment>,
51 pub meta_data: Option<MetaData>,
53}
54
55#[skip_serializing_none]
59#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
60#[serde(rename_all = "PascalCase")]
61pub struct CheckBillPayment {
62 pub print_status: Option<String>,
63 pub bank_account_ref: Option<NtRef>,
64}
65
66#[skip_serializing_none]
70#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
71pub struct CreditCardBillPayment {
72 #[serde(rename = "CCAccountRef")]
73 pub cc_account_ref: Option<NtRef>,
74}
75
76#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
80pub enum PayType {
81 #[default]
82 CreditCard,
83 Check,
84}
85
86impl QBCreatable for BillPayment {
87 fn can_create(&self) -> bool {
88 self.vendor_ref.is_some()
89 && self.total_amt.is_some()
90 && self.line.is_some()
91 && self.pay_type.as_ref().is_some_and(|e| match e {
92 PayType::CreditCard => self.credit_card_payment.is_some(),
93 PayType::Check => self.check_payment.is_some(),
94 })
95 }
97}
98
99impl QBVoidable for BillPayment {}
100impl QBDeletable for BillPayment {}
101impl QBFullUpdatable for BillPayment {
102 fn can_full_update(&self) -> bool {
103 self.can_create() && self.has_read()
104 }
105}