|
|
|
@ -12,13 +12,11 @@ import net.pokeranalytics.android.ui.graph.DataSetFactory |
|
|
|
import java.util.* |
|
|
|
import java.util.* |
|
|
|
import kotlin.collections.HashMap |
|
|
|
import kotlin.collections.HashMap |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
class BankrollReport(setup: BankrollReportSetup) { |
|
|
|
* This class holds the results from the BankrollCalculator computations |
|
|
|
|
|
|
|
* It has all the information required for the Bankroll various displays |
|
|
|
/** |
|
|
|
*/ |
|
|
|
* The setup used to compute the report |
|
|
|
class BankrollReport(var setup: BankrollReportSetup) { |
|
|
|
*/ |
|
|
|
|
|
|
|
var setup: BankrollReportSetup = setup |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* The value of the bankroll |
|
|
|
* The value of the bankroll |
|
|
|
@ -49,6 +47,9 @@ class BankrollReport(setup: BankrollReportSetup) { |
|
|
|
this.computeBankrollTotal() |
|
|
|
this.computeBankrollTotal() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Computes the bankroll total |
|
|
|
|
|
|
|
*/ |
|
|
|
fun computeBankrollTotal() { |
|
|
|
fun computeBankrollTotal() { |
|
|
|
this.total = this.initial + this.netResult + this.transactionsNet |
|
|
|
this.total = this.initial + this.netResult + this.transactionsNet |
|
|
|
} |
|
|
|
} |
|
|
|
@ -82,20 +83,39 @@ class BankrollReport(setup: BankrollReportSetup) { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
var riskOfRuin: Double? = null |
|
|
|
var riskOfRuin: Double? = null |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* The list of transactions held by the bankroll |
|
|
|
|
|
|
|
*/ |
|
|
|
var transactions: List<Transaction> = mutableListOf() |
|
|
|
var transactions: List<Transaction> = mutableListOf() |
|
|
|
private set |
|
|
|
private set |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* A map containing TransactionBuckets by transaction types |
|
|
|
|
|
|
|
*/ |
|
|
|
var transactionBuckets: HashMap<String, TransactionBucket> = HashMap() |
|
|
|
var transactionBuckets: HashMap<String, TransactionBucket> = HashMap() |
|
|
|
private set |
|
|
|
private set |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* The list of bankroll graph points |
|
|
|
|
|
|
|
*/ |
|
|
|
var evolutionPoints: MutableList<BRGraphPoint> = mutableListOf() |
|
|
|
var evolutionPoints: MutableList<BRGraphPoint> = mutableListOf() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* The list of dated items used for the graph |
|
|
|
|
|
|
|
*/ |
|
|
|
var evolutionItems: MutableList<DatedValue> = mutableListOf() |
|
|
|
var evolutionItems: MutableList<DatedValue> = mutableListOf() |
|
|
|
private set |
|
|
|
private set |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Adds a list of dated items to the evolution items used to get the bankroll graph |
|
|
|
|
|
|
|
*/ |
|
|
|
fun addDatedItems(items: Collection<DatedValue>) { |
|
|
|
fun addDatedItems(items: Collection<DatedValue>) { |
|
|
|
this.evolutionItems.addAll(items) |
|
|
|
this.evolutionItems.addAll(items) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Adds a transaction to its type bucket |
|
|
|
|
|
|
|
*/ |
|
|
|
fun addTransaction(transaction: Transaction) { |
|
|
|
fun addTransaction(transaction: Transaction) { |
|
|
|
|
|
|
|
|
|
|
|
transaction.type?.let { type -> |
|
|
|
transaction.type?.let { type -> |
|
|
|
@ -116,6 +136,9 @@ class BankrollReport(setup: BankrollReportSetup) { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Generates the graph points used for the virtual bankroll |
|
|
|
|
|
|
|
*/ |
|
|
|
fun generateGraphPointsIfNecessary() { |
|
|
|
fun generateGraphPointsIfNecessary() { |
|
|
|
|
|
|
|
|
|
|
|
if (!this.setup.virtualBankroll) { |
|
|
|
if (!this.setup.virtualBankroll) { |
|
|
|
@ -131,6 +154,9 @@ class BankrollReport(setup: BankrollReportSetup) { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Returns a data set used for the bankroll graph |
|
|
|
|
|
|
|
*/ |
|
|
|
fun lineDataSet(context: Context): LineDataSet { |
|
|
|
fun lineDataSet(context: Context): LineDataSet { |
|
|
|
|
|
|
|
|
|
|
|
val entries = mutableListOf<Entry>() |
|
|
|
val entries = mutableListOf<Entry>() |
|
|
|
@ -149,11 +175,18 @@ class BankrollReport(setup: BankrollReportSetup) { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
class BankrollReportSetup(val bankroll: Bankroll? = null, val from: Date? = null, val to: Date? = null) { |
|
|
|
class BankrollReportSetup(val bankroll: Bankroll? = null, val from: Date? = null, val to: Date? = null) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Returns whether the setup concerns the virtual bankroll, |
|
|
|
|
|
|
|
* i.e. the bankroll summing all concrete bankrolls |
|
|
|
|
|
|
|
*/ |
|
|
|
val virtualBankroll: Boolean |
|
|
|
val virtualBankroll: Boolean |
|
|
|
get() { |
|
|
|
get() { |
|
|
|
return this.bankroll == null |
|
|
|
return this.bankroll == null |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* the query used to get bankroll transactions |
|
|
|
|
|
|
|
*/ |
|
|
|
val query: Query |
|
|
|
val query: Query |
|
|
|
get() { |
|
|
|
get() { |
|
|
|
val query = Query() |
|
|
|
val query = Query() |
|
|
|
@ -175,14 +208,35 @@ class BankrollReportSetup(val bankroll: Bankroll? = null, val from: Date? = null |
|
|
|
return query |
|
|
|
return query |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Returns whether or not the initial value should be added for the bankroll total |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
val shouldAddInitialValue: Boolean |
|
|
|
|
|
|
|
get() { |
|
|
|
|
|
|
|
return this.from == null |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* A TransactionBucket holds a list of transactions and computes its amount sum |
|
|
|
|
|
|
|
*/ |
|
|
|
class TransactionBucket(useRate: Boolean = false) { |
|
|
|
class TransactionBucket(useRate: Boolean = false) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* A list of transactions |
|
|
|
|
|
|
|
*/ |
|
|
|
var transactions: MutableList<Transaction> = mutableListOf() |
|
|
|
var transactions: MutableList<Transaction> = mutableListOf() |
|
|
|
private set |
|
|
|
private set |
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* The sum of all transactions |
|
|
|
|
|
|
|
*/ |
|
|
|
var total: Double = 0.0 |
|
|
|
var total: Double = 0.0 |
|
|
|
private set |
|
|
|
private set |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Whether the bankroll rate should be used |
|
|
|
|
|
|
|
*/ |
|
|
|
var useRate: Boolean = useRate |
|
|
|
var useRate: Boolean = useRate |
|
|
|
private set |
|
|
|
private set |
|
|
|
|
|
|
|
|
|
|
|
|