summaryrefslogtreecommitdiff
path: root/sandbox/src/main/kotlin/tech/libeufin
diff options
context:
space:
mode:
authorMS <ms@taler.net>2023-05-23 14:07:11 +0200
committerMS <ms@taler.net>2023-05-23 14:07:11 +0200
commitc2061383dd400528fde8426a0c72a3888c31a555 (patch)
treecdf791b09992e77710e7cfa35353f4977159644f /sandbox/src/main/kotlin/tech/libeufin
parentd827d155c9fc7b4008bc8f8ed8b9c5158eb1f9b3 (diff)
downloadlibeufin-c2061383dd400528fde8426a0c72a3888c31a555.tar.gz
libeufin-c2061383dd400528fde8426a0c72a3888c31a555.tar.bz2
libeufin-c2061383dd400528fde8426a0c72a3888c31a555.zip
fix cash-out DB fetcher
Diffstat (limited to 'sandbox/src/main/kotlin/tech/libeufin')
-rw-r--r--sandbox/src/main/kotlin/tech/libeufin/sandbox/ConversionService.kt24
1 files changed, 15 insertions, 9 deletions
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/ConversionService.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/ConversionService.kt
index a080dc80..c760a2b1 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/ConversionService.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/ConversionService.kt
@@ -107,7 +107,7 @@ fun downloadLoop(block: () -> Unit) {
* that came from Nexus. The result is the regional amount
* that will be wired to the exchange Sandbox account.
*/
-private fun applyBuyinRatioAndFees(
+fun applyBuyinRatioAndFees(
amount: BigDecimal,
ratiosAndFees: RatioAndFees
): BigDecimal {
@@ -248,21 +248,27 @@ fun buyinMonitor(
}
}
-// DB query helper. The List return type (instead of SizedIterable) lets
-// the caller NOT open a transaction block to access the values -- although
-// some operations _on the values_ may be forbidden.
-private fun getUnsubmittedTransactions(bankAccountLabel: String): List<BankAccountTransactionEntity> {
+/* DB query helper that fetches the latest cash-out operations that were
+ confirmed in the regional currency. A cash-out operation is 'confirmed'
+ when the bank account pointed by the parameter 'bankAccountLabel' gets
+ one incoming payment.
+
+ The List return type (instead of SizedIterable) lets the caller NOT open
+ a transaction block to access the values -- although some operations _on
+ the values_ may be forbidden.
+*/
+fun getUnsubmittedTransactions(bankAccountLabel: String): List<BankAccountTransactionEntity> {
return transaction {
val bankAccount = getBankAccountFromLabel(bankAccountLabel)
val lowerExclusiveLimit = bankAccount.lastFiatSubmission?.id?.value ?: 0
BankAccountTransactionEntity.find {
BankAccountTransactionsTable.id greater lowerExclusiveLimit and (
BankAccountTransactionsTable.direction eq "CRDT"
- )
+ ) and (BankAccountTransactionsTable.account eq bankAccount.id)
}.sortedBy { it.id }.map { it }
- // The latest payment must occupy the highest index,
- // to reliably update the bank account row with the last
- // submitted cash-out.
+ /* The latest payment must occupy the highest index,
+ to reliably update the 'lastFiatSubmission' column of
+ the bank account. */
}
}