# Transaction

## Extends

- `Transaction`

### payload

```ts
payload: Transaction;
```

The underlying payload data for this resource

#### Inherited from

```ts
Bkper.Transaction.payload
```

### addFile()

```ts
addFile(file): Transaction;
```

Add a File attachment to the Transaction.

Files not previously created in the Book will be automatically created when the Transaction is persisted.

#### Parameters

| Parameter | Type |
| :------ | :------ |
| `file` | `any` |

#### Returns

`Transaction`

This Transaction, for chainning.

#### Inherited from

```ts
Bkper.Transaction.addFile
```

***

### addRemoteId()

```ts
addRemoteId(remoteId): Transaction;
```

Add a remote id to the Transaction.

#### Parameters

| Parameter | Type |
| :------ | :------ |
| `remoteId` | `string` |

#### Returns

`Transaction`

This Transaction, for chainning.

#### Inherited from

```ts
Bkper.Transaction.addRemoteId
```

***

### addUrl()

```ts
addUrl(url): Transaction;
```

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

#### Parameters

| Parameter | Type |
| :------ | :------ |
| `url` | `string` |

#### Returns

`Transaction`

This Transaction, for chainning.

#### Inherited from

```ts
Bkper.Transaction.addUrl
```

***

### check()

```ts
check(): Transaction;
```

Perform check transaction.

#### Returns

`Transaction`

#### Inherited from

```ts
Bkper.Transaction.check
```

***

### create()

```ts
create(): Transaction;
```

Perform create new draft transaction.

#### Returns

`Transaction`

#### Inherited from

```ts
Bkper.Transaction.create
```

***

### deleteProperty()

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

Deletes a custom property.

#### Parameters

| Parameter | Type |
| :------ | :------ |
| `key` | `string` |

#### Returns

`this`

This resource, for chaining

#### Inherited from

```ts
Bkper.Transaction.deleteProperty
```

***

### from()

```ts
from(account): Transaction;
```

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

#### Parameters

| Parameter | Type |
| :------ | :------ |
| `account` | `string` \| `Account` |

#### Returns

`Transaction`

This Transaction, for chainning.

#### Inherited from

```ts
Bkper.Transaction.from
```

***

### getAccountBalance()

```ts
getAccountBalance(raw?): Amount;
```

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

| Parameter | Type |
| :------ | :------ |
| `raw?` | `boolean` |

#### Returns

`Amount`

#### Inherited from

```ts
Bkper.Transaction.getAccountBalance
```

***

### getAgentId()

```ts
getAgentId(): string;
```

#### Returns

`string`

The id of the agent that created this transaction

#### Inherited from

```ts
Bkper.Transaction.getAgentId
```

***

### getAmount()

```ts
getAmount(): Amount;
```

#### Returns

`Amount`

The amount of the transaction.

#### Inherited from

```ts
Bkper.Transaction.getAmount
```

***

### getCreatedAt()

```ts
getCreatedAt(): Date;
```

#### Returns

`Date`

The date the transaction was created.

#### Inherited from

```ts
Bkper.Transaction.getCreatedAt
```

***

### getCreatedAtFormatted()

```ts
getCreatedAtFormatted(): string;
```

#### Returns

`string`

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

#### Inherited from

```ts
Bkper.Transaction.getCreatedAtFormatted
```

***

### getCreditAccount()

```ts
getCreditAccount(): Account;
```

#### Returns

`Account`

The credit account. The same as origin account.

#### Inherited from

```ts
Bkper.Transaction.getCreditAccount
```

***

### getCreditAccountName()

```ts
getCreditAccountName(): string;
```

#### Returns

`string`

The credit account name.

#### Inherited from

```ts
Bkper.Transaction.getCreditAccountName
```

***

### getCreditAmount()

```ts
getCreditAmount(account): Amount;
```

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

#### Parameters

| Parameter | Type |
| :------ | :------ |
| `account` | `string` \| `Account` |

#### Returns

`Amount`

#### Inherited from

```ts
Bkper.Transaction.getCreditAmount
```

***

### getDate()

```ts
getDate(): string;
```

#### Returns

`string`

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

#### Inherited from

```ts
Bkper.Transaction.getDate
```

***

### getDateFormatted()

```ts
getDateFormatted(): string;
```

#### Returns

`string`

The Transaction date, formatted on the date pattern of the [[Book]].

#### Inherited from

```ts
Bkper.Transaction.getDateFormatted
```

***

### getDateObject()

```ts
getDateObject(): Date;
```

#### Returns

`Date`

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

#### Inherited from

```ts
Bkper.Transaction.getDateObject
```

***

### getDateValue()

```ts
getDateValue(): number;
```

#### Returns

`number`

The Transaction date number, in format YYYYMMDD.

#### Inherited from

```ts
Bkper.Transaction.getDateValue
```

***

### getDebitAccount()

```ts
getDebitAccount(): Account;
```

#### Returns

`Account`

The debit account. The same as destination account.

#### Inherited from

```ts
Bkper.Transaction.getDebitAccount
```

***

### getDebitAccountName()

```ts
getDebitAccountName(): string;
```

#### Returns

`string`

The debit account name.

#### Inherited from

```ts
Bkper.Transaction.getDebitAccountName
```

***

### getDebitAmount()

```ts
getDebitAmount(account): Amount;
```

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

#### Parameters

| Parameter | Type |
| :------ | :------ |
| `account` | `string` \| `Account` |

#### Returns

`Amount`

#### Inherited from

```ts
Bkper.Transaction.getDebitAmount
```

***

### getDescription()

```ts
getDescription(): string;
```

#### Returns

`string`

The description of this transaction.

#### Inherited from

```ts
Bkper.Transaction.getDescription
```

***

### getFiles()

```ts
getFiles(): File[];
```

#### Returns

`File`[]

The files attached to the transaction.

#### Inherited from

```ts
Bkper.Transaction.getFiles
```

***

### getId()

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

#### Returns

`string`

The id of the Transaction.

#### Inherited from

```ts
Bkper.Transaction.getId
```

***

### ~~getInformedDate()~~

```ts
getInformedDate(): Date;
```

> **Caution: Deprecated**
> Use getDateObject instead.
#### Returns

`Date`

The date the user informed for this transaction, adjusted to book's time zone.

#### Inherited from

```ts
Bkper.Transaction.getInformedDate
```

***

### ~~getInformedDateText()~~

```ts
getInformedDateText(): string;
```

> **Caution: Deprecated**
> use getDateFormatted instead
#### Returns

`string`

The date the user informed for this transaction, formatted according to the date pattern of [[Book]].

#### Inherited from

```ts
Bkper.Transaction.getInformedDateText
```

***

### ~~getInformedDateValue()~~

```ts
getInformedDateValue(): number;
```

> **Caution: Deprecated**
> use getDateValue instead.
#### Returns

`number`

The date numbe. The number format is YYYYMMDD.

#### Inherited from

```ts
Bkper.Transaction.getInformedDateValue
```

***

### getOtherAccount()

```ts
getOtherAccount(account): Account;
```

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

#### Parameters

| Parameter | Type |
| :------ | :------ |
| `account` | `string` \| `Account` |

#### Returns

`Account`

#### Inherited from

```ts
Bkper.Transaction.getOtherAccount
```

***

### getOtherAccountName()

```ts
getOtherAccountName(account): string;
```

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

#### Parameters

| Parameter | Type |
| :------ | :------ |
| `account` | `string` \| `Account` |

#### Returns

`string`

#### Inherited from

```ts
Bkper.Transaction.getOtherAccountName
```

***

### ~~getPostDate()~~

```ts
getPostDate(): Date;
```

> **Caution: Deprecated**
> use getCreatedAt instead.
#### Returns

`Date`

The date time user has recorded/posted this transaction.

#### Inherited from

```ts
Bkper.Transaction.getPostDate
```

***

### ~~getPostDateText()~~

```ts
getPostDateText(): string;
```

> **Caution: Deprecated**
> use getCreatedAtFormatted instead.
#### Returns

`string`

The date time user has recorded/posted this transaction, formatted according to the date pattern of [[Book]].

#### Inherited from

```ts
Bkper.Transaction.getPostDateText
```

***

### getProperties()

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

Gets the custom properties stored in this resource.

#### Returns

`object`

Object with key/value pair properties

#### Inherited from

```ts
Bkper.Transaction.getProperties
```

***

### getProperty()

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

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

#### Parameters

| Parameter | Type |
| :------ | :------ |
| ...`keys` | `string`[] |

#### Returns

`string`

The property value or null if not found

#### Inherited from

```ts
Bkper.Transaction.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
Bkper.Transaction.getPropertyKeys
```

***

### getRemoteIds()

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

Remote ids are used to avoid duplication.

#### Returns

`string`[]

The remote ids of the Transaction.

#### Inherited from

```ts
Bkper.Transaction.getRemoteIds
```

***

### getStatus()

```ts
getStatus(): TransactionStatus;
```

Gets the status of the transaction.

The status is determined by precedence: TRASHED > DRAFT > CHECKED/UNCHECKED

#### Returns

[`TransactionStatus`](https://bkper.com/docs/api/bkper-gs/enumerations/transactionstatus.md)

The transaction status.

#### Inherited from

```ts
Bkper.Transaction.getStatus
```

***

### getTags()

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

#### Returns

`string`[]

All #hashtags used on the transaction.

#### Inherited from

```ts
Bkper.Transaction.getTags
```

***

### getUrls()

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

#### Returns

`string`[]

All urls of the transaction.

#### Inherited from

```ts
Bkper.Transaction.getUrls
```

***

### 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
Bkper.Transaction.getVisibleProperties
```

***

### hasTag()

```ts
hasTag(tag): boolean;
```

Check if the transaction has the specified tag.

#### Parameters

| Parameter | Type |
| :------ | :------ |
| `tag` | `string` |

#### Returns

`boolean`

#### Inherited from

```ts
Bkper.Transaction.hasTag
```

***

### isChecked()

```ts
isChecked(): boolean;
```

#### Returns

`boolean`

True if transaction is checked.

#### Inherited from

```ts
Bkper.Transaction.isChecked
```

***

### isCredit()

```ts
isCredit(account): boolean;
```

Tell if the given account is credit on the transaction

#### Parameters

| Parameter | Type |
| :------ | :------ |
| `account` | `Account` |

#### Returns

`boolean`

#### Inherited from

```ts
Bkper.Transaction.isCredit
```

***

### isDebit()

```ts
isDebit(account): boolean;
```

Tell if the given account is debit on the transaction

#### Parameters

| Parameter | Type |
| :------ | :------ |
| `account` | `Account` |

#### Returns

`boolean`

#### Inherited from

```ts
Bkper.Transaction.isDebit
```

***

### isLocked()

```ts
isLocked(): boolean;
```

#### Returns

`boolean`

True if a transaction is locked by the book lock/closing date

#### Inherited from

```ts
Bkper.Transaction.isLocked
```

***

### isPosted()

```ts
isPosted(): boolean;
```

#### Returns

`boolean`

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

#### Inherited from

```ts
Bkper.Transaction.isPosted
```

***

### isTrashed()

```ts
isTrashed(): boolean;
```

#### Returns

`boolean`

True if transaction is in trash.

#### Inherited from

```ts
Bkper.Transaction.isTrashed
```

***

### json()

```ts
json(): Transaction;
```

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

#### Returns

`Transaction`

An immutable copy of the json payload

#### Inherited from

```ts
Bkper.Transaction.json
```

***

### post()

```ts
post(): Transaction;
```

Perform post transaction, changing credit and debit [[Account]] balances.

#### Returns

`Transaction`

#### Inherited from

```ts
Bkper.Transaction.post
```

***

### ~~remove()~~

```ts
remove(): Transaction;
```

Remove the transaction, sending to trash.

> **Caution: Deprecated**
> This API is no longer supported and may be removed in a future release.
#### Returns

`Transaction`

#### Inherited from

```ts
Bkper.Transaction.remove
```

***

### ~~restore()~~

```ts
restore(): Transaction;
```

Restore the transaction from trash.

> **Caution: Deprecated**
> This API is no longer supported and may be removed in a future release.
#### Returns

`Transaction`

#### Inherited from

```ts
Bkper.Transaction.restore
```

***

### setAmount()

```ts
setAmount(amount): Transaction;
```

Set the amount of the Transaction.

#### Parameters

| Parameter | Type |
| :------ | :------ |
| `amount` | `string` \| `number` \| `Amount` |

#### Returns

`Transaction`

This Transaction, for chainning.

#### Inherited from

```ts
Bkper.Transaction.setAmount
```

***

### setChecked()

```ts
setChecked(checked): Transaction;
```

Set the check state of the Transaction.

#### Parameters

| Parameter | Type |
| :------ | :------ |
| `checked` | `boolean` |

#### Returns

`Transaction`

This Transaction, for chainning.

#### Inherited from

```ts
Bkper.Transaction.setChecked
```

***

### setCreditAccount()

```ts
setCreditAccount(account): Transaction;
```

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

#### Parameters

| Parameter | Type |
| :------ | :------ |
| `account` | `string` \| `Account` |

#### Returns

`Transaction`

This Transaction, for chainning.

#### Inherited from

```ts
Bkper.Transaction.setCreditAccount
```

***

### setDate()

```ts
setDate(date): Transaction;
```

Set the date of the Transaction.

#### Parameters

| Parameter | Type |
| :------ | :------ |
| `date` | `string` \| `Date` |

#### Returns

`Transaction`

This Transaction, for chainning

#### Inherited from

```ts
Bkper.Transaction.setDate
```

***

### setDebitAccount()

```ts
setDebitAccount(account): Transaction;
```

Set the debit/destination Account of the Transaction. Same as to().

#### Parameters

| Parameter | Type |
| :------ | :------ |
| `account` | `string` \| `Account` |

#### Returns

`Transaction`

This Transaction, for chainning.

#### Inherited from

```ts
Bkper.Transaction.setDebitAccount
```

***

### setDescription()

```ts
setDescription(description): Transaction;
```

Set the description of the Transaction.

#### Parameters

| Parameter | Type |
| :------ | :------ |
| `description` | `string` |

#### Returns

`Transaction`

This Transaction, for chainning.

#### Inherited from

```ts
Bkper.Transaction.setDescription
```

***

### setProperties()

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

Sets the custom properties of this resource.

#### Parameters

| Parameter | Type |
| :------ | :------ |
| `properties` | \{ \[`key`: `string`\]: `string`; \} |

#### Returns

`this`

This resource, for chaining

#### Inherited from

```ts
Bkper.Transaction.setProperties
```

***

### setProperty()

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

Sets a custom property in this resource.

#### Parameters

| Parameter | Type |
| :------ | :------ |
| `key` | `string` |
| `value` | `string` |

#### Returns

`this`

This resource, for chaining

#### Inherited from

```ts
Bkper.Transaction.setProperty
```

***

### setUrls()

```ts
setUrls(urls): Transaction;
```

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

#### Parameters

| Parameter | Type |
| :------ | :------ |
| `urls` | `string`[] |

#### Returns

`Transaction`

This Transaction, for chainning.

#### Inherited from

```ts
Bkper.Transaction.setUrls
```

***

### 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 |
| :------ | :------ |
| `properties` | \{ \[`key`: `string`\]: `string`; \} |

#### Returns

`this`

This resource, for chaining

#### Inherited from

```ts
Bkper.Transaction.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 |
| :------ | :------ |
| `key` | `string` |
| `value` | `string` \| `null` |

#### Returns

`this`

This resource, for chaining

#### Inherited from

```ts
Bkper.Transaction.setVisibleProperty
```

***

### to()

```ts
to(account): Transaction;
```

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

#### Parameters

| Parameter | Type |
| :------ | :------ |
| `account` | `string` \| `Account` |

#### Returns

`Transaction`

This Transaction, for chainning.

#### Inherited from

```ts
Bkper.Transaction.to
```

***

### trash()

```ts
trash(): Transaction;
```

Perform trash transaction.

#### Returns

`Transaction`

#### Inherited from

```ts
Bkper.Transaction.trash
```

***

### uncheck()

```ts
uncheck(): Transaction;
```

Perform uncheck transaction.

#### Returns

`Transaction`

#### Inherited from

```ts
Bkper.Transaction.uncheck
```

***

### untrash()

```ts
untrash(): Transaction;
```

Perform untrash transaction.

#### Returns

`Transaction`

#### Inherited from

```ts
Bkper.Transaction.untrash
```

***

### update()

```ts
update(): Transaction;
```

Upddate transaction, applying pending changes.

#### Returns

`Transaction`

#### Inherited from

```ts
Bkper.Transaction.update
```
