Added recipient account id and bank id to ShowTransferMoneyDialogData
This commit is contained in:
parent
418c188eb6
commit
89b700b740
|
@ -22,4 +22,6 @@ interface BankingRepository {
|
|||
|
||||
fun getAllTransactionsOfUserAccount(userAccount: UserAccountEntity): List<AccountTransactionEntity>
|
||||
|
||||
fun getTransactionById(transactionId: Long): AccountTransactionEntity?
|
||||
|
||||
}
|
|
@ -40,6 +40,9 @@ class InMemoryBankingRepository(
|
|||
override fun getAllTransactionsOfUserAccount(userAccount: UserAccountEntity): List<AccountTransactionEntity> =
|
||||
getAllAccountTransactions().filter { it.userAccountId == userAccount.id }
|
||||
|
||||
override fun getTransactionById(transactionId: Long): AccountTransactionEntity? =
|
||||
getAllAccountTransactions().firstOrNull { it.id == transactionId }
|
||||
|
||||
|
||||
private fun map(account: UserAccount) = UserAccountEntity(
|
||||
nextId++,
|
||||
|
|
|
@ -107,75 +107,16 @@ open class SqliteBankingRepository(
|
|||
}.executeAsList()
|
||||
|
||||
override fun getAllAccountTransactions(): List<AccountTransactionEntity> {
|
||||
return accountTransactionQueries.selectAllTransactions { id, userAccountId, bankAccountId, amount, currency, reference, bookingDate, valueDate, otherPartyName, otherPartyBankCode, otherPartyAccountId, bookingText, userSetDisplayName, category, notes, information, statementNumber, sequenceNumber, openingBalance, closingBalance, endToEndReference, customerReference, mandateReference, creditorIdentifier, originatorsIdentificationCode, compensationAmount, originalAmount, sepaReference, deviantOriginator, deviantRecipient, referenceWithNoSpecialType, primaNotaNumber, textKeySupplement, currencyType, bookingKey, referenceForTheAccountOwner, referenceOfTheAccountServicingInstitution, supplementaryDetails, transactionReferenceNumber, relatedReferenceNumber ->
|
||||
AccountTransactionEntity(
|
||||
id,
|
||||
userAccountId, bankAccountId,
|
||||
|
||||
Amount(amount), currency, reference,
|
||||
mapToDate(bookingDate), mapToDate(valueDate),
|
||||
otherPartyName, otherPartyBankCode, otherPartyAccountId,
|
||||
bookingText,
|
||||
|
||||
userSetDisplayName, category, notes,
|
||||
|
||||
information,
|
||||
statementNumber?.toInt(), sequenceNumber?.toInt(),
|
||||
|
||||
mapToAmount(openingBalance), mapToAmount(closingBalance),
|
||||
|
||||
endToEndReference, customerReference, mandateReference,
|
||||
creditorIdentifier, originatorsIdentificationCode,
|
||||
compensationAmount, originalAmount,
|
||||
sepaReference,
|
||||
deviantOriginator, deviantRecipient,
|
||||
referenceWithNoSpecialType, primaNotaNumber,
|
||||
textKeySupplement,
|
||||
|
||||
currencyType, bookingKey,
|
||||
referenceForTheAccountOwner, referenceOfTheAccountServicingInstitution,
|
||||
supplementaryDetails,
|
||||
|
||||
transactionReferenceNumber, relatedReferenceNumber
|
||||
)
|
||||
}.executeAsList()
|
||||
return accountTransactionQueries.selectAllTransactions(::mapTransaction).executeAsList()
|
||||
}
|
||||
|
||||
override fun getAllTransactionsOfUserAccount(userAccount: UserAccountEntity): List<AccountTransactionEntity> {
|
||||
return accountTransactionQueries.selectAllTransactionsOfUserAccount(userAccount.id) { id, userAccountId, bankAccountId, amount, currency, reference, bookingDate, valueDate, otherPartyName, otherPartyBankCode, otherPartyAccountId, bookingText, userSetDisplayName, category, notes, information, statementNumber, sequenceNumber, openingBalance, closingBalance, endToEndReference, customerReference, mandateReference, creditorIdentifier, originatorsIdentificationCode, compensationAmount, originalAmount, sepaReference, deviantOriginator, deviantRecipient, referenceWithNoSpecialType, primaNotaNumber, textKeySupplement, currencyType, bookingKey, referenceForTheAccountOwner, referenceOfTheAccountServicingInstitution, supplementaryDetails, transactionReferenceNumber, relatedReferenceNumber ->
|
||||
AccountTransactionEntity(
|
||||
id,
|
||||
userAccountId, bankAccountId,
|
||||
|
||||
Amount(amount), currency, reference,
|
||||
mapToDate(bookingDate), mapToDate(valueDate),
|
||||
otherPartyName, otherPartyBankCode, otherPartyAccountId,
|
||||
bookingText,
|
||||
|
||||
userSetDisplayName, category, notes,
|
||||
|
||||
information,
|
||||
statementNumber?.toInt(), sequenceNumber?.toInt(),
|
||||
|
||||
mapToAmount(openingBalance), mapToAmount(closingBalance),
|
||||
|
||||
endToEndReference, customerReference, mandateReference,
|
||||
creditorIdentifier, originatorsIdentificationCode,
|
||||
compensationAmount, originalAmount,
|
||||
sepaReference,
|
||||
deviantOriginator, deviantRecipient,
|
||||
referenceWithNoSpecialType, primaNotaNumber,
|
||||
textKeySupplement,
|
||||
|
||||
currencyType, bookingKey,
|
||||
referenceForTheAccountOwner, referenceOfTheAccountServicingInstitution,
|
||||
supplementaryDetails,
|
||||
|
||||
transactionReferenceNumber, relatedReferenceNumber
|
||||
)
|
||||
}.executeAsList()
|
||||
return accountTransactionQueries.selectAllTransactionsOfUserAccount(userAccount.id, ::mapTransaction).executeAsList()
|
||||
}
|
||||
|
||||
override fun getTransactionById(transactionId: Long): AccountTransactionEntity? =
|
||||
accountTransactionQueries.getTransactionWithId(transactionId, ::mapTransaction).executeAsOneOrNull()
|
||||
|
||||
|
||||
override suspend fun persistTransactions(bankAccount: BankAccountEntity, transactions: List<AccountTransaction>): List<AccountTransactionEntity> {
|
||||
return accountTransactionQueries.transactionWithResult {
|
||||
|
@ -225,6 +166,49 @@ open class SqliteBankingRepository(
|
|||
userAccountQueries.getLastInsertedId().executeAsOne()
|
||||
|
||||
|
||||
private fun mapTransaction(
|
||||
id: Long, userAccountId: Long, bankAccountId: Long,
|
||||
amount: String, currency: String, reference: String, bookingDate: String, valueDate: String,
|
||||
otherPartyName: String?, otherPartyBankCode: String?, otherPartyAccountId: String?, bookingText: String?,
|
||||
userSetDisplayName: String?, category: String?, notes: String?,
|
||||
information: String?, statementNumber: Long?, sequenceNumber: Long?,
|
||||
openingBalance: String?, closingBalance: String?,
|
||||
endToEndReference: String?, customerReference: String?, mandateReference: String?, creditorIdentifier: String?, originatorsIdentificationCode: String?,
|
||||
compensationAmount: String?, originalAmount: String?, sepaReference: String?, deviantOriginator: String?, deviantRecipient: String?, referenceWithNoSpecialType: String?,
|
||||
primaNotaNumber: String?, textKeySupplement: String?, currencyType: String?, bookingKey: String?, referenceForTheAccountOwner: String?, referenceOfTheAccountServicingInstitution: String?,
|
||||
supplementaryDetails: String?, transactionReferenceNumber: String?, relatedReferenceNumber: String?): AccountTransactionEntity =
|
||||
AccountTransactionEntity(
|
||||
id,
|
||||
userAccountId, bankAccountId,
|
||||
|
||||
Amount(amount), currency, reference,
|
||||
mapToDate(bookingDate), mapToDate(valueDate),
|
||||
otherPartyName, otherPartyBankCode, otherPartyAccountId,
|
||||
bookingText,
|
||||
|
||||
userSetDisplayName, category, notes,
|
||||
|
||||
information,
|
||||
statementNumber?.toInt(), sequenceNumber?.toInt(),
|
||||
|
||||
mapToAmount(openingBalance), mapToAmount(closingBalance),
|
||||
|
||||
endToEndReference, customerReference, mandateReference,
|
||||
creditorIdentifier, originatorsIdentificationCode,
|
||||
compensationAmount, originalAmount,
|
||||
sepaReference,
|
||||
deviantOriginator, deviantRecipient,
|
||||
referenceWithNoSpecialType, primaNotaNumber,
|
||||
textKeySupplement,
|
||||
|
||||
currencyType, bookingKey,
|
||||
referenceForTheAccountOwner, referenceOfTheAccountServicingInstitution,
|
||||
supplementaryDetails,
|
||||
|
||||
transactionReferenceNumber, relatedReferenceNumber
|
||||
)
|
||||
|
||||
|
||||
@JvmName("mapAmount")
|
||||
@JsName("mapAmount")
|
||||
private fun mapAmount(amount: Amount?): String? =
|
||||
|
|
|
@ -12,6 +12,7 @@ import androidx.compose.ui.input.pointer.pointerInput
|
|||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.DpOffset
|
||||
import androidx.compose.ui.unit.dp
|
||||
import kotlinx.coroutines.launch
|
||||
import net.codinux.banking.client.model.UserAccount
|
||||
import net.codinux.banking.ui.composables.BankIcon
|
||||
import net.codinux.banking.ui.config.Colors
|
||||
|
@ -37,16 +38,24 @@ fun TransactionListItem(userAccount: UserAccount?, transaction: AccountTransacti
|
|||
|
||||
var showMenuAt by remember { mutableStateOf<DpOffset?>(null) }
|
||||
|
||||
val coroutineScope = rememberCoroutineScope()
|
||||
|
||||
|
||||
fun newMoneyTransferToOtherParty(withSameData: Boolean) {
|
||||
showMenuAt = null
|
||||
|
||||
DI.uiState.showTransferMoneyDialogData.value = ShowTransferMoneyDialogData(
|
||||
DI.uiState.userAccounts.value.firstNotNullOf { it.accounts.firstOrNull { it.id == transaction.bankAccountId } },
|
||||
transaction.otherPartyName,
|
||||
if (withSameData) transaction.amount else null,
|
||||
if (withSameData) transaction.reference else null
|
||||
)
|
||||
coroutineScope.launch {
|
||||
val transactionEntity = DI.bankingService.getTransaction(transaction.id)
|
||||
|
||||
DI.uiState.showTransferMoneyDialogData.value = ShowTransferMoneyDialogData(
|
||||
DI.uiState.userAccounts.value.firstNotNullOf { it.accounts.firstOrNull { it.id == transaction.bankAccountId } },
|
||||
transaction.otherPartyName,
|
||||
transactionEntity?.otherPartyBankCode,
|
||||
transactionEntity?.otherPartyAccountId,
|
||||
if (withSameData) transaction.amount else null,
|
||||
if (withSameData) transaction.reference else null
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -103,7 +112,7 @@ fun TransactionListItem(userAccount: UserAccount?, transaction: AccountTransacti
|
|||
)
|
||||
}
|
||||
|
||||
DropdownMenu(showMenuAt != null, { showMenuAt = null }, Modifier.widthIn(min = 350.dp),
|
||||
DropdownMenu(showMenuAt != null, { showMenuAt = null }, Modifier.widthIn(min = 375.dp),
|
||||
offset = showMenuAt ?: DpOffset.Zero,
|
||||
) {
|
||||
DropdownMenuItem({ newMoneyTransferToOtherParty(false) }) {
|
||||
|
|
|
@ -56,7 +56,7 @@ fun TransferMoneyDialog(
|
|||
var senderAccount by remember { mutableStateOf(data.senderAccount ?: accountsSupportingTransferringMoney.first()) }
|
||||
|
||||
var recipientName by remember { mutableStateOf(data.recipientName ?: "") }
|
||||
var recipientAccountIdentifier by remember { mutableStateOf("") }
|
||||
var recipientAccountIdentifier by remember { mutableStateOf(data.recipientAccountIdentifier ?: "") }
|
||||
var amount by remember { mutableStateOf(data.amount?.amount ?: "") }
|
||||
var paymentReference by remember { mutableStateOf(data.reference ?: "") }
|
||||
val accountSupportsInstantTransfer by remember(senderAccount) { derivedStateOf { senderAccount.supportsAnyFeature(BankAccountFeatures.InstantPayment) } }
|
||||
|
|
|
@ -6,7 +6,8 @@ import net.codinux.banking.dataaccess.entities.BankAccountEntity
|
|||
data class ShowTransferMoneyDialogData(
|
||||
val senderAccount: BankAccountEntity? = null,
|
||||
val recipientName: String? = null,
|
||||
// TODO: add recipient account identifier
|
||||
val recipientBankCode: String? = null,
|
||||
val recipientAccountIdentifier: String? = null,
|
||||
val amount: Amount? = null,
|
||||
val reference: String? = null
|
||||
)
|
|
@ -65,6 +65,8 @@ class BankingService(
|
|||
|
||||
fun getAllAccountTransactionsAsViewModel() = bankingRepository.getAllAccountTransactionsAsViewModel()
|
||||
|
||||
fun getTransaction(transactionId: Long) = bankingRepository.getTransactionById(transactionId)
|
||||
|
||||
|
||||
suspend fun findBanks(query: String): List<BankInfo> =
|
||||
bankFinder.findBankByNameBankCodeOrCity(query, 25)
|
||||
|
|
|
@ -124,4 +124,8 @@ FROM AccountTransaction;
|
|||
|
||||
selectAllTransactionsOfUserAccount:
|
||||
SELECT AccountTransaction.*
|
||||
FROM AccountTransaction WHERE userAccountId = ?;
|
||||
FROM AccountTransaction WHERE userAccountId = ?;
|
||||
|
||||
getTransactionWithId:
|
||||
SELECT AccountTransaction.*
|
||||
FROM AccountTransaction WHERE id = ?;
|
Loading…
Reference in New Issue