ledger balances helpers like Sub, Sum, Invert

This commit is contained in:
Bel LaPointe
2024-12-12 22:17:08 -07:00
parent 849a8696f5
commit eb3af4b54f
2 changed files with 58 additions and 9 deletions

View File

@@ -4,7 +4,6 @@ import (
"flag"
"fmt"
"io"
"maps"
"os"
"slices"
@@ -101,14 +100,7 @@ func Main() {
for _, date := range register.Dates() {
balances := register[date]
newBalances := make(ledger.Balances)
for k, v := range balances {
if got := prev[k]; !maps.Equal(v, got) {
newBalances[k] = v
}
}
if len(newBalances) > 0 {
if newBalances := balances.Sub(prev).Nonzero(); len(newBalances) > 0 {
fmt.Println(date)
FPrintBalances(os.Stdout, newBalances)
}