Skip to content

Group

This class defines a Group of [[Accounts]].

Accounts can be grouped by different meaning, like Expenses, Revenue, Assets, Liabilities and so on

Its useful to keep organized and for high level analysis.

Extends

  • ResourceProperty<bkper.Group>

Constructors

Constructor

new Group(book, payload?): Group;

Parameters

ParameterType
bookBook
payload?Group

Returns

Group

Overrides

ResourceProperty<bkper.Group>.constructor

Properties

payload

payload: Group;

The underlying payload data for this resource

Inherited from

ResourceProperty.payload

Methods

create()

create(): Promise<Group>;

Performs create new group.

Returns

Promise<Group>

A promise that resolves to this Group


deleteProperty()

deleteProperty(key): this;

Deletes a custom property.

Parameters

ParameterTypeDescription
keystringThe property key

Returns

this

This resource, for chaining

Inherited from

ResourceProperty.deleteProperty

getAccounts()

getAccounts(): Promise<Account[]>;

Gets all Accounts of this group.

Returns

Promise<Account[]>

All Accounts of this group


getChildren()

getChildren(): Group[];

Gets the children of the Group.

Returns

Group[]

An array of child Groups


getDepth()

getDepth(): number;

Gets the depth of the Group in the hierarchy.

Returns

number

The depth of the Group


getDescendants()

getDescendants(): Set<Group>;

Gets all descendant Groups of the current Group.

Returns

Set<Group>

A set of descendant Groups


getDescendantTreeIds()

getDescendantTreeIds(): Set<string>;

Gets the IDs of all descendant Groups in a tree structure.

Returns

Set<string>

A set of descendant Group IDs


getId()

getId(): string | undefined;

Gets the id of this Group.

Returns

string | undefined

The id of this Group


getName()

getName(): string | undefined;

Gets the name of this Group.

Returns

string | undefined

The name of this Group


getNormalizedName()

getNormalizedName(): string;

Gets the normalized name of this group without spaces and special characters.

Returns

string

The name of this group without spaces and special characters


getParent()

getParent(): Group | undefined;

Gets the parent Group.

Returns

Group | undefined

The parent Group


getProperties()

getProperties(): object;

Gets the custom properties stored in this resource.

Returns

object

Object with key/value pair properties

Inherited from

ResourceProperty.getProperties

getProperty()

getProperty(...keys): string | undefined;

Gets the property value for given keys. First property found will be retrieved.

Parameters

ParameterTypeDescription
keysstring[]The property keys to search for

Returns

string | undefined

The property value or undefined if not found

Inherited from

ResourceProperty.getProperty

getPropertyKeys()

getPropertyKeys(): string[];

Gets the custom properties keys stored in this resource.

Returns

string[]

Array of property keys sorted alphabetically

Inherited from

ResourceProperty.getPropertyKeys

getRoot()

getRoot(): Group;

Gets the root Group of the current Group.

Returns

Group

The root Group


getRootName()

getRootName(): string;

Gets the name of the root Group.

Returns

string

The name of the root Group


getType()

getType(): AccountType;

Gets the type of the accounts of this group.

Returns

AccountType

The type for of the accounts of this group. Null if mixed


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.getVisibleProperties

hasAccounts()

hasAccounts(): boolean | undefined;

Tells if this group has any account in it.

Returns

boolean | undefined

True if this group has any account in it


hasChildren()

hasChildren(): boolean;

Checks if the Group has any children.

Returns

boolean

True if the Group has children, otherwise false


hasParent()

hasParent(): boolean;

Checks if the Group has a parent.

Returns

boolean

True if the Group has a parent, otherwise false


isBalanceVerified()

isBalanceVerified(): Promise<boolean | undefined>;

Tells if the balance of this Group has been verified/audited.

Returns

Promise<boolean | undefined>

True if the balance of this Group has been verified/audited


isCredit()

isCredit(): boolean | undefined;

Tells if this is a credit (Incoming and Liabilities) group.

Returns

boolean | undefined

True if this is a credit group


isHidden()

isHidden(): boolean | undefined;

Tells if the Group is hidden on main transactions menu.

Returns

boolean | undefined

True if the Group is hidden, false otherwise


isLeaf()

isLeaf(): boolean;

Checks if the Group is a leaf node (i.e., has no children).

Returns

boolean

True if the Group is a leaf, otherwise false


isLocked()

isLocked(): boolean;

Tells if the Group is locked by the Book owner.

Returns

boolean

True if the Group is locked


isMixed()

isMixed(): boolean | undefined;

Tells if this is a mixed (Assets/Liabilities or Incoming/Outgoing) group.

Returns

boolean | undefined

True if this is a mixed group


isPermanent()

isPermanent(): boolean | undefined;

Tells if the Group is permanent.

Returns

boolean | undefined

True if the Group is permanent


isRoot()

isRoot(): boolean;

Checks if the Group is a root node (i.e., has no parent).

Returns

boolean

True if the Group is a root, otherwise false


json()

json(): Group;

Gets an immutable copy of the JSON payload for this resource.

Returns

Group

An immutable copy of the json payload

Inherited from

ResourceProperty.json

remove()

remove(): Promise<Group>;

Performs delete group.

Returns

Promise<Group>

A promise that resolves to this Group


setHidden()

setHidden(hidden): Group;

Hide/Show group on main menu.

Parameters

ParameterTypeDescription
hiddenbooleanWhether to hide the group

Returns

Group

This Group, for chaining


setLocked()

setLocked(locked): Group;

Sets the locked state of the Group.

Parameters

ParameterTypeDescription
lockedbooleanThe locked state of the Group.

Returns

Group

This Group, for chaining


setName()

setName(name): Group;

Sets the name of the Group.

Parameters

ParameterTypeDescription
namestringThe name to set

Returns

Group

This Group, for chaining


setParent()

setParent(group): Group;

Sets the parent Group.

Parameters

ParameterTypeDescription
groupGroup | null | undefinedThe parent Group to set

Returns

Group

This Group, for chaining


setProperties()

setProperties(properties): this;

Sets the custom properties of this resource.

Parameters

ParameterTypeDescription
properties{ [key: string]: string; }Object with key/value pair properties

Returns

this

This resource, for chaining

Inherited from

ResourceProperty.setProperties

setProperty()

setProperty(key, value): this;

Sets a custom property in this resource.

Parameters

ParameterTypeDescription
keystringThe property key
valuestring | null | undefinedThe property value, or null/undefined to clean it

Returns

this

This resource, for chaining

Inherited from

ResourceProperty.setProperty

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

ParameterTypeDescription
properties{ [key: string]: string; }Object with key/value pair properties

Returns

this

This resource, for chaining

Inherited from

ResourceProperty.setVisibleProperties

setVisibleProperty()

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

ParameterTypeDescription
keystringThe property key
valuestring | null | undefinedThe property value, or null/undefined to clean it

Returns

this

This resource, for chaining

Inherited from

ResourceProperty.setVisibleProperty

update()

update(): Promise<Group>;

Performs update group, applying pending changes.

Returns

Promise<Group>

A promise that resolves to this Group