aboutsummaryrefslogtreecommitdiffstats
path: root/src/models/transaction_detail.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/models/transaction_detail.rs')
-rw-r--r--src/models/transaction_detail.rs51
1 files changed, 39 insertions, 12 deletions
diff --git a/src/models/transaction_detail.rs b/src/models/transaction_detail.rs
index ca6be2e..b363b3b 100644
--- a/src/models/transaction_detail.rs
+++ b/src/models/transaction_detail.rs
@@ -10,6 +10,7 @@
+
#[derive(Debug, PartialEq, Serialize, Deserialize)]
pub struct TransactionDetail {
#[serde(rename = "id")]
@@ -24,13 +25,13 @@ pub struct TransactionDetail {
pub memo: Option<String>,
/// The cleared status of the transaction
#[serde(rename = "cleared")]
- pub cleared: String,
+ pub cleared: Cleared,
/// Whether or not the transaction is approved
#[serde(rename = "approved")]
pub approved: bool,
/// The transaction flag
#[serde(rename = "flag_color", skip_serializing_if = "Option::is_none")]
- pub flag_color: Option<String>,
+ pub flag_color: Option<FlagColor>,
#[serde(rename = "account_id")]
pub account_id: String,
#[serde(rename = "payee_id", skip_serializing_if = "Option::is_none")]
@@ -64,29 +65,55 @@ pub struct TransactionDetail {
}
impl TransactionDetail {
- pub fn new(id: String, date: String, amount: i64, cleared: String, approved: bool, account_id: String, deleted: bool, account_name: String, subtransactions: Vec<crate::models::SubTransaction>) -> TransactionDetail {
+ pub fn new(id: String, date: String, amount: i64, cleared: Cleared, approved: bool, account_id: String, deleted: bool, account_name: String, subtransactions: Vec<crate::models::SubTransaction>) -> TransactionDetail {
TransactionDetail {
- id: id,
- date: date,
- amount: amount,
+ id,
+ date,
+ amount,
memo: None,
- cleared: cleared,
- approved: approved,
+ cleared,
+ approved,
flag_color: None,
- account_id: account_id,
+ account_id,
payee_id: None,
category_id: None,
transfer_account_id: None,
transfer_transaction_id: None,
matched_transaction_id: None,
import_id: None,
- deleted: deleted,
- account_name: account_name,
+ deleted,
+ account_name,
payee_name: None,
category_name: None,
- subtransactions: subtransactions,
+ subtransactions,
}
}
}
+/// The cleared status of the transaction
+#[derive(Debug, PartialEq, Serialize, Deserialize)]
+pub enum Cleared {
+ #[serde(rename = "cleared")]
+ Cleared,
+ #[serde(rename = "uncleared")]
+ Uncleared,
+ #[serde(rename = "reconciled")]
+ Reconciled,
+}
+/// The transaction flag
+#[derive(Debug, PartialEq, Serialize, Deserialize)]
+pub enum FlagColor {
+ #[serde(rename = "red")]
+ Red,
+ #[serde(rename = "orange")]
+ Orange,
+ #[serde(rename = "yellow")]
+ Yellow,
+ #[serde(rename = "green")]
+ Green,
+ #[serde(rename = "blue")]
+ Blue,
+ #[serde(rename = "purple")]
+ Purple,
+}