to multifile always
This commit is contained in:
@@ -4,20 +4,15 @@ import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type File string
|
||||
type Files []string
|
||||
|
||||
func NewFile(p string) (File, error) {
|
||||
f := File(p)
|
||||
func NewFiles(p string, q ...string) (Files, error) {
|
||||
f := Files(append([]string{p}, q...))
|
||||
_, err := f.Deltas()
|
||||
return f, err
|
||||
}
|
||||
|
||||
func (file File) Balances(like ...Like) (map[string]map[Currency]float64, error) {
|
||||
deltas, err := file.Deltas(like...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
func Balances(deltas []Delta) (map[string]map[Currency]float64, error) {
|
||||
result := make(map[string]map[Currency]float64)
|
||||
for _, delta := range deltas {
|
||||
if _, ok := result[delta.Account]; !ok {
|
||||
@@ -32,8 +27,8 @@ func (file File) Balances(like ...Like) (map[string]map[Currency]float64, error)
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (file File) Deltas(like ...Like) ([]Delta, error) {
|
||||
transactions, err := file.transactions()
|
||||
func (files Files) Deltas(like ...Like) ([]Delta, error) {
|
||||
transactions, err := files.transactions()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user