howeyc further reduced
parent
7db1eff2b3
commit
703b7b632d
|
|
@ -2,8 +2,6 @@ package ledger
|
|||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/howeyc/ledger"
|
||||
)
|
||||
|
||||
type Currency string
|
||||
|
|
@ -19,15 +17,6 @@ type Delta struct {
|
|||
Currency Currency
|
||||
}
|
||||
|
||||
func newDeltas(t *ledger.Transaction) []Delta {
|
||||
result := make([]Delta, len(t.AccountChanges))
|
||||
for i, a := range t.AccountChanges {
|
||||
value, _ := a.Balance.Float64()
|
||||
result[i] = newDelta(t.Date, a.Name, value)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func newDelta(d time.Time, a string, v float64) Delta {
|
||||
return Delta{
|
||||
Date: d,
|
||||
|
|
|
|||
|
|
@ -21,7 +21,9 @@ func (file File) Deltas(like ...Like) ([]Delta, error) {
|
|||
}
|
||||
result := make([]Delta, 0, len(transactions)*2)
|
||||
for _, transaction := range transactions {
|
||||
for _, delta := range newDeltas(transaction) {
|
||||
for _, acc := range transaction.AccountChanges {
|
||||
value, _ := acc.Balance.Float64()
|
||||
delta := newDelta(transaction.Date, acc.Name, value)
|
||||
if !likes(like).all(delta) {
|
||||
continue
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue