WIP api transactions doesnt return net house debt hrmmmm
cicd / ci (push) Successful in 1m39s Details

main
bel 2024-07-20 10:18:58 -06:00
parent fe8d80ffc8
commit 9a0eb89f54
1 changed files with 13 additions and 5 deletions

View File

@ -90,12 +90,20 @@ func (router Router) APITransactions(w http.ResponseWriter, r *http.Request) {
if err != nil { if err != nil {
panic(err) panic(err)
} }
sixMonths := time.Hour * 24 * 365 / 2
deltasForHouse := deltas.Like(ledger.LikeName(`^House`))
houseRelatedDeltas := deltas.Like(ledger.LikeTransactions(deltasForHouse...))
houseRelatedBalances := houseRelatedDeltas.Balances().
Group(`^[^:]*`).
WithBPIs(bpis).
NotLike(`^Withdrawal`)
json.NewEncoder(w).Encode(map[string]any{ json.NewEncoder(w).Encode(map[string]any{
"deltas": deltas.Like(ledger.LikeAfter(time.Now().Add(-1 * time.Hour * 24 * 365 / 2).Format("2006-01"))), "deltas": deltasForHouse.
"balances": deltas.Balances(). Like(ledger.LikeAfter(time.Now().Add(-1 * sixMonths / 3).Format("2006-01"))),
Like("^(Bel:Asset|Zach:Asset|HouseyMcHouseface:Debts:Credit)"). "balances": houseRelatedBalances,
Group(`^[^:]*`).
WithBPIs(bpis),
}) })
} }