debugs
This commit is contained in:
30
ledger/balances.go
Normal file
30
ledger/balances.go
Normal 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, " + ")
|
||||
}
|
||||
Reference in New Issue
Block a user