Bkper

This is the main Entry Point of the bkper-node library.

getBook(id:

string

):

Promise

Gets the Book with the specified bookId from url param.

Parameters:
Name
Description
id

The universal book id - The same bookId param of URL you access at app.bkper.com

setApiKey(key:

string

):

App

Sets the API key to identify the agent.

API keys are intended for agent identification only, not for authentication. Learn more

See how to create your api key here.

Parameters:
Name
Description
key

The key from GCP API & Services Credentials console.

setOAuthTokenProvider(oauthTokenProvider:

OAuthTokenProvider

):

Promise

Sets the OAuthTokenProvider.

OAuthTokenProvider issue a valid OAuth token upon calling the Bkper Rest API.

Parameters:
Name
Description
oauthTokenProvider

The OAuthTokenProvider implementation.

Account

This class defines an Account of a Book.

It mantains a balance of all amount credited and debited in it by Transactions.

An Account can be grouped by Groups.

addGroup(group:

string

|

Group

):

Promise

Add a group to the Account.

Returns This Account, for chainning.

create():

Promise

Perform create new account.

deleteProperty(key:

string

):

Account

Delete a custom property

Returns This Account, for chainning.

Parameters:
Name
Description
key

The property key

getBalance(raw?:

boolean

):

Amount

Gets the balance based on credit nature of this Account.

Returns The balance of this account.

Parameters:
Name
Description
raw

True to get the raw balance, no matter the credit nature of this Account.

getCheckedBalance(raw?:

boolean

):

Amount

Gets the checked balance based on credit nature of this Account.

Returns The checked balance of this Account

Parameters:
Name
Description
raw

True to get the raw balance, no matter the credit nature of this Account.

getGroups():

Promise

Get the Groups of this account.

getId():

string

Gets the account internal id.

getName():

string

Gets the account name.

getNormalizedName():

string

Returns The name of this account without spaces or special characters.

getProperties(): any

Gets the custom properties stored in this Account.

getProperty(keys:

string

[]):

string

Gets the property value for given keys. First property found will be retrieved

Parameters:
Name
Description
keys

The property key

getType():

AccountType

Returns The type for of this account.

hasTransactionPosted():

boolean

Tell if the Account has any transaction already posted.

Accounts with transaction posted, even with zero balance, can only be archived.

isArchived():

boolean

Tell if this account is archived.

isCredit():

boolean

Tell if the account has a Credit nature or Debit otherwise

Credit accounts are just for representation purposes. It increase or decrease the absolute balance. It doesn’t affect the overall balance or the behavior of the system.

The absolute balance of credit accounts increase when it participate as a credit/origin in a transaction. Its usually for Accounts that increase the balance of the assets, like revenue accounts.

        Crediting a credit
  Thus ---------------------> account increases its absolute balance
        Debiting a debit


        Debiting a credit
  Thus ---------------------> account decreases its absolute balance
        Crediting a debit

As a rule of thumb, and for simple understanding, almost all accounts are Debit nature (NOT credit), except the ones that “offers” amount for the books, like revenue accounts.

isInGroup(group:

string

|

Group

):

Promise

Tell if this account is in the Group

Parameters:
Name
Description
group

The Group name, id or object

isPermanent():

boolean

Tell if the account is permanent.

Permanent Accounts are the ones which final balance is relevant and keep its balances over time.

They are also called Real Accounts

Usually represents assets or tangibles, capable of being perceived by the senses or the mind, like bank accounts, money, debts and so on.

Returns True if its a permanent Account

remove():

Promise

Perform delete account.

removeGroup(group:

string

|

Group

):

Promise

Remove a group from the Account.

setArchived(archived:

boolean

):

Account

Set account archived/unarchived.

Returns This Account, for chainning.

setGroups(groups:

string

[] |

Group

[]):

Account

Sets the groups of the Account.

Returns This Account, for chainning.

setName(name:

string

):

Account

Sets the name of the Account.

Returns This Account, for chainning.

setProperties(properties: any):

Account

Sets the custom properties of the Account

Returns This Account, for chainning.

Parameters:
Name
Description
properties

Object with key/value pair properties

setProperty(key:

string

, value:

string

):

Account

Sets a custom property in the Account.

Returns This Account, for chainning.

Parameters:
Name
Description
key

The property key

value

The property value

setType(type:

AccountType

):

Account

Sets the type of the Account.

Returns This Account, for chainning

update():

Promise

Perform update account, applying pending changes.

AccountsDataTableBuilder

A AccountsDataTableBuilder is used to setup and build two-dimensional arrays containing transactions.

build():

Promise

Returns A two-dimensional array containing all Accounts.

includeArchived(include:

boolean

):

AccountsDataTableBuilder

Defines whether the archived accounts should included.

Returns This builder, for chaining.

Amount

This class defines an Amount for arbitrary-precision decimal arithmetic.

It inherits methods from big.js library

abs():

Amount

Returns an absolute Amount.

cmp(n:

number

|

string

|

Amount

):

-1

|

0

|

1

Compare

div(n:

number

|

string

|

Amount

):

Amount

Divide by

eq(n:

number

|

string

|

Amount

):

boolean

Equals to

gt(n:

number

|

string

|

Amount

):

boolean

Greater than

gte(n:

number

|

string

|

Amount

):

boolean

Greater than or equal

lt(n:

number

|

string

|

Amount

):

boolean

Less than

lte(n:

number

|

string

|

Amount

):

boolean

Less than or equal to

minus(n:

number

|

string

|

Amount

):

Amount

Minus

mod(n:

number

|

string

|

Amount

):

Amount

Modulo - the integer remainder of dividing this Amount by n.

Similar to % operator

plus(n:

number

|

string

|

Amount

):

Amount

Sum

round(dp?:

number

):

Amount

Round to a maximum of dp decimal places.

times(n:

number

|

string

|

Amount

):

Amount

Multiply

toFixed(dp?:

number

):

string

Returns a string representing the value of this Amount in normal notation to a fixed number of decimal places dp.

toNumber():

number

Returns a primitive number representing the value of this Amount.

toString():

string

Returns a string representing the value of this Amount.

App

Defines an App on Bkper.

Apps can be installed on Books by users.s

patch():

Promise

Partially update an App, applying pending changes.

setWebhookUrlDev(webhookUrlDev:

string

):

App

Sets the webhook url for development.

Returns This App, for chainning.

Balance

Class that represents an Account, Group or #hashtag balance on a window of time (Day / Month / Year).

getCheckedCumulativeBalance():

Amount

The cumulative checked balance to the date, since the first transaction posted.

getCheckedPeriodBalance():

Amount

The checked balance on the date period.

getCumulativeBalance():

Amount

The cumulative balance to the date, since the first transaction posted.

getDate():

Date

Date object constructed based on Book time zone offset. Usefull for

If Month or Day is zero, the date will be constructed with first Month (January) or Day (1).

getDay():

number

The day of the balance. Days starts on 1 to 31.

Day can be 0 (zero) in case of Monthly or Early Periodicity of the BalancesReport

getFuzzyDate():

number

The Fuzzy Date of the balance, based on Periodicity of the BalancesReport query, composed by Year, Month and Day.

The format is YYYYMMDD. Very usefull for ordering and indexing

Month and Day can be 0 (zero), depending on the granularity of the Periodicity.

Example:

20180125 - 25, January, 2018 - DAILY Periodicity

20180100 - January, 2018 - MONTHLY Periodicity

20180000 - 2018 - YEARLY Periodicity

getMonth():

number

The month of the balance. Months starts on 1 (January) to 12 (December)

Month can be 0 (zero) in case of Early Periodicity of the BalancesReport

getPeriodBalance():

Amount

The balance on the date period.

getUncheckedCumulativeBalance():

Amount

The unchecked cumulative balance to the date, since the first transaction posted.

getUncheckedPeriodBalance():

Amount

The unchecked balance on the date period.

getYear():

number

The year of the balance

BalancesDataTableBuilder

A BalancesDataTableBuilder is used to setup and build two-dimensional arrays containing balance information.

build():

any

[][]

Builds an two-dimensional array with the balances.

expanded(expanded:

boolean

):

BalancesDataTableBuilder

Defines wheter Groups should expand its child accounts.

Returns This builder with respective expanded option, for chaining.

formatDates(format:

boolean

):

BalancesDataTableBuilder

Defines whether the dates should be formatted based on date pattern and periodicity of the Book.

Returns This builder with respective formatting option, for chaining.

formatValues(format:

boolean

):

BalancesDataTableBuilder

Defines whether the value should be formatted based on decimal separator of the Book.

Returns This builder with respective formatting option, for chaining.

hideDates(hide:

boolean

):

BalancesDataTableBuilder

Defines whether the dates should be hidden for PERIOD or CUMULATIVE BalanceType.

Returns This builder with respective hide dates option, for chaining.

hideNames(hide:

boolean

):

BalancesDataTableBuilder

Defines whether the Accounts and Groups names should be hidden.

Returns This builder with respective hide names option, for chaining.

transposed(transposed:

boolean

):

BalancesDataTableBuilder

Defines wheter should rows and columns should be transposed.

For TOTAL BalanceType, the transposed table looks like:

  _____________________________
 | Expenses | Income  |  ...  |
 | 4568.23  | 5678.93 |  ...  |
 |__________|_________|_______|

Two rows, and each Account or Group per column.

For PERIOD or CUMULATIVE BalanceType, the transposed table will be a time table, and the format looks like:

  _______________________________________________________________
 |            | 15/01/2014 | 15/02/2014 | 15/03/2014 |    ...    |
 |  Expenses  |  2345.23   |  2345.93   |  2456.45   |    ...    |
 |  Income    |  3452.93   |  3456.46   |  3567.87   |    ...    |
 |     ...    |     ...    |     ...    |     ...    |    ...    |
 |____________|____________|____________|____________|___________|

First column will be each Account or Group, and one column for each Date.

Returns This builder with respective transposed option, for chaining.

Fluent method to set the BalanceType for the builder.

Returns This builder with respective balance type, for chaining.

Parameters:
Name
Description
type

The type of balance for this data table

For TOTAL BalanceType, the table format looks like:

  _____________________
 | Expenses  | 4568.23 |
 | Income    | 5678.93 |
 |    ...    |   ...   |
 |___________|_________|

Two columns, and each Account or Group per line.

For PERIOD or CUMULATIVE BalanceType, the table will be a time table, and the format looks like:

 _____________________________________________
 |            | Expenses | Income  |    ...   |
 | 15/01/2014 | 2345.23  | 3452.93 |    ...   |
 | 15/02/2014 | 2345.93  | 3456.46 |    ...   |
 | 15/03/2014 | 2456.45  | 3567.87 |    ...   |
 |    ...     |   ...    |   ...   |    ...   |
 |___________ |__________|_________|__________|

First column will be the Date column, and one column for each Account or Group.

BalancesReport

Class representing a Balance Report, generated when calling Book.getBalanceReport

createDataTable():

BalancesDataTableBuilder

Creates a BalancesDataTableBuilder to generate a two-dimensional array with all BalancesContainers.

getBalanceCheckedType():

BalanceCheckedType

The BalanceCheckedType of the query used to generate the report.

getBalancesContainer(groupName:

string

):

BalancesContainer

Gets a specific BalancesContainers.

getBalancesContainers():

BalancesContainer

[]

Gets all BalancesContainers of the report.

getBook():

Book

The Book that generated the report.

getPeriodicity():

Periodicity

The Periodicity of the query used to generate the report.

hasOnlyOneGroup():

boolean

Check if the report has only one Group specified on query.

Book

A Book represents 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;

audit():

void

Trigger Balances Audit async process.

batchCreateAccounts(accounts:

Account

[]):

Promise

Create Accounts on the Book, in batch.

batchCreateGroups(groups:

Group

[]):

Promise

Create Groups on the Book, in batch.

batchCreateTransactions(transactions:

Transaction

[]):

Promise

Create Transactions on the Book, in batch.

clearAccountsCache():

void

configureTransactions_(transactions:

Transaction

[]):

Transaction

[]

continueTransactionIterator(query:

string

, continuationToken:

string

):

TransactionIterator

Resumes a transaction iteration using a continuation token from a previous iterator.

Returns a collection of transactions that remained in a previous iterator when the continuation token was generated

Parameters:
Name
Description
continuationToken

continuation token from a previous transaction iterator

createAccountsDataTable():

Promise

Create a AccountsDataTableBuilder, to build two dimensional Array representations of Accounts dataset.

Returns Accounts data table builder.

createBalancesDataTable(query:

string

):

Promise

Create a BalancesDataTableBuilder based on a query, to create two dimensional Array representation of balances of Account, Group or #hashtag

See Query Guide to learn more

Returns The balances data table builder

Example:

var book = BkperApp.getBook("agtzfmJrcGVyLWhyZHITCxIGTGVkZ2VyGICAgIDggqALDA");

var balancesDataTable = book.createBalancesDataTable("#rental #energy after:8/2013 before:9/2013").build();

Parameters:
Name
Description
query

The balances report query

createTransactionsDataTable(query?:

string

):

TransactionsDataTableBuilder

Create a TransactionsDataTableBuilder based on a query, to build two dimensional Array representations of Transactions dataset.

See Query Guide to learn more

Returns Transactions data table builder.

Example:

var book = BkperApp.getBook("agtzfmJrcGVyLWhyZHITCxIGTGVkZ2VyGICAgIDggqALDA");

var transactionsDataTable = book.createTransactionsDataTable("account:'Bank' after:8/2013 before:9/2013").build();

Parameters:
Name
Description
query

The flter query.

formatDate(date:

Date

, timeZone?:

string

):

string

Formats a date according to date pattern of the Book.

Returns The date formated

Parameters:
Name
Description
date

The date to format as string.

timeZone

The output timezone of the result. Default to script’s timeZone

formatValue(value:

Amount

|

number

):

string

Formats a value according to DecimalSeparator and fraction digits of the Book.

Returns The value formated

Parameters:
Name
Description
value

The value to be formatted.

getAccount(idOrName:

string

):

Promise

Gets an Account object

Returns The matching Account object

Parameters:
Name
Description
idOrName

The id or name of the Account

getAccounts():

Promise

Gets all Accounts of this Book

getBalancesReport(query:

string

):

Promise

Create a BalancesReport based on query

Parameters:
Name
Description
query

The balances report query

getCollection():

Collection

Returns The collection of this book

getDatePattern():

string

Returns The date pattern of the Book. Current: dd/MM/yyyy MM/dd/yyyy yyyy/MM/dd

getDecimalPlaces():

number

Returns The number of decimal places supported by this Book. Same as getFractionDigits

getDecimalSeparator():

DecimalSeparator

Returns The decimal separator of the Book

getFile(id:

string

):

Promise

Retrieve a file by id

getFractionDigits():

number

Returns The number of fraction digits supported by this Book. Same as getDecimalPlaces

getGroup(idOrName:

string

):

Promise

Gets a Group object

Returns The matching Group object

Parameters:
Name
Description
idOrName

The id or name of the Group

getGroups():

Promise

Gets all Groups of this Book

getId():

string

Same as bookId param

getLastUpdateMs():

number

Returns The last update date of the book, in in milliseconds

getName():

string

Returns The name of this Book

getOwnerName():

string

Returns The name of the owner of the Book

getPageSize():

number

Returns The transactions pagination page size

getPeriod():

Period

Returns The period slice for balances visualization

getPeriodStartMonth():

Month

Returns The start month when YEAR period set

getPermission():

Permission

Returns The permission for the current user

getProperties(): any

Gets the custom properties stored in this Book

getProperty(keys:

string

[]):

string

Gets the property value for given keys. First property found will be retrieved

Parameters:
Name
Description
keys

The property key

getSavedQueries():

Promise

Gets all saved queries from this book

getTimeZone():

string

Returns The time zone of the Book

getTimeZoneOffset():

number

Returns The time zone offset of the book, in minutes

getTransaction(id:

string

):

Promise

Retrieve a transaction by id

getTransactions(query?:

string

):

TransactionIterator

Get Book transactions based on a query.

See Query Guide to learn more

Returns The Transactions result as an iterator.

Example:

var book = BkperApp.getBook("agtzfmJrcGVyLWhyZHITCxIGTGVkZ2VyGICAgIDggqALDA");

var transactions = book.getTransactions("account:CreditCard after:28/01/2013 before:29/01/2013");

while (transactions.hasNext()) {
 var transaction = transactions.next();
 Logger.log(transaction.getDescription());
}

Parameters:
Name
Description
query

The query string.

newAccount():

Account

Instantiate a new Account

Example:

var book = BkperApp.getBook("agtzfmJrcGVyLWhyZHITCxIGTGVkZ2VyGICAgIDggqALDA");

book.newAccount()
 .setName('Some New Account')
 .setType('INCOMING')
 .addGroup('Revenue').addGroup('Salary')
 .setProperties({prop_a: 'A', prop_b: 'B'})
 .create();

newFile():

File

Instantiate a new [[BkperFile]]

Example:

var book = BkperApp.getBook("agtzfmJrcGVyLWhyZHITCxIGTGVkZ2VyGICAgIDggqALDA");

book.newFile()
 .setBlob(UrlFetchApp.fetch('https://bkper.com/images/index/integrations4.png').getBlob())
 .create();

newGroup():

Group

Instantiate a new Group

Example:

var book = BkperApp.getBook("agtzfmJrcGVyLWhyZHITCxIGTGVkZ2VyGICAgIDggqALDA");

book.newGroup()
 .setName('Some New Group')
 .setProperty('key', 'value')
 .create();

newTransaction():

Transaction

Instantiate a new Transaction

Example:

var book = BkperApp.getBook("agtzfmJrcGVyLWhyZHITCxIGTGVkZ2VyGICAgIDggqALDA");

book.newTransaction()
 .setDate('2013-01-25')
 .setDescription("Filling tank of my truck")
 .from('Credit Card')
 .to('Gas')
 .setAmount(126.50)
 .create();

parseValue(value:

string

):

Amount

Parse a value string according to DecimalSeparator and fraction digits of the Book.

round(value:

Amount

|

number

):

Amount

Rounds a value according to the number of fraction digits of the Book

Returns The value rounded

Parameters:
Name
Description
value

The value to be rounded

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 chainning.

setDecimalSeparator(decimalSeparator:

DecimalSeparator

):

Book

Sets the decimal separator of the Book

Returns This Book, for chainning.

setFractionDigits(fractionDigits:

number

):

Book

Sets the number of fraction digits (decimal places) supported by this Book

Returns This Book, for chainning.

setName(name:

string

):

Book

Sets the name of the Book.

Returns This Book, for chainning.

setPageSize(pageSize:

number

):

Book

Sets the transactions pagination page size

Returns This Book, for chainning.

setPeriod(period:

Period

):

Book

Sets the period slice for balances visualization

Returns This Book, for chainning.

setPeriodStartMonth(month:

Month

):

Book

Sets the start month when YEAR period set

Returns This Book, for chainning.

setProperties(properties: any):

Book

Sets the custom properties of the Book

Returns This Book, for chainning.

Parameters:
Name
Description
properties

Object with key/value pair properties

setProperty(key:

string

, value:

string

):

Book

Sets a custom property in the Book.

Returns This Book, for chainning.

Parameters:
Name
Description
key

The property key

value

The property value

setTimeZone(timeZone:

string

):

Book

Sets the time zone of the Book

Returns This Book, for chainning.

update():

Promise

Perform update Book, applying pending changes.

Collection

This class defines a Collection of Books.

getBooks():

Book

[]

Returns All Books of this collection.

getId():

string

Returns The id of this Collection

getName():

string

Returns The name of this Collection

File

This class defines a File uploaded to a Book.

A File can be attached to a Transaction or used to import data.

create():

Promise

Perform create new File.

getContent():

Promise

Gets the file content Base64 encoded

getContentType():

string

Gets the File content type

getId():

string

Gets the File id

getName():

string

Gets the File name

getSize():

number

Gets the file size in bytes

getUrl():

string

Gets the file serving url for accessing via browser

setContent(content:

string

):

File

Sets the File content Base64 encoded.

Returns This File, for chainning.

setContentType(contentType:

string

):

File

Sets the File content type.

Returns This File, for chainning.

setName(name:

string

):

File

Sets the name of the File.

Returns This File, for chainning.

Group

This class defines a Group of Accounts.

Accounts can be grouped by different meaning, like Expenses, Revenue, Assets, Liabilities and so on

Its useful to keep organized and for high level analysis.

create():

Promise

Perform create new group.

deleteProperty(key:

string

):

Group

Delete a custom property

Returns This Group, for chainning.

Parameters:
Name
Description
key

The property key

getAccounts():

Promise

Returns All Accounts of this group.

getId():

string

Returns The id of this Group

getName():

string

Returns The name of this Group

getNormalizedName():

string

Returns The name of this group without spaces and special characters

getProperties(): any

Gets the custom properties stored in this Group

getProperty(keys:

string

[]):

string

Gets the property value for given keys. First property found will be retrieved

Parameters:
Name
Description
keys

The property key

hasAccounts():

Promise

Returns True if this group has any account in it

isHidden():

boolean

Tell if the Group is hidden on main transactions menu

remove():

Promise

Perform delete group.

setHidden(hidden:

boolean

):

Group

Hide/Show group on main menu.

setName(name:

string

):

Group

Sets the name of the Group.

Returns This Group, for chainning.

setProperties(properties: any):

Group

Sets the custom properties of the Group

Returns This Group, for chainning.

Parameters:
Name
Description
properties

Object with key/value pair properties

setProperty(key:

string

, value:

string

):

Group

Sets a custom property in the Group.

Parameters:
Name
Description
key

The property key

value

The property value

update():

Promise

Perform update group, applying pending changes.

Transaction

This class defines a Transaction between credit and debit Accounts.

A Transaction is the main entity on the Double Entry Bookkeeping system.

addFile(file:

File

):

Promise

Adds a file attachment to the Transaction.

Files not previously created in the Book will be automatically created.

Returns This Transaction, for chainning.

Parameters:
Name
Description
file

The file to add

addRemoteId(remoteId:

string

):

Transaction

Add a remote id to the Transaction.

Returns This Transaction, for chainning.

Parameters:
Name
Description
remoteId

The remote id to add.

addUrl(url:

string

):

Transaction

Add a url to the Transaction. Url starts with https://

Returns This Transaction, for chainning.

Parameters:
Name
Description
url

The url to add.

check():

Promise

Perform check transaction.

create():

Promise

Perform create new draft transaction.

deleteProperty(key:

string

):

Transaction

Delete a custom property

Returns This Transaction, for chainning.

Parameters:
Name
Description
key

The property key

from(account:

Account

):

Transaction

Sets the credit/origin Account of the Transaction. Same as setCreditAccount().

Returns This Transaction, for chainning.

Parameters:
Name
Description
account

Account id, name or object.

getAccountBalance(raw?:

boolean

):

Promise

Gets the balance that the Account has at that day, when listing transactions of that Account.

Evolved balances is returned when searching for transactions of a permanent Account.

Only comes with the last posted transaction of the day.

Parameters:
Name
Description
raw

True to get the raw balance, no matter the credit nature of the Account.

getAgentId():

string

Returns The id of the agent that created this transaction

getAmount():

Amount

Returns The amount of the transaction.

getCreatedAt():

Date

Returns The date the transaction was created.

getCreatedAtFormatted():

string

Returns The date the transaction was created, formatted according to the date pattern of Book.

getCreditAccount():

Promise

Returns The credit account. The same as origin account.

getCreditAccountName():

Promise

Returns The credit account name.

getCreditAmount(account:

Account

|

string

):

Promise

Get the absolute amount of this transaction if the given account is at the credit side, else null.

Parameters:
Name
Description
account

The account object, id or name.

getDate():

string

Returns The Transaction date, in ISO format yyyy-MM-dd.

getDateFormatted():

string

Returns The Transaction date, formatted on the date pattern of the Book.

getDateObject():

Date

Returns The Transaction Date object, on the time zone of the Book.

getDateValue():

number

Returns The Transaction date number, in format YYYYMMDD.

getDebitAccount():

Promise

Returns The debit account. The same as destination account.

getDebitAccountName():

Promise

Returns The debit account name.

getDebitAmount(account:

Account

|

string

):

Promise

Gets the absolute amount of this transaction if the given account is at the debit side, else null.

Parameters:
Name
Description
account

The account object, id or name.

getDescription():

string

Returns The description of this transaction.

getFiles():

File

[]

Returns The files attached to the transaction.

getId():

string

Returns The id of the Transaction.

getOtherAccount(account:

Account

|

string

):

Promise

Gets the Account at the other side of the transaction given the one in one side.

Parameters:
Name
Description
account

The account object, id or name.

getOtherAccountName(account:

string

|

Account

):

Promise

The account name at the other side of the transaction given the one in one side.

Parameters:
Name
Description
account

The account object, id or name.

getProperties(): any

Gets the custom properties stored in this Transaction.

getProperty(keys:

string

[]):

string

Gets the property value for given keys. First property found will be retrieved

Parameters:
Name
Description
keys

The property key

getRemoteIds():

string

[]

Remote ids are used to avoid duplication.

Returns The remote ids of the Transaction.

getTags():

string

[]

Returns All #hashtags used on the transaction.

getUrls():

string

[]

Returns All urls of the transaction.

hasTag(tag:

string

):

boolean

Check if the transaction has the specified tag.

isChecked():

boolean

Returns True if transaction is checked.

isPosted():

boolean

Returns True if transaction was already posted to the accounts. False if is still a Draft.

isTrashed():

boolean

Returns True if transaction is in trash.

post():

Promise

Perform post transaction, changing credit and debit Account balances.

remove():

Promise

Remove the transaction, sending to trash.

restore():

Promise

Restore the transaction from trash.

setAmount(amount:

Amount

|

number

|

string

):

Transaction

Sets the amount of the Transaction.

Returns This Transaction, for chainning.

setCreditAccount(account:

Account

):

Transaction

Sets the credit/origin Account of the Transaction. Same as from().

Returns This Transaction, for chainning.

Parameters:
Name
Description
account

Account id, name or object.

setDate(date:

string

|

Date

):

Transaction

Sets the date of the Transaction.

Returns This Transaction, for chainning

setDebitAccount(account:

Account

):

Transaction

Sets the debit/origin Account of the Transaction. Same as to().

Returns This Transaction, for chainning.

Parameters:
Name
Description
account

Account id, name or object.

setDescription(description:

string

):

Transaction

Sets the description of the Transaction.

Returns This Transaction, for chainning.

setProperties(properties: any):

Transaction

Sets the custom properties of the Transaction

Returns This Transaction, for chainning.

Parameters:
Name
Description
properties

Object with key/value pair properties

setProperty(key:

string

, value:

string

):

Transaction

Sets a custom property in the Transaction.

Returns This Transaction, for chainning.

Parameters:
Name
Description
key

The property key

value

The property value

setUrls(urls:

string

[]):

Transaction

Sets the Transaction urls. Url starts with https://

Returns This Transaction, for chainning.

Parameters:
Name
Description
urls

The urls array.

to(account:

Account

):

Transaction

Sets the debit/origin Account of the Transaction. Same as setDebitAccount().

Returns This Transaction, for chainning.

Parameters:
Name
Description
account

Account id, name or object.

uncheck():

Promise

Perform uncheck transaction.

update():

Promise

Upddate transaction, applying pending changes.

TransactionIterator

An iterator that allows scripts to iterate over a potentially large collection of transactions.

Example:

var book = BkperApp.getBook("agtzfmJrcGVyLWhyZHITCxIGTGVkZ2VyGICAgIDggqALDA");

var transactionIterator = book.getTransactions("account:CreditCard after:28/01/2013 before:29/01/2013");

while (transactionIterator.hasNext()) {
 var transaction = transactions.next();
 Logger.log(transaction.getDescription());
}

getAccount():

Promise

Returns The account, when filtering by a single account.

getBook():

Book

Gets the Book that originate the iterator

getContinuationToken():

string

Gets a token that can be used to resume this iteration at a later time.

This method is useful if processing an iterator in one execution would exceed the maximum execution time.

Continuation tokens are generally valid short period of time.

hasNext():

Promise

Determines whether calling next() will return a transaction.

next():

Promise

Gets the next transaction in the collection of transactions.

setContinuationToken(continuationToken:

string

):

Promise

Sets a continuation token from previous paused iteration

TransactionsDataTableBuilder

A TransactionsDataTableBuilder is used to setup and build two-dimensional arrays containing transactions.

build():

Promise

Returns A two-dimensional array containing all Transactions.

formatDates(format:

boolean

):

TransactionsDataTableBuilder

Defines whether the dates should be formatted, based on date patter of the Book

Returns This builder with respective formatting option, for chaining.

formatValues(format:

boolean

):

TransactionsDataTableBuilder

Defines whether amounts should be formatted based on DecimalSeparator of the Book

Returns This builder with respective formatting option, for chaining.

getAccount():

Promise

Returns The account, when filtering by a single account.

includeUrls(include:

boolean

):

TransactionsDataTableBuilder

Defines whether include attachments and url links.

Returns This builder with respective add attachment option, for chaining.

BalancesContainer

The container of balances of an Account, Group or #hashtag

The container is composed of a list of Balances for a window of time, as well as its period and cumulative totals.

createDataTable():

BalancesDataTableBuilder

Creates a BalancesDataTableBuilder to generate a two-dimensional array with all BalancesContainers

getBalances():

Balance

[]

All Balances of the container

getBalancesContainer(name:

string

):

BalancesContainer

Gets a specific BalancesContainer.

NOTE: Only for Group balance containers. Accounts returns null.

getBalancesContainers():

BalancesContainer

[]

Gets all child BalancesContainers.

NOTE: Only for Group balance containers. Accounts returns null.

getBalancesReport():

BalancesReport

The parent BalancesReport of the container

getCheckedCumulativeBalance():

Amount

The cumulative checked balance to the date, since the first transaction posted.

getCheckedCumulativeBalanceText():

string

The cumulative checked balance formatted according to Book decimal format and fraction digits.

getCheckedPeriodBalance():

Amount

The checked balance on the date period.

getCheckedPeriodBalanceText():

string

The checked balance on the date period formatted according to Book decimal format and fraction digits

getCumulativeBalance():

Amount

The cumulative balance to the date, since the first transaction posted.

getCumulativeBalanceText():

string

The cumulative balance formatted according to Book decimal format and fraction digits.

getName():

string

The Account name, Group name or #hashtag

getPeriodBalance():

Amount

The balance on the date period.

getPeriodBalanceText():

string

The balance on the date period formatted according to Book decimal format and fraction digits

getUncheckedCumulativeBalance():

Amount

The cumulative unchecked balance to the date, since the first transaction posted.

getUncheckedCumulativeBalanceText():

string

The cumulative unchecked balance formatted according to Book decimal format and fraction digits.

getUncheckedPeriodBalance():

Amount

The unchecked balance on the date period.

getUncheckedPeriodBalanceText():

string

The unchecked balance on the date period formatted according to Book decimal format and fraction digits

isCredit():

boolean

Gets the credit nature of the BalancesContainer, based on Account, Group or #hashtag this container represents.

For Account, the credit nature will be the same as the one from the Account

For Group, the credit nature will be the same, if all accounts containing on it has the same credit nature. False if mixed.

For #hashtag, the credit nature will be true.

OAuthTokenProvider

Interface to provide OAuth2 tokens upon calling the API.

AccountType Enum

Enum that represents account types.

Name
Description
ASSET

Asset account type

INCOMING

Incoming account type

LIABILITY

Liability account type

OUTGOING

Outgoing account type

BalanceCheckedType Enum

Enum that represents queried balances of checked/unchecked transactions.

The type is obtained from parsing the is:checked is:unchecked query operator.

Name
Description
CHECKED_BALANCE

Balances of is:checked transactions only.

FULL_BALANCE

Balances of all transactions, no matter its checked or unchecked state.

UNCHECKED_BALANCE

Balances of is:unchecked transactions only.

BalanceType Enum

Enum that represents balance types.

Name
Description
CUMULATIVE

Cumulative balance

PERIOD

Period balance

TOTAL

Total balance

DecimalSeparator Enum

Decimal separator of numbers on book

Name
Description
COMMA

,

DOT

.

Month Enum

Enum that represents a Month.

Name
Description
APRIL

AUGUST

DECEMBER

FEBRUARY

JANUARY

JULY

JUNE

MARCH

MAY

NOVEMBER

OCTOBER

SEPTEMBER

Period Enum

Enum that represents a period slice.

Name
Description
MONTH

Monthly period

QUARTER

Quarterly period

YEAR

Yearly period

Periodicity Enum

The Periodicity of the query. It may depend on the level of granularity you write the range params.

Name
Description
DAILY

Example: after:25/01/1983, before:04/03/2013, after:$d-30, before:$d, after:$d-15/$m

MONTHLY

Example: after:jan/2013, before:mar/2013, after:$m-1, before:$m

YEARLY

Example: on:2013, after:2013, $y

Permission Enum

Enum representing permissions of user in the Book

Learn more at share article.

Name
Description
EDITOR

Manage accounts, transactions, book configuration and sharing

NONE

No permission

OWNER

Manage everything, including book visibility and deletion. Only one owner per book.

POSTER

View transactions, accounts, record and delete drafts

RECORDER

Record and delete drafts only. Useful to collect data only

VIEWER

View transactions, accounts and balances.