From 9cb86b850699dc5b19e2582f5a2c64c5acc0a24b Mon Sep 17 00:00:00 2001 From: PROINT <> Date: Wed, 22 Jul 2026 14:41:42 +0700 Subject: Added AccountRepository trait --- src/types/account.rs | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/types/account.rs (limited to 'src/types/account.rs') 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 +} + +impl NewAccount { + fn new(account_type: AccountType, name: impl Into, description: impl Into, parent: Option) -> NewAccount { + NewAccount { + account_type, + name: name.into(), + description: description.into(), + parent + } + } +} -- cgit v1.3