diff --git a/cmd/cli/config.go b/cmd/cli/config.go index 242d175..ab0a5f0 100644 --- a/cmd/cli/config.go +++ b/cmd/cli/config.go @@ -9,5 +9,6 @@ type Config struct { Depth int Reverse bool NoExchanging bool + Normalize bool } } diff --git a/cmd/cli/main.go b/cmd/cli/main.go index 94bc28b..d153ddd 100644 --- a/cmd/cli/main.go +++ b/cmd/cli/main.go @@ -8,6 +8,7 @@ import ( "slices" "strings" + "gogs.inhome.blapointe.com/ana-ledger/src/ana" "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.IntVar(&config.Query.Depth, "depth", 0, "depth grouping") 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") if err := fs.Parse(os.Args[1:]); err != nil { panic(err) @@ -70,6 +72,10 @@ func Main() { } group := ledger.GroupName(pattern) + if config.Query.Normalize { + deltas = ana.NewDefaultNormalizer().Normalize(deltas) + } + switch cmd[:3] { case "bal": /* diff --git a/cmd/http/router.go b/cmd/http/router.go index f86792d..e1a18c4 100644 --- a/cmd/http/router.go +++ b/cmd/http/router.go @@ -102,7 +102,7 @@ func (router Router) APITransactions(w http.ResponseWriter, r *http.Request) { )) recent := time.Hour * 24 * 365 / 6 - normalizer := ana.NewDefaultNormalizer(). + normalizer := ana.NewDefaultNormalizer() { deltas := houseRelatedDeltas.