Adjusted to new data model that AccountTransaction now has userSetReference and userSetOtherPartyName, and that userSetDisplayName got added to TanMedium, TanMethod and Holding

This commit is contained in:
dankito 2024-09-17 00:59:08 +02:00
parent 34f2fca126
commit 75ccc648c5
8 changed files with 65 additions and 31 deletions

View File

@ -120,7 +120,7 @@ open class SqliteBankingRepository(
}
private fun getAllTanMethods(): List<TanMethodEntity> = bankQueries.getAllTanMethods { id, bankId, displayName, type, identifier, maxTanInputLength, allowedTanFormat ->
private fun getAllTanMethods(): List<TanMethodEntity> = bankQueries.getAllTanMethods { id, bankId, displayName, type, identifier, maxTanInputLength, allowedTanFormat, userSetDisplayName ->
TanMethodEntity(
id,
bankId,
@ -129,7 +129,9 @@ open class SqliteBankingRepository(
mapToEnum(type, TanMethodType.entries),
identifier,
mapToInt(maxTanInputLength),
mapToEnum(allowedTanFormat, AllowedTanFormat.entries)
mapToEnum(allowedTanFormat, AllowedTanFormat.entries),
userSetDisplayName
)
}.executeAsList()
@ -144,7 +146,9 @@ open class SqliteBankingRepository(
mapEnum(tanMethod.type),
tanMethod.identifier,
mapInt(tanMethod.maxTanInputLength),
mapEnum(tanMethod.allowedTanFormat)
mapEnum(tanMethod.allowedTanFormat),
tanMethod.userSetDisplayName
)
val tanMethodId = getLastInsertedId()
@ -153,7 +157,7 @@ open class SqliteBankingRepository(
}
private fun getAllTanMedia(): List<TanMediumEntity> = bankQueries.getAllTanMedia { id, bankId, type, mediumName, status, phoneNumber, concealedPhoneNumber, cardNumber, cardSequenceNumber, cardType, validFrom, validTo ->
private fun getAllTanMedia(): List<TanMediumEntity> = bankQueries.getAllTanMedia { id, bankId, type, mediumName, status, phoneNumber, concealedPhoneNumber, cardNumber, cardSequenceNumber, cardType, validFrom, validTo, userSetDisplayName ->
val mobilePhone = if (phoneNumber != null || concealedPhoneNumber != null) {
MobilePhoneTanMedium(phoneNumber, concealedPhoneNumber)
} else {
@ -175,7 +179,9 @@ open class SqliteBankingRepository(
mapToEnum(status, TanMediumStatus.entries),
tanGenerator,
mobilePhone
mobilePhone,
userSetDisplayName
)
}.executeAsList()
@ -197,7 +203,9 @@ open class SqliteBankingRepository(
medium.tanGenerator?.cardSequenceNumber,
mapInt(medium.tanGenerator?.cardType),
mapDate(medium.tanGenerator?.validFrom),
mapDate(medium.tanGenerator?.validTo)
mapDate(medium.tanGenerator?.validTo),
medium.userSetDisplayName
)
val tanMediumId = getLastInsertedId()
@ -266,8 +274,8 @@ open class SqliteBankingRepository(
override fun getAllAccountTransactionsAsViewModel(): List<AccountTransactionViewModel> =
accountTransactionQueries.getAllTransactionsAsViewModel { id, bankId, accountId, amount, currency, reference, valueDate, otherPartyName, postingText, userSetDisplayName, category ->
AccountTransactionViewModel(id, bankId, accountId, mapToAmount(amount), currency, reference, mapToDate(valueDate), otherPartyName, postingText, userSetDisplayName, category)
accountTransactionQueries.getAllTransactionsAsViewModel { id, bankId, accountId, amount, currency, reference, valueDate, otherPartyName, postingText, userSetDisplayName, userSetOtherPartyName ->
AccountTransactionViewModel(id, bankId, accountId, mapToAmount(amount), currency, reference, mapToDate(valueDate), otherPartyName, postingText, userSetDisplayName, userSetOtherPartyName)
}.executeAsList()
override fun getAllAccountTransactions(): List<AccountTransactionEntity> {
@ -305,7 +313,8 @@ open class SqliteBankingRepository(
mapAmount(transaction.openingBalance), mapAmount(transaction.closingBalance),
transaction.userSetDisplayName, transaction.category, transaction.notes,
transaction.userSetReference, transaction.userSetReference,
transaction.category, transaction.notes,
transaction.statementNumber?.toLong(), transaction.sheetNumber?.toLong(),
@ -345,7 +354,8 @@ open class SqliteBankingRepository(
openingBalance: String?, closingBalance: String?,
userSetDisplayName: String?, category: String?, notes: String?,
userSetDisplayName: String?, userSetReference: String?,
category: String?, notes: String?,
statementNumber: Long?, sheetNumber: Long?,
@ -375,7 +385,8 @@ open class SqliteBankingRepository(
mapToAmount(openingBalance), mapToAmount(closingBalance),
userSetDisplayName, category, notes,
userSetDisplayName, userSetReference,
category, notes,
statementNumber?.toInt(), sheetNumber?.toInt(),

View File

@ -25,7 +25,8 @@ class AccountTransactionEntity(
openingBalance: Amount? = null,
closingBalance: Amount? = null,
userSetDisplayName: String? = null,
userSetReference: String? = null,
userSetOtherPartyName: String? = null,
category: String? = null,
notes: String? = null,
@ -80,7 +81,7 @@ class AccountTransactionEntity(
isReversal,
userSetDisplayName, category, notes
userSetReference, userSetOtherPartyName, category, notes
) {
constructor(id: Long, bankId: Long, accountId: Long, transaction: AccountTransaction) : this(
id, bankId, accountId,
@ -93,7 +94,8 @@ class AccountTransactionEntity(
transaction.openingBalance, transaction.closingBalance,
transaction.userSetDisplayName, transaction.category, transaction.notes,
transaction.userSetReference, transaction.userSetOtherPartyName,
transaction.category, transaction.notes,
transaction.statementNumber, transaction.sheetNumber,

View File

@ -3,6 +3,7 @@ package net.codinux.banking.dataaccess.entities
import kotlinx.datetime.Instant
import kotlinx.datetime.LocalDate
import net.codinux.banking.client.model.*
import kotlin.jvm.JvmName
class BankAccountEntity(
val id: Long,
@ -74,6 +75,7 @@ class BankAccountEntity(
)
@JvmName("addHoldingsEntities")
fun addHoldings(holdings: List<HoldingEntity>) {
this.holdings.addAll(holdings)
}

View File

@ -11,10 +11,12 @@ class TanMediumEntity(
status: TanMediumStatus,
tanGenerator: TanGeneratorTanMedium? = null,
mobilePhone: MobilePhoneTanMedium? = null
) : TanMedium(type, mediumName, status, tanGenerator, mobilePhone) {
mobilePhone: MobilePhoneTanMedium? = null,
userSetDisplayName: String? = null
) : TanMedium(type, mediumName, status, tanGenerator, mobilePhone, userSetDisplayName) {
constructor(id: Long, bankId: Long, medium: TanMedium)
: this(id, bankId, medium.type, medium.mediumName, medium.status, medium.tanGenerator, medium.mobilePhone)
: this(id, bankId, medium.type, medium.mediumName, medium.status, medium.tanGenerator, medium.mobilePhone, medium.userSetDisplayName)
}

View File

@ -12,10 +12,12 @@ class TanMethodEntity(
type: TanMethodType,
identifier: String,
maxTanInputLength: Int? = null,
allowedTanFormat: AllowedTanFormat = AllowedTanFormat.Alphanumeric
) : TanMethod(displayName, type, identifier, maxTanInputLength, allowedTanFormat) {
allowedTanFormat: AllowedTanFormat = AllowedTanFormat.Alphanumeric,
userSetDisplayName: String? = null,
) : TanMethod(displayName, type, identifier, maxTanInputLength, allowedTanFormat, userSetDisplayName) {
constructor(id: Long, bankId: Long, tanMethod: TanMethod)
: this(id, bankId, tanMethod.displayName, tanMethod.type, tanMethod.identifier, tanMethod.maxTanInputLength, tanMethod.allowedTanFormat)
: this(id, bankId, tanMethod.displayName, tanMethod.type, tanMethod.identifier, tanMethod.maxTanInputLength, tanMethod.allowedTanFormat, tanMethod.userSetDisplayName)
}

View File

@ -17,11 +17,11 @@ data class AccountTransactionViewModel(
val otherPartyName: String? = null,
val postingText: String? = null,
val userSetDisplayName: String? = null,
val category: String? = null
val userSetReference: String? = null,
val userSetOtherPartyName: String? = null
) {
constructor(entity: AccountTransactionEntity) : this(entity.id, entity.bankId, entity.accountId, entity)
constructor(id: Long, bankId: Long, accountId: Long, transaction: AccountTransaction)
: this(id, bankId, accountId, transaction.amount, transaction.currency, transaction.reference, transaction.valueDate, transaction.otherPartyName, transaction.postingText)
: this(id, bankId, accountId, transaction.amount, transaction.currency, transaction.reference, transaction.valueDate, transaction.otherPartyName, transaction.postingText, transaction.userSetReference, transaction.userSetOtherPartyName)
}

View File

@ -22,7 +22,8 @@ CREATE TABLE IF NOT EXISTS AccountTransaction (
openingBalance TEXT,
closingBalance TEXT,
userSetDisplayName TEXT,
userSetReference TEXT,
userSetOtherPartyName TEXT,
category TEXT,
notes TEXT,
@ -72,7 +73,8 @@ INSERT INTO AccountTransaction(
openingBalance, closingBalance,
userSetDisplayName, category, notes,
userSetReference, userSetOtherPartyName,
category, notes,
statementNumber, sheetNumber,
@ -102,7 +104,8 @@ VALUES(
?, ?,
?, ?, ?,
?, ?,
?, ?,
?, ?,
@ -129,7 +132,7 @@ SELECT AccountTransaction.*
FROM AccountTransaction;
getAllTransactionsAsViewModel:
SELECT id, bankId, accountId, amount, currency, reference, valueDate, otherPartyName, postingText, userSetDisplayName, category
SELECT id, bankId, accountId, amount, currency, reference, valueDate, otherPartyName, postingText, userSetReference, userSetOtherPartyName
FROM AccountTransaction;

View File

@ -165,7 +165,9 @@ CREATE TABLE IF NOT EXISTS TanMethod (
type TEXT NOT NULL,
identifier TEXT NOT NULL,
maxTanInputLength INTEGER ,
allowedTanFormat TEXT NOT NULL
allowedTanFormat TEXT NOT NULL,
userSetDisplayName TEXT
);
CREATE INDEX idx_TanMethod_bankId
@ -180,7 +182,9 @@ INSERT INTO TanMethod(
type,
identifier,
maxTanInputLength,
allowedTanFormat
allowedTanFormat,
userSetDisplayName
)
VALUES (
?,
@ -189,6 +193,8 @@ VALUES (
?,
?,
?,
?,
?
);
@ -217,7 +223,9 @@ CREATE TABLE IF NOT EXISTS TanMedium (
cardSequenceNumber TEXT,
cardType INTEGER,
validFrom TEXT,
validTo TEXT
validTo TEXT,
userSetDisplayName TEXT
);
CREATE INDEX idx_TanMedium_bankId
@ -239,7 +247,9 @@ INSERT INTO TanMedium(
cardSequenceNumber,
cardType,
validFrom,
validTo
validTo,
userSetDisplayName
)
VALUES (
?,
@ -255,6 +265,8 @@ VALUES (
?,
?,
?,
?,
?
);