commit 92f8e94155b8e8063e636e009dd06f3e03e45690
parent 2e49f3b90d43e5f10cc2b7c79bf5f6f5e64ddf2b
Author: MS <ms@taler.net>
Date: Mon, 30 Aug 2021 22:38:34 -1100
Ebics C53 handler takes the response from the DB.
It used to generate it on the fly. The next step is
to make it accept a date range parameter.
Diffstat:
1 file changed, 15 insertions(+), 10 deletions(-)
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt
@@ -467,17 +467,22 @@ private fun constructCamtResponse(type: Int, subscriber: EbicsSubscriberEntity):
} else Pair(parseDashedDate("1970-01-01"), LocalDateTime.now())
*/
+ /**
+ * FIXME: when this function throws an exception, it makes a JSON response being responded.
+ * That is bad, because here we're inside a Ebics handler and only XML should
+ * be returned to the requester. This problem makes the (unhelpful) "bank didn't
+ * return XML" message appear in the Nexus logs.
+ */
val bankAccount = getBankAccountFromSubscriber(subscriber)
- logger.info("getting history for account with iban ${bankAccount.iban}")
- val history = historyForAccount(bankAccount)
- val baseBalance = BigDecimal.ZERO
- return buildCamtString(
- type,
- bankAccount.iban,
- history,
- balancePrcd = baseBalance,
- balanceClbd = balanceForAccount(history, baseBalance)
- ).camtMessage
+ val camtMessage = transaction {
+ BankAccountStatementEntity.find {
+ BankAccountStatementsTable.bankAccount eq bankAccount.id
+ }.lastOrNull()?.xmlMessage ?: throw EbicsRequestError(
+ "[EBICS_NO_DOWNLOAD_DATA_AVAILABE]",
+ "090005"
+ )
+ }
+ return camtMessage
}
/**