Fuentes v0.0.1 Fuentes.Account

The Account module represents accounts in the system which are of asset, liability, or equity types, in accordance with the “accounting equation”.

Each account must be set to one of the following types:

TYPE | NORMAL BALANCE | DESCRIPTION


assetDebitResources owned by the Business Entity
liabilityCreditDebts owed to outsiders
equityCreditOwners rights to the Assets

Each account can also be marked as a “Contra Account”. A contra account will have it’s normal balance swapped. For example, to remove equity, a “Drawing” account may be created as a contra equity account as follows:

account = %Fuentes.Account{name: "Drawing", type: "asset", contra: true}

At all times the balance of all accounts should conform to the “accounting equation”

Assets = Liabilities + Owner’s Equity

Each account type acts as it’s own ledger.

For more details see:

Wikipedia - Accounting Equation

Wikipedia - Debits, Credits, and Contra Accounts

Summary

Functions

Computes the trial balance for all accounts in the provided Ecto.Repo. Returns Decimal type

Computes the account balance for a list of Fuentes.Account in a given Ecto.Repo inclusive of all entries. This function is intended to be used with a list of Fuentes.Accounts of the same type. Returns Decimal type

Computes the account balance for a given Fuentes.Account in a given Ecto.Repo when provided with a map of dates in the format %{from_date: from_date, to_date: to_date}. Returns Decimal type

Creates a changeset requiring a :name and :type

Functions

balance(repo)

Computes the trial balance for all accounts in the provided Ecto.Repo. Returns Decimal type.

balance(accounts, repo)

Computes the account balance for a list of Fuentes.Account in a given Ecto.Repo inclusive of all entries. This function is intended to be used with a list of Fuentes.Accounts of the same type. Returns Decimal type.

balance(account, dates, repo)

Computes the account balance for a given Fuentes.Account in a given Ecto.Repo when provided with a map of dates in the format %{from_date: from_date, to_date: to_date}. Returns Decimal type.

changeset(model, params \\ %{})

Creates a changeset requiring a :name and :type