View Source Bookk.Notation (bookk v0.1.3)

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

Link to this macro

journalize(list1, list2)

View Source (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)
Link to this macro

journalize!(list1, list2)

View Source (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