diff --git a/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/MessageLogEntry.kt b/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/MessageLogEntry.kt index 977a8d31..8e25da97 100644 --- a/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/MessageLogEntry.kt +++ b/BankingClientModel/src/commonMain/kotlin/net/codinux/banking/client/model/MessageLogEntry.kt @@ -6,10 +6,18 @@ import kotlinx.datetime.Instant open class MessageLogEntry( open val type: MessageLogEntryType, open val message: String, - open val messageTrace: String? = null, + open val messageWithoutSensitiveData: String? = null, open val error: Throwable? = null, open val time: Instant = Clock.System.now(), + val messageNumberString: String? = null, + val messageNumber: Int? = null, + + val jobType: String? = null, + val messageCategory: String? = null, + val bank: BankAccess? = null, // TODO: make non-null val account: BankAccount? = null -) \ No newline at end of file +) { + override fun toString() = "$messageNumberString $jobType $messageCategory $type $message" +} \ No newline at end of file diff --git a/FinTs4jBankingClient/src/commonMain/kotlin/net/codinux/banking/client/fints4k/FinTs4kBankingClient.kt b/FinTs4jBankingClient/src/commonMain/kotlin/net/codinux/banking/client/fints4k/FinTs4kBankingClient.kt index 19a2a99e..42078411 100644 --- a/FinTs4jBankingClient/src/commonMain/kotlin/net/codinux/banking/client/fints4k/FinTs4kBankingClient.kt +++ b/FinTs4jBankingClient/src/commonMain/kotlin/net/codinux/banking/client/fints4k/FinTs4kBankingClient.kt @@ -56,7 +56,7 @@ open class FinTs4kBankingClient( Triple(account, parameter, response) } - return mapper.map(responses) + return mapper.map(bank, responses) } return Response.error(ErrorType.NoneOfTheAccountsSupportsRetrievingData, "Keines der Konten unterstützt das Abholen der Umsätze oder des Kontostands") // TODO: translate diff --git a/FinTs4jBankingClient/src/commonMain/kotlin/net/codinux/banking/client/fints4k/FinTs4kMapper.kt b/FinTs4jBankingClient/src/commonMain/kotlin/net/codinux/banking/client/fints4k/FinTs4kMapper.kt index 78dac98e..530fcf5e 100644 --- a/FinTs4jBankingClient/src/commonMain/kotlin/net/codinux/banking/client/fints4k/FinTs4kMapper.kt +++ b/FinTs4jBankingClient/src/commonMain/kotlin/net/codinux/banking/client/fints4k/FinTs4kMapper.kt @@ -7,6 +7,7 @@ import kotlinx.datetime.toLocalDateTime import net.codinux.banking.client.model.* import net.codinux.banking.client.model.AccountTransaction import net.codinux.banking.client.model.Amount +import net.codinux.banking.client.model.MessageLogEntry import net.codinux.banking.client.model.MessageLogEntryType import net.codinux.banking.client.model.extensions.EuropeBerlin import net.codinux.banking.client.model.tan.* @@ -32,7 +33,6 @@ import net.codinux.banking.fints.messages.datenelemente.implementierte.tan.TanGe import net.codinux.banking.fints.messages.datenelemente.implementierte.tan.TanMedium import net.codinux.banking.fints.messages.datenelemente.implementierte.tan.TanMediumStatus import net.codinux.banking.fints.model.* -import net.codinux.banking.fints.model.MessageLogEntry import net.codinux.banking.fints.serialization.FinTsModelSerializer import net.codinux.banking.fints.transactions.swift.model.Holding import net.dankito.banking.banklistcreator.prettifier.BankingGroupMapper @@ -102,17 +102,17 @@ open class FinTs4kMapper { mapError(response, mapMessageLog(response)) } - open fun map(responses: List>): Response> { + open fun map(bank: BankAccess, responses: List>): Response> { val type = if (responses.all { it.third.successful }) ResponseType.Success else ResponseType.Error // TODO: update BankAccess and BankAccount objects according to retrieved data val mappedResponses = responses.map { (account, param, getAccountDataResponse) -> - val bank = getAccountDataResponse.customerAccount - val finTsBankAccount = bank?.accounts?.firstOrNull { it.identifier == account.identifier && it.subAccountNumber == account.subAccountNumber } + val fintsBank = getAccountDataResponse.customerAccount + val finTsBankAccount = fintsBank?.accounts?.firstOrNull { it.identifier == account.identifier && it.subAccountNumber == account.subAccountNumber } - val messageLog = mapMessageLog(getAccountDataResponse) + val messageLog = mapMessageLog(getAccountDataResponse, bank, account) - if (getAccountDataResponse.successful && bank != null && finTsBankAccount != null) { + if (getAccountDataResponse.successful && fintsBank != null && finTsBankAccount != null) { if (finTsBankAccount.lastAccountUpdateTime != null) { account.lastAccountUpdateTime = finTsBankAccount.lastAccountUpdateTime } @@ -413,24 +413,33 @@ open class FinTs4kMapper { open fun mapToMoney(amount: Amount, currency: String): Money = Money(amount.toString(), currency) - open fun mapMessageLog(response: FinTsClientResponse, bank: BankAccess? = null, account: BankAccount? = null) = - mapMessageLog(response.messageLog, bank) + open fun mapMessageLog(response: net.dankito.banking.client.model.response.FinTsClientResponse, bank: BankAccess? = null, account: BankAccount? = null) = + mapMessageLog(response.messageLog, bank, account) - open fun mapMessageLog(messageLog: List, bank: BankAccess? = null, account: BankAccount? = null) = - messageLog.map { mapMessageLogEntry(it) } + open fun mapMessageLog(messageLog: List, bank: BankAccess? = null, account: BankAccount? = null) = + messageLog.map { mapMessageLogEntry(it, bank, account) } - open fun mapMessageLogEntry(messageLogEntry: MessageLogEntry, bank: BankAccess? = null, account: BankAccount? = null): net.codinux.banking.client.model.MessageLogEntry { + open fun mapMessageLogEntry(messageLogEntry: net.codinux.banking.fints.model.MessageLogEntry, bank: BankAccess? = null, account: BankAccount? = null): MessageLogEntry { // TODO: may map messageLogEntry.context.BankData to BankAccess - val fintsAccount = messageLogEntry.context.account + val context = messageLogEntry.context + val fintsAccount = context.account val effectiveAccount = account ?: bank?.accounts?.firstOrNull { it.identifier == fintsAccount?.accountIdentifier && it.subAccountNumber == fintsAccount?.subAccountAttribute } - return net.codinux.banking.client.model.MessageLogEntry( + val messageNumberString = "${context.jobNumber.toString().padStart(2, '0')}_${context.dialogNumber.toString().padStart(2, '0')}_${context.messageNumber.toString().padStart(2, '0')}" + + return MessageLogEntry( MessageLogEntryType.valueOf(messageLogEntry.type.name), - messageLogEntry.message, messageLogEntry.messageTrace, + messageLogEntry.message, messageLogEntry.messageWithoutSensitiveData, messageLogEntry.error, messageLogEntry.time, - bank = bank, - account = effectiveAccount + messageNumberString, + messageNumberString.replace("_", "").toIntOrNull(), + + context.jobType.toString(), + context.messageType.toString(), + + bank, + effectiveAccount ) }