This commit is contained in:
bel
2023-10-24 21:09:02 -06:00
parent 21fed9437f
commit 5d0e7c9a3d
9 changed files with 42 additions and 40 deletions

View File

@@ -15,13 +15,13 @@ func (deltas Deltas) Like(like ...Like) Deltas {
func (deltas Deltas) Balances() (map[string]map[Currency]float64, error) {
result := make(map[string]map[Currency]float64)
for _, delta := range deltas {
if _, ok := result[delta.Account]; !ok {
result[delta.Account] = make(map[Currency]float64)
if _, ok := result[delta.Name]; !ok {
result[delta.Name] = make(map[Currency]float64)
}
if _, ok := result[delta.Account][delta.Currency]; !ok {
result[delta.Account][delta.Currency] = 0
if _, ok := result[delta.Name][delta.Currency]; !ok {
result[delta.Name][delta.Currency] = 0
}
result[delta.Account][delta.Currency] += delta.Value
result[delta.Name][delta.Currency] += delta.Value
}
return result, nil