Setting countDaysForWhichTransactionsAreKept now on account and not on bank anymore as the count may differs from account type to account type (e.g. 540 days for checking accounts and 9999 days for credit card accounts)

This commit is contained in:
dankito 2020-09-30 00:01:33 +02:00
parent 6d41b89f1d
commit 5580313eeb
14 changed files with 24 additions and 20 deletions

View File

@ -409,7 +409,7 @@ open class FinTsClient(
val successful = response.successful && (parameter.alsoRetrieveBalance == false || balance != null) val successful = response.successful && (parameter.alsoRetrieveBalance == false || balance != null)
val fromDate = parameter.fromDate val fromDate = parameter.fromDate
?: dialogContext.bank.countDaysForWhichTransactionsAreKept?.let { Date(Date.today.millisSinceEpoch - it * OneDayMillis) } ?: parameter.account.countDaysForWhichTransactionsAreKept?.let { Date(Date.today.millisSinceEpoch - it * OneDayMillis) }
?: bookedTransactions.map { it.valueDate }.sortedBy { it.millisSinceEpoch }.firstOrNull() ?: bookedTransactions.map { it.valueDate }.sortedBy { it.millisSinceEpoch }.firstOrNull()
val retrievedData = RetrievedAccountData(parameter.account, successful, balance, bookedTransactions, unbookedTransactions, fromDate, parameter.toDate ?: Date.today) val retrievedData = RetrievedAccountData(parameter.account, successful, balance, bookedTransactions, unbookedTransactions, fromDate, parameter.toDate ?: Date.today)
@ -1011,10 +1011,6 @@ open class FinTsClient(
} }
} }
response.receivedSegments.filterIsInstance<RetrieveAccountTransactionsInMt940Parameters>().firstOrNull()?.let { retrieveTransactionsParameters ->
bank.countDaysForWhichTransactionsAreKept = retrieveTransactionsParameters.countDaysForWhichTransactionsAreKept
}
response.getFirstSegmentById<SepaAccountInfo>(InstituteSegmentId.SepaAccountInfo)?.let { sepaAccountInfo -> response.getFirstSegmentById<SepaAccountInfo>(InstituteSegmentId.SepaAccountInfo)?.let { sepaAccountInfo ->
sepaAccountInfo.account.bic?.let { sepaAccountInfo.account.bic?.let {
bank.bic = it // TODO: really set BIC on bank then? bank.bic = it // TODO: really set BIC on bank then?
@ -1066,6 +1062,10 @@ open class FinTsClient(
mapAccountType(accountInfo), accountInfo.currency, accountHolderName, accountInfo.productName, mapAccountType(accountInfo), accountInfo.currency, accountHolderName, accountInfo.productName,
accountInfo.accountLimit, accountInfo.allowedJobNames) accountInfo.accountLimit, accountInfo.allowedJobNames)
bank.supportedJobs.filterIsInstance<RetrieveAccountTransactionsParameters>().sortedByDescending { it.segmentVersion }.firstOrNull { newAccount.allowedJobNames.contains(it.jobName) }?.let { transactionsParameters ->
newAccount.countDaysForWhichTransactionsAreKept = transactionsParameters.countDaysForWhichTransactionsAreKept
}
bank.addAccount(newAccount) bank.addAccount(newAccount)
} }

View File

@ -29,6 +29,9 @@ open class AccountData(
get() = FinTsClient.SupportedAccountTypes.contains(accountType) get() = FinTsClient.SupportedAccountTypes.contains(accountType)
open var countDaysForWhichTransactionsAreKept: Int? = null
protected open val _supportedFeatures = mutableSetOf<AccountFeature>() protected open val _supportedFeatures = mutableSetOf<AccountFeature>()
open val supportedFeatures: Collection<AccountFeature> open val supportedFeatures: Collection<AccountFeature>

View File

@ -42,8 +42,6 @@ open class BankData(
*/ */
open var countMaxJobsPerMessage: Int = 0, open var countMaxJobsPerMessage: Int = 0,
open var countDaysForWhichTransactionsAreKept: Int? = null,
open var supportedHbciVersions: List<HbciVersion> = listOf(), open var supportedHbciVersions: List<HbciVersion> = listOf(),
open var supportedJobs: List<JobParameters> = listOf() open var supportedJobs: List<JobParameters> = listOf()
) { ) {

View File

@ -34,14 +34,13 @@ open class Bank(
override var tanMedia: List<TanMedium> = listOf(), override var tanMedia: List<TanMedium> = listOf(),
override var countDaysForWhichTransactionsAreKept: Int? = null,
@PrimaryKey(autoGenerate = true) @PrimaryKey(autoGenerate = true)
open var id: Long = BaseDao.IdNotSet, open var id: Long = BaseDao.IdNotSet,
override var technicalId: String = id.toString(), override var technicalId: String = id.toString(),
override var savePassword: Boolean = true,
override var userSetDisplayName: String? = null, override var userSetDisplayName: String? = null,
override var displayIndex: Int = 0 override var displayIndex: Int = 0
) : TypedBankData { ) : TypedBankData {

View File

@ -60,6 +60,8 @@ open class BankAccount(
override var isAccountTypeSupportedByApplication: Boolean = true override var isAccountTypeSupportedByApplication: Boolean = true
override var countDaysForWhichTransactionsAreKept: Int? = null
override var userSetDisplayName: String? = null override var userSetDisplayName: String? = null

View File

@ -33,6 +33,7 @@ open class BankAccountEntity(
override var userSetDisplayName: String? = null, override var userSetDisplayName: String? = null,
override var haveAllTransactionsBeenRetrieved: Boolean = false, override var haveAllTransactionsBeenRetrieved: Boolean = false,
override var isAccountTypeSupportedByApplication: Boolean = true, override var isAccountTypeSupportedByApplication: Boolean = true,
override var countDaysForWhichTransactionsAreKept: Int? = null,
override var displayIndex: Int = 0, override var displayIndex: Int = 0,
override var hideAccount: Boolean = false, override var hideAccount: Boolean = false,
override var updateAccountAutomatically: Boolean = true, override var updateAccountAutomatically: Boolean = true,

View File

@ -23,8 +23,8 @@ open class BankDataEntity(
override var supportedTanMethods: List<TanMethod> = listOf(), override var supportedTanMethods: List<TanMethod> = listOf(),
override var selectedTanMethod: TanMethod? = null, override var selectedTanMethod: TanMethod? = null,
override var tanMedia: List<TanMedium> = listOf(), override var tanMedia: List<TanMedium> = listOf(),
override var countDaysForWhichTransactionsAreKept: Int? = null,
override var technicalId: String = UUID.randomUUID().toString(), override var technicalId: String = UUID.randomUUID().toString(),
override var savePassword: Boolean = true,
override var userSetDisplayName: String? = null, override var userSetDisplayName: String? = null,
override var displayIndex: Int = 0 override var displayIndex: Int = 0
) : IBankData<BankAccountEntity, AccountTransactionEntity> { ) : IBankData<BankAccountEntity, AccountTransactionEntity> {

View File

@ -44,6 +44,8 @@ open class BankAccount @JvmOverloads constructor(
override var isAccountTypeSupportedByApplication: Boolean = true override var isAccountTypeSupportedByApplication: Boolean = true
override var countDaysForWhichTransactionsAreKept: Int? = null
override var userSetDisplayName: String? = null override var userSetDisplayName: String? = null

View File

@ -29,6 +29,7 @@ interface IBankAccount<TTransaction: IAccountTransaction> : OrderedDisplayable {
var technicalId: String var technicalId: String
var haveAllTransactionsBeenRetrieved: Boolean var haveAllTransactionsBeenRetrieved: Boolean
var isAccountTypeSupportedByApplication: Boolean var isAccountTypeSupportedByApplication: Boolean
var countDaysForWhichTransactionsAreKept: Int?
var userSetDisplayName: String? var userSetDisplayName: String?
/** /**

View File

@ -57,9 +57,6 @@ interface IBankData<TAccount: IBankAccount<TAccountTransaction>, TAccountTransac
get() = tanMedia.sortedByDescending { it.status == TanMediumStatus.Used } get() = tanMedia.sortedByDescending { it.status == TanMediumStatus.Used }
var countDaysForWhichTransactionsAreKept: Int?
val stringRepresentation: String val stringRepresentation: String
get() = "$bankName $userName" get() = "$bankName $userName"

View File

@ -400,7 +400,7 @@ open class BankingPresenter(
} }
protected open fun didFetchAllTransactionsStoredOnBankServer(account: IBankAccount<IAccountTransaction>, fetchedTransactions: Collection<IAccountTransaction>): Boolean { protected open fun didFetchAllTransactionsStoredOnBankServer(account: IBankAccount<IAccountTransaction>, fetchedTransactions: Collection<IAccountTransaction>): Boolean {
account.bank.countDaysForWhichTransactionsAreKept?.let { countDaysForWhichTransactionsAreKept -> account.countDaysForWhichTransactionsAreKept?.let { countDaysForWhichTransactionsAreKept ->
(account.retrievedTransactionsFromOn ?: getDateOfFirstRetrievedTransaction(account.bookedTransactions) ?: getDateOfFirstRetrievedTransaction(fetchedTransactions))?.let { retrievedTransactionsFromOn -> (account.retrievedTransactionsFromOn ?: getDateOfFirstRetrievedTransaction(account.bookedTransactions) ?: getDateOfFirstRetrievedTransaction(fetchedTransactions))?.let { retrievedTransactionsFromOn ->
val dayOfFirstTransactionStoredOnBankServer = Date(Date.today.millisSinceEpoch - countDaysForWhichTransactionsAreKept * OneDayMillis) val dayOfFirstTransactionStoredOnBankServer = Date(Date.today.millisSinceEpoch - countDaysForWhichTransactionsAreKept * OneDayMillis)

View File

@ -47,6 +47,7 @@
<attribute name="accountHolderName" attributeType="String"/> <attribute name="accountHolderName" attributeType="String"/>
<attribute name="accountLimit" optional="YES" attributeType="String"/> <attribute name="accountLimit" optional="YES" attributeType="String"/>
<attribute name="balance" attributeType="Decimal" defaultValueString="0.0"/> <attribute name="balance" attributeType="Decimal" defaultValueString="0.0"/>
<attribute name="countDaysForWhichTransactionsAreKept" optional="YES" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="YES"/>
<attribute name="currency" attributeType="String"/> <attribute name="currency" attributeType="String"/>
<attribute name="displayIndex" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="YES"/> <attribute name="displayIndex" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="YES"/>
<attribute name="doNotShowStrikingFetchAllTransactionsView" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/> <attribute name="doNotShowStrikingFetchAllTransactionsView" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES"/>
@ -73,7 +74,6 @@
<attribute name="bankCode" attributeType="String"/> <attribute name="bankCode" attributeType="String"/>
<attribute name="bankName" attributeType="String"/> <attribute name="bankName" attributeType="String"/>
<attribute name="bic" attributeType="String"/> <attribute name="bic" attributeType="String"/>
<attribute name="countDaysForWhichTransactionsAreKept" optional="YES" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="NO"/>
<attribute name="customerName" attributeType="String"/> <attribute name="customerName" attributeType="String"/>
<attribute name="displayIndex" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="YES"/> <attribute name="displayIndex" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="YES"/>
<attribute name="finTsServerAddress" attributeType="String"/> <attribute name="finTsServerAddress" attributeType="String"/>
@ -107,7 +107,7 @@
<elements> <elements>
<element name="PersistedAccountTransaction" positionX="-36" positionY="45" width="128" height="553"/> <element name="PersistedAccountTransaction" positionX="-36" positionY="45" width="128" height="553"/>
<element name="PersistedAppSettings" positionX="-45" positionY="144" width="128" height="118"/> <element name="PersistedAppSettings" positionX="-45" positionY="144" width="128" height="118"/>
<element name="PersistedBankAccount" positionX="-54" positionY="63" width="128" height="403"/> <element name="PersistedBankAccount" positionX="-54" positionY="63" width="128" height="418"/>
<element name="PersistedBankData" positionX="-63" positionY="-18" width="128" height="283"/> <element name="PersistedBankData" positionX="-63" positionY="-18" width="128" height="283"/>
<element name="PersistedTanMedium" positionX="-45" positionY="144" width="128" height="28"/> <element name="PersistedTanMedium" positionX="-45" positionY="144" width="128" height="28"/>
<element name="PersistedTanMethod" positionX="-54" positionY="135" width="128" height="118"/> <element name="PersistedTanMethod" positionX="-54" positionY="135" width="128" height="118"/>

View File

@ -37,7 +37,6 @@ class Mapper {
mapped.customerName = bank.customerName mapped.customerName = bank.customerName
mapped.userId = bank.userId mapped.userId = bank.userId
mapped.iconUrl = bank.iconUrl mapped.iconUrl = bank.iconUrl
mapped.countDaysForWhichTransactionsAreKept = mapFromInt(bank.countDaysForWhichTransactionsAreKept)
mapped.userSetDisplayName = bank.userSetDisplayName mapped.userSetDisplayName = bank.userSetDisplayName
mapped.displayIndex = bank.displayIndex mapped.displayIndex = bank.displayIndex
@ -62,6 +61,7 @@ class Mapper {
mapped.haveAllTransactionsBeenRetrieved = account.haveAllTransactionsBeenRetrieved mapped.haveAllTransactionsBeenRetrieved = account.haveAllTransactionsBeenRetrieved
mapped.isAccountTypeSupportedByApplication = account.isAccountTypeSupportedByApplication mapped.isAccountTypeSupportedByApplication = account.isAccountTypeSupportedByApplication
mapped.countDaysForWhichTransactionsAreKept = mapToInt(account.countDaysForWhichTransactionsAreKept)
mapped.userSetDisplayName = account.userSetDisplayName mapped.userSetDisplayName = account.userSetDisplayName
mapped.displayIndex = account.displayIndex mapped.displayIndex = account.displayIndex
@ -92,7 +92,6 @@ class Mapper {
mapped.balance = account.balance.decimal mapped.balance = account.balance.decimal
mapped.currency = account.currency mapped.currency = account.currency
mapped.type = map(account.type) mapped.type = map(account.type)
mapped.isAccountTypeSupportedByApplication = account.isAccountTypeSupportedByApplication
mapped.productName = account.productName mapped.productName = account.productName
mapped.accountLimit = account.accountLimit mapped.accountLimit = account.accountLimit
mapped.retrievedTransactionsFromOn = account.retrievedTransactionsFromOn?.date mapped.retrievedTransactionsFromOn = account.retrievedTransactionsFromOn?.date
@ -103,6 +102,8 @@ class Mapper {
mapped.supportsRealTimeTransfer = account.supportsRealTimeTransfer mapped.supportsRealTimeTransfer = account.supportsRealTimeTransfer
mapped.haveAllTransactionsBeenRetrieved = account.haveAllTransactionsBeenRetrieved mapped.haveAllTransactionsBeenRetrieved = account.haveAllTransactionsBeenRetrieved
mapped.isAccountTypeSupportedByApplication = account.isAccountTypeSupportedByApplication
mapped.countDaysForWhichTransactionsAreKept = mapFromInt(account.countDaysForWhichTransactionsAreKept)
mapped.userSetDisplayName = account.userSetDisplayName mapped.userSetDisplayName = account.userSetDisplayName
mapped.displayIndex = account.displayIndex mapped.displayIndex = account.displayIndex

View File

@ -77,7 +77,6 @@ open class fints4kModelMapper(protected val modelCreator: IModelCreator) {
bank.bankName = fintsBank.bankName bank.bankName = fintsBank.bankName
bank.bic = fintsBank.bic bank.bic = fintsBank.bic
bank.customerName = fintsBank.customerName bank.customerName = fintsBank.customerName
bank.countDaysForWhichTransactionsAreKept = fintsBank.countDaysForWhichTransactionsAreKept
bank.userId = fintsBank.userId bank.userId = fintsBank.userId
bank.accounts = mapAccounts(bank, fintsBank.accounts) bank.accounts = mapAccounts(bank, fintsBank.accounts)
@ -120,6 +119,7 @@ open class fints4kModelMapper(protected val modelCreator: IModelCreator) {
account.currency = accountData.currency ?: "EUR" account.currency = accountData.currency ?: "EUR"
account.type = mapBankAccountType(accountData.accountType) account.type = mapBankAccountType(accountData.accountType)
account.isAccountTypeSupportedByApplication = accountData.isAccountTypeSupportedByApplication account.isAccountTypeSupportedByApplication = accountData.isAccountTypeSupportedByApplication
account.countDaysForWhichTransactionsAreKept = accountData.countDaysForWhichTransactionsAreKept
account.productName = accountData.productName account.productName = accountData.productName
account.accountLimit = accountData.accountLimit account.accountLimit = accountData.accountLimit