|
|
|
@ -4,9 +4,10 @@ import android.content.Context |
|
|
|
import com.github.mikephil.charting.data.Entry |
|
|
|
import com.github.mikephil.charting.data.Entry |
|
|
|
import com.github.mikephil.charting.data.LineDataSet |
|
|
|
import com.github.mikephil.charting.data.LineDataSet |
|
|
|
import io.realm.Realm |
|
|
|
import io.realm.Realm |
|
|
|
|
|
|
|
import net.pokeranalytics.android.exceptions.PAIllegalStateException |
|
|
|
import net.pokeranalytics.android.model.filter.Query |
|
|
|
import net.pokeranalytics.android.model.filter.Query |
|
|
|
import net.pokeranalytics.android.model.filter.QueryCondition |
|
|
|
import net.pokeranalytics.android.model.filter.QueryCondition |
|
|
|
import net.pokeranalytics.android.model.interfaces.DatedValue |
|
|
|
import net.pokeranalytics.android.model.interfaces.DatedGraphEntry |
|
|
|
import net.pokeranalytics.android.model.realm.Bankroll |
|
|
|
import net.pokeranalytics.android.model.realm.Bankroll |
|
|
|
import net.pokeranalytics.android.model.realm.Transaction |
|
|
|
import net.pokeranalytics.android.model.realm.Transaction |
|
|
|
import net.pokeranalytics.android.ui.graph.DataSetFactory |
|
|
|
import net.pokeranalytics.android.ui.graph.DataSetFactory |
|
|
|
@ -116,12 +117,12 @@ class BankrollReport(var setup: BankrollReportSetup) { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* The list of dated items used for the graph |
|
|
|
* The list of dated items used for the graph |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private var evolutionItems: MutableList<DatedValue> = mutableListOf() |
|
|
|
private var evolutionItems: MutableList<DatedGraphEntry> = mutableListOf() |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Adds a list of dated items to the evolution items used to get the bankroll graph |
|
|
|
* 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<DatedGraphEntry>) { |
|
|
|
this.evolutionItems.addAll(items) |
|
|
|
this.evolutionItems.addAll(items) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -143,7 +144,7 @@ class BankrollReport(var setup: BankrollReportSetup) { |
|
|
|
bucket.addTransaction(transaction) |
|
|
|
bucket.addTransaction(transaction) |
|
|
|
|
|
|
|
|
|
|
|
} ?: run { |
|
|
|
} ?: run { |
|
|
|
throw IllegalStateException("Transaction has no type") |
|
|
|
throw PAIllegalStateException("Transaction has no type") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
@ -162,7 +163,7 @@ class BankrollReport(var setup: BankrollReportSetup) { |
|
|
|
var total = this.initial |
|
|
|
var total = this.initial |
|
|
|
this.evolutionItems.forEach { |
|
|
|
this.evolutionItems.forEach { |
|
|
|
total += it.amount |
|
|
|
total += it.amount |
|
|
|
val point = BRGraphPoint(total, it.date, it) |
|
|
|
val point = BRGraphPoint(total, it.date, it.objectIdentifier) |
|
|
|
this.evolutionPoints.add(point) |
|
|
|
this.evolutionPoints.add(point) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -276,6 +277,6 @@ class TransactionBucket(var name: String, useRate: Boolean = false) { |
|
|
|
|
|
|
|
|
|
|
|
data class BRGraphPoint(var value: Double, var date: Date, var data: Any? = null) { |
|
|
|
data class BRGraphPoint(var value: Double, var date: Date, var data: Any? = null) { |
|
|
|
|
|
|
|
|
|
|
|
var variation: Double = 0.0 |
|
|
|
// var variation: Double = 0.0 |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|