Implemented displaying remittee's bank name
This commit is contained in:
parent
e44a68addc
commit
bf41bde90a
|
@ -15,6 +15,11 @@ abstract class BankFinderBase : IBankFinder {
|
||||||
|
|
||||||
protected abstract fun findBankByNameOrCityForNonEmptyQuery(query: String): List<BankInfo>
|
protected abstract fun findBankByNameOrCityForNonEmptyQuery(query: String): List<BankInfo>
|
||||||
|
|
||||||
|
abstract fun searchBankByBic(bic: String): BankInfo?
|
||||||
|
|
||||||
|
|
||||||
|
protected val cachedBanksByBic = mutableMapOf<String, BankInfo?>()
|
||||||
|
|
||||||
|
|
||||||
override fun findBankByNameBankCodeOrCity(query: String?): List<BankInfo> {
|
override fun findBankByNameBankCodeOrCity(query: String?): List<BankInfo> {
|
||||||
if (query.isNullOrBlank()) {
|
if (query.isNullOrBlank()) {
|
||||||
|
@ -29,6 +34,19 @@ abstract class BankFinderBase : IBankFinder {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
override fun findBankByBic(bic: String): BankInfo? {
|
||||||
|
cachedBanksByBic[bic]?.let {
|
||||||
|
return it
|
||||||
|
}
|
||||||
|
|
||||||
|
val bankForBic = searchBankByBic(bic)
|
||||||
|
|
||||||
|
cachedBanksByBic[bic] = bankForBic
|
||||||
|
|
||||||
|
return bankForBic
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
protected open fun loadBankListFile(): List<BankInfo> {
|
protected open fun loadBankListFile(): List<BankInfo> {
|
||||||
try {
|
try {
|
||||||
val bankListString = readBankListFile()
|
val bankListString = readBankListFile()
|
||||||
|
|
|
@ -43,6 +43,11 @@ open class InMemoryBankFinder() : BankFinderBase(), IBankFinder {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
override fun searchBankByBic(bic: String): BankInfo? {
|
||||||
|
return getBankList().firstOrNull { it.bic == bic }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
override fun preloadBankList() {
|
override fun preloadBankList() {
|
||||||
findBankByBankCode("1")
|
findBankByBankCode("1")
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,6 +104,15 @@ open class LuceneBankFinder(indexFolder: File) : BankFinderBase(), IBankFinder {
|
||||||
return getBanksFromQuery(luceneQuery)
|
return getBanksFromQuery(luceneQuery)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun searchBankByBic(bic: String): BankInfo? {
|
||||||
|
(bankFinderWhileUpdatingIndex as? BankFinderBase)?.let {
|
||||||
|
return it.searchBankByBic(bic)
|
||||||
|
}
|
||||||
|
|
||||||
|
return getBanksFromQuery(queries.exact(BankInfoBicFieldName, bic)).firstOrNull()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
override fun getBankList(): List<BankInfo> {
|
override fun getBankList(): List<BankInfo> {
|
||||||
bankFinderWhileUpdatingIndex?.let {
|
bankFinderWhileUpdatingIndex?.let {
|
||||||
return it.getBankList()
|
return it.getBankList()
|
||||||
|
@ -178,10 +187,10 @@ open class LuceneBankFinder(indexFolder: File) : BankFinderBase(), IBankFinder {
|
||||||
return writer.createDocumentForNonNullFields(
|
return writer.createDocumentForNonNullFields(
|
||||||
fields.fullTextSearchField(BankInfoNameFieldName, bank.name, true),
|
fields.fullTextSearchField(BankInfoNameFieldName, bank.name, true),
|
||||||
fields.keywordField(BankInfoBankCodeFieldName, bank.bankCode, true),
|
fields.keywordField(BankInfoBankCodeFieldName, bank.bankCode, true),
|
||||||
|
fields.keywordField(BankInfoBicFieldName, bank.bic, true),
|
||||||
fields.fullTextSearchField(BankInfoCityIndexedFieldName, bank.city, true),
|
fields.fullTextSearchField(BankInfoCityIndexedFieldName, bank.city, true),
|
||||||
|
|
||||||
fields.storedField(BankInfoCityStoredFieldName, bank.city),
|
fields.storedField(BankInfoCityStoredFieldName, bank.city),
|
||||||
fields.storedField(BankInfoBicFieldName, bank.bic),
|
|
||||||
fields.storedField(BankInfoPostalCodeFieldName, bank.postalCode),
|
fields.storedField(BankInfoPostalCodeFieldName, bank.postalCode),
|
||||||
fields.storedField(BankInfoChecksumMethodFieldName, bank.checksumMethod),
|
fields.storedField(BankInfoChecksumMethodFieldName, bank.checksumMethod),
|
||||||
fields.nullableStoredField(BankInfoPinTanServerAddressFieldName, bank.pinTanAddress),
|
fields.nullableStoredField(BankInfoPinTanServerAddressFieldName, bank.pinTanAddress),
|
||||||
|
|
|
@ -18,6 +18,8 @@ open class RemitteeListAdapter(protected val itemClicked: ((Remittee) -> Unit)?
|
||||||
override fun bindItemToView(viewHolder: RemitteeViewHolder, item: Remittee) {
|
override fun bindItemToView(viewHolder: RemitteeViewHolder, item: Remittee) {
|
||||||
viewHolder.txtvwRemitteeName.text = item.name
|
viewHolder.txtvwRemitteeName.text = item.name
|
||||||
|
|
||||||
|
viewHolder.txtvwRemitteeBankName.text = item.bankName
|
||||||
|
|
||||||
viewHolder.txtvwRemitteeBankCode.text = item.iban
|
viewHolder.txtvwRemitteeBankCode.text = item.iban
|
||||||
|
|
||||||
viewHolder.itemView.setOnClickListener {
|
viewHolder.itemView.setOnClickListener {
|
||||||
|
|
|
@ -10,6 +10,8 @@ open class RemitteeViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView
|
||||||
|
|
||||||
val txtvwRemitteeName: TextView = itemView.txtvwRemitteeName
|
val txtvwRemitteeName: TextView = itemView.txtvwRemitteeName
|
||||||
|
|
||||||
|
val txtvwRemitteeBankName: TextView = itemView.txtvwRemitteeBankName
|
||||||
|
|
||||||
val txtvwRemitteeBankCode: TextView = itemView.txtvwRemitteeBankCode
|
val txtvwRemitteeBankCode: TextView = itemView.txtvwRemitteeBankCode
|
||||||
|
|
||||||
}
|
}
|
|
@ -16,11 +16,20 @@
|
||||||
android:textSize="@dimen/list_item_bank_info_bank_name_text_size"
|
android:textSize="@dimen/list_item_bank_info_bank_name_text_size"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/txtvwRemitteeBankName"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="@dimen/list_item_remittee_space_between_fields"
|
||||||
|
style="@style/TextAppearance.AppCompat.Small"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/txtvwRemitteeBankCode"
|
android:id="@+id/txtvwRemitteeBankCode"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="@dimen/list_item_remittee_bank_code_margin_top"
|
android:layout_marginTop="@dimen/list_item_remittee_space_between_fields"
|
||||||
android:layout_marginBottom="@dimen/list_item_remittee_bank_code_margin_bottom"
|
android:layout_marginBottom="@dimen/list_item_remittee_bank_code_margin_bottom"
|
||||||
style="@style/TextAppearance.AppCompat.Small"
|
style="@style/TextAppearance.AppCompat.Small"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
|
|
|
@ -61,8 +61,8 @@
|
||||||
<dimen name="list_item_bank_account_icon_margin_right">8dp</dimen>
|
<dimen name="list_item_bank_account_icon_margin_right">8dp</dimen>
|
||||||
<dimen name="list_item_bank_account_text_size">13sp</dimen>
|
<dimen name="list_item_bank_account_text_size">13sp</dimen>
|
||||||
|
|
||||||
<dimen name="list_item_remittee_height">60dp</dimen>
|
<dimen name="list_item_remittee_height">80dp</dimen>
|
||||||
<dimen name="list_item_remittee_bank_code_margin_top">6dp</dimen>
|
<dimen name="list_item_remittee_space_between_fields">4dp</dimen>
|
||||||
<dimen name="list_item_remittee_bank_code_margin_bottom">6dp</dimen>
|
<dimen name="list_item_remittee_bank_code_margin_bottom">6dp</dimen>
|
||||||
|
|
||||||
<dimen name="view_tan_image_controls_buttons_height">40dp</dimen>
|
<dimen name="view_tan_image_controls_buttons_height">40dp</dimen>
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
package net.dankito.banking.ui.javafx.dialogs.cashtransfer
|
package net.dankito.banking.ui.javafx.dialogs.cashtransfer
|
||||||
|
|
||||||
import net.dankito.banking.search.Remittee
|
import net.dankito.banking.search.Remittee
|
||||||
import tornadofx.ListCellFragment
|
import tornadofx.*
|
||||||
import tornadofx.bindTo
|
|
||||||
import tornadofx.label
|
|
||||||
import tornadofx.vbox
|
|
||||||
|
|
||||||
|
|
||||||
open class RemitteeListCellFragment : ListCellFragment<Remittee>() {
|
open class RemitteeListCellFragment : ListCellFragment<Remittee>() {
|
||||||
|
@ -15,6 +12,12 @@ open class RemitteeListCellFragment : ListCellFragment<Remittee>() {
|
||||||
override val root = vbox {
|
override val root = vbox {
|
||||||
label(remittee.name)
|
label(remittee.name)
|
||||||
|
|
||||||
|
label(remittee.bankName) {
|
||||||
|
vboxConstraints {
|
||||||
|
marginTopBottom(6.0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
label(remittee.iban)
|
label(remittee.iban)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,8 @@ open class RemitteeViewModel : ItemViewModel<Remittee>() {
|
||||||
|
|
||||||
val name = bind { SimpleStringProperty(item?.name) }
|
val name = bind { SimpleStringProperty(item?.name) }
|
||||||
|
|
||||||
|
val bankName = bind { SimpleStringProperty(item?.bankName) }
|
||||||
|
|
||||||
val iban = bind { SimpleStringProperty(item?.iban) }
|
val iban = bind { SimpleStringProperty(item?.iban) }
|
||||||
|
|
||||||
}
|
}
|
|
@ -9,6 +9,8 @@ interface IBankFinder {
|
||||||
|
|
||||||
fun findBankByNameBankCodeOrCity(query: String?): List<BankInfo>
|
fun findBankByNameBankCodeOrCity(query: String?): List<BankInfo>
|
||||||
|
|
||||||
|
fun findBankByBic(bic: String): BankInfo?
|
||||||
|
|
||||||
fun preloadBankList()
|
fun preloadBankList()
|
||||||
|
|
||||||
}
|
}
|
|
@ -4,7 +4,8 @@ package net.dankito.banking.search
|
||||||
data class Remittee(
|
data class Remittee(
|
||||||
val name: String,
|
val name: String,
|
||||||
val iban: String?,
|
val iban: String?,
|
||||||
val bic: String?
|
val bic: String?,
|
||||||
|
var bankName: String? = null
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -414,7 +414,13 @@ open class BankingPresenter(
|
||||||
}
|
}
|
||||||
|
|
||||||
open fun findRemitteesForName(name: String): List<Remittee> {
|
open fun findRemitteesForName(name: String): List<Remittee> {
|
||||||
return remitteeSearcher.findRemittees(name)
|
return remitteeSearcher.findRemittees(name).map { remittee ->
|
||||||
|
remittee.bic?.let { bic ->
|
||||||
|
remittee.bankName = bankFinder.findBankByBic(bic)?.name
|
||||||
|
}
|
||||||
|
|
||||||
|
remittee
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue