package ana

import (
	"slices"
	"testing"
	"time"

	"gogs.inhome.blapointe.com/ana-ledger/src/ledger"
)

func TestBPIPrediction(t *testing.T) {
	t.Run("fixed growth", func(t *testing.T) {
		bpis := ledger.BPIs{
			ledger.USD: ledger.BPI{
				"2001-01": -1000,
				"2001-02": 100,
			},
		}

		got, err := BPIsWithFixedGrowthPrediction(bpis, time.Hour*24*365, string(ledger.USD), 0.06)
		if err != nil {
			t.Fatal(err)
		}

		dates := []string{}
		for d := range got[ledger.USD] {
			dates = append(dates, d)
		}
		slices.Sort(dates)

		for _, d := range dates {
			t.Logf("%s | %s %.2f", ledger.USD, d, got[ledger.USD][d])
		}
	})
}
