types: show borrowed balance

This commit is contained in:
c9s 2022-04-26 16:07:27 +08:00
parent cbec4ac199
commit 2933db20cd
No known key found for this signature in database
GPG Key ID: F0A7E4490F2EBC8C

View File

@ -38,12 +38,19 @@ func (b Balance) Total() fixedpoint.Value {
return b.Available.Add(b.Locked) return b.Available.Add(b.Locked)
} }
func (b Balance) String() string { func (b Balance) String() (o string) {
o = fmt.Sprintf("%s: %s", b.Currency, b.Available.String())
if b.Locked.Sign() > 0 { if b.Locked.Sign() > 0 {
return fmt.Sprintf("%s: %v (locked %v)", b.Currency, b.Available, b.Locked) o += fmt.Sprintf(" (locked %v)", b.Locked)
} }
return fmt.Sprintf("%s: %s", b.Currency, b.Available.String()) if b.Borrowed.Sign() > 0 {
o += fmt.Sprintf(" (borrowed: %v)", b.Borrowed)
}
return o
} }
type Asset struct { type Asset struct {