package ledger import ( "time" "github.com/howeyc/ledger" ) type Currency string const ( USD = Currency("$") ) type Delta struct { Date time.Time Account string Value float64 Currency Currency } func newDeltas(t *ledger.Transaction) []Delta { result := make([]Delta, len(t.AccountChanges)) for i, a := range t.AccountChanges { result[i] = newDelta(t.Date, a) } return result } func newDelta(d time.Time, a ledger.Account) Delta { value, _ := a.Balance.Float64() return Delta{ Date: d, Account: a.Name, Value: value, Currency: USD, // TODO } } func (delta Delta) Plus(other Delta) Delta { return Delta{ Date: other.Date, Account: delta.Account, Value: delta.Value + other.Value, Currency: other.Currency, } }