|
|
|
@ -30,7 +30,7 @@ open class Result : RealmObject(), Filterable { |
|
|
|
set(value) { |
|
|
|
set(value) { |
|
|
|
field = value |
|
|
|
field = value |
|
|
|
this.computeNumberOfRebuy() |
|
|
|
this.computeNumberOfRebuy() |
|
|
|
this.computeNet() |
|
|
|
this.computeNet(true) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
@ -39,7 +39,7 @@ open class Result : RealmObject(), Filterable { |
|
|
|
var cashout: Double? = null |
|
|
|
var cashout: Double? = null |
|
|
|
set(value) { |
|
|
|
set(value) { |
|
|
|
field = value |
|
|
|
field = value |
|
|
|
this.computeNet() |
|
|
|
this.computeNet(true) |
|
|
|
if (value != null) { |
|
|
|
if (value != null) { |
|
|
|
this.session?.end() |
|
|
|
this.session?.end() |
|
|
|
} |
|
|
|
} |
|
|
|
@ -60,9 +60,9 @@ open class Result : RealmObject(), Filterable { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
field = value |
|
|
|
field = value |
|
|
|
this.computeNet() |
|
|
|
this.computeNet(false) |
|
|
|
if (value != null) { |
|
|
|
if (value != null) { |
|
|
|
this.session.end() |
|
|
|
this.session?.end() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -103,12 +103,27 @@ open class Result : RealmObject(), Filterable { |
|
|
|
val isPositive: Int = if (this.net >= 0.0) 1 else 0 |
|
|
|
val isPositive: Int = if (this.net >= 0.0) 1 else 0 |
|
|
|
|
|
|
|
|
|
|
|
// Computes the Net |
|
|
|
// Computes the Net |
|
|
|
private fun computeNet() { |
|
|
|
private fun computeNet(withBuyin: Boolean? = null) { |
|
|
|
|
|
|
|
|
|
|
|
val transactionsSum = transactions.sumByDouble { it.amount } |
|
|
|
val transactionsSum = transactions.sumByDouble { it.amount } |
|
|
|
|
|
|
|
|
|
|
|
val isLive = this.session?.isLive ?: true |
|
|
|
// choose the method to compute the net |
|
|
|
if (isLive) { |
|
|
|
var useBuyin = withBuyin ?: true |
|
|
|
|
|
|
|
if (withBuyin == null) { |
|
|
|
|
|
|
|
if (netResult != null) { |
|
|
|
|
|
|
|
useBuyin = false |
|
|
|
|
|
|
|
} else if (buyin != null || cashout != null) { |
|
|
|
|
|
|
|
useBuyin = true |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
this.session?.let { session -> |
|
|
|
|
|
|
|
if (session.isCashGame() && !session.isLive) { |
|
|
|
|
|
|
|
useBuyin = false |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (useBuyin) { |
|
|
|
val buyin = this.buyin ?: 0.0 |
|
|
|
val buyin = this.buyin ?: 0.0 |
|
|
|
val cashOut = this.cashout ?: 0.0 |
|
|
|
val cashOut = this.cashout ?: 0.0 |
|
|
|
this.net = cashOut - buyin + transactionsSum |
|
|
|
this.net = cashOut - buyin + transactionsSum |
|
|
|
|