Transaction
This class defines a Transaction between credit and debit Accounts.
A Transaction is the main entity on the Double Entry Bookkeeping system.
Adds a file attachment to the Transaction.
Files MUST be previously created in the Book.
Returns This Transaction, for chaining
Add a remote id to the Transaction.
Returns This Transaction, for chaining
Add a url to the Transaction. Url starts with https://
Returns This Transaction, for chaining
Perform check transaction.
Returns This Transaction, for chaining
Perform create new draft transaction.
Returns This Transaction, for chaining
Delete a custom property
Returns This Transaction, for chaining
Sets the credit/origin Account of this Transaction. Same as setCreditAccount()
Returns This Transaction, for chaining
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.
Returns The account balance at the transaction date
raw
True to get the raw balance, no matter the credit nature of the Account
getAgentId():
string
|
undefined
Gets the unique identifier of the agent that created this transaction.
Returns The id of the agent that created this transaction
getAgentLogoUrl():
string
|
undefined
Gets the logo URL of the agent that created this transaction.
Returns The logo of the agent that created this transaction
getAgentLogoUrlDark():
string
|
undefined
Gets the dark mode logo URL of the agent that created this transaction.
Returns The logo of the agent that created this transaction in dark mode
getAgentName():
string
|
undefined
Gets the name of the agent that created this transaction.
Returns The name of the agent that created this transaction
getAmount():
Amount
|
undefined
Gets the amount of this Transaction.
Returns The amount of this Transaction
Gets the formatted amount of this Transaction according to the Book format.
Returns The amount of this Transaction, formatted according to the Book format
Gets the book associated with this transaction.
Returns The book of the Transaction
Gets the date when the transaction was created.
Returns The date the transaction was created
Gets the formatted creation date of the transaction.
Returns The date the transaction was created, formatted according to the date pattern of the Book
getCreditAccount():
Promise<
Account
|
undefined
>
Gets the credit account associated with this Transaction. Same as origin account
Returns The credit (origin) account
getCreditAccountName():
Promise<
string
|
undefined
>
Gets the name of this Transaction’s credit account.
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.
Returns The credit amount or undefined
account
The account object, id or name
getDate():
string
|
undefined
Gets the transaction date in ISO format.
Returns The Transaction date, in ISO format yyyy-MM-dd
Gets the transaction date formatted according to the book’s date pattern.
Returns The Transaction date, formatted on the date pattern of the Book
Gets the transaction date as a Date object in the book’s timezone.
Returns The Transaction Date object, on the time zone of the Book
getDateValue():
number
|
undefined
Gets the transaction date as a numeric value.
Returns The Transaction date number, in format YYYYMMDD
getDebitAccount():
Promise<
Account
|
undefined
>
Gets the debit account associated with this Transaction. Same as destination account
Returns The debit (destination) account
getDebitAccountName():
Promise<
string
|
undefined
>
Gets the name of this Transaction’s debit account.
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.
Returns The debit amount or undefined
account
The account object, id or name
Gets the description of this Transaction.
Returns The description of this Transaction
Gets all files attached to the transaction.
Returns The files attached to the transaction
getId():
string
|
undefined
Gets the unique identifier of the transaction.
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.
Returns The account at the other side of the transaction
account
The account object, id or name
getOtherAccountName(
account:
string
|
Account
):
Promise<
string
|
undefined
>
The Account name at the other side of this Transaction given the one in one side.
Returns The name of the Account at the other side
account
The Account object, id or name
getProperties():
any
Gets the custom properties stored in this Transaction.
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 property value or undefined if not found
getPropertyKeys():
string
[]
Gets the custom properties keys stored in this Transaction.
Returns Array of property keys
Gets the remote IDs associated with this transaction. Remote ids are used to avoid duplication.
Returns The remote ids of the Transaction
Gets all hashtags used in the transaction.
Returns All #hashtags used on the transaction
Gets the date when the transaction was last updated.
Returns The date the transaction was last updated
Gets the formatted last update date of the transaction.
Returns The date the transaction was last updated, formatted according to the date pattern of the Book
Gets all URLs associated with the transaction.
Returns All urls of the transaction
hasTag(
tag:
string
):
boolean
Check if the transaction has the specified tag.
Returns True if the transaction has the specified tag
isChecked():
boolean
|
undefined
Checks if the transaction is marked as checked.
Returns True if transaction is checked
isCredit(
account?:
Account
):
Promise<
boolean
>
Tell if the given account is credit on this Transaction
Returns True if the account is the credit account
isDebit(
account?:
Account
):
Promise<
boolean
>
Tell if the given account is debit on the Transaction
Returns True if the Account is the debit account
Checks if the transaction is locked by the book’s lock or closing date.
Returns True if a transaction is locked by the book lock/closing date
isPosted():
boolean
|
undefined
Checks if the transaction has been posted to the accounts.
Returns True if transaction was already posted to the accounts. False if is still a Draft
isTrashed():
boolean
|
undefined
Checks if the transaction is in the trash.
Returns True if transaction is in trash
Gets the JSON representation of the transaction.
Returns An immutable copy of the json payload
post():
Promise<
Transaction
>
Perform post transaction, changing credit and debit Account balances.
Returns This Transaction, for chaining
Sets the amount of this Transaction.
Returns This Transaction, for chaining
Set the check state of the Transaction.
Returns This Transaction, for chaining
Sets the credit/origin Account of this Transaction. Same as from()
Returns This Transaction, for chaining
Sets the date of the Transaction.
Returns This Transaction, for chaining
date
The date to set as string or Date object
Sets the debit/destination Account of this Transaction. Same as to()
Returns This Transaction, for chaining
Sets the description of the Transaction.
Returns This Transaction, for chaining
Sets the custom properties of the Transaction
Returns This Transaction, for chaining
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 chaining
Sets the Transaction urls. Url starts with https://
Returns This Transaction, for chaining
Sets the debit/destination Account of this Transaction. Same as setDebitAccount()
Returns This Transaction, for chaining
Trash the transaction.
Returns This Transaction, for chaining
Perform uncheck transaction.
Returns This Transaction, for chaining
Untrash the transaction.
Returns This Transaction, for chaining
Update transaction, applying pending changes.
Returns This Transaction, for chaining