Book
A Book represents a General Ledger for a company or business, but can also represent a Ledger for a project or department
It contains all Accounts where Transactions are recorded/posted;
batchCheckTransactions(
transactions:
Transaction
[]):
Promise<
void
>
Batch check Transactions on the Book.
transactions
The transactions to be checked
Create Accounts on the Book, in batch.
Returns The created Accounts
accounts
The accounts to be created
batchCreateGroups(
groups:
Group
[]):
Promise<
Group
[]>
Create Groups on the Book, in batch.
Returns The created Groups
Batch create Transactions on the Book.
Returns The created Transactions
transactions
The transactions to be created
batchPostTransactions(
transactions:
Transaction
[]):
Promise<
void
>
Batch post Transactions on the Book.
transactions
The transactions to be posted
batchReplayEvents(
events:
Event
[],
errorOnly?:
boolean
):
Promise<
void
>
Replay Events on the Book, in batch.
events
The events to be replayed
errorOnly
True to only replay events with errors
batchTrashTransactions(
transactions:
Transaction
[],
trashChecked?:
boolean
):
Promise<
void
>
Batch trash Transactions on the Book.
transactions
The transactions to be trashed
trashChecked
True to also trash checked transactions
batchUncheckTransactions(
transactions:
Transaction
[]):
Promise<
void
>
Batch uncheck Transactions on the Book.
transactions
The transactions to be unchecked
batchUntrashTransactions(
transactions:
Transaction
[]):
Promise<
void
>
Batch untrash Transactions on the Book.
transactions
The transactions to be untrashed
Batch update Transactions on the Book.
Returns The updated draft Transactions
transactions
The transactions to be updated
updateChecked
True to also update checked transactions
copy(
name:
string
,
copyTransactions?:
boolean
,
fromDate?:
number
):
Promise<
Book
>
Creates a copy of this Book
Returns The copied Book object
name
The name for the copied book
copyTransactions
True to copy transactions from the source book (user must be the Book owner)
fromDate
Start date to consider if copying transactions (numeric value in YYYYMMDD format)
Performs create new Book.
Returns The created Book object
Formats a date according to date pattern of the Book.
Returns The formatted date
date
The date to format as string.
timeZone
The output timezone of the result. Default to script’s timeZone
Formats a value according to DecimalSeparator and fraction digits of the Book.
Returns The formatted value
value
The value to be formatted.
getAccount(
idOrName?:
string
):
Promise<
Account
|
undefined
>
Gets an Account object by id or name.
Results are cached to avoid repeated server calls. Account-group relationships
are included if the full chart was loaded via getAccounts() or when the Book
was loaded with includeAccounts=true.
Returns The matching Account object
example **
// Get individual account (basic data, cached)
const account = await book.getAccount('Bank Account');
// For account-group relationships, use one of these approaches:
// Option 1: Load book with full data upfront
const bookWithAccounts = await Bkper.getBook(bookId, true);
const accountWithGroups = await bookWithAccounts.getAccount('Bank Account');
// Option 2: Load full chart when needed
await book.getAccounts();
const accountWithGroups2 = await book.getAccount('Bank Account');
idOrName
The id or name of the Account
Gets all Accounts of this Book with full account-group relationships.
Results are cached for performance. Groups are automatically loaded first
to ensure proper linking. Consider using Bkper.getBook(id, true) for
upfront loading when you know you’ll need all accounts.
Returns The retrieved Account objects
example **
// Load all accounts with complete relationships
const accounts = await book.getAccounts();
// Alternative: Load book with accounts upfront (more efficient)
const bookWithAccounts = await Bkper.getBook(bookId, true);
const accounts2 = await bookWithAccounts.getAccounts(); // Already cached
getApps():
Promise<
App
[]>
Retrieve installed Apps for this Book.
Returns The retrieved Apps objects
getAutoPost():
boolean
|
undefined
Gets the auto post status of the Book.
Returns The auto post status of the Book
getBacklog():
Promise<
Backlog
>
Gets the Backlog of this Book.
Returns The Backlog object
Create a BalancesReport based on query.
Returns The balances report
Example:
var book = BkperApp.getBook("agtzfmJrcGVyLWhyZHITCxIGTGVkZ2VyGICAgPXjx7oKDA");
var balancesReport = book.getBalancesReport("group:'Equity' after:7/2018 before:8/2018");
var accountBalance = balancesReport.getBalancesContainer("Bank Account").getCumulativeBalance();
query
The balances report query
getClosingDate():
string
|
undefined
Gets the closing date of the Book in ISO format yyyy-MM-dd.
Returns The closing date of the Book in ISO format yyyy-MM-dd
Gets all collaborators of this Book.
Returns Array of Collaborator objects
Gets the collection of this Book, if any.
Returns The collection of this Book, if any
Gets the date pattern of the Book.
Returns The date pattern of the Book. Current: dd/MM/yyyy |
MM/dd/yyyy |
yyyy/MM/dd |
getDecimalPlaces():
number
|
undefined
Gets the number of decimal places supported by this Book.
Returns The number of decimal places supported by this Book. Same as getFractionDigits
Gets the decimal separator of the Book.
Returns The decimal separator of the Book
getFile(
id:
string
):
Promise<
File
|
undefined
>
Retrieve a file by id.
Returns The File object
getFractionDigits():
number
|
undefined
Gets the number of fraction digits supported by this Book.
Returns The number of fraction digits supported by this Book. Same as getDecimalPlaces
getGroup(
idOrName?:
string
):
Promise<
Group
|
undefined
>
Gets a Group object by id or name.
Results are cached to avoid repeated server calls. Parent/child relationships
are included if all groups were loaded via getGroups() or when the Book was
loaded with includeGroups=true.
Returns The matching Group object
example **
// Get individual group (basic data, cached)
const group = await book.getGroup('Assets');
// For parent/child relationships, use one of these approaches:
// Option 1: Load book with full hierarchy upfront
const bookWithGroups = await Bkper.getBook(bookId, false, true);
const groupWithTree = await bookWithGroups.getGroup('Assets');
// Option 2: Load full hierarchy when needed
await book.getGroups();
const groupWithTree2 = await book.getGroup('Assets');
console.log(groupWithTree2.getParent(), groupWithTree2.getChildren());
idOrName
The id or name of the Group
getGroups():
Promise<
Group
[]>
Gets all Groups of this Book with complete parent/child hierarchy.
Results are cached for performance. Group tree relationships are built
during loading. Consider using Bkper.getBook(id, false, true) for
upfront loading when you know you’ll need all groups.
Returns The retrieved Group objects
example **
// Load all groups with complete hierarchy
const groups = await book.getGroups();
// Alternative: Load book with groups upfront (more efficient)
const bookWithGroups = await Bkper.getBook(bookId, false, true);
const groups2 = await bookWithGroups.getGroups(); // Already cached
Gets the unique identifier of this Book.
Returns This Book’s unique identifier
Gets the existing Integrations in the Book.
Returns The retrieved Integration objects
getLastUpdateMs():
number
|
undefined
Gets the last update date of the book, in milliseconds.
Returns The last update date of the book, in milliseconds
getLockDate():
string
|
undefined
Gets the lock date of the Book in ISO format yyyy-MM-dd.
Returns The lock date of the Book in ISO format yyyy-MM-dd
getName():
string
|
undefined
Gets the name of this Book.
Returns The name of this Book
getOwnerName():
string
|
undefined
Gets the name of the owner of the Book.
Returns The name of the owner of the Book
getPageSize():
number
|
undefined
Gets the transactions pagination page size.
Returns The transactions pagination page size
Gets the period slice for balances visualization.
Returns The period slice for balances visualization
getPeriodStartMonth():
Month
Gets the start month when YEAR period is set.
Returns The start month when YEAR period is set
Gets the permission for the current user in this Book.
Returns The permission for the current user in this Book
getProperties():
any
Gets the custom properties stored in this Book.
Returns The custom properties object
getProperty(
keys:
string
[]):
string
|
undefined
Gets the property value for given keys. First property found will be retrieved.
Returns The property value or undefined if not found
keys
The property keys to search for
getSavedQueries():
Promise<
Query
[]>
Gets the saved queries from this book.
Returns The saved queries from this book
getTimeZone():
string
|
undefined
Gets the time zone of the Book.
Returns The time zone of the Book
getTimeZoneOffset():
number
|
undefined
Gets the time zone offset of the book, in minutes.
Returns The time zone offset of the book, in minutes
getTotalTransactions():
number
Gets the total number of posted transactions.
Returns The total number of posted transactions
getTotalTransactionsCurrentMonth():
number
Gets the total number of posted transactions on current month.
Returns The total number of posted transactions on current month
getTotalTransactionsCurrentYear():
number
Gets the total number of posted transactions on current year.
Returns The total number of posted transactions on current year
getTransaction(
id:
string
):
Promise<
Transaction
|
undefined
>
Retrieve a transaction by id.
Returns The Transaction object
Gets the visibility of the book.
Returns The visibility of the book
Gets an immutable copy of the JSON payload for this resource.
Returns An immutable copy of the json payload
listEvents(
afterDate:
string
|
null
,
beforeDate:
string
|
null
,
onError:
boolean
,
resourceId:
string
|
null
,
limit:
number
,
cursor?:
string
):
Promise<
EventList
>
Lists events in the Book based on the provided parameters.
Returns An EventList object containing the list of events
afterDate
The start date (inclusive) for the events search range, in RFC3339 format. Can be null
beforeDate
The end date (exclusive) for the events search range, in RFC3339 format. Can be null
onError
True to search only for events on error
resourceId
The ID of the event’s resource (Transaction, Account, or Group). Can be null
limit
The maximum number of events to return
cursor
The cursor for pagination. Can be null
listTransactions(
query?:
string
,
limit?:
number
,
cursor?:
string
):
Promise<
TransactionList
>
Lists transactions in the Book based on the provided query, limit, and cursor, for pagination.
Returns A TransactionList object containing the list of transactions
query
The query string to filter transactions
limit
The maximum number of transactions to return. Default to 100, max to 1000
cursor
The cursor for pagination
parseDate(
date:
string
):
Date
Parse a date string according to date pattern and timezone of the Book. Also parse ISO yyyy-mm-dd format.
Returns The parsed Date object
parseValue(
value:
string
):
Amount
|
undefined
Parse a value string according to DecimalSeparator and fraction digits of the Book.
Returns The parsed Amount or undefined if parsing fails
value
The value string to parse
Rounds a value according to the number of fraction digits of the Book.
Returns The rounded value
setAutoPost(
autoPost:
boolean
):
Book
Sets the auto post status of the Book.
Returns This Book, for chaining
autoPost
The auto post status to set
setClosingDate(
closingDate:
string
|
null
):
Book
Sets the closing date of the Book in ISO format yyyy-MM-dd.
Returns This Book, for chaining
closingDate
The closing date to set in ISO format yyyy-MM-dd
setDatePattern(
datePattern:
string
):
Book
Sets the date pattern of the Book. Current: dd/MM/yyyy |
MM/dd/yyyy |
yyyy/MM/dd |
Returns This Book, for chaining
Sets the decimal separator of the Book
Returns This Book, for chaining
decimalSeparator
The decimal separator to set
setFractionDigits(
fractionDigits:
number
):
Book
Sets the number of fraction digits (decimal places) supported by this Book.
Returns This Book, for chaining
fractionDigits
The number of fraction digits to set (0 to 8)
setLockDate(
lockDate:
string
|
null
):
Book
Sets the lock date of the Book in ISO format yyyy-MM-dd.
Returns This Book, for chaining
lockDate
The lock date to set in ISO format yyyy-MM-dd
setName(
name:
string
):
Book
Sets the name of the Book.
Returns This Book, for chaining
setPageSize(
pageSize:
number
):
Book
Sets the transactions pagination page size.
Returns This Book, for chaining
Sets the period slice for balances visualization.
Returns This Book, for chaining
Sets the start month when YEAR period is set.
Returns This Book, for chaining
setProperties(
properties:
any):
Book
Sets the custom properties of the Book.
Returns This Book, for chaining
properties
Object with key/value pair properties
setProperty(
key:
string
,
value:
string
|
null
):
Book
Sets a custom property in the Book.
Returns This Book, for chaining
setTimeZone(
timeZone:
string
):
Book
Sets the time zone of the Book.
Returns This Book, for chaining
Sets the visibility of the book.
Returns This Book, for chaining
Perform update Book, applying pending changes.
Returns The updated Book object