# BalancesContainer

The container of balances of an [[Account]] or [[Group]]

The container is composed of a list of [[Balances]] for a window of time, as well as its period and cumulative totals.

### getAccount()

```ts
getAccount: () => Promise;
```

Gets the [[Account]] associated with this container.

#### Returns

`Promise`\<[`Account`](https://bkper.com/docs/api/bkper-js/classes/account.md) \| `null`\>

The [[Account]] associated with this container

***

### getBalances()

```ts
getBalances: () => Balance[];
```

Gets all [[Balances]] of the container

#### Returns

[`Balance`](https://bkper.com/docs/api/bkper-js/classes/balance.md)[]

All [[Balances]] of the container

***

### getBalancesContainer()

```ts
getBalancesContainer: (name) => BalancesContainer;
```

Gets a specific [[BalancesContainer]].

#### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| `name` | `string` | The [[Account]] or [[Group]] name |

#### Returns

`BalancesContainer`

The retrieved [[BalancesContainer]]

***

### getBalancesContainers()

```ts
getBalancesContainers: () => BalancesContainer[];
```

Gets all child [[BalancesContainers]].

**NOTE**: Only for Group balance containers. Accounts returns null.

#### Returns

`BalancesContainer`[]

All child [[BalancesContainers]]

***

### getBalancesReport()

```ts
getBalancesReport: () => BalancesReport;
```

Gets the parent [[BalancesReport]] of the container.

#### Returns

[`BalancesReport`](https://bkper.com/docs/api/bkper-js/classes/balancesreport.md)

The parent [[BalancesReport]] of the container

***

### getCumulativeBalance()

```ts
getCumulativeBalance: () => Amount;
```

Gets the cumulative balance to the date.

#### Returns

[`Amount`](https://bkper.com/docs/api/bkper-js/classes/amount.md)

The cumulative balance to the date

***

### getCumulativeBalanceRaw()

```ts
getCumulativeBalanceRaw: () => Amount;
```

Gets the cumulative raw balance to the date.

#### Returns

[`Amount`](https://bkper.com/docs/api/bkper-js/classes/amount.md)

The cumulative raw balance to the date

***

### getCumulativeBalanceRawText()

```ts
getCumulativeBalanceRawText: () => string;
```

Gets the cumulative raw balance formatted according to [[Book]] decimal format and fraction digits.

#### Returns

`string`

The cumulative raw balance formatted according to [[Book]] decimal format and fraction digits

***

### getCumulativeBalanceText()

```ts
getCumulativeBalanceText: () => string;
```

Gets the cumulative balance formatted according to [[Book]] decimal format and fraction digits.

#### Returns

`string`

The cumulative balance formatted according to [[Book]] decimal format and fraction digits

***

### getDepth()

```ts
getDepth: () => number;
```

Gets the depth in the parent chain up to the root.

#### Returns

`number`

The depth in the parent chain up to the root

***

### getGroup()

```ts
getGroup: () => Promise;
```

Gets the [[Group]] associated with this container.

#### Returns

`Promise`\<[`Group`](https://bkper.com/docs/api/bkper-js/classes/group.md) \| `null`\>

The [[Group]] associated with this container

***

### getName()

```ts
getName: () => string;
```

Gets the [[Account]] or [[Group]] name.

#### Returns

`string`

The [[Account]] or [[Group]] name

***

### getNormalizedName()

```ts
getNormalizedName: () => string;
```

Gets the [[Account]] or [[Group]] name without spaces or special characters.

#### Returns

`string`

The [[Account]] or [[Group]] name without spaces or special characters

***

### getParent()

```ts
getParent: () => BalancesContainer | null;
```

Gets the parent BalanceContainer.

#### Returns

`BalancesContainer` \| `null`

The parent BalanceContainer

***

### getPeriodBalance()

```ts
getPeriodBalance: () => Amount;
```

Gets the balance on the date period.

#### Returns

[`Amount`](https://bkper.com/docs/api/bkper-js/classes/amount.md)

The balance on the date period

***

### getPeriodBalanceRaw()

```ts
getPeriodBalanceRaw: () => Amount;
```

Gets the raw balance on the date period.

#### Returns

[`Amount`](https://bkper.com/docs/api/bkper-js/classes/amount.md)

The raw balance on the date period

***

### getPeriodBalanceRawText()

```ts
getPeriodBalanceRawText: () => string;
```

Gets the raw balance on the date period formatted according to [[Book]] decimal format and fraction digits.

#### Returns

`string`

The raw balance on the date period formatted according to [[Book]] decimal format and fraction digits

***

### getPeriodBalanceText()

```ts
getPeriodBalanceText: () => string;
```

Gets the balance on the date period formatted according to [[Book]] decimal format and fraction digits.

#### Returns

`string`

The balance on the date period formatted according to [[Book]] decimal format and fraction digits

***

### hasGroupBalances()

```ts
hasGroupBalances: () => boolean;
```

Gets whether the balance container is from a parent group.

#### Returns

`boolean`

True if the balance container is from a parent group

***

### isCredit()

```ts
isCredit: () => boolean | undefined;
```

Gets the credit nature of the BalancesContainer, based on [[Account]] or [[Group]].

For [[Account]], the credit nature will be the same as the one from the Account.

For [[Group]], the credit nature will be the same, if all accounts containing on it has the same credit nature. False if mixed.

#### Returns

`boolean` \| `undefined`

The credit nature of the BalancesContainer

***

### isFromAccount()

```ts
isFromAccount: () => boolean;
```

Gets whether this balance container is from an [[Account]].

#### Returns

`boolean`

True if this balance container if from an [[Account]]

***

### isFromGroup()

```ts
isFromGroup: () => boolean;
```

Gets whether this balance container is from a [[Group]].

#### Returns

`boolean`

True if this balance container if from a [[Group]]

***

### isPermanent()

```ts
isPermanent: () => boolean;
```

Tell if this balance container is permanent, based on the [[Account]] or [[Group]].

Permanent are the ones which final balance is relevant and keep its balances over time.

They are also called [Real Accounts](http://en.wikipedia.org/wiki/Account_(accountancy)#Based_on_periodicity_of_flow).

Usually represents assets or liabilities, capable of being perceived by the senses or the mind, like bank accounts, money, debts and so on.

#### Returns

`boolean`

True if its a permanent Account

***

### payload

```ts
payload: AccountBalances | GroupBalances;
```

### createDataTable()

```ts
createDataTable(): BalancesDataTableBuilder;
```

Creates a BalancesDataTableBuilder to generate a two-dimensional array with all [[BalancesContainers]]

#### Returns

[`BalancesDataTableBuilder`](https://bkper.com/docs/api/bkper-js/classes/balancesdatatablebuilder.md)

***

### getCumulativeCredit()

```ts
getCumulativeCredit(): Amount;
```

The cumulative credit to the date.

#### Returns

[`Amount`](https://bkper.com/docs/api/bkper-js/classes/amount.md)

***

### getCumulativeCreditText()

```ts
getCumulativeCreditText(): string;
```

The cumulative credit formatted according to [[Book]] decimal format and fraction digits.

#### Returns

`string`

***

### getCumulativeDebit()

```ts
getCumulativeDebit(): Amount;
```

The cumulative debit to the date.

#### Returns

[`Amount`](https://bkper.com/docs/api/bkper-js/classes/amount.md)

***

### getCumulativeDebitText()

```ts
getCumulativeDebitText(): string;
```

The cumulative credit formatted according to [[Book]] decimal format and fraction digits.

#### Returns

`string`

***

### getPeriodCredit()

```ts
getPeriodCredit(): Amount;
```

The credit on the date period.

#### Returns

[`Amount`](https://bkper.com/docs/api/bkper-js/classes/amount.md)

***

### getPeriodCreditText()

```ts
getPeriodCreditText(): string;
```

The credit on the date period formatted according to [[Book]] decimal format and fraction digits

#### Returns

`string`

***

### getPeriodDebit()

```ts
getPeriodDebit(): Amount;
```

The debit on the date period.

#### Returns

[`Amount`](https://bkper.com/docs/api/bkper-js/classes/amount.md)

***

### getPeriodDebitText()

```ts
getPeriodDebitText(): string;
```

The debit on the date period formatted according to [[Book]] decimal format and fraction digits

#### Returns

`string`

***

### getProperties()

```ts
getProperties(): object;
```

Gets the custom properties stored in this Account or Group.

#### Returns

`object`

***

### getProperty()

```ts
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 key |

#### Returns

`string` \| `undefined`

***

### getPropertyKeys()

```ts
getPropertyKeys(): string[];
```

Gets the custom properties keys stored in the associated [[Account]] or [[Group]].

#### Returns

`string`[]
