pub struct AccountUseCases { /* private fields */ }Expand description
Use cases for managing accounts in the Belgian PCMN
This orchestrates account operations, including:
- CRUD operations for accounts
- Seeding Belgian PCMN chart of accounts (inspired by Noalyss mono-belge.sql)
- Hierarchical account management
- Account validation and business rules
Implementations§
Source§impl AccountUseCases
impl AccountUseCases
pub fn new(repository: Arc<dyn AccountRepository>) -> Self
Sourcepub async fn create_account(
&self,
code: String,
label: String,
parent_code: Option<String>,
account_type: AccountType,
direct_use: bool,
organization_id: Uuid,
) -> Result<Account, String>
pub async fn create_account( &self, code: String, label: String, parent_code: Option<String>, account_type: AccountType, direct_use: bool, organization_id: Uuid, ) -> Result<Account, String>
Create a new account
§Arguments
code- Account code (e.g., “700”, “604001”)label- Account descriptionparent_code- Optional parent account codeaccount_type- Account classificationdirect_use- Whether account can be used in transactionsorganization_id- Organization ID
§Returns
Created account or error message
Sourcepub async fn get_account_by_code(
&self,
code: &str,
organization_id: Uuid,
) -> Result<Option<Account>, String>
pub async fn get_account_by_code( &self, code: &str, organization_id: Uuid, ) -> Result<Option<Account>, String>
Get account by code within an organization
Sourcepub async fn list_accounts(
&self,
organization_id: Uuid,
) -> Result<Vec<Account>, String>
pub async fn list_accounts( &self, organization_id: Uuid, ) -> Result<Vec<Account>, String>
List all accounts for an organization
Sourcepub async fn list_accounts_by_type(
&self,
account_type: AccountType,
organization_id: Uuid,
) -> Result<Vec<Account>, String>
pub async fn list_accounts_by_type( &self, account_type: AccountType, organization_id: Uuid, ) -> Result<Vec<Account>, String>
List accounts by type (for financial reports)
Sourcepub async fn list_child_accounts(
&self,
parent_code: &str,
organization_id: Uuid,
) -> Result<Vec<Account>, String>
pub async fn list_child_accounts( &self, parent_code: &str, organization_id: Uuid, ) -> Result<Vec<Account>, String>
List child accounts of a parent
Sourcepub async fn list_direct_use_accounts(
&self,
organization_id: Uuid,
) -> Result<Vec<Account>, String>
pub async fn list_direct_use_accounts( &self, organization_id: Uuid, ) -> Result<Vec<Account>, String>
List accounts that can be used directly in transactions
Sourcepub async fn search_accounts(
&self,
code_pattern: &str,
organization_id: Uuid,
) -> Result<Vec<Account>, String>
pub async fn search_accounts( &self, code_pattern: &str, organization_id: Uuid, ) -> Result<Vec<Account>, String>
Search accounts by code pattern (e.g., “60%” for all class 6 accounts)
Sourcepub async fn update_account(
&self,
id: Uuid,
label: Option<String>,
parent_code: Option<Option<String>>,
account_type: Option<AccountType>,
direct_use: Option<bool>,
) -> Result<Account, String>
pub async fn update_account( &self, id: Uuid, label: Option<String>, parent_code: Option<Option<String>>, account_type: Option<AccountType>, direct_use: Option<bool>, ) -> Result<Account, String>
Update an existing account
Sourcepub async fn delete_account(&self, id: Uuid) -> Result<(), String>
pub async fn delete_account(&self, id: Uuid) -> Result<(), String>
Delete an account
Validates:
- Account has no children
- Account is not used in expenses
Sourcepub async fn count_accounts(&self, organization_id: Uuid) -> Result<i64, String>
pub async fn count_accounts(&self, organization_id: Uuid) -> Result<i64, String>
Count accounts in an organization
Sourcepub async fn seed_belgian_pcmn(
&self,
organization_id: Uuid,
) -> Result<i64, String>
pub async fn seed_belgian_pcmn( &self, organization_id: Uuid, ) -> Result<i64, String>
Seed Belgian PCMN (Plan Comptable Minimum Normalisé) for a new organization
Creates a standard chart of accounts for Belgian property management. This seed data is inspired by Noalyss’ mono-belge.sql, curated for property management (syndic de copropriété).
§Arguments
organization_id- Organization to seed accounts for
§Returns
Number of accounts created or error message
§Belgian PCMN Structure
- Class 1: Liabilities (Capital, Reserves)
- Classes 2-5: Assets (Fixed assets, Receivables, Bank)
- Class 6: Expenses (Electricity, Maintenance, Insurance, etc.)
- Class 7: Revenue (Regular fees, Extraordinary fees, Interest)
Reference: Noalyss contrib/mono-dossier/mono-belge.sql
Auto Trait Implementations§
impl Freeze for AccountUseCases
impl !RefUnwindSafe for AccountUseCases
impl Send for AccountUseCases
impl Sync for AccountUseCases
impl Unpin for AccountUseCases
impl !UnwindSafe for AccountUseCases
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Chain<T> for T
impl<T> Chain<T> for T
§impl<T> Fake for T
impl<T> Fake for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more