Bkper

This is the main entry point of the bkper-js library.

You start by setting the API Config object.

Example:

Bkper.setConfig({
  apiKeyProvider: () => process.env.BKPER_API_KEY,
  oauthTokenProvider: () => process.env.BKPER_OAUTH_TOKEN
})

Once the config is set, you can start using the library.

getApps(): Promise<

App

[]>

Gets all Apps available for the user.

Returns The retrieved list of Apps

getBillingPortalUrl(returnUrl:

string

): Promise<

string

|

undefined

>

Gets the URL to redirect the User to the billing portal.

Returns The URL to redirect the User to the billing portal

Parameters:
Name
Description
returnUrl

The URL to return to after the User has been redirected to the billing portal

getBook(id:

string

, includeAccounts?:

boolean

): Promise<

Book

>

Gets the Book with the specified bookId from url param.

Returns The retrieved Book, for chaining

Parameters:
Name
Description
id

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

includeAccounts

Optional parameter to include accounts in the retrieved Book

getBooks(): Promise<

Book

[]>

Gets all Books the user has access to.

Returns The retrieved list of Books

getCollections(): Promise<

Collection

[]>

Gets all [[Collections]] the user has access to.

Returns The retrieved list of Collections

getTemplates(): Promise<

Template

[]>

Gets all Template available for the user.

Returns The retrieved list of Templates

getUser(): Promise<

User

>

Gets the current logged User.

Returns The retrieved User, for chaining

newBook():

Book

Instantiate a new Book

Example:

var book = Bkper.newBook()
 .setName('My New Book')
 .setFractionDigits(2)
 .setDecimalSeparator('DOT')
 .create();

setApiKey(key:

string

):

App

Sets the API key to identify the agent.

Returns The defined App object

deprecated ** Use setConfig() instead

Parameters:
Name
Description
key

The API key

setConfig(config:

Config

):

void

Sets the API Config object.

Parameters:
Name
Description
config

The Config object

setOAuthTokenProvider(oauthTokenProvider:): Promise<

void

>

Sets the provider of the valid OAuth2 access token

deprecated ** Use setConfig() instead

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:

Group

|

bkper.Group

):

Account

Add a group to the Account.

Returns This Account, for chainning.

create(): Promise<

Account

>

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():

Amount

Gets the balance based on credit nature of this Account.

Returns The balance of this account.

deprecated ** Use Book.getBalancesReport instead.

getBalanceRaw():

Amount

Gets the raw balance, no matter credit nature of this Account.

Returns The balance of this account.

deprecated ** Use Book.getBalancesReport instead.

getGroups(): Promise<

Group

[]>

Get the Groups of this account.

getId():

string

|

undefined

Gets the account internal id.

getName():

string

|

undefined

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

|

undefined

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

|

undefined

Tell if the Account has any transaction already posted.

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

isArchived():

boolean

|

undefined

Tell if this account is archived.

isCredit():

boolean

|

undefined

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<

boolean

>

Tell if this account is in the Group

Parameters:
Name
Description
group

The Group name, id or object

isPermanent():

boolean

|

undefined

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

json():

bkper.Account

Returns An immutable copy of the json payload

remove(): Promise<

Account

>

Perform delete account.

removeGroup(group:

string

|

Group

): Promise<

Account

>

Remove a group from the Account.

setArchived(archived:

boolean

):

Account

Set account archived/unarchived.

Returns This Account, for chainning.

setGroups(groups:

Group

[] |

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

|

null

):

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<

Account

>

Perform update account, applying pending changes.

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.

create(): Promise<

App

>

Performs the app creation, applying pending changes.

The App id MUST be unique. If another app is already existing, an error will be thrown.

getId():

string

|

undefined

Returns The App universal identifier

json():

bkper.App

Returns The wrapped plain json object

patch(): Promise<

App

>

Partially update an App, applying pending changes.

setClientSecret(clientSecret?:

string

):

App

Sets the client secret

Returns This App for chaining

setDeveloperEmail(email?:

string

):

App

Sets the developer email

Returns This App for chaining

setReadme(readme?:

string

):

App

Sets the readme text

Returns This App for chaining

setUserEmails(emails?:

string

):

App

Sets the whitelabeled user emails

Returns This App for chaining

setWebhookUrlDev(webhookUrlDev:

string

):

App

Sets the webhook url for development.

Returns This App, for chainning.

update(): Promise<

App

>

Perform update App, applying pending changes.

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.

batchCreateTransactions(transactions:

Transaction

[]): Promise<

Transaction

[]>

Create Transactions on the Book, in batch.

batchTrashTransactions(transactions:

Transaction

[]): Promise<

void

>

Trash Transactions on the Book, in batch.

create(): Promise<

Book

>

Performs create new Book.

Returns The created Book object

createIntegration(integration:

bkper.Integration

|

Integration

): Promise<

Integration

>

Creates a new Integration in the Book.

Returns The created Integration object

Parameters:
Name
Description
integration

The Integration object or wrapped plain json

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

|

null

|

undefined

):

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<

Account

|

undefined

>

Gets an Account object

Returns The matching Account object

Parameters:
Name
Description
idOrName

The id or name of the Account

getAccounts(): Promise<

Account

[]>

Gets all Accounts of this Book

Returns The retrieved Account objects

getClosingDate():

string

|

undefined

Returns The closing date of the Book in ISO format yyyy-MM-dd

getCollection():

Collection

|

undefined

Returns The collection of this book

getDatePattern():

string

|

undefined

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

getDecimalPlaces():

number

|

undefined

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<

File

>

Retrieve a file by id

getFractionDigits():

number

|

undefined

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

getGroup(idOrName?:

string

): Promise<

Group

|

undefined

>

Gets a Group object

Returns The matching Group object

Parameters:
Name
Description
idOrName

The id or name of the Group

getGroups(): Promise<

Group

[]>

Gets all Groups of this Book

Returns The retrieved Group objects

getId():

string

Same as bookId param

getIntegrations(): Promise<

Integration

[]>

Gets the existing Integrations in the Book.

Returns The existing Integration objects

getLastUpdateMs():

number

|

undefined

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

getLockDate():

string

|

undefined

Returns The lock date of the Book in ISO format yyyy-MM-dd

getName():

string

|

undefined

Returns The name of this Book

getOwnerName():

string

|

undefined

Returns The name of the owner of the Book

getPageSize():

number

|

undefined

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

|

undefined

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

Parameters:
Name
Description
keys

The property key

getTimeZone():

string

|

undefined

Returns The time zone of the Book

getTimeZoneOffset():

number

|

undefined

Returns The time zone offset of the book, in minutes

getTotalTransactions():

number

Returns The total number of posted transactions

getTotalTransactionsCurrentMonth():

number

Returns The total number of posted transactions on current month

getTotalTransactionsCurrentYear():

number

Returns The total number of posted transactions on current year

getTransaction(id:

string

): Promise<

Transaction

|

undefined

>

Retrieve a transaction by id

getVisibility():

Visibility

Returns The visibility of the book

json():

bkper.Book

Returns An immutable copy of the json payload

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 TransactionPage object containing the list of transactions

Parameters:
Name
Description
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.

parseValue(value:

string

):

Amount

|

undefined

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

setClosingDate(closingDate:

string

):

Book

Sets the closing date of the Book in ISO format yyyy-MM-dd.

Returns This Book, for chainning.

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.

setLockDate(lockDate:

string

):

Book

Sets the lock date of the Book in ISO format yyyy-MM-dd.

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

|

null

):

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<

Book

>

Perform update Book, applying pending changes.

updateIntegration(integration:

bkper.Integration

): Promise<

Integration

>

Updates an existing Integration in the Book.

Returns The updated Integration object

Parameters:
Name
Description
integration

The Integration wrapped plain json

Collection

This class defines a Collection of Books.

addBooks(books:

Book

[]): Promise<

Book

[]>

Adds Books to this Collection.

Returns The added Book objects

create(): Promise<

Collection

>

Performs create new Collection.

Returns The created Collection object

getBooks():

Book

[]

Returns All Books of this collection.

getId():

string

|

undefined

Returns The id of this Collection

getName():

string

|

undefined

Returns The name of this Collection

getOwnerUsername():

string

|

undefined

Gets the username of the owner of this Collection

Returns The Collection’s owner username

getPermission():

Permission

|

undefined

Gets the user permission for this Collection

Returns The permission for the current user

getUpdatedAt():

string

|

undefined

Gets the last update date of this Collection

Returns The Collection’s last update timestamp, in milliseconds

json():

bkper.Collection

Returns The wrapped plain json object

remove(): Promise<

Book

[]>

Performs delete Collection.

Returns The list of Books the user has access to that were affected by the deletion of this Collection

removeBooks(books:

Book

[]): Promise<

Book

[]>

Removes Books from this Collection.

Returns The removed Book objects

setName(name:

string

):

Collection

Sets the name of the Collection.

Returns This Collection, for chainning.

update(): Promise<

Collection

>

Performs update Collection, applying pending changes.

Returns The updated Collection object

Connection

This class defines a Connection from an User to an external service.

clearTokenProperties():

void

Cleans any token property stored in the Connection.

create(): Promise<

Connection

>

Performs create new Connection.

Returns The created Connection, for chaining

deleteProperty(key:

string

):

Connection

Deletes a custom property stored in the Connection.

Returns The Connection, for chainning

Parameters:
Name
Description
key

The property key

getAgentId():

string

|

undefined

Gets the agentId of the Connection.

Returns The Connection’s agentId

getDateAddedMs():

string

|

undefined

Gets the date when the Connection was added.

Returns The Connection add date in milliseconds

getEmail():

string

|

undefined

Gets the email of the owner of the Connection.

Returns The Connection owner’s email

getId():

string

|

undefined

Gets the id of the Connection.

Returns The Connection’s id

getIntegrations(): Promise<

Integration

[]>

Gets the existing Integrations on the Connection.

Returns The existing Integration objects

Gets the logo of the Connection.

Returns The Connection logo

getName():

string

|

undefined

Gets the name of the Connection.

Returns The Connection name

getProperties(): any

Gets the custom properties stored in the Connection

Returns Object with key/value pair properties

getProperty(keys:

string

[]):

string

|

undefined

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

Returns The retrieved property value

Parameters:
Name
Description
keys

The property key

getPropertyKeys():

string

[]

Gets the custom properties keys stored in the Connection.

Returns The retrieved property keys

getType(): | |

undefined

Gets the type of the Connection.

Returns The Connection type

getUUID():

string

|

undefined

Gets the universal unique identifier of this Connection.

Returns The Connection’s universal unique identifier name

json():

bkper.Connection

Returns An immutable copy of the json payload

remove(): Promise<

Connection

>

Performs remove Connection.

Returns The removed Connection object

setAgentId(agentId:

string

):

Connection

Sets the Connection agentId.

Returns The Connection, for chainning

Parameters:
Name
Description
agentId

The Connection agentId

setName(name:

string

):

Connection

Sets the name of the Connection.

Returns The Connection, for chainning

Parameters:
Name
Description
name

The name of the Connection

setProperties(properties: any):

Connection

Sets the custom properties of the Connection.

Returns The Connection, for chainning

Parameters:
Name
Description
properties

Object with key/value pair properties

setProperty(key:

string

, value:

string

|

null

):

Connection

Sets a custom property in the Connection.

Returns The Connection, for chaining

Parameters:
Name
Description
key

The property key

value

The property value

setType(type: |):

Connection

Sets the Connection type.

Returns The Connection, for chainning

Parameters:
Name
Description
type

The Connection type

setUUID(uuid:

string

):

Connection

Sets the universal unique identifier of the Connection.

Returns The Connection, for chainning

Parameters:
Name
Description
uuid

The universal unique identifier of the Connection

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<

File

>

Perform create new File.

getContent(): Promise<

string

|

undefined

>

Gets the file content Base64 encoded

getContentType():

string

|

undefined

Gets the File content type

getId():

string

|

undefined

Gets the File id

getName():

string

|

undefined

Gets the File name

getSize():

number

|

undefined

Gets the file size in bytes

getUrl():

string

|

undefined

Gets the file serving url for accessing via browser

json():

bkper.File

Returns An immutable copy of the json payload

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<

Group

>

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<

Account

[]>

Returns All Accounts of this group.

getId():

string

|

undefined

Returns The id of this Group

getName():

string

|

undefined

Returns The name of this Group

getNormalizedName():

string

Returns The name of this group without spaces and special characters

getParent(): Promise<

Group

|

undefined

>

Returns The parent Group

getProperties(): any

Gets the custom properties stored in this Group

getProperty(keys:

string

[]):

string

|

undefined

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 the accounts of this group. Null if mixed

hasAccounts():

boolean

|

undefined

Returns True if this group has any account in it

isHidden():

boolean

|

undefined

Tell if the Group is hidden on main transactions menu

json():

bkper.Group

Returns An immutable copy of the json payload

remove(): Promise<

Group

>

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.

setParent(group:

Group

|

null

|

undefined

):

Group

Sets the parent 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

|

null

):

Group

Sets a custom property in the Group.

Parameters:
Name
Description
key

The property key

value

The property value

update(): Promise<

Group

>

Perform update group, applying pending changes.

Integration

This class defines a Integration from an User to an external service.

deleteProperty(key:

string

):

Integration

Deletes a custom property stored in the Integration.

Returns The Integration, for chainning

Parameters:
Name
Description
key

The property key

getAddedBy():

string

|

undefined

Gets the name of the user who added the Integration.

Returns The user name of who added the Integration

getAgentId():

string

|

undefined

Gets the agent id of the Integration.

Returns The Integration’s agent id

getBookId():

string

|

undefined

Gets the Book id of the Integration.

Returns The Integration’s Book id

getDateAddedMs():

string

|

undefined

Gets the date when the Integration was added.

Returns The Integration add date in milliseconds

getId():

string

|

undefined

Gets the id of the Integration.

Returns This Integration’s id

getLastUpdateMs():

string

|

undefined

Gets the date when the Integration was last updated.

Returns The Integration last update date in milliseconds

Gets the logo of the Integration.

Returns The Integration’s logo

getName():

string

|

undefined

Gets the name of the Integration.

Returns The Integration’s name

getProperties(): any

Gets the custom properties stored in the Integration.

Returns Object with key/value pair properties

getProperty(keys:

string

[]):

string

|

undefined

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

Returns The retrieved property value

Parameters:
Name
Description
keys

The property key

json():

bkper.Integration

Returns An immutable copy of the json payload

remove(): Promise<

Integration

>

Performs remove Integration.

Returns The removed Integration object

setProperties(properties: any):

Integration

Sets the custom properties of the Integration.

Returns The Integration, for chainning

Parameters:
Name
Description
properties

Object with key/value pair properties

setProperty(key:

string

, value:

string

|

null

):

Integration

Sets a custom property in the Integration.

Returns The Integration, for chaining

Parameters:
Name
Description
key

The property key

value

The property value

Template

This class defines a Template.

A Template is a pre-configured setup for Books and associated Google Sheets that provides users with a starting point for specific accounting or financial management needs.

getBookId():

string

|

undefined

Gets the bookId of the Book associated with the Template.

Returns The bookId of the Book associated with the Template

Gets the link of the Book associated with the Template.

Returns The link of the Book associated with the Template

getCategory():

string

|

undefined

Gets the category of the Template.

Returns The Template’s category. Example: “PERSONAL”, “BUSINESS”, etc

getDescription():

string

|

undefined

Gets the description of the Template.

Returns The Template’s description

getImageUrl():

string

|

undefined

Gets the url of the image of the Template.

Returns The url of the Template’s image

getName():

string

|

undefined

Gets the name of the Template.

Returns The Template’s name

Gets the link of the Google Sheets spreadsheet associated with the Template.

Returns The link of the Google Sheets spreadsheet associated with the Template

getTimesUsed():

number

Gets the times the Template has been used.

Returns The number of times the Template has been used

json():

bkper.Template

Returns An immutable copy of the json payload

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

):

Transaction

Adds a file attachment to the Transaction.

Files MUST be previously created in the Book.

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<

Transaction

>

Perform check transaction.

create(): Promise<

Transaction

>

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

|

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

Amount

|

undefined

>

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

|

undefined

Returns The id of the agent that created this transaction

getAmount():

Amount

|

undefined

Returns The amount of the transaction.

getBook():

Book

Returns The book 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<

Account

|

undefined

>

Returns The credit account. The same as origin account.

getCreditAccountName(): Promise<

string

|

undefined

>

Returns The credit account name.

getCreditAmount(account:

Account

|

string

): Promise<

Amount

|

undefined

>

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

|

undefined

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

getDateFormatted():

string

|

undefined

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

|

undefined

Returns The Transaction date number, in format YYYYMMDD.

getDebitAccount(): Promise<

Account

|

undefined

>

Returns The debit account. The same as destination account.

getDebitAccountName(): Promise<

string

|

undefined

>

Returns The debit account name.

getDebitAmount(account:

Account

|

string

): Promise<

Amount

|

undefined

>

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

|

undefined

Returns The id of the Transaction.

getOtherAccount(account:

Account

|

string

): Promise<

Account

|

undefined

>

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<

string

|

undefined

>

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

|

undefined

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

Parameters:
Name
Description
keys

The property key

getPropertyKeys():

string

[]

Gets the custom properties keys stored in this Transaction.

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

|

undefined

Returns True if transaction is checked.

isCredit(account?:

Account

): Promise<

boolean

>

Tell if the given account is credit on the transaction

Parameters:
Name
Description
account

The account object

isDebit(account?:

Account

): Promise<

boolean

>

Tell if the given account is debit on the transaction

Parameters:
Name
Description
account

The account object

isPosted():

boolean

|

undefined

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

isTrashed():

boolean

|

undefined

Returns True if transaction is in trash.

json():

bkper.Transaction

Returns An immutable copy of the json payload

post(): Promise<

Transaction

>

Perform post transaction, changing credit and debit Account balances.

setAmount(amount:

Amount

|

number

|

string

):

Transaction

Sets the amount of the Transaction.

Returns This Transaction, for chainning.

setChecked(checked:

boolean

):

Transaction

Set the check state of the Transaction.

Returns This Transaction, for chainning.

Parameters:
Name
Description
checked

The check state.

setCreditAccount(account:

Account

|

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

|

bkper.Account

):

Transaction

Sets the debit/destination 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

|

null

):

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

|

bkper.Account

):

Transaction

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

Returns This Transaction, for chainning.

Parameters:
Name
Description
account

Account id, name or object.

trash(): Promise<

Transaction

>

Trash the transaction.

uncheck(): Promise<

Transaction

>

Perform uncheck transaction.

untrash(): Promise<

Transaction

>

Untrash the transaction.

update(): Promise<

Transaction

>

Upddate transaction, applying pending changes.

TransactionList

A list associated with a transaction query.

getAccount(): Promise<

Account

|

undefined

>

Retrieves the account associated with the query, when filtering by account.

getCursor():

string

|

undefined

Returns The cursor associated with the query for pagination.

getFirst():

Transaction

|

undefined

Returns The first Transaction in the list.

getItems():

Transaction

[]

Get the transactions in the list.

Returns An array of Transaction objects.

size():

number

Get the total number of transactions in the list.

Returns The total number of transactions.

User

This class defines a User.

getConnection(id:

string

): Promise<

Connection

>

Gets a Connection of the User.

Returns The retrieved Connection object

Parameters:
Name
Description
id

The Connection’s id

getConnections(): Promise<

Connection

[]>

Gets the Connections of the User.

Returns The retrieved Connection objects

getDaysLeftInTrial():

number

|

undefined

Gets the days left in User’s trial.

Returns The User’s days left in trial

getEmail():

string

|

undefined

Gets the email of the User.

Returns The User’s email

getFullName():

string

|

undefined

Gets the full name of the User.

Returns The User’s full name

getHostedDomain():

string

|

undefined

Gets the hosted domain of the User.

Returns The User’s hosted domain

getId():

string

|

undefined

Gets the id of the User.

Returns The User’s id

getName():

string

|

undefined

Gets the name of the User.

Returns The User’s name

hasStartedTrial():

boolean

|

undefined

Tells if the User has started the trial.

Returns True if the User has started the trial

hasUsedConnections():

boolean

|

undefined

Tells if the User has already used Connections.

Returns True if the User has already used Connections

isFree():

boolean

|

undefined

Tells if the User is in the free plan.

Returns True if the User is in the free plan

json():

bkper.User

Returns An immutable copy of the json payload

Config

This class defines the Bkper API Config.

apiBaseUrl():

Sets the base api url. Default to https://app.bkper.com/_ah/api/bkper

apiKeyProvider(): Promise<

string

>

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.

oauthTokenProvider(): Promise<

string

|

undefined

>

Issue a valid OAuth2 access token with https://www.googleapis.com/auth/userinfo.email scope authorized.

requestErrorHandler(error:

any

):

any

Custom request error handler

param error The error object of the failed request.

requestHeadersProvider(): Promise<any>

Provides additional headers to append to the API request

requestRetryHandler(status?:

number

, error?:

any

, attempt?:

number

): Promise<

void

>

Custom request retry handler.

This function is called when a request fails and needs to be retried. It provides the HTTP status code, error message, and the number of retry attempts made so far.

param code The HTTP status code of the failed request.

param error The error object of the failed request.

param attempt The number of retry attempts made so far.

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

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.

Visibility Enum

Enum representing the visibility of a Book

Name
Description
PRIVATE

The book can be accessed by the owner and collaborators

PUBLIC

The book can be accessed by anyone with the link