You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
545 B
23 lines
545 B
package com.xsn.explorer.models
|
|
|
|
import play.api.libs.json._
|
|
|
|
case class Balance(
|
|
address: Address,
|
|
received: BigDecimal = BigDecimal(0),
|
|
spent: BigDecimal = BigDecimal(0)) {
|
|
|
|
def available: BigDecimal = received - spent
|
|
}
|
|
|
|
object Balance {
|
|
implicit val writes: Writes[Balance] = Writes { obj =>
|
|
val values = Map(
|
|
"address" -> JsString(obj.address.string),
|
|
"received" -> JsNumber(obj.received),
|
|
"spent" -> JsNumber(obj.spent),
|
|
"available" -> JsNumber(obj.available))
|
|
|
|
JsObject.apply(values)
|
|
}
|
|
}
|
|
|