# Book

A Book represents a [General Ledger](https://en.wikipedia.org/wiki/General_ledger) for a company or business, but can also represent a [Ledger](https://en.wikipedia.org/wiki/Ledger) for a project or department

It contains all [[Accounts]] where [[Transactions]] are recorded/posted;

## Extends

- `ResourceProperty`\<`bkper.Book`\>

### Constructor

```ts
new Book(payload?, config?): Book;
```

#### Parameters

| Parameter | Type |
| :------ | :------ |
| `payload?` | `Book` |
| `config?` | [`Config`](https://bkper.com/docs/api/bkper-js/interfaces/config.md) |

#### Returns

`Book`

#### Overrides

```ts
ResourceProperty<bkper.Book>.constructor
```

### payload

```ts
payload: Book;
```

The underlying payload data for this resource

#### Inherited from

```ts
ResourceProperty.payload
```

### audit()

```ts
audit(): void;
```

Trigger Balances Audit async process.

#### Returns

`void`

***

### batchCheckTransactions()

```ts
batchCheckTransactions(transactions): Promise<void>;
```

Batch check [[Transactions]] on the Book.

#### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| `transactions` | [`Transaction`](https://bkper.com/docs/api/bkper-js/classes/transaction.md)[] | The transactions to be checked |

#### Returns

`Promise`\<`void`\>

***

### batchCreateAccounts()

```ts
batchCreateAccounts(accounts): Promise;
```

Create [[Accounts]] on the Book, in batch.

#### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| `accounts` | [`Account`](https://bkper.com/docs/api/bkper-js/classes/account.md)[] | The accounts to be created |

#### Returns

`Promise`\<[`Account`](https://bkper.com/docs/api/bkper-js/classes/account.md)[]\>

The created Accounts

***

### batchCreateGroups()

```ts
batchCreateGroups(groups): Promise;
```

Create [[Groups]] on the Book, in batch.

#### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| `groups` | [`Group`](https://bkper.com/docs/api/bkper-js/classes/group.md)[] | The groups to be created |

#### Returns

`Promise`\<[`Group`](https://bkper.com/docs/api/bkper-js/classes/group.md)[]\>

The created Groups

***

### batchCreateTransactions()

```ts
batchCreateTransactions(transactions): Promise;
```

Batch create [[Transactions]] on the Book.

#### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| `transactions` | [`Transaction`](https://bkper.com/docs/api/bkper-js/classes/transaction.md)[] | The transactions to be created |

#### Returns

`Promise`\<[`Transaction`](https://bkper.com/docs/api/bkper-js/classes/transaction.md)[]\>

The created Transactions

***

### batchDeleteAccounts()

```ts
batchDeleteAccounts(accounts): Promise;
```

Delete [[Accounts]] on the Book, in batch.

#### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| `accounts` | [`Account`](https://bkper.com/docs/api/bkper-js/classes/account.md)[] | The accounts to be deleted |

#### Returns

`Promise`\<[`Account`](https://bkper.com/docs/api/bkper-js/classes/account.md)[]\>

The deleted Accounts

***

### batchPostTransactions()

```ts
batchPostTransactions(transactions): Promise<void>;
```

Batch post [[Transactions]] on the Book.

#### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| `transactions` | [`Transaction`](https://bkper.com/docs/api/bkper-js/classes/transaction.md)[] | The transactions to be posted |

#### Returns

`Promise`\<`void`\>

***

### batchReplayEvents()

```ts
batchReplayEvents(events, errorOnly?): Promise<void>;
```

Replay [[Events]] on the Book, in batch.

#### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| `events` | [`Event`](https://bkper.com/docs/api/bkper-js/classes/event.md)[] | The events to be replayed |
| `errorOnly?` | `boolean` | True to only replay events with errors |

#### Returns

`Promise`\<`void`\>

***

### batchTrashTransactions()

```ts
batchTrashTransactions(transactions, trashChecked?): Promise<void>;
```

Batch trash [[Transactions]] on the Book.

#### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| `transactions` | [`Transaction`](https://bkper.com/docs/api/bkper-js/classes/transaction.md)[] | The transactions to be trashed |
| `trashChecked?` | `boolean` | True to also trash checked transactions |

#### Returns

`Promise`\<`void`\>

***

### batchUncheckTransactions()

```ts
batchUncheckTransactions(transactions): Promise<void>;
```

Batch uncheck [[Transactions]] on the Book.

#### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| `transactions` | [`Transaction`](https://bkper.com/docs/api/bkper-js/classes/transaction.md)[] | The transactions to be unchecked |

#### Returns

`Promise`\<`void`\>

***

### batchUntrashTransactions()

```ts
batchUntrashTransactions(transactions): Promise<void>;
```

Batch untrash [[Transactions]] on the Book.

#### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| `transactions` | [`Transaction`](https://bkper.com/docs/api/bkper-js/classes/transaction.md)[] | The transactions to be untrashed |

#### Returns

`Promise`\<`void`\>

***

### batchUpdateAccounts()

```ts
batchUpdateAccounts(accounts): Promise;
```

Update [[Accounts]] on the Book, in batch.

#### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| `accounts` | [`Account`](https://bkper.com/docs/api/bkper-js/classes/account.md)[] | The accounts to be updated |

#### Returns

`Promise`\<[`Account`](https://bkper.com/docs/api/bkper-js/classes/account.md)[]\>

The updated Accounts

***

### batchUpdateTransactions()

```ts
batchUpdateTransactions(transactions, updateChecked?): Promise;
```

Batch update [[Transactions]] on the Book.

#### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| `transactions` | [`Transaction`](https://bkper.com/docs/api/bkper-js/classes/transaction.md)[] | The transactions to be updated |
| `updateChecked?` | `boolean` | True to also update checked transactions |

#### Returns

`Promise`\<[`Transaction`](https://bkper.com/docs/api/bkper-js/classes/transaction.md)[]\>

The updated draft Transactions

***

### copy()

```ts
copy(
   name, 
   copyTransactions?, 
fromDate?): Promise;
```

Creates a copy of this Book

#### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| `name` | `string` | The name for the copied book |
| `copyTransactions?` | `boolean` | True to copy transactions from the source book (user must be the Book owner) |
| `fromDate?` | `number` | Start date to consider if copying transactions (numeric value in YYYYMMDD format) |

#### Returns

`Promise`\<`Book`\>

The copied Book object

***

### countTransactions()

```ts
countTransactions(query?): Promise<number | undefined>;
```

Retrieve the number of transactions based on a query.

#### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| `query?` | `string` | The query string |

#### Returns

`Promise`\<`number` \| `undefined`\>

The number of matching transactions

***

### create()

```ts
create(): Promise;
```

Performs create new Book.

#### Returns

`Promise`\<`Book`\>

The created Book object

***

### createAccountsDataTable()

```ts
createAccountsDataTable(accounts?): Promise;
```

Create a [AccountsDataTableBuilder](https://bkper.com/docs/api/bkper-js/classes/accountsdatatablebuilder.md), to build two dimensional Array representations of [Account](https://bkper.com/docs/api/bkper-js/classes/account.md) dataset.

#### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| `accounts?` | [`Account`](https://bkper.com/docs/api/bkper-js/classes/account.md)[] | Optional array of accounts. If not provided, all accounts will be fetched. |

#### Returns

`Promise`\<[`AccountsDataTableBuilder`](https://bkper.com/docs/api/bkper-js/classes/accountsdatatablebuilder.md)\>

Accounts data table builder.

***

### createGroupsDataTable()

```ts
createGroupsDataTable(groups?): Promise;
```

Create a [GroupsDataTableBuilder](https://bkper.com/docs/api/bkper-js/classes/groupsdatatablebuilder.md), to build two dimensional Array representations of [Group](https://bkper.com/docs/api/bkper-js/classes/group.md) dataset.

#### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| `groups?` | [`Group`](https://bkper.com/docs/api/bkper-js/classes/group.md)[] | Optional array of groups. If not provided, all groups will be fetched. |

#### Returns

`Promise`\<[`GroupsDataTableBuilder`](https://bkper.com/docs/api/bkper-js/classes/groupsdatatablebuilder.md)\>

Groups data table builder.

***

### createIntegration()

```ts
createIntegration(integration): Promise;
```

Creates a new [[Integration]] in the Book.

#### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| `integration` | `Integration` \| [`Integration`](https://bkper.com/docs/api/bkper-js/classes/integration.md) | The [[Integration]] object or wrapped plain json |

#### Returns

`Promise`\<[`Integration`](https://bkper.com/docs/api/bkper-js/classes/integration.md)\>

The created [[Integration]] object

***

### createTransactionsDataTable()

```ts
createTransactionsDataTable(transactions, account?): TransactionsDataTableBuilder;
```

Create a [TransactionsDataTableBuilder](https://bkper.com/docs/api/bkper-js/classes/transactionsdatatablebuilder.md), to build two dimensional Array representations of [Transaction](https://bkper.com/docs/api/bkper-js/classes/transaction.md) dataset.

#### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| `transactions` | [`Transaction`](https://bkper.com/docs/api/bkper-js/classes/transaction.md)[] | Array of transactions to include in the table. |
| `account?` | [`Account`](https://bkper.com/docs/api/bkper-js/classes/account.md) | Optional account for balance column display. |

#### Returns

[`TransactionsDataTableBuilder`](https://bkper.com/docs/api/bkper-js/classes/transactionsdatatablebuilder.md)

Transactions data table builder.

***

### deleteProperty()

```ts
deleteProperty(key): this;
```

Deletes a custom property.

#### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| `key` | `string` | The property key |

#### Returns

`this`

This resource, for chaining

#### Inherited from

```ts
ResourceProperty.deleteProperty
```

***

### formatDate()

```ts
formatDate(date, timeZone?): string;
```

Formats a date according to date pattern of the Book.

#### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| `date` | `Date` | The date to format as string. |
| `timeZone?` | `string` | The output timezone of the result. Default to script's timeZone |

#### Returns

`string`

The formatted date

***

### formatValue()

```ts
formatValue(value): string;
```

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

#### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| `value` | \| `number` \| [`Amount`](https://bkper.com/docs/api/bkper-js/classes/amount.md) \| `null` \| `undefined` | The value to be formatted. |

#### Returns

`string`

The formatted value

***

### getAccount()

```ts
getAccount(idOrName?): Promise;
```

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.

#### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| `idOrName?` | `string` | The id or name of the Account |

#### Returns

`Promise`\<[`Account`](https://bkper.com/docs/api/bkper-js/classes/account.md) \| `undefined`\>

The matching Account object

#### Example

```typescript
// 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');
```

***

### getAccounts()

```ts
getAccounts(): Promise;
```

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

`Promise`\<[`Account`](https://bkper.com/docs/api/bkper-js/classes/account.md)[]\>

The retrieved [[Account]] objects

#### Example

```typescript
// 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()

```ts
getApps(): Promise;
```

Retrieve installed [[Apps]] for this Book.

#### Returns

`Promise`\<[`App`](https://bkper.com/docs/api/bkper-js/classes/app.md)[]\>

The retrieved Apps objects

***

### getAutoPost()

```ts
getAutoPost(): boolean | undefined;
```

Gets the auto post status of the Book.

#### Returns

`boolean` \| `undefined`

The auto post status of the Book

***

### getBacklog()

```ts
getBacklog(): Promise;
```

Gets the Backlog of this Book.

#### Returns

`Promise`\<[`Backlog`](https://bkper.com/docs/api/bkper-js/classes/backlog.md)\>

The Backlog object

***

### getBalancesReport()

```ts
getBalancesReport(query): Promise;
```

Create a [[BalancesReport]] based on query.

#### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| `query` | `string` | The balances report query |

#### Returns

`Promise`\<[`BalancesReport`](https://bkper.com/docs/api/bkper-js/classes/balancesreport.md)\>

The balances report

Example:

```js
var book = BkperApp.getBook("agtzfmJrcGVyLWhyZHITCxIGTGVkZ2VyGICAgPXjx7oKDA");

var balancesReport = book.getBalancesReport("group:'Equity' after:7/2018 before:8/2018");

var accountBalance = balancesReport.getBalancesContainer("Bank Account").getCumulativeBalance();
```

***

### getClosingDate()

```ts
getClosingDate(): string | undefined;
```

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

#### Returns

`string` \| `undefined`

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

***

### getCollaborators()

```ts
getCollaborators(): Promise;
```

Gets all collaborators of this Book.

#### Returns

`Promise`\<[`Collaborator`](https://bkper.com/docs/api/bkper-js/classes/collaborator.md)[]\>

Array of Collaborator objects

***

### getCollection()

```ts
getCollection(): Collection | undefined;
```

Gets the collection of this Book, if any.

#### Returns

[`Collection`](https://bkper.com/docs/api/bkper-js/classes/collection.md) \| `undefined`

The collection of this Book, if any

***

### getDatePattern()

```ts
getDatePattern(): string;
```

Gets the date pattern of the Book.

#### Returns

`string`

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

***

### getDecimalPlaces()

```ts
getDecimalPlaces(): number | undefined;
```

Gets the number of decimal places supported by this Book.

#### Returns

`number` \| `undefined`

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

***

### getDecimalSeparator()

```ts
getDecimalSeparator(): DecimalSeparator;
```

Gets the decimal separator of the Book.

#### Returns

[`DecimalSeparator`](https://bkper.com/docs/api/bkper-js/enumerations/decimalseparator.md)

The decimal separator of the Book

***

### getFile()

```ts
getFile(id): Promise;
```

Retrieve a file by id.

#### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| `id` | `string` | The file ID |

#### Returns

`Promise`\<[`File`](https://bkper.com/docs/api/bkper-js/classes/file.md) \| `undefined`\>

The [[File]] object

***

### getFractionDigits()

```ts
getFractionDigits(): number | undefined;
```

Gets the number of fraction digits supported by this Book.

#### Returns

`number` \| `undefined`

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

***

### getGroup()

```ts
getGroup(idOrName?): Promise;
```

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.

#### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| `idOrName?` | `string` | The id or name of the Group |

#### Returns

`Promise`\<[`Group`](https://bkper.com/docs/api/bkper-js/classes/group.md) \| `undefined`\>

The matching Group object

#### Example

```typescript
// 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());
```

***

### getGroups()

```ts
getGroups(): Promise;
```

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

`Promise`\<[`Group`](https://bkper.com/docs/api/bkper-js/classes/group.md)[]\>

The retrieved [[Group]] objects

#### Example

```typescript
// 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
```

***

### getId()

```ts
getId(): string;
```

Gets the unique identifier of this Book.

#### Returns

`string`

This Book's unique identifier

***

### getIntegrations()

```ts
getIntegrations(): Promise;
```

Gets the existing [[Integrations]] in the Book.

#### Returns

`Promise`\<[`Integration`](https://bkper.com/docs/api/bkper-js/classes/integration.md)[]\>

The retrieved Integration objects

***

### getLastUpdateMs()

```ts
getLastUpdateMs(): number | undefined;
```

Gets the last update date of the book, in milliseconds.

#### Returns

`number` \| `undefined`

The last update date of the book, in milliseconds

***

### getLockDate()

```ts
getLockDate(): string | undefined;
```

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

#### Returns

`string` \| `undefined`

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

***

### getLogoUrl()

```ts
getLogoUrl(): string | undefined;
```

Gets the logo URL of the Book owner's custom domain, if any.

#### Returns

`string` \| `undefined`

The logo URL, or undefined if the owner has no custom domain logo

***

### getName()

```ts
getName(): string | undefined;
```

Gets the name of this Book.

#### Returns

`string` \| `undefined`

The name of this Book

***

### getOwnerName()

```ts
getOwnerName(): string | undefined;
```

Gets the name of the owner of the Book.

#### Returns

`string` \| `undefined`

The name of the owner of the Book

***

### getPageSize()

```ts
getPageSize(): number | undefined;
```

Gets the transactions pagination page size.

#### Returns

`number` \| `undefined`

The transactions pagination page size

***

### getPeriod()

```ts
getPeriod(): Period;
```

Gets the period slice for balances visualization.

#### Returns

[`Period`](https://bkper.com/docs/api/bkper-js/enumerations/period.md)

The period slice for balances visualization

***

### getPeriodStartMonth()

```ts
getPeriodStartMonth(): Month;
```

Gets the start month when YEAR period is set.

#### Returns

[`Month`](https://bkper.com/docs/api/bkper-js/enumerations/month.md)

The start month when YEAR period is set

***

### getPermission()

```ts
getPermission(): Permission;
```

Gets the permission for the current user in this Book.

#### Returns

[`Permission`](https://bkper.com/docs/api/bkper-js/enumerations/permission.md)

The permission for the current user in this Book

***

### getProperties()

```ts
getProperties(): object;
```

Gets the custom properties stored in this resource.

#### Returns

`object`

Object with key/value pair properties

#### Inherited from

```ts
ResourceProperty.getProperties
```

***

### getProperty()

```ts
getProperty(...keys): string | undefined;
```

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

#### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| ...`keys` | `string`[] | The property keys to search for |

#### Returns

`string` \| `undefined`

The property value or undefined if not found

#### Inherited from

```ts
ResourceProperty.getProperty
```

***

### getPropertyKeys()

```ts
getPropertyKeys(): string[];
```

Gets the custom properties keys stored in this resource.

#### Returns

`string`[]

Array of property keys sorted alphabetically

#### Inherited from

```ts
ResourceProperty.getPropertyKeys
```

***

### getSavedQueries()

```ts
getSavedQueries(): Promise;
```

Gets the saved queries from this book.

#### Returns

`Promise`\<[`Query`](https://bkper.com/docs/api/bkper-js/classes/query.md)[]\>

The saved queries from this book

***

### getTimeZone()

```ts
getTimeZone(): string | undefined;
```

Gets the time zone of the Book.

#### Returns

`string` \| `undefined`

The time zone of the Book

***

### getTimeZoneOffset()

```ts
getTimeZoneOffset(): number | undefined;
```

Gets the time zone offset of the book, in minutes.

#### Returns

`number` \| `undefined`

The time zone offset of the book, in minutes

***

### getTotalTransactions()

```ts
getTotalTransactions(): number;
```

Gets the total number of posted transactions.

#### Returns

`number`

The total number of posted transactions

***

### getTotalTransactionsCurrentMonth()

```ts
getTotalTransactionsCurrentMonth(): number;
```

Gets the total number of posted transactions on current month.

#### Returns

`number`

The total number of posted transactions on current month

***

### getTotalTransactionsCurrentYear()

```ts
getTotalTransactionsCurrentYear(): number;
```

Gets the total number of posted transactions on current year.

#### Returns

`number`

The total number of posted transactions on current year

***

### getTransaction()

```ts
getTransaction(id): Promise;
```

Retrieve a transaction by id.

#### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| `id` | `string` | The transaction ID |

#### Returns

`Promise`\<[`Transaction`](https://bkper.com/docs/api/bkper-js/classes/transaction.md) \| `undefined`\>

The [[Transaction]] object

***

### getVisibility()

```ts
getVisibility(): Visibility;
```

Gets the visibility of the book.

#### Returns

[`Visibility`](https://bkper.com/docs/api/bkper-js/enumerations/visibility.md)

The visibility of the book

***

### getVisibleProperties()

```ts
getVisibleProperties(): object;
```

Gets the visible custom properties stored in this resource.
Hidden properties (those ending with "_") are excluded from the result.

#### Returns

`object`

Object with key/value pair properties, excluding hidden properties

#### Inherited from

```ts
ResourceProperty.getVisibleProperties
```

***

### json()

```ts
json(): Book;
```

Gets an immutable copy of the JSON payload for this resource.

#### Returns

`Book`

An immutable copy of the json payload

#### Inherited from

```ts
ResourceProperty.json
```

***

#### Call Signature

```ts
listEvents(options): Promise;
```

Lists events in the Book based on the provided options.

##### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| `options` | [`ListEventsOptions`](https://bkper.com/docs/api/bkper-js/interfaces/listeventsoptions.md) | The event list options |

##### Returns

`Promise`\<[`EventList`](https://bkper.com/docs/api/bkper-js/classes/eventlist.md)\>

An [[EventList]] object containing the list of events

#### Call Signature

```ts
listEvents(
   afterDate, 
   beforeDate, 
   onError, 
   resourceId, 
   limit, 
cursor?): Promise;
```

Lists events in the Book based on the provided parameters.

> **Caution: Deprecated**
> Use `listEvents(options)` instead.
##### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| `afterDate` | `string` \| `null` | The start date (inclusive) for the events search range, in [RFC3339](https://en.wikipedia.org/wiki/ISO_8601#RFC_3339) format. |
| `beforeDate` | `string` \| `null` | The end date (exclusive) for the events search range, in [RFC3339](https://en.wikipedia.org/wiki/ISO_8601#RFC_3339) format. |
| `onError` | `boolean` \| `null` | Whether to filter events by error responses. `true` returns events with at least one error response. `false` returns events with no error responses. `null` or `undefined` includes events regardless of error responses. Ignored when `resourceId` is set. |
| `resourceId` | `string` \| `null` | The ID of the event's resource (Transaction, Account, or Group). When set, `onError` is ignored. |
| `limit` | `number` | The maximum number of events to return. Defaults to `50`, maximum is `200`. |
| `cursor?` | `string` | The cursor for pagination. |

##### Returns

`Promise`\<[`EventList`](https://bkper.com/docs/api/bkper-js/classes/eventlist.md)\>

An [[EventList]] object containing the list of events

***

### listFiles()

```ts
listFiles(limit?, cursor?): Promise;
```

Lists files in the Book, for pagination.

#### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| `limit?` | `number` | The maximum number of files to return. Default to 100 |
| `cursor?` | `string` | The cursor for pagination |

#### Returns

`Promise`\<[`FileList`](https://bkper.com/docs/api/bkper-js/classes/filelist.md)\>

A [[FileList]] object containing the list of files

***

### listTransactions()

```ts
listTransactions(
   query?, 
   limit?, 
cursor?): Promise;
```

Lists transactions in the Book based on the provided query, limit, and cursor, for pagination.

#### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| `query?` | `string` | The query string to filter transactions |
| `limit?` | `number` | The maximum number of transactions to return. Default to 100, max to 1000 |
| `cursor?` | `string` | The cursor for pagination |

#### Returns

`Promise`\<[`TransactionList`](https://bkper.com/docs/api/bkper-js/classes/transactionlist.md)\>

A [[TransactionList]] object containing the list of transactions

***

### mergeTransactions()

```ts
mergeTransactions(transaction1, transaction2): Promise;
```

Merge two [[Transactions]] into a single new canonical transaction.

The merged transaction is created synchronously. Cleanup of the two
originals is scheduled asynchronously by the backend.

#### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| `transaction1` | \| `string` \| `Transaction` \| [`Transaction`](https://bkper.com/docs/api/bkper-js/classes/transaction.md) | The first transaction to merge. Accepts a wrapped [[Transaction]], a plain `bkper.Transaction` payload, or a transaction id. |
| `transaction2` | \| `string` \| `Transaction` \| [`Transaction`](https://bkper.com/docs/api/bkper-js/classes/transaction.md) | The second transaction to merge. Accepts a wrapped [[Transaction]], a plain `bkper.Transaction` payload, or a transaction id. |

#### Returns

`Promise`\<[`Transaction`](https://bkper.com/docs/api/bkper-js/classes/transaction.md)\>

The merged Transaction

***

### parseDate()

```ts
parseDate(date): Date;
```

Parse a date string according to date pattern and timezone of the Book. Also parse ISO yyyy-mm-dd format.

#### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| `date` | `string` | The date string to parse |

#### Returns

`Date`

The parsed Date object

***

### parseValue()

```ts
parseValue(value): Amount | undefined;
```

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

#### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| `value` | `string` | The value string to parse |

#### Returns

[`Amount`](https://bkper.com/docs/api/bkper-js/classes/amount.md) \| `undefined`

The parsed Amount or undefined if parsing fails

***

### remove()

```ts
remove(): Promise;
```

Warning!

Deletes this Book and all its data (transactions, accounts, groups). Book owner only.

#### Returns

`Promise`\<`Book`\>

This Book after deletion

***

### resolveAccessRequest()

```ts
resolveAccessRequest(accessRequestId): Promise;
```

Resolves an access request for this Book.

Resolving the request does not grant access. Call Collaborator.create
on the returned Collaborator to grant access to the Book.

#### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| `accessRequestId` | `string` | The access request id |

#### Returns

`Promise`\<[`Collaborator`](https://bkper.com/docs/api/bkper-js/classes/collaborator.md)\>

The matching [[Collaborator]] object

***

### round()

```ts
round(value): Amount;
```

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

#### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| `value` | `number` \| [`Amount`](https://bkper.com/docs/api/bkper-js/classes/amount.md) | The value to be rounded |

#### Returns

[`Amount`](https://bkper.com/docs/api/bkper-js/classes/amount.md)

The rounded value

***

### setAutoPost()

```ts
setAutoPost(autoPost): Book;
```

Sets the auto post status of the Book.

#### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| `autoPost` | `boolean` | The auto post status to set |

#### Returns

`Book`

This Book, for chaining

***

### setClosingDate()

```ts
setClosingDate(closingDate): Book;
```

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

#### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| `closingDate` | `string` \| `null` | The closing date to set in ISO format yyyy-MM-dd |

#### Returns

`Book`

This Book, for chaining

***

### setDatePattern()

```ts
setDatePattern(datePattern): Book;
```

Sets the date pattern of the Book. Current: dd/MM/yyyy | MM/dd/yyyy | yyyy/MM/dd

#### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| `datePattern` | `string` | The date pattern to set |

#### Returns

`Book`

This Book, for chaining

***

### setDecimalSeparator()

```ts
setDecimalSeparator(decimalSeparator): Book;
```

Sets the decimal separator of the Book

#### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| `decimalSeparator` | [`DecimalSeparator`](https://bkper.com/docs/api/bkper-js/enumerations/decimalseparator.md) | The decimal separator to set |

#### Returns

`Book`

This Book, for chaining

***

### setFractionDigits()

```ts
setFractionDigits(fractionDigits): Book;
```

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

#### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| `fractionDigits` | `number` | The number of fraction digits to set (0 to 8) |

#### Returns

`Book`

This Book, for chaining

***

### setLockDate()

```ts
setLockDate(lockDate): Book;
```

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

#### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| `lockDate` | `string` \| `null` | The lock date to set in ISO format yyyy-MM-dd |

#### Returns

`Book`

This Book, for chaining

***

### setName()

```ts
setName(name): Book;
```

Sets the name of the Book.

#### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| `name` | `string` | The name to set |

#### Returns

`Book`

This Book, for chaining

***

### setPageSize()

```ts
setPageSize(pageSize): Book;
```

Sets the transactions pagination page size.

#### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| `pageSize` | `number` | The page size to set |

#### Returns

`Book`

This Book, for chaining

***

### setPeriod()

```ts
setPeriod(period): Book;
```

Sets the period slice for balances visualization.

#### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| `period` | [`Period`](https://bkper.com/docs/api/bkper-js/enumerations/period.md) | The period to set |

#### Returns

`Book`

This Book, for chaining

***

### setPeriodStartMonth()

```ts
setPeriodStartMonth(month): Book;
```

Sets the start month when YEAR period is set.

#### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| `month` | [`Month`](https://bkper.com/docs/api/bkper-js/enumerations/month.md) | The start month to set |

#### Returns

`Book`

This Book, for chaining

***

### setProperties()

```ts
setProperties(properties): this;
```

Sets the custom properties of this resource.

#### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| `properties` | \{ \[`key`: `string`\]: `string`; \} | Object with key/value pair properties |

#### Returns

`this`

This resource, for chaining

#### Inherited from

```ts
ResourceProperty.setProperties
```

***

### setProperty()

```ts
setProperty(key, value): this;
```

Sets a custom property in this resource.

Property keys are normalized and validated by the API when saved. Keep keys
to 30 characters or fewer after normalization. Use a trailing underscore
(`_`) for hidden/internal properties.

#### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| `key` | `string` | The property key |
| `value` | `string` \| `null` \| `undefined` | The property value, or null/undefined to clean it |

#### Returns

`this`

This resource, for chaining

#### Inherited from

```ts
ResourceProperty.setProperty
```

***

### setTimeZone()

```ts
setTimeZone(timeZone): Book;
```

Sets the time zone of the Book.

#### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| `timeZone` | `string` | The time zone to set |

#### Returns

`Book`

This Book, for chaining

***

### setVisibility()

```ts
setVisibility(visibility): Book;
```

Sets the visibility of the book.

#### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| `visibility` | [`Visibility`](https://bkper.com/docs/api/bkper-js/enumerations/visibility.md) | The visibility to set |

#### Returns

`Book`

This Book, for chaining

***

### setVisibleProperties()

```ts
setVisibleProperties(properties): this;
```

Sets the custom properties of this resource, filtering out hidden properties.
Hidden properties are those whose keys end with an underscore "_".

#### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| `properties` | \{ \[`key`: `string`\]: `string`; \} | Object with key/value pair properties |

#### Returns

`this`

This resource, for chaining

#### Inherited from

```ts
ResourceProperty.setVisibleProperties
```

***

### setVisibleProperty()

```ts
setVisibleProperty(key, value): this;
```

Sets a custom property in this resource, filtering out hidden properties.
Hidden properties are those whose keys end with an underscore "_".

#### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| `key` | `string` | The property key |
| `value` | `string` \| `null` \| `undefined` | The property value, or null/undefined to clean it |

#### Returns

`this`

This resource, for chaining

#### Inherited from

```ts
ResourceProperty.setVisibleProperty
```

***

### update()

```ts
update(): Promise;
```

Perform update Book, applying pending changes.

#### Returns

`Promise`\<`Book`\>

The updated Book object

***

### updateIntegration()

```ts
updateIntegration(integration): Promise;
```

Updates an existing [[Integration]] in the Book.

#### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| `integration` | `Integration` | The [[Integration]] wrapped plain json |

#### Returns

`Promise`\<[`Integration`](https://bkper.com/docs/api/bkper-js/classes/integration.md)\>

The updated [[Integration]] object
