Bookk.Notation (bookk v0.1.4)

View Source

DSL notation for describing an interledger entries (Bookk.InterledgerEntry).

Summary

Functions

DSL notation for describing an interledger entries (Bookk.InterledgerEntry).

Same as journalize/2 but it raises an error if the resulting interledger journal entry is unbalanced.

Functions

journalize(list1, list2)

(macro)

DSL notation for describing an interledger entries (Bookk.InterledgerEntry).

Examples

Returns a balanced interledger journal entry:

iex> import Bookk.Notation, only: [journalize: 2]
iex>
iex> %Bookk.InterledgerEntry{} = journal_entry =
iex>   journalize using: TestChartOfAccounts do
iex>     on ledger(:acme) do
iex>       debit account(:cash), 150_00
iex>       credit account(:deposits), 150_00
iex>     end
iex>   end
iex>
iex> assert not Bookk.InterledgerEntry.empty?(journal_entry)
iex> assert Bookk.InterledgerEntry.balanced?(journal_entry)

Returns an unbalanced interledger journal entry:

iex> import Bookk.Notation, only: [journalize: 2]
iex>
iex> %Bookk.InterledgerEntry{} = journal_entry =
iex>   journalize using: TestChartOfAccounts do
iex>     on ledger(:acme) do
iex>       debit account(:cash), 150_00
iex>       credit account(:deposits), 50_00
iex>     end
iex>   end
iex>
iex> assert not Bookk.InterledgerEntry.empty?(journal_entry)
iex> assert not Bookk.InterledgerEntry.balanced?(journal_entry)

journalize!(list1, list2)

(macro)

Same as journalize/2 but it raises an error if the resulting interledger journal entry is unbalanced.

Examples

Returns a balanced interledger journal entry:

iex> import Bookk.Notation, only: [journalize!: 2]
iex>
iex> %Bookk.InterledgerEntry{} = journal_entry =
iex>   journalize! using: TestChartOfAccounts do
iex>     on ledger(:acme) do
iex>       debit account(:cash), 150_00
iex>       credit account(:deposits), 150_00
iex>     end
iex>   end
iex>
iex> assert not Bookk.InterledgerEntry.empty?(journal_entry)
iex> assert Bookk.InterledgerEntry.balanced?(journal_entry)

Raises an error when an unbalanced interledger journal entry is produced:

iex> import Bookk.Notation, only: [journalize!: 2]
iex>
iex> journalize! using: TestChartOfAccounts do
iex>   on ledger(:acme) do
iex>     debit account(:cash), 150_00
iex>     credit account(:deposits), 50_00
iex>   end
iex> end
** (Bookk.UnbalancedError) `journalize!/2` produced an unbalanced journal entry