main
Bel LaPointe 2023-10-25 14:11:26 -06:00
parent 6b666c7220
commit e1c6ad0d3f
2 changed files with 14 additions and 0 deletions

1
cmd/clitest/bpi.dat Symbolic link
View File

@ -0,0 +1 @@
../../../../../../Sync/Core/ledger/bpi.dat

View File

@ -25,6 +25,7 @@ func main() {
likeLedger := flag.Bool("like-ledger", false, "limit data to these -like-* rather than zoom to these -like-*")
groupName := flag.String("group-name", ".*", "grouping to apply to names")
groupDate := flag.String("group-date", ".*", "grouping to apply to dates")
bpiPath := flag.String("bpi", "/dev/null", "bpi file")
jsonOutput := flag.Bool("json", false, "json output")
httpOutput := flag.String("http", "", "http output listen address, like :8080")
flag.Parse()
@ -44,6 +45,14 @@ func main() {
deltas = deltas.Group(ledger.GroupName(*groupName), ledger.GroupDate(*groupDate))
bpis := make(ledger.BPIs)
if *bpiPath != "" {
bpis, err = ledger.NewBPIs(*bpiPath)
if err != nil {
panic(err)
}
}
like := ledger.Likes{ledger.LikeName(*likeName)}
if *httpOutput != "" {
@ -66,10 +75,14 @@ func main() {
}
register := deltas.Like(foolike...).Register()
nameCurrencyDateValue := map[string]map[ledger.Currency]map[string]float64{}
dates := []string{}
for date, balances := range register {
dates = append(dates, date)
if r.URL.Query().Get("bpi") != "" {
balances = balances.WithBPIs(bpis)
}
for name, balance := range balances {
for currency, value := range balance {
if _, ok := nameCurrencyDateValue[name]; !ok {