can get retirement contributions with grepping

main
Bel LaPointe 2024-12-12 22:44:38 -07:00
parent e25d52b141
commit c3f7800dec
2 changed files with 18 additions and 6 deletions

View File

@ -8,5 +8,6 @@ type Config struct {
NoRounding bool NoRounding bool
Depth int Depth int
Reverse bool Reverse bool
NoExchanging bool
} }
} }

View File

@ -20,6 +20,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.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)
} }
@ -110,7 +111,17 @@ func Main() {
for _, transaction := range transactions { for _, transaction := range transactions {
balances := ledger.Deltas(transaction).Like(likes...).Balances() 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) fmt.Printf("%s\t%s\n", transaction[0].Date, transaction[0].Description)
FPrintBalances(os.Stdout, "\t\t", ledger.Deltas(transaction).Like(likes...).Balances()) FPrintBalances(os.Stdout, "\t\t", ledger.Deltas(transaction).Like(likes...).Balances())
} }