summaryrefslogtreecommitdiff
path: root/src/types/account.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/types/account.rs')
-rw-r--r--src/types/account.rs46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/types/account.rs b/src/types/account.rs
new file mode 100644
index 0000000..66796a6
--- /dev/null
+++ b/src/types/account.rs
@@ -0,0 +1,46 @@
+use super::ids::AccountId;
+use super::path::MaterializedPath;
+
+#[derive(PartialEq, Clone)]
+pub enum AccountType {
+ Asset,
+ Liability,
+ Equity,
+ Revenue,
+ Expense
+}
+
+#[derive(Clone)]
+pub struct Account {
+ account_id: AccountId,
+ pub account_type: AccountType,
+ pub name: String,
+ pub description: String,
+ pub path: MaterializedPath
+}
+
+impl Account {
+ pub(crate) fn from_parts(account_id: AccountId, account_type: AccountType, name: String, description: String, path: MaterializedPath) -> Self {
+ Account { account_id, account_type, name, description, path }
+ }
+
+ pub fn id(&self) -> AccountId { self.account_id }
+}
+
+pub struct NewAccount {
+ pub account_type: AccountType,
+ pub name: String,
+ pub description: String,
+ pub parent: Option<AccountId>
+}
+
+impl NewAccount {
+ fn new(account_type: AccountType, name: impl Into<String>, description: impl Into<String>, parent: Option<AccountId>) -> NewAccount {
+ NewAccount {
+ account_type,
+ name: name.into(),
+ description: description.into(),
+ parent
+ }
+ }
+}