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 chainning.
Add a remote id to the Transaction.
Returns This Transaction, for chainning.
Add a url to the Transaction. Url starts with https://
Returns This Transaction, for chainning.
Perform check transaction.
Perform create new draft transaction.
Delete a custom property
Returns This Transaction, for chainning.
Sets the credit/origin Account of the Transaction. Same as setCreditAccount().
Returns This Transaction, for chainning.
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.
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.
Returns The amount of the transaction, formatted according to the Book format.
Returns The book of the Transaction.
Returns The date the transaction was created.
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.
account
The account object, id or name.
getDate():
string
|
undefined
Returns The Transaction date, in ISO format yyyy-MM-dd.
Returns The Transaction date, formatted on the date pattern of the Book.
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.
account
The account object, id or name.
Returns The description of this transaction.
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.
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.
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
getPropertyKeys():
string
[]
Gets the custom properties keys stored in this Transaction.
Remote ids are used to avoid duplication.
Returns The remote ids of the Transaction.
Returns All #hashtags used on the transaction.
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
isDebit(
account?:
Account
):
Promise<
boolean
>
Tell if the given account is debit on the transaction
Returns True if a transaction is locked by the book lock/closing date
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.
Returns An immutable copy of the json payload
post():
Promise<
Transaction
>
Perform post transaction, changing credit and debit Account balances.
Sets the amount of the Transaction.
Returns This Transaction, for chainning.
Set the check state of the Transaction.
Returns This Transaction, for chainning.
Sets the credit/origin Account of the Transaction. Same as from().
Returns This Transaction, for chainning.
account
Account id, name or object.
Sets the date of the Transaction.
Returns This Transaction, for chainning
Sets the debit/destination Account of the Transaction. Same as to().
Returns This Transaction, for chainning.
account
Account id, name or object.
Sets the description of the Transaction.
Returns This Transaction, for chainning.
Sets the custom properties of the Transaction
Returns This Transaction, for chainning.
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.
Sets the Transaction urls. Url starts with https://
Returns This Transaction, for chainning.
Sets the debit/destination Account of the Transaction. Same as setDebitAccount().
Returns This Transaction, for chainning.
account
Account id, name or object.
Perform uncheck transaction.
Upddate transaction, applying pending changes.