diff --git a/cmd/cli/config.go b/cmd/cli/config.go index f1c12d5..242d175 100644 --- a/cmd/cli/config.go +++ b/cmd/cli/config.go @@ -3,10 +3,11 @@ package cli type Config struct { Files FileList Query struct { - Period Period - Sort string - NoRounding bool - Depth int - Reverse bool + Period Period + Sort string + NoRounding bool + Depth int + Reverse bool + NoExchanging bool } } diff --git a/cmd/cli/main.go b/cmd/cli/main.go index 203f1d7..540e9b9 100644 --- a/cmd/cli/main.go +++ b/cmd/cli/main.go @@ -20,6 +20,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.NoExchanging, "no-exchanging", true, "omit currency exchanges") if err := fs.Parse(os.Args[1:]); err != nil { panic(err) } @@ -110,7 +111,17 @@ func Main() { for _, transaction := range transactions { balances := ledger.Deltas(transaction).Like(likes...).Balances() - if len(balances) > 0 { + shouldPrint := false + shouldPrint = shouldPrint || len(balances) > 2 + if config.Query.NoExchanging { + shouldPrint = shouldPrint || len(balances) > 1 + for _, v := range balances { + shouldPrint = shouldPrint || len(v) == 1 + } + } else { + shouldPrint = shouldPrint || len(balances) > 0 + } + if shouldPrint { fmt.Printf("%s\t%s\n", transaction[0].Date, transaction[0].Description) FPrintBalances(os.Stdout, "\t\t", ledger.Deltas(transaction).Like(likes...).Balances()) }