This commit is contained in:
Bel LaPointe
2023-10-25 06:38:51 -06:00
parent cb9d895161
commit bece66b5b3
3 changed files with 43 additions and 3 deletions

30
ledger/balances.go Normal file
View File

@@ -0,0 +1,30 @@
package ledger
import (
"fmt"
"strings"
)
type Balances map[string]Balance
type Balance map[Currency]float64
func (balances Balances) Debug() string {
result := []string{}
for k, v := range balances {
result = append(result, fmt.Sprintf("%s:[%s]", k, v.Debug()))
}
return strings.Join(result, " ")
}
func (balance Balance) Debug() string {
result := []string{}
for k, v := range balance {
if k == USD {
result = append(result, fmt.Sprintf("%s%.2f", k, v))
} else {
result = append(result, fmt.Sprintf("%.3f %s", v, k))
}
}
return strings.Join(result, " + ")
}