Files
ana-ledger/src/ledger/group.go
Bel LaPointe 58462fb5a4
Some checks failed
cicd / ci (push) Failing after 51s
cli graph graphs
2025-05-07 15:34:31 -06:00

39 lines
653 B
Go

package ledger
import (
"regexp"
)
type Group func(Delta) Delta
type Groups []Group
func (groups Groups) Each(d Delta) Delta {
for i := range groups {
d = groups[i](d)
}
return d
}
func GroupDate(pattern string) Group {
p := regexp.MustCompile(pattern)
return func(d Delta) Delta {
d.Date = p.FindString(d.Date)
for i := range d.with {
d.with[i].Date = p.FindString(d.with[i].Date)
}
return d
}
}
func GroupName(pattern string) Group {
p := regexp.MustCompile(pattern)
return func(d Delta) Delta {
d.Name = p.FindString(d.Name)
for i := range d.with {
d.with[i].Name = p.FindString(d.with[i].Name)
}
return d
}
}