wip ledger/register.go
This commit is contained in:
@@ -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{}
|
||||
|
||||
Reference in New Issue
Block a user