Skip to content

Commit

Permalink
Add test for getting ledger opening balances
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnStarich committed Mar 11, 2020
1 parent 0b479a7 commit faebdae
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions ledger/ledger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -913,3 +913,27 @@ func TestSize(t *testing.T) {
require.NoError(t, err)
assert.Equal(t, len(txns), l.Size())
}

func TestOpeningBalances(t *testing.T) {
l, err := New(nil)
require.NoError(t, err)
_, ok := l.OpeningBalances()
assert.False(t, ok, "No opening balance expected")

txns := []Transaction{
{
Date: parseDate(t, "2020/01/01"),
Payee: "some payee",
Postings: []Posting{
{Account: "assets", Amount: *decFloat(10)},
{Account: "liabilities", Amount: *decFloat(32)},
{Account: "*Opening-Balances", Tags: map[string]string{idTag: OpeningBalanceID}},
},
},
}
l, err = New(txns)
require.NoError(t, err)
opening, ok := l.OpeningBalances()
require.True(t, ok)
assert.Equal(t, txns[0], opening)
}

0 comments on commit faebdae

Please sign in to comment.