-
Notifications
You must be signed in to change notification settings - Fork 1
Account
Documentation > Account
An Account is collection of related economic activity. For example, an Account might represent a bank account, income from a particular client, or entity equity. Many Accounts together compose an Entity.
Accounts themselves are composed of Transactions, and the sum of constituent transactions yield an Account Balance.
The Accounts that compose an Entity may be viewed together as part of the Tree.
An identifier for this account, unique within an Entity
Example: 42
.session
- Session
The Session used to initialise this Account
.entity
- Entity
The Entity of which this Account is a member
A friendly name for this Account
Example: "Subscription revenue"
.type
- Type
The type of the Account, one of .asset
, .liability
, .income
, .expense
or .equity
Example: Type.income
The identifier of this Account's parent, if there is one
Example: 154
The identifier of this Account's denominating Global Unit, or null
if this Account is denominated by a Custom Unit
Example: 5
The identifier of this Account's denominating Custom Unit, or null
if this Account is denominated by a Global Unit
Example: null
The identifier of an Entity identified as a counter-party to this Account, if any
Example: null
Friendly description of this Account
Example: "Sweet loot from accounting API subscriptions"
Hex colour value associated with this Account
Example: "#FFFFFF"
Retrieve an existing Account
const _ = Account.retrieve(
session,
megaCorp,
42,
(error, account) => {
console.log(account.id) // Logs 42
});
Create a new Account denominated in a Global Unit - One of the 36 daily priced currencies available by default in Amatino.
- session: Session
- entity: Entity
- name: String
- type: Type
- parent: Number or
null
- globalUnitId: Number
- counterPartyEntity: String or
null
- description: String
- colour: String or
null
- callback: (Error, Account)
const _ = Account.createWithGlobalUnit(
session,
megaCorp,
"Subscription income",
Type.revenue,
null,
5,
null,
"Sweet loot from accounting software subscriptions",
null,
(error, account) => {
console.log(account.name) // Logs 'Subscription income'
]);
Create a new Account denominated in a Custom Unit. For example, you might have created a Custom Unit for Bitcoin, Apple stock, or hourly U.S. Dollar prices.
- session: Session
- entity: Entity
- name: String
- type: Type
- parent: Number or
null
- customUnitId: Number
- counterPartyEntity: String or
null
- description: String
- colour: String or
null
- callback: (Error, Account)
const _ = Account.createWithCustomUnitDenomination(
session,
megaCorp,
"Bitcoin Holdings",
Type.asset,
null,
3,
null,
"Bitcoin account at Coinbase",
null,
(error, account) => {
console.log(account.name) // Logs 'Bitcoin Holdings'
]);
Update an Account. For example, you might wish to change its name, description, or parent.
- name: String
- type: Type
- parentAccountId: Number or
null
- globalUnitId: Number or
null
- customUnitId: Number or `null
- counterPartyEntityId: String or
null
- description: String
- colour: String or
null
- callback: (Error, Account)
account.update(
"New, improved account name",
account.type,
account.parentAccountId,
account.globalUnitId,
account.customUnitId,
account.counterPartyEntityId,
"New, improved account description",
account.colour,
(error, account) => {
console.log(account.name); // logs 'New, improved account name'
}
);
Deletes the Account. This requires some consideration: Deleting an account does not delete Transactions party to it. As such, the deletion operation requires some additional data telling Amatino what you want to happen to those Transactions. In addition, Amatino needs to know what you would like to happen to any children of this Account.
The entryReplacementAccount
is the Account to which any party Entries should be moved. If you have deleted all party Transactions, then you can specify any Account here. deleteChildren
flags whether child Accounts should also be deleted. Finally, newChildParentAccount
tells Amatino where surviving direct children should be re-parented. If you supply null
, they will become new top-level Accounts. In both cases, the children's descendants retain their existing parent / child relationships.
- entryReplacementAccount: Account
- deleteChildren: Boolean
- newChildParentAccount: Account or
null
- callback: (Error, [Object])
The [Object]
Array in parameter #4 contains objects of the form: {"account_id": 42}
- Wherein each Object represents a deleted Account. For example, if you delete all children, the array will contain an object specifying the ID of each deleted child, as well as the target.
// Suppose we have two Account instances, `equipment` and `fixedAssets`.
equipment.delete(
fixedAssets,
false,
fixedAssets, // All `equipment` children will be re-parented by `fixedAssets`
(error, deletedAccountIds) => {
for (let i = 0; i < deletedAccountIds.length; i++) {
const deletedId = deletedAccountIds[i]['account_id']
console.log('Deleted account with ID:', deletedId)
}
}
)'