Account
This class defines an Account of a [[Book]].
It maintains a balance of all amount credited and debited in it by [[Transactions]].
An Account can be grouped by [[Groups]].
Remarks
Account has no getBalance() method. To retrieve account balances, use
Book.getBalancesReport and read the resulting BalancesContainer.
Extends
ResourceProperty<bkper.Account>
Constructors
Constructor
new Account(book, payload?): Account;Parameters
| Parameter | Type |
|---|---|
book | Book |
payload? | Account |
Returns
Account
Overrides
ResourceProperty<bkper.Account>.constructorProperties
payload
payload: Account;The underlying payload data for this resource
Inherited from
ResourceProperty.payloadMethods
addGroup()
addGroup(group): Account;Adds a group to the Account.
Parameters
| Parameter | Type | Description |
|---|---|---|
group | Group | Group | The group to add |
Returns
Account
This Account, for chaining
create()
create(): Promise<Account>;Performs create new Account.
Returns
Promise<Account>
Promise with this Account after creation
deleteProperty()
deleteProperty(key): this;Deletes a custom property.
Parameters
| Parameter | Type | Description |
|---|---|---|
key | string | The property key |
Returns
this
This resource, for chaining
Inherited from
ResourceProperty.deletePropertygetGroups()
getGroups(): Promise<Group[]>;Gets the [[Groups]] of this Account.
When groups are already embedded in the account payload (e.g. from Bkper.getBook with includeGroups), resolves them from the book’s cache instead of making API calls.
Returns
Promise<Group[]>
Promise with the [[Groups]] of this Account
getId()
getId(): string | undefined;Gets the Account internal id.
Returns
string | undefined
The Account internal id
getName()
getName(): string | undefined;Gets the Account name.
Returns
string | undefined
The Account name
getNormalizedName()
getNormalizedName(): string;Gets the normalized name of this Account without spaces or special characters.
Returns
string
The name of this Account without spaces or special characters
getProperties()
getProperties(): object;Gets the custom properties stored in this resource.
Returns
object
Object with key/value pair properties
Inherited from
ResourceProperty.getPropertiesgetProperty()
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
ResourceProperty.getPropertygetPropertyKeys()
getPropertyKeys(): string[];Gets the custom properties keys stored in this resource.
Returns
string[]
Array of property keys sorted alphabetically
Inherited from
ResourceProperty.getPropertyKeysgetType()
getType(): AccountType;Gets the type of this Account.
Returns
The [[AccountType]] of this Account
getVisibleProperties()
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
ResourceProperty.getVisiblePropertieshasTransactionPosted()
hasTransactionPosted(): boolean | undefined;Tells if the Account has any transaction already posted.
Accounts with transaction posted, even with zero balance, can only be archived.
Returns
boolean | undefined
True if the Account has transactions posted
isArchived()
isArchived(): boolean | undefined;Tells if this Account is archived.
Returns
boolean | undefined
True if the Account is archived
isBalanceVerified()
isBalanceVerified(): boolean | undefined;Tells if the balance of this Account has been verified/audited.
Returns
boolean | undefined
True if the balance of this Account has been verified/audited
isCredit()
isCredit(): boolean | undefined;Tells if the Account has a Credit nature or Debit otherwise.
Credit Accounts are just for representation purposes. It increase or decrease the absolute balance. It doesn’t affect the overall balance or the behavior of the system.
The absolute balance of credit Accounts increase when it participate as a credit/origin in a transaction. Its usually for Accounts that increase the balance of the assets, like revenue Accounts.
Crediting a credit Thus ---------------------> Account increases its absolute balance Debiting a debit
Debiting a credit Thus ---------------------> Account decreases its absolute balance Crediting a debitAs a rule of thumb, and for simple understanding, almost all Accounts are Debit nature (NOT credit), except the ones that “offers” amount for the books, like revenue Accounts.
Returns
boolean | undefined
True if the Account has credit nature
isInGroup()
isInGroup(group): Promise<boolean>;Tells if this Account is in the [[Group]].
Parameters
| Parameter | Type | Description |
|---|---|---|
group | string | Group | The Group name, id or object |
Returns
Promise<boolean>
Promise with true if the Account is in the group
isPermanent()
isPermanent(): boolean | undefined;Tells if the Account is permanent.
Permanent Accounts are the ones which final balance is relevant and keep its balances over time.
They are also called Real Accounts
Usually represents assets or tangibles, capable of being perceived by the senses or the mind, like bank Accounts, money, debts and so on.
Returns
boolean | undefined
True if its a permanent Account
json()
json(): Account;Gets an immutable copy of the JSON payload for this resource.
Returns
Account
An immutable copy of the json payload
Inherited from
ResourceProperty.jsonremove()
remove(): Promise<Account>;Performs delete Account.
Returns
Promise<Account>
Promise with this Account after deletion
removeGroup()
removeGroup(group): Promise<Account>;Removes a group from the Account.
Parameters
| Parameter | Type | Description |
|---|---|---|
group | string | Group | The group name, id or object to remove |
Returns
Promise<Account>
Promise with this Account, for chaining
setArchived()
setArchived(archived): Account;Sets Account archived/unarchived.
Parameters
| Parameter | Type | Description |
|---|---|---|
archived | boolean | True to archive, false to unarchive |
Returns
Account
This Account, for chaining
setGroups()
setGroups(groups): Account;Sets the groups of the Account.
Parameters
| Parameter | Type | Description |
|---|---|---|
groups | Group[] | Group[] | The groups to set |
Returns
Account
This Account, for chaining
setName()
setName(name): Account;Sets the name of the Account.
Parameters
| Parameter | Type | Description |
|---|---|---|
name | string | The name to set |
Returns
Account
This Account, for chaining
setProperties()
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
ResourceProperty.setPropertiessetProperty()
setProperty(key, value): this;Sets a custom property in this resource.
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
ResourceProperty.setPropertysetType()
setType(type): Account;Sets the type of the Account.
Parameters
| Parameter | Type | Description |
|---|---|---|
type | AccountType | The [[AccountType]] to set |
Returns
Account
This Account, for chaining
setVisibleProperties()
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
ResourceProperty.setVisiblePropertiessetVisibleProperty()
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
ResourceProperty.setVisiblePropertyupdate()
update(): Promise<Account>;Performs update Account, applying pending changes.
Returns
Promise<Account>
Promise with this Account after update