Class: Transaction

Transaction

This class defines a Transaction between credit and debit Accounts.

A Transaction is the main entity on the Double Entry Bookkeeping system.
Transactions are also used for Single Entry process when using #hashtags in its description.

new Transaction()

Methods

getAccountBalance(strict)

Gets the balance that the Account has at that informed date, 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 Type Argument Description
strict boolean <optional>
True to strict get the balance, no matter the credit nature of this Account.
See:

getAmount(format) → {number}

Parameters:
Name Type Description
format boolean Formats the amount according to decimal separator of book
Returns:
The amount of this transaction
Type
number

getCreditAccount() → {Account}

Returns:
The credit account. The same as origin account.
Type
Account

getCreditAccountName() → {string}

Returns:
The credit account name.
Type
string

getCreditAmount(account) → {number}

Parameters:
Name Type Description
account Account | string The account object, id or name
Returns:
The absolute amount of this transaction if the given account is at the credit side, else null
Type
number

getDebitAccount() → {Account}

Returns:
The debit account. The same as destination account.
Type
Account

getDebitAccountName() → {string}

Returns:
The debit account name.
Type
string

getDebitAmount(account) → {number}

Parameters:
Name Type Description
account Account | string The account object, id or name
Returns:
The absolute amount of this transaction if the given account is at the debit side, else null
Type
number

getDescription() → {string}

See:
  • {Transaction#setDescription}
Returns:
The description of this transaction
Type
string

getId() → {string}

Returns:
The id of this Transaction
Type
string

getInformedDate() → {Date}

Returns:
The date the user informed for this transaction, adjusted to book's time zone
Type
Date

getInformedDateText() → {string}

Returns:
The date the user informed for this transaction, formatted according to date pattern of book
Type
string

getInformedDateValue() → {number}

Returns:
The date the user informed for this transaction. The number format is YYYYMMDD
Type
number

getOtherAccount(account) → {Account}

Parameters:
Name Type Description
account Account | string The account object, id or name
Returns:
The account at the other side of the transaction given one side.
Type
Account

getOtherAccountName(account) → {Account}

Parameters:
Name Type Description
account Account | string The account object, id or name
Returns:
The account name at the other side of the transaction given one side.
Type
Account

getPostDate() → {Date}

Returns:
The date time user has recorded/posted this transaction
Type
Date

getTags() → {Array.<String>}

Returns:
All #hashtags used on this transaction
Type
Array.<String>

getUrls() → {Array.<String>}

Returns:
All urls used on this transaction
Type
Array.<String>

hasTag(tag) → {boolean}

Parameters:
Name Type Description
tag string The #hashtag to check
Returns:
true if has this tag
Type
boolean

isPosted() → {boolean}

Returns:
True if transaction is already posted. False otherwise.
Type
boolean