Compare commits
2 Commits
af1b23731a
...
0eaeeec359
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0eaeeec359 | ||
|
|
188b31aa0c |
@@ -9,5 +9,6 @@ type Config struct {
|
|||||||
Depth int
|
Depth int
|
||||||
Reverse bool
|
Reverse bool
|
||||||
NoExchanging bool
|
NoExchanging bool
|
||||||
|
Normalize bool
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import (
|
|||||||
"slices"
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"gogs.inhome.blapointe.com/ana-ledger/src/ana"
|
||||||
"gogs.inhome.blapointe.com/ana-ledger/src/ledger"
|
"gogs.inhome.blapointe.com/ana-ledger/src/ledger"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -21,6 +22,7 @@ func Main() {
|
|||||||
fs.BoolVar(&config.Query.NoRounding, "no-rounding", false, "no rounding")
|
fs.BoolVar(&config.Query.NoRounding, "no-rounding", false, "no rounding")
|
||||||
fs.IntVar(&config.Query.Depth, "depth", 0, "depth grouping")
|
fs.IntVar(&config.Query.Depth, "depth", 0, "depth grouping")
|
||||||
fs.BoolVar(&config.Query.Reverse, "r", false, "reverse printed accounts")
|
fs.BoolVar(&config.Query.Reverse, "r", false, "reverse printed accounts")
|
||||||
|
fs.BoolVar(&config.Query.Normalize, "n", false, "normalize with default normalizer")
|
||||||
fs.BoolVar(&config.Query.NoExchanging, "no-exchanging", true, "omit currency exchanges")
|
fs.BoolVar(&config.Query.NoExchanging, "no-exchanging", true, "omit currency exchanges")
|
||||||
if err := fs.Parse(os.Args[1:]); err != nil {
|
if err := fs.Parse(os.Args[1:]); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
@@ -70,6 +72,10 @@ func Main() {
|
|||||||
}
|
}
|
||||||
group := ledger.GroupName(pattern)
|
group := ledger.GroupName(pattern)
|
||||||
|
|
||||||
|
if config.Query.Normalize {
|
||||||
|
deltas = ana.NewDefaultNormalizer().Normalize(deltas)
|
||||||
|
}
|
||||||
|
|
||||||
switch cmd[:3] {
|
switch cmd[:3] {
|
||||||
case "bal":
|
case "bal":
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -102,20 +102,7 @@ func (router Router) APITransactions(w http.ResponseWriter, r *http.Request) {
|
|||||||
))
|
))
|
||||||
recent := time.Hour * 24 * 365 / 6
|
recent := time.Hour * 24 * 365 / 6
|
||||||
|
|
||||||
normalizer := ana.NewNormalizer().
|
normalizer := ana.NewDefaultNormalizer()
|
||||||
With("^Zach:", "2023-10-05", 139). // to turtle
|
|
||||||
With("^Zach:", "2021-12-30", 135). // at pluralsight
|
|
||||||
With("^Zach:", "2020-07-30", 120). // to pluralsight
|
|
||||||
With("^Zach:", "2019-07-16", 77). // at fedex
|
|
||||||
With("^Zach:", "2017-02-16", 49). // to fedex
|
|
||||||
With("^Bel:", "2023-12-05", 190). // to render
|
|
||||||
With("^Bel:", "2022-12-31", 154). // at q
|
|
||||||
With("^Bel:", "2022-06-30", 148). // at q
|
|
||||||
With("^Bel:", "2021-12-31", 122). // at q
|
|
||||||
With("^Bel:", "2020-12-31", 118). // at q
|
|
||||||
With("^Bel:", "2019-12-31", 111). // at q
|
|
||||||
With("^Bel:", "2018-12-31", 92). // at q
|
|
||||||
With("^Bel:", "2018-02-16", 86) // to q
|
|
||||||
|
|
||||||
{
|
{
|
||||||
deltas := houseRelatedDeltas.
|
deltas := houseRelatedDeltas.
|
||||||
|
|||||||
@@ -17,6 +17,23 @@ type normalize struct {
|
|||||||
factor float64
|
factor float64
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewDefaultNormalizer() Normalizer {
|
||||||
|
return NewNormalizer().
|
||||||
|
With("^Zach:", "2023-10-05", 139). // to turtle
|
||||||
|
With("^Zach:", "2021-12-30", 135). // at pluralsight
|
||||||
|
With("^Zach:", "2020-07-30", 120). // to pluralsight
|
||||||
|
With("^Zach:", "2019-07-16", 77). // at fedex
|
||||||
|
With("^Zach:", "2017-02-16", 49). // to fedex
|
||||||
|
With("^Bel:", "2023-12-05", 190). // to render
|
||||||
|
With("^Bel:", "2022-12-31", 154). // at q
|
||||||
|
With("^Bel:", "2022-06-30", 148). // at q
|
||||||
|
With("^Bel:", "2021-12-31", 122). // at q
|
||||||
|
With("^Bel:", "2020-12-31", 118). // at q
|
||||||
|
With("^Bel:", "2019-12-31", 111). // at q
|
||||||
|
With("^Bel:", "2018-12-31", 92). // at q
|
||||||
|
With("^Bel:", "2018-02-16", 86) // to q
|
||||||
|
}
|
||||||
|
|
||||||
func NewNormalizer() Normalizer {
|
func NewNormalizer() Normalizer {
|
||||||
return Normalizer{
|
return Normalizer{
|
||||||
m: make(map[string][]normalize),
|
m: make(map[string][]normalize),
|
||||||
|
|||||||
Reference in New Issue
Block a user