This commit is contained in:
bel
2023-10-22 22:03:26 -06:00
parent 61cd82b307
commit 078c425d9e
6 changed files with 108 additions and 0 deletions

38
ledger/delta.go Normal file
View 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
}
}