This commit is contained in:
Bel LaPointe
2023-10-27 20:37:15 -06:00
parent 7908530b52
commit be555abbe8
3 changed files with 30 additions and 4 deletions

View File

@@ -73,6 +73,11 @@
<input name="predictFixedGrowth" type="text" value="VBTLX=0.02&predictFixedGrowth=GLD=0.02&predictFixedGrowth=FXAIX=0.03&predictFixedGrowth=FSPSX=0.03"/>
</span>
<span>
<label for="whatIf">whatIf</label>
<input name="whatIf" type="text" value="AssetAccount:Cash $ -1.00"/>
</span>
<span>
<input type="submit"/>
</span>

View File

@@ -93,11 +93,31 @@ func main() {
foolike = like
}
register := deltas.Like(foolike...).Register()
deltas := deltas.Like(foolike...)
// MODIFIERS
for i, whatIf := range r.URL.Query()["whatIf"] {
fields := strings.Fields(whatIf)
date := "2001-01"
name := fields[0]
currency := ledger.Currency(fields[1])
value, err := strconv.ParseFloat(fields[2], 64)
if err != nil {
panic(err)
}
deltas = append(deltas, ledger.Delta{
Date: date,
Name: name,
Value: value,
Currency: currency,
Description: fmt.Sprintf("?whatIf[%d]", i),
})
}
register := deltas.Register()
predicted := make(ledger.Register)
bpis := maps.Clone(bpis)
// MODIFIERS
if predictionMonths, err := strconv.ParseInt(r.URL.Query().Get("predictionMonths"), 10, 16); err == nil && predictionMonths > 0 {
window := time.Hour * 24.0 * 365.0 / 12.0 * time.Duration(predictionMonths)
// TODO whatif