Class: Book

Book

This class defines a Book.
A is an abstraction of a structure that you want to control, like a business, project, or personal expenses and so forth.
It contains all Accounts where Transactions are recorded/posted;

new Book()

Methods

continueTransactionIterator(continuationToken) → {TransactionIterator}

Resumes a transaction iteration using a continuation token from a previous iterator.
Parameters:
Name Type Description
continuationToken string continuation token from a previous folder iterator
Returns:
a collection of transactions that remained in a previous iterator when the continuation token was generated
Type
TransactionIterator

createAccount(name, group, description) → {Account}

Create an Account in this book. The type of account will be determined by the type of others Accounts in same group. If not specified, the type ASSET (permanent=true/credit=false) will be set. If all other accounts in same group is in another group, the account will also be added to the other group.
Parameters:
Name Type Argument Description
name string The name of the Account
group string <optional>
The group of the Account.
description string <optional>
The description of the Account
Returns:
The created Account object
Type
Account

createTransactionsDataTable(query) → {TransactionsDataTableBuilder}

Create a TransactionsDataTableBuilder based on a query.

This method gives a TransactionsDataTableBuilder to create two dimensional Array representations of transactions dataset.

Go to bkper.com and open report wizard: to learn more about query sintax.
Parameters:
Name Type Description
query string The flter query.
See:
Returns:
the Transactions list builder.
Type
TransactionsDataTableBuilder
Example
var book = BkperApp.openById("agtzfmJrcGVyLWhyZHITCxIGTGVkZ2VyGICAgIDggqALDA");


  book.createTransactionsDataTable("acc:'Bank' after:8/2013 before:9/2013");
  ...
  book.createTransactionsDataTable("after:$m before:$m+1");
  ...
  book.createTransactionsDataTable("#gas");

  

formatDate(date, timeZone) → {string}

Parameters:
Name Type Argument Description
date Date The date to format as string.
timeZone string <optional>
The output timezone of the result. Default to script's timeZone
Returns:
The date formated according to date pattern of book
Type
string

formatValue(value) → {string}

Parameters:
Name Type Description
value Number The value to be formatted.
Returns:
The value formated according to decimal separator and fraction digits of book}
Type
string

getAccount(idOrName) → {Account}

Gets an Account object
Parameters:
Name Type Description
idOrName number | string The id or name of the Account
Returns:
The matching Account object
Type
Account

getAccounts() → {Array.<Account>}

Gets all Accounts of this Book
Returns:
Type
Array.<Account>

getBalanceReport(query) → {Report.BalanceReport}

Get balances reports given a query. Balance queries starts with "=".

This method gives a Report.BalanceReport.
Usually balances are used to populate data tables for charts with Chart Services and create great user interfaces, dashboards or insert in documents to report it for users.

Go to bkper.com and open report wizard: to learn more about query sintax.
Parameters:
Name Type Description
query string The report query (starting with '=')
See:
Returns:
A Balance Report representation
Type
Report.BalanceReport
Example
var book = BkperApp.openById("agtzfmJrcGVyLWhyZHITCxIGTGVkZ2VyGICAgIDggqALDA");



  book.getBalanceReport("=#rental #energy after:8/2013 before:9/2013");
  ...
  book.getBalanceReport("=group:'Expenses' after:$m before:$m+1");
  ...
  book.getBalanceReport("=acc:'Home' acc:'Transport' #medicines after:8/2013 before:12/2013");

  

getDatePattern() → {string}

Returns:
The date pattern of the Book
Type
string

getDecimalSeparator() → {DecimalSeparator}

Returns:
The decimal separator of the Book
Type
DecimalSeparator

getFractionDigits() → {string}

Returns:
The fraction digits of this Book
Type
string

getGroup(idOrName) → {Group}

Gets an Group object
Parameters:
Name Type Description
idOrName number | string The id or name of the Group
Returns:
The matching Group object
Type
Group

getGroups() → {Array.<Group>}

Gets all @{link Group|Groups} of this Book
Returns:
Type
Array.<Group>

getId() → {string}

Returns:
The id of this Book
Type
string

getLastUpdateMs() → {number}

Returns:
The last update date of the book, in in milliseconds
Type
number

getLocale() → {string}

Deprecated:
Returns:
The locale of the Book
Type
string

getName() → {string}

Returns:
The name of this Book
Type
string

getOwnerName() → {string}

Returns:
The name of this Book Owner
Type
string

getPermission() → {Permission}

Returns:
The permission of the current user
Type
Permission

getTimeZone() → {string}

Returns:
The time zone of the book
Type
string

getTimeZoneOffset() → {number}

Returns:
The time zone offset of the book, in minutes
Type
number

record(transactions, timeZone)

Records Transactions a on the Book. The text is usually amount and description, but it can also can contain an informed Date in full format (dd/mm/yyyy - mm/dd/yyyy).
Parameters:
Name Type Argument Description
transactions string | Array.<string> | Array.<Array> The text/array/matrix containing transaction records, one per line/row. Each line/row records one transaction.
timeZone string <optional>
The time zone to format dates.
Search for transactions.
Go to bkper.com and open search wizard: to learn more about query syntax.
Parameters:
Name Type Description
query string The query string.
Returns:
The search result as an iterator.
Type
TransactionIterator
Example
var book = BkperApp.loadBook("agtzfmJrcGVyLWhyZHITCxIGTGVkZ2VyGICAgIDggqALDA");
  var transactions = book.search("acc:CreditCard after:28/01/2013 before:29/01/2013");
  ...
  transactions = book.search("#fuel");
  ...
  transactions = book.search("#fuel after:$d-4");
  ...
  transactions = book.search("after:23/01/2013 before:29/01/2013 using:postDate");
  ...
  while (transactions.hasNext()) {
    var transaction = transactions.next();
    Logger.log(transaction.getDescription());
  }