Skip to main content

wave_api/models/
account.rs

1use rust_decimal::Decimal;
2use serde::Deserialize;
3
4use super::common::Currency;
5use crate::enums::{AccountNormalBalanceType, AccountSubtypeValue, AccountTypeValue};
6
7/// An account from the Chart of Accounts.
8#[derive(Debug, Clone, Deserialize)]
9#[serde(rename_all = "camelCase")]
10pub struct Account {
11    pub id: String,
12    pub name: String,
13    pub description: Option<String>,
14    pub display_id: Option<String>,
15    pub currency: Currency,
16    #[serde(rename = "type")]
17    pub account_type: AccountType,
18    pub subtype: AccountSubtype,
19    pub normal_balance_type: AccountNormalBalanceType,
20    pub is_archived: bool,
21    pub sequence: i64,
22    pub balance: Option<Decimal>,
23    pub balance_in_business_currency: Option<Decimal>,
24}
25
26/// Account type descriptor.
27#[derive(Debug, Clone, Deserialize)]
28#[serde(rename_all = "camelCase")]
29pub struct AccountType {
30    pub name: String,
31    pub value: AccountTypeValue,
32    pub normal_balance_type: AccountNormalBalanceType,
33}
34
35/// Account subtype descriptor.
36#[derive(Debug, Clone, Deserialize)]
37#[serde(rename_all = "camelCase")]
38pub struct AccountSubtype {
39    pub name: String,
40    pub value: AccountSubtypeValue,
41    #[serde(rename = "type")]
42    pub account_type: Option<AccountType>,
43}