commit a6ad71bb7054b84ab4b8f141cb89265b7c37dede
parent a9e9e30adcede04a0d409a5fc9bd032762ff9e66
Author: Marcello Stanisci <stanisci.m@gmail.com>
Date: Mon, 16 Mar 2020 19:44:56 +0100
Extra check for submitting payments.
Make sure to not re-submit payments marked
as invalid.
Diffstat:
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt
@@ -44,6 +44,7 @@ import org.apache.commons.compress.utils.SeekableInMemoryByteChannel
import org.jetbrains.exposed.exceptions.ExposedSQLException
import org.jetbrains.exposed.sql.StdOutSqlLogger
import org.jetbrains.exposed.sql.addLogger
+import org.jetbrains.exposed.sql.and
import org.jetbrains.exposed.sql.transactions.transaction
import org.joda.time.DateTime
import org.slf4j.Logger
@@ -522,7 +523,7 @@ fun main() {
post("/ebics/admin/execute-payments") {
val (paymentRowId, painDoc: String, debtorAccount) = transaction {
val entity = Pain001Entity.find {
- Pain001Table.submitted eq false
+ (Pain001Table.submitted eq false) and (Pain001Table.invalid eq false)
}.firstOrNull() ?: throw NexusError(HttpStatusCode.Accepted, reason = "No ready payments found")
Triple(entity.id, createPain001document(entity), entity.debtorAccount)
}