halfway to moolah2
This commit is contained in:
@@ -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")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user