Fixed that changes make in UI settings haven't been reflected in clients
This commit is contained in:
parent
b7d94e8a17
commit
744af2880c
|
@ -1,6 +1,7 @@
|
|||
package net.dankito.banking.ui
|
||||
|
||||
import net.dankito.banking.ui.model.BankAccount
|
||||
import net.dankito.banking.ui.model.Customer
|
||||
import net.dankito.banking.ui.model.MessageLogEntry
|
||||
import net.dankito.banking.ui.model.parameters.GetTransactionsParameter
|
||||
import net.dankito.banking.ui.model.parameters.TransferMoneyData
|
||||
|
@ -24,4 +25,7 @@ interface IBankingClient {
|
|||
|
||||
fun transferMoneyAsync(data: TransferMoneyData, callback: (BankingClientResponse) -> Unit)
|
||||
|
||||
|
||||
fun dataChanged(customer: Customer)
|
||||
|
||||
}
|
|
@ -394,6 +394,8 @@ open class BankingPresenter(
|
|||
|
||||
open fun accountUpdated(bank: Customer) {
|
||||
persistAccount(bank)
|
||||
|
||||
getBankingClientForAccount(bank)?.dataChanged(bank)
|
||||
}
|
||||
|
||||
open fun accountUpdated(account: BankAccount) {
|
||||
|
|
|
@ -65,7 +65,7 @@ open class fints4kBankingClient(
|
|||
|
||||
protected open fun handleAddAccountResponse(response: net.dankito.banking.fints.response.client.AddAccountResponse,
|
||||
callback: (AddAccountResponse) -> Unit) {
|
||||
mapper.mapCustomer(customer, bank)
|
||||
mapper.mapBank(customer, bank)
|
||||
val mappedResponse = mapper.mapResponse(customer, response)
|
||||
|
||||
saveData()
|
||||
|
@ -132,6 +132,11 @@ open class fints4kBankingClient(
|
|||
}
|
||||
|
||||
|
||||
override fun dataChanged(customer: Customer) {
|
||||
mapper.mapChangesFromUiToClientModel(customer, bank)
|
||||
}
|
||||
|
||||
|
||||
protected open fun findAccountForBankAccount(bankAccount: BankAccount, findAccountResult: (AccountData?, error: String?) -> Unit) {
|
||||
val mappedAccount = mapper.findAccountForBankAccount(bank, bankAccount)
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ open class fints4kModelMapper {
|
|||
}
|
||||
|
||||
|
||||
open fun mapCustomer(customer: Customer, bank: BankData) {
|
||||
open fun mapBank(customer: Customer, bank: BankData) {
|
||||
customer.bankCode = bank.bankCode
|
||||
customer.customerId = bank.customerId
|
||||
customer.password = bank.pin
|
||||
|
@ -75,6 +75,18 @@ open class fints4kModelMapper {
|
|||
updateTanMediaAndProcedures(customer, bank)
|
||||
}
|
||||
|
||||
/**
|
||||
* In UI only customerId, password, (bankCode,) and selected TAN procedure can be set
|
||||
*/
|
||||
open fun mapChangesFromUiToClientModel(customer: Customer, bank: BankData) {
|
||||
bank.customerId = customer.customerId
|
||||
bank.pin = customer.password
|
||||
|
||||
bank.bankCode = customer.bankCode
|
||||
|
||||
bank.selectedTanProcedure = findTanProcedure(bank, customer.selectedTanProcedure) ?: bank.selectedTanProcedure
|
||||
}
|
||||
|
||||
// TODO: move to a fints4k internal mapper
|
||||
open fun updateCustomer(bank: BankData, updatedBank: BankData) {
|
||||
bank.pin = updatedBank.pin
|
||||
|
@ -284,6 +296,14 @@ open class fints4kModelMapper {
|
|||
return customer.supportedTanProcedures.firstOrNull { it.bankInternalProcedureCode == tanProcedure.securityFunction.code }
|
||||
}
|
||||
|
||||
protected open fun findTanProcedure(bank: BankData, tanProcedure: TanProcedure?): net.dankito.banking.fints.model.TanProcedure? {
|
||||
if (tanProcedure == null) {
|
||||
return null
|
||||
}
|
||||
|
||||
return bank.tanProceduresAvailableForUser.firstOrNull { it.securityFunction.code == tanProcedure.bankInternalProcedureCode }
|
||||
}
|
||||
|
||||
|
||||
open fun mapTanMediums(tanMediums: List<net.dankito.banking.fints.messages.datenelemente.implementierte.tan.TanMedium>): List<TanMedium> {
|
||||
return tanMediums.map { mapTanMedium(it) }
|
||||
|
|
|
@ -48,7 +48,7 @@ open class hbci4jBankingClient(
|
|||
}
|
||||
|
||||
|
||||
protected val credentials = AccountCredentials(customer.bankCode, customer.customerId, customer.password)
|
||||
protected val credentials = AccountCredentials(customer)
|
||||
|
||||
|
||||
protected val mapper = hbci4jModelMapper()
|
||||
|
@ -271,6 +271,17 @@ open class hbci4jBankingClient(
|
|||
}
|
||||
|
||||
|
||||
override fun dataChanged(customer: Customer) {
|
||||
if (customer.bankCode != credentials.bankCode || customer.customerId != credentials.customerId || customer.password != credentials.password) {
|
||||
getPassportFile(credentials).delete()
|
||||
}
|
||||
|
||||
credentials.bankCode = customer.bankCode
|
||||
credentials.customerId = customer.customerId
|
||||
credentials.password = customer.password
|
||||
}
|
||||
|
||||
|
||||
protected open fun connect(): ConnectResult {
|
||||
return connect(credentials, HBCIVersion.HBCI_300)
|
||||
}
|
||||
|
@ -286,10 +297,7 @@ open class hbci4jBankingClient(
|
|||
// Die Datei kann problemlos geloescht werden. Sie wird beim naechsten mal automatisch neu erzeugt,
|
||||
// wenn der Parameter "client.passport.PinTan.init" den Wert "1" hat (siehe unten).
|
||||
// Wir speichern die Datei der Einfachheit halber im aktuellen Verzeichnis.
|
||||
val hbciClientFolder = File(dataFolder, "hbci4j-client")
|
||||
hbciClientFolder.mkdirs()
|
||||
|
||||
val passportFile = File(hbciClientFolder, "passport_${credentials.bankCode}_${credentials.customerId}.dat")
|
||||
val passportFile = getPassportFile(credentials)
|
||||
|
||||
// Wir setzen die Kernel-Parameter zur Laufzeit. Wir koennten sie alternativ
|
||||
// auch oben in "props" setzen.
|
||||
|
@ -336,6 +344,13 @@ open class hbci4jBankingClient(
|
|||
return ConnectResult(true, null, handle, passport)
|
||||
}
|
||||
|
||||
protected open fun getPassportFile(credentials: AccountCredentials): File {
|
||||
val hbciClientFolder = File(dataFolder, "hbci4j-client")
|
||||
hbciClientFolder.mkdirs()
|
||||
|
||||
return File(hbciClientFolder, "passport_${credentials.bankCode}_${credentials.customerId}.dat")
|
||||
}
|
||||
|
||||
protected open fun closeConnection(connection: ConnectResult) {
|
||||
closeConnection(connection.handle, connection.passport)
|
||||
}
|
||||
|
|
|
@ -1,8 +1,14 @@
|
|||
package net.dankito.banking.model
|
||||
|
||||
import net.dankito.banking.ui.model.Customer
|
||||
|
||||
|
||||
open class AccountCredentials(
|
||||
val bankCode: String,
|
||||
val customerId: String,
|
||||
var bankCode: String,
|
||||
var customerId: String,
|
||||
var password: String
|
||||
)
|
||||
) {
|
||||
|
||||
constructor(bank: Customer) : this(bank.bankCode, bank.customerId, bank.password)
|
||||
|
||||
}
|
Loading…
Reference in New Issue