api/transactions pretty

main
Bel LaPointe 2024-07-20 10:43:57 -06:00
parent cd36e12b68
commit ae44534fc3
1 changed files with 9 additions and 10 deletions

View File

@ -91,19 +91,18 @@ func (router Router) APITransactions(w http.ResponseWriter, r *http.Request) {
panic(err) panic(err)
} }
houseRelatedDeltas := deltas.Like(ledger.LikeTransactions(
deltas.Like(ledger.LikeName(`^House`))...,
))
sixMonths := time.Hour * 24 * 365 / 2 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": deltasForHouse. "deltas": houseRelatedDeltas.
Like(ledger.LikeAfter(time.Now().Add(-1 * sixMonths / 3).Format("2006-01"))), Like(ledger.LikeAfter(time.Now().Add(-1 * sixMonths).Format("2006-01"))),
"balances": houseRelatedBalances, "balances": houseRelatedDeltas.Balances().
Like(`^(Zach|Bel|House[^:]*:Debts:)`).
Group(`^[^:]*`).
WithBPIs(bpis),
}) })
} }