Edit

GetBalance (searchExpression, PeriodorDate [, Budget])

Result Type: Number

Definition: Returns the balance of the ledger records identified by the search-Expression at the end of the period (or the period in which balDate falls). Note that the Ledger file (not the Accounts file) is searched, so the search expression has to contain valid ledger fields (AccountCode, Department, Category, Classification, Type, or Concat). If you want to get budget information instead of actual, the optional Budget parameter should be “A” or “B” to indicate the desired budget.

Examples:  GetBalance("Type = `IN`", '31/12/2012')

returns the balance of all income accounts at the end of the period which contains 31/12/2012.

Note:  For efficiency when writing reports that iterate over Ledger records, there is a Ledger method variant of the GetBalance function that applies specifically to a single, loaded Ledger record.

ledger.GetBalance (DateOrPeriod [, Budget])

Result Type: Number

Definition: Must be used in the context of a selection of ledger records, i.e. within a ForEach L in Ledger loop in a report. Returns the balance of the ledger as at the end of the specified period (or the period identified by the date). The function will respect the “Include Unposted”, “Cash Basis” and Breakdown setting when the report is run. If the Budget parameter is specified (as “A” or “B”), the budget is returned instead of the actual.

Examples:  L.GetBalance(today())

returns the balance as at the end of the current period for whatever ledger account L is referencing (which would be set in a preceding for loop).

L.GetBalance(today(), "A")

Same as above, but returns the A budget instead of the balance.

Availability:  In custom reports