someday
This commit is contained in:
38
ledger/delta.go
Normal file
38
ledger/delta.go
Normal file
@@ -0,0 +1,38 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user