summaryrefslogtreecommitdiffstats
path: root/cli/src/model.rs
diff options
context:
space:
mode:
Diffstat (limited to 'cli/src/model.rs')
-rw-r--r--cli/src/model.rs15
1 files changed, 12 insertions, 3 deletions
diff --git a/cli/src/model.rs b/cli/src/model.rs
index 01b645a..c70e43d 100644
--- a/cli/src/model.rs
+++ b/cli/src/model.rs
@@ -4,7 +4,6 @@ use std::convert::AsRef;
use std::fs;
use std::hash::{Hash, Hasher};
use std::path::{Path, PathBuf};
-use std::str::FromStr;
use structopt::StructOpt;
use twox_hash::XxHash64;
@@ -21,7 +20,7 @@ pub enum TransactionKind {
//TODO Transfer,
}
-impl FromStr for TransactionKind {
+impl std::str::FromStr for TransactionKind {
type Err = String;
fn from_str(s: &str) -> Result<Self, Self::Err> {
@@ -91,6 +90,17 @@ impl Store {
}
Ok(())
}
+
+ pub fn categories(&self) -> Vec<Category> {
+ let mut categories: Vec<_> = self
+ .transactions
+ .iter()
+ .map(|t| t.category.clone())
+ .collect();
+ categories.sort();
+ categories.dedup();
+ categories
+ }
}
impl Transaction {
@@ -109,4 +119,3 @@ impl Transaction {
h.finish()
}
}
-