FRAGMENT supports queries for generating common financial reports.
A balance sheet reports the net worth of a business at the end of a reporting period.
query GetBalanceSheet(
$ledgerIk: SafeString!
$balanceAtEndOf: LastMoment!
$accountsFilter: LedgerAccountsFilterSet!
) {
ledger(ledger: { ik: $ledgerIk }) {
ledgerAccounts(filter: $accountsFilter) {
nodes {
id
name
type
balance(at: $balanceAtEndOf)
}
}
}
}
{
"ledgerIk": "ik-used-to-create-ledger",
"accountsFilter": {
"type": {
"in": ["asset", "liability"]
}
},
"balanceAtEndOf": "1969"
}
Generate a balance sheet by querying balance
on all asset
and liability
Ledger Accounts.
Providing a LastMoment
to the at
parameter on balance
returns the balance at the end of that period. Values provided to in
operators are OR'd, so both asset
and liability
accounts are returned.
An income statement reports how a business's net worth changed over the course of a reporting period.
query GetIncomeStatement(
$ledgerIk: SafeString!
$balanceChangeDuring: Period!
$accountsFilter: LedgerAccountsFilterSet!
) {
ledger(ledger: { ik: $ledgerIk }) {
ledgerAccounts(filter: $accountsFilter) {
nodes {
path
name
type
balanceChange(period: $balanceChangeDuring)
}
}
}
}
{
"ledgerIk": "ik-used-to-create-ledger",
"accountsFilter": {
"type": {
"in": ["income", "expense"]
}
},
"balanceChangeDuring": "1969"
}
Generate an income statement by querying balanceChange
on all income
and expense
Ledger Accounts.
Providing a Period
to the period
parameter on balanceChange
retrieves the difference in the Ledger Account's balance between the start and end of that period.
An account statement reports how a Ledger Account changed over the course of a reporting period. It contains a Ledger Account's starting balance, ending balance and all Ledger Lines posted to it.
query GetAccountStatement(
$accountMatch: LedgerAccountMatchInput!
$startingBalanceAtEndOf: LastMoment!
$endingBalanceAtEndOf: LastMoment!
$linesFilter: LedgerLinesFilterSet!
) {
ledgerAccount(ledgerAccount: $accountMatch) {
path
name
type
startingBalance: balance(at: $startingBalanceAtEndOf)
endingBalance: balance(at: $endingBalanceAtEndOf)
lines(filter: $linesFilter) {
nodes {
id
key
posted
description
amount
ledgerEntryId
}
}
}
}
{
"accountMatch": {
"ledger": {
"ik": "ik-used-to-create-ledger"
},
"path": "liabilities/customer-deposits/customer:123"
},
"linesFilter": {
"posted": {
"after": "1969-07-01T00:00:00.000Z",
"before": "1969-07-30T23:59:59.999Z"
}
},
"startingBalanceAtEndOf": "1969-06",
"endingBalanceAtEndOf": "1969-07"
}
Generate an account statement by querying for balance
and lines
on a Ledger Account.
Get the starting balance by passing a DateTime
to the at
parameter on balance
. Use a GraphQL alias to make multiple balance
queries within one request.
To get all Ledger Lines that were posted during the reporting period, use the filter
parameter on lines
. The after
and before
filters are inclusive, so use timestamps for the first and last moments of the reporting period.
A journal export lists all Ledger Entries posted to a Ledger during a reporting period.
query GetJournalExport(
$ledgerIk: SafeString!
$entriesFilter: LedgerEntriesFilterSet!
$entriesCursor: String
) {
ledger(ledger: { ik: $ledgerIk }) {
ledgerEntries(filter: $entriesFilter, after: $entriesCursor) {
nodes {
id
type
posted
description
lines {
nodes {
id
description
account {
name
path
type
}
amount
}
}
}
pageInfo {
hasNextPage
endCursor
}
}
}
}
{
"ledgerIk": "ik-used-to-create-ledger",
"entriesFilter": {
"posted": {
"after": "1969-01-01T00:00:00.000Z",
"before": "1969-03-31T23:59:59.999Z"
}
},
"entriesCursor": "{{data.ledger.ledgerEntries.pageInfo.endCursor}}"
}
Generate a journal export by listing Ledger Entries. For each Ledger Entry, include its Ledger Lines and their Ledger Accounts.
This can be a long list, so query pageInfo
to get a pagination cursor. It can be passed to the after
parameter on ledgerEntries
to page through the results.