pub struct ChartOfAccounts {
pub coa_id: String,
pub name: String,
pub country: String,
pub industry: IndustrySector,
pub accounts: Vec<GLAccount>,
pub complexity: CoAComplexity,
pub account_format: String,
pub accounting_framework: Option<String>,
/* private fields */
}Expand description
Complete Chart of Accounts structure.
Contains all GL accounts for an entity along with metadata about the overall structure.
Fields§
§coa_id: StringUnique identifier for this CoA
name: StringName/description
country: StringCountry/region code
industry: IndustrySectorIndustry sector this CoA is designed for
accounts: Vec<GLAccount>All accounts in this CoA
complexity: CoAComplexityComplexity level
account_format: StringAccount number format (e.g., “######” for 6 digits)
accounting_framework: Option<String>v4.4.1+ accounting framework for this CoA — “us_gaap”, “ifrs”,
“french_gaap”, “german_gaap”, or “dual_reporting”. Populated by
the orchestrator from config.accounting_standards.framework
when accounting_standards.enabled = true; None otherwise.
SDK consumers previously reported this field as null across
the board — before v4.4.1 it simply didn’t exist.
Implementations§
Source§impl ChartOfAccounts
impl ChartOfAccounts
Sourcepub fn new(
coa_id: String,
name: String,
country: String,
industry: IndustrySector,
complexity: CoAComplexity,
) -> Self
pub fn new( coa_id: String, name: String, country: String, industry: IndustrySector, complexity: CoAComplexity, ) -> Self
Create a new empty Chart of Accounts.
Sourcepub fn with_accounting_framework(self, framework: impl Into<String>) -> Self
pub fn with_accounting_framework(self, framework: impl Into<String>) -> Self
v4.4.1+ builder for the accounting framework label (e.g.
"us_gaap", "ifrs"). Typically invoked by the orchestrator
from the parsed AccountingFrameworkConfig.
Sourcepub fn add_account(&mut self, account: GLAccount)
pub fn add_account(&mut self, account: GLAccount)
Add an account to the CoA.
Sourcepub fn rebuild_index(&mut self)
pub fn rebuild_index(&mut self)
Rebuild the account index (call after deserialization).
Sourcepub fn get_account(&self, account_number: &str) -> Option<&GLAccount>
pub fn get_account(&self, account_number: &str) -> Option<&GLAccount>
Get an account by number.
Sourcepub fn get_postable_accounts(&self) -> Vec<&GLAccount>
pub fn get_postable_accounts(&self) -> Vec<&GLAccount>
Get all postable accounts.
Sourcepub fn get_accounts_by_type(&self, account_type: AccountType) -> Vec<&GLAccount>
pub fn get_accounts_by_type(&self, account_type: AccountType) -> Vec<&GLAccount>
Get all accounts of a specific type.
Sourcepub fn get_accounts_by_sub_type(
&self,
sub_type: AccountSubType,
) -> Vec<&GLAccount>
pub fn get_accounts_by_sub_type( &self, sub_type: AccountSubType, ) -> Vec<&GLAccount>
Get all accounts of a specific sub-type.
Sourcepub fn get_suspense_accounts(&self) -> Vec<&GLAccount>
pub fn get_suspense_accounts(&self) -> Vec<&GLAccount>
Get suspense/clearing accounts.
Sourcepub fn pick_subaccount_for_document(
&self,
parent_account: &str,
document_id: Uuid,
) -> Option<String>
pub fn pick_subaccount_for_document( &self, parent_account: &str, document_id: Uuid, ) -> Option<String>
v5.7.0 — pick a postable sub-account for a parent canonical
account, deterministic per document_id.
When the COA was generated with
expand_industry_subaccounts: true, each canonical parent (e.g.
"4000") is non-postable and its real postings target one of
its 6-digit sub-accounts ("400010", "400020", …). This
helper deterministically selects one of those sub-accounts based
on a stable hash of document_id and the configured weights:
- If
parent_accountdoesn’t exist in the COA, returnsNone. - If no sub-accounts (children with
parent_account == parent) exist, returnsparent_accountitself (legacy behaviour — expansion was not enabled or this parent is not in the industry pack). - Otherwise hashes
document_idto a position in the cumulative weight distribution and returns that sub-account number.
Determinism: the same (parent_account, document_id) pair
always returns the same sub-account, across regenerations and
across platforms.
Sourcepub fn get_industry_weighted_accounts(
&self,
account_type: AccountType,
) -> Vec<(&GLAccount, f64)>
pub fn get_industry_weighted_accounts( &self, account_type: AccountType, ) -> Vec<(&GLAccount, f64)>
Get accounts weighted by industry relevance.
Sourcepub fn account_count(&self) -> usize
pub fn account_count(&self) -> usize
Get total account count.
Sourcepub fn postable_count(&self) -> usize
pub fn postable_count(&self) -> usize
Get count of postable accounts.
Trait Implementations§
Source§impl Clone for ChartOfAccounts
impl Clone for ChartOfAccounts
Source§fn clone(&self) -> ChartOfAccounts
fn clone(&self) -> ChartOfAccounts
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ChartOfAccounts
impl Debug for ChartOfAccounts
Source§impl Default for ChartOfAccounts
impl Default for ChartOfAccounts
Source§fn default() -> ChartOfAccounts
fn default() -> ChartOfAccounts
Source§impl<'de> Deserialize<'de> for ChartOfAccounts
impl<'de> Deserialize<'de> for ChartOfAccounts
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for ChartOfAccounts
impl RefUnwindSafe for ChartOfAccounts
impl Send for ChartOfAccounts
impl Sync for ChartOfAccounts
impl Unpin for ChartOfAccounts
impl UnsafeUnpin for ChartOfAccounts
impl UnwindSafe for ChartOfAccounts
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.