From e1c6ad0d3f6447c3d3137ff4e3e94f0d02fae92a Mon Sep 17 00:00:00 2001 From: Bel LaPointe Date: Wed, 25 Oct 2023 14:11:26 -0600 Subject: [PATCH] BPI GET --- cmd/clitest/bpi.dat | 1 + cmd/clitest/main.go | 13 +++++++++++++ 2 files changed, 14 insertions(+) create mode 120000 cmd/clitest/bpi.dat diff --git a/cmd/clitest/bpi.dat b/cmd/clitest/bpi.dat new file mode 120000 index 0000000..f5da145 --- /dev/null +++ b/cmd/clitest/bpi.dat @@ -0,0 +1 @@ +../../../../../../Sync/Core/ledger/bpi.dat \ No newline at end of file diff --git a/cmd/clitest/main.go b/cmd/clitest/main.go index edb8d8a..5efbcec 100644 --- a/cmd/clitest/main.go +++ b/cmd/clitest/main.go @@ -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 {