Implemented that balance and account transaction's amount are formatted the same
This commit is contained in:
parent
4d551197f9
commit
f2550d4e9e
|
@ -105,7 +105,7 @@ open class AccountTransactionsTable @JvmOverloads constructor(
|
||||||
|
|
||||||
cellValueFactory = Callback { object : ObjectBinding<String>() {
|
cellValueFactory = Callback { object : ObjectBinding<String>() {
|
||||||
override fun computeValue(): String {
|
override fun computeValue(): String {
|
||||||
return it.value.amount.toString() + " " + it.value.currency
|
return presenter.formatAmount(it.value.amount) + " " + it.value.currency
|
||||||
}
|
}
|
||||||
|
|
||||||
} }
|
} }
|
||||||
|
|
|
@ -126,7 +126,7 @@ open class AccountTransactionsView(private val presenter: BankingPresenter) : Vi
|
||||||
transactionsToDisplay.setAll(presenter.searchSelectedAccountTransactions(filter))
|
transactionsToDisplay.setAll(presenter.searchSelectedAccountTransactions(filter))
|
||||||
|
|
||||||
// TODO: if transactions are filtered calculate and show balance of displayed transactions?
|
// TODO: if transactions are filtered calculate and show balance of displayed transactions?
|
||||||
balance.value = presenter.balanceOfSelectedBankAccounts.toString()
|
balance.value = presenter.formatAmount(presenter.balanceOfSelectedBankAccounts)
|
||||||
}
|
}
|
||||||
|
|
||||||
protected open fun handleGetTransactionsResponseOffUiThread(response: GetTransactionsResponse) {
|
protected open fun handleGetTransactionsResponseOffUiThread(response: GetTransactionsResponse) {
|
||||||
|
|
|
@ -294,6 +294,11 @@ open class BankingPresenter(
|
||||||
persistAccountTransactions(response.bookedTransactions, response.unbookedTransactions)
|
persistAccountTransactions(response.bookedTransactions, response.unbookedTransactions)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
open fun formatAmount(amount: BigDecimal): String {
|
||||||
|
return String.format("%.02f", amount)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
protected open fun persistAccount(account: Account) {
|
protected open fun persistAccount(account: Account) {
|
||||||
persister.saveOrUpdateAccount(account, accounts)
|
persister.saveOrUpdateAccount(account, accounts)
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import android.view.View
|
||||||
import net.dankito.banking.fints4java.android.R
|
import net.dankito.banking.fints4java.android.R
|
||||||
import net.dankito.banking.fints4java.android.ui.adapter.viewholder.AccountTransactionViewHolder
|
import net.dankito.banking.fints4java.android.ui.adapter.viewholder.AccountTransactionViewHolder
|
||||||
import net.dankito.banking.ui.model.AccountTransaction
|
import net.dankito.banking.ui.model.AccountTransaction
|
||||||
|
import net.dankito.banking.ui.presenter.BankingPresenter
|
||||||
import net.dankito.utils.android.extensions.asActivity
|
import net.dankito.utils.android.extensions.asActivity
|
||||||
import net.dankito.utils.android.extensions.setTextColorToColorResource
|
import net.dankito.utils.android.extensions.setTextColorToColorResource
|
||||||
import net.dankito.utils.android.ui.adapter.ListRecyclerAdapter
|
import net.dankito.utils.android.ui.adapter.ListRecyclerAdapter
|
||||||
|
@ -12,7 +13,7 @@ import java.math.BigDecimal
|
||||||
import java.text.DateFormat
|
import java.text.DateFormat
|
||||||
|
|
||||||
|
|
||||||
open class AccountTransactionAdapter
|
open class AccountTransactionAdapter(protected val presenter: BankingPresenter)
|
||||||
: ListRecyclerAdapter<AccountTransaction, AccountTransactionViewHolder>() {
|
: ListRecyclerAdapter<AccountTransaction, AccountTransactionViewHolder>() {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -46,7 +47,7 @@ open class AccountTransactionAdapter
|
||||||
viewHolder.txtvwUsage2.visibility = View.GONE // TODO
|
viewHolder.txtvwUsage2.visibility = View.GONE // TODO
|
||||||
viewHolder.txtvwUsage2.text = "" // TODO
|
viewHolder.txtvwUsage2.text = "" // TODO
|
||||||
|
|
||||||
viewHolder.txtvwAmount.text = String.format("%.02f", item.amount)
|
viewHolder.txtvwAmount.text = presenter.formatAmount(item.amount)
|
||||||
viewHolder.txtvwAmount.setTextColorToColorResource(if (item.amount >= BigDecimal.ZERO) R.color.positiveAmount else R.color.negativeAmount)
|
viewHolder.txtvwAmount.setTextColorToColorResource(if (item.amount >= BigDecimal.ZERO) R.color.positiveAmount else R.color.negativeAmount)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ class HomeFragment : Fragment() {
|
||||||
private lateinit var mnitmUpdateTransactions: MenuItem
|
private lateinit var mnitmUpdateTransactions: MenuItem
|
||||||
|
|
||||||
|
|
||||||
private val transactionAdapter = AccountTransactionAdapter()
|
private val transactionAdapter: AccountTransactionAdapter
|
||||||
|
|
||||||
protected var appliedTransactionsFilter = ""
|
protected var appliedTransactionsFilter = ""
|
||||||
|
|
||||||
|
@ -45,6 +45,8 @@ class HomeFragment : Fragment() {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
BankingComponent.component.inject(this)
|
BankingComponent.component.inject(this)
|
||||||
|
|
||||||
|
transactionAdapter = AccountTransactionAdapter(presenter)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -203,7 +205,7 @@ class HomeFragment : Fragment() {
|
||||||
transactionAdapter.items = presenter.searchSelectedAccountTransactions(appliedTransactionsFilter)
|
transactionAdapter.items = presenter.searchSelectedAccountTransactions(appliedTransactionsFilter)
|
||||||
|
|
||||||
// TODO: if transactions are filtered calculate and show balance of displayed transactions?
|
// TODO: if transactions are filtered calculate and show balance of displayed transactions?
|
||||||
mnitmBalance.title = presenter.balanceOfSelectedBankAccounts.toString()
|
mnitmBalance.title = presenter.formatAmount(presenter.balanceOfSelectedBankAccounts)
|
||||||
mnitmBalance.isVisible = presenter.doSelectedBankAccountsSupportRetrievingBalance
|
mnitmBalance.isVisible = presenter.doSelectedBankAccountsSupportRetrievingBalance
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue