QueryFacet
Facet for querying account balances and information in the ledger
Handles balance calculations, account queries, and data retrieval
Functions
onlyInitialized
modifier onlyInitialized();
getAccountBalance
Gets the direct balance of an account (excluding children)
function getAccountBalance(string memory code) external view onlyInitialized returns (int256);
Parameters
code
string
The account code
Returns
<none>
int256
The current balance
getAccountTotalBalance
Gets the total balance of an account including all its children recursively
function getAccountTotalBalance(string memory code) external view onlyInitialized returns (int256);
Parameters
code
string
The account code
Returns
<none>
int256
The total balance including children
_getAccountTotalBalanceRecursive
Internal recursive function to calculate total balance including children
function _getAccountTotalBalanceRecursive(string memory code) internal view returns (int256);
Parameters
code
string
The account code
Returns
<none>
int256
The total balance including children
getChildAccounts
Gets all direct child accounts of a parent account
function getChildAccounts(string memory parentCode) external view onlyInitialized returns (string[] memory);
Parameters
parentCode
string
The parent account code
Returns
<none>
string[]
Array of child account codes
isDebitNormalForAccount
Determines if an account is debit-normal, considering contra accounts
function isDebitNormalForAccount(string memory code) external view onlyInitialized returns (bool);
Parameters
code
string
The account code
Returns
<none>
bool
True if debit increases the account balance, false otherwise
accounts
Get account information
function accounts(string memory code)
external
view
onlyInitialized
returns (string memory, string memory, string memory, int256, uint256, string memory, bool, bool, bool);
Parameters
code
string
The account code
Returns
<none>
string
code The account code
<none>
string
name The account name
<none>
string
description The account description
<none>
int256
balance The account balance
<none>
uint256
sectionId The section ID
<none>
string
parentCode The parent code
<none>
bool
active Whether the account is active
<none>
bool
isParent Whether the account is a parent
<none>
bool
isContraAccount Whether the account is a contra account
accountSections
Get account section information
function accountSections(uint256 sectionId)
external
view
onlyInitialized
returns (LedgerStorage.AccountSectionInfo memory section);
Parameters
sectionId
uint256
The section ID
Returns
section
LedgerStorage.AccountSectionInfo
The account section struct
nextSectionId
Get the next section ID
function nextSectionId() external view onlyInitialized returns (uint256);
Returns
<none>
uint256
The next section ID
decimals
Get the number of decimal places
function decimals() external view onlyInitialized returns (uint8);
Returns
<none>
uint8
The decimal places
currencyCode
Get the currency code
function currencyCode() external view onlyInitialized returns (string memory);
Returns
<none>
string
The ISO currency code
accountExists
Check if an account exists
function accountExists(string memory code) external view onlyInitialized returns (bool);
Parameters
code
string
The account code
Returns
<none>
bool
True if the account exists
isAccountActive
Check if an account is active
function isAccountActive(string memory code) external view onlyInitialized returns (bool);
Parameters
code
string
The account code
Returns
<none>
bool
True if the account is active
isParentAccount
Check if an account is a parent account
function isParentAccount(string memory code) external view onlyInitialized returns (bool);
Parameters
code
string
The account code
Returns
<none>
bool
True if the account is a parent account
isContraAccount
Check if an account is a contra account
function isContraAccount(string memory code) external view onlyInitialized returns (bool);
Parameters
code
string
The account code
Returns
<none>
bool
True if the account is a contra account
getAccountSectionId
Get the section ID for an account
function getAccountSectionId(string memory code) external view onlyInitialized returns (uint256);
Parameters
code
string
The account code
Returns
<none>
uint256
The section ID
getAccountParentCode
Get the parent code for an account
function getAccountParentCode(string memory code) external view onlyInitialized returns (string memory);
Parameters
code
string
The account code
Returns
<none>
string
The parent account code (empty string if top-level)
sectionExists
Check if a section exists
function sectionExists(uint256 sectionId) external view onlyInitialized returns (bool);
Parameters
sectionId
uint256
The section ID
Returns
<none>
bool
True if the section exists
isSectionActive
Check if a section is active
function isSectionActive(uint256 sectionId) external view onlyInitialized returns (bool);
Parameters
sectionId
uint256
The section ID
Returns
<none>
bool
True if the section is active
getSectionCodeRange
Get the code range for a section
function getSectionCodeRange(uint256 sectionId)
external
view
onlyInitialized
returns (uint256 codeStart, uint256 codeEnd);
Parameters
sectionId
uint256
The section ID
Returns
codeStart
uint256
The start of the code range
codeEnd
uint256
The end of the code range
getSectionName
Get the section name
function getSectionName(uint256 sectionId) external view onlyInitialized returns (string memory);
Parameters
sectionId
uint256
The section ID
Returns
<none>
string
The section name
Last updated
Was this helpful?