halfway to moolah2

This commit is contained in:
Bel LaPointe
2023-10-27 21:28:31 -06:00
parent e36f08deba
commit dafac49126
4 changed files with 82 additions and 0 deletions

View File

@@ -2,6 +2,8 @@ package ledger
import (
"fmt"
"maps"
"regexp"
"strings"
)
@@ -9,6 +11,17 @@ type Balances map[string]Balance
type Balance map[Currency]float64
func (balances Balances) Like(pattern string) Balances {
result := make(Balances)
p := regexp.MustCompile(pattern)
for k, v := range balances {
if p.MatchString(k) {
result[k] = maps.Clone(v)
}
}
return result
}
func (balances Balances) WithBPIs(bpis BPIs) Balances {
return balances.WithBPIsAt(bpis, "9")
}