wip ledger/register.go

This commit is contained in:
Bel LaPointe
2023-10-25 15:47:29 -06:00
parent 8155e57619
commit 31e1a86795
3 changed files with 116 additions and 0 deletions

View File

@@ -10,7 +10,9 @@ import (
"os"
"slices"
"sort"
"strconv"
"strings"
"time"
"github.com/go-echarts/go-echarts/v2/charts"
"github.com/go-echarts/go-echarts/v2/opts"
@@ -82,6 +84,24 @@ func main() {
register[date] = register[date].WithBPIs(bpis)
}
}
if predictionMonths, err := strconv.ParseInt(r.URL.Query().Get("predictionMonths"), 10, 8); err == nil && predictionMonths > 0 {
predictionDuration := time.Hour * 24 * 365 / 12 * time.Duration(predictionMonths)
if r.URL.Query().Get("predictContributions") != "" {
register = ledger.RegisterWithContributionPrediction(register, predictionDuration)
}
for _, nameRate := range r.URL.Query()["predictCompoundingInterest"] {
splits := strings.Split(nameRate, "=")
if len(splits) != 2 {
panic(splits)
}
name := splits[0]
rate, err := strconv.ParseFloat(splits[1], 64)
if err != nil {
panic(err)
}
register = ledger.RegisterWithCompoundingInterestPrediction(register, predictionDuration, name, rate)
}
}
// /MODIFIERS
nameCurrencyDateValue := map[string]map[ledger.Currency]map[string]float64{}