libeufin

Integration and sandbox testing for FinTech APIs and data formats
Log | Files | Refs | Submodules | README | LICENSE

commit 26ffdc3a51b6b9c8544e28ee07e4a04382dd5698
parent d6f75f52ed1c9a5508effeef669c513509e88536
Author: MS <ms@taler.net>
Date:   Mon,  4 Sep 2023 11:15:01 +0200

Improving the "get all the transactions" query.

Only used in tests, the improvement comes from extending
the latest point in time where Nexus expects bank transactions
to be returned.  This lets also the very latest transactions
to appear in the history.

Diffstat:
Mnexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsNexus.kt | 15++++++++++++++-
Mnexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt | 1+
Msandbox/src/main/kotlin/tech/libeufin/sandbox/Database.kt | 3---
Msandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt | 1+
Mutil/src/main/kotlin/Ebics.kt | 11++++++++++-
5 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsNexus.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsNexus.kt @@ -695,12 +695,25 @@ class EbicsBankConnectionProtocol: BankConnectionProtocol { val p = EbicsStandardOrderParams() addForLevel(fetchSpec.level, p) } + /** + * This spec wants _all_ the records, therefore the + * largest time frame possible needs to be specified. + * Rarely employed in production, but useful for tests. + */ is FetchSpecAllJson -> { val start = ZonedDateTime.ofInstant( Instant.EPOCH, ZoneOffset.UTC ) - val end = ZonedDateTime.ofInstant(Instant.now(), ZoneOffset.systemDefault()) + val end = ZonedDateTime.ofInstant( + /** + * XML date sets the time to 'start of the day'. By + * adding 24 hours, we make sure today's transactions + * are included in the response. + */ + Instant.now().plusSeconds(60 * 60 * 24), + ZoneOffset.systemDefault() + ) val p = EbicsStandardOrderParams( EbicsDateRange(start, end) ) diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/server/NexusServer.kt @@ -767,6 +767,7 @@ val nexusApp: Application.() -> Unit = { val fetchSpec = if (call.request.hasBody()) { call.receive<FetchSpecJson>() } else { + logger.warn("fetch-transactions wants statements (they aren't implemented at the bank)") FetchSpecLatestJson( FetchLevel.STATEMENT, null diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Database.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Database.kt @@ -662,7 +662,4 @@ class Database(private val dbConfig: String) { ) } } - - // NOTE: EBICS not needed for BFH and NB. - } diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt @@ -481,6 +481,7 @@ private fun constructCamtResponse( val history = mutableListOf<XLibeufinBankTransaction>() if (type == 52) { if (dateRange != null) { + logger.debug("Finding date-ranged transactions for account: ${bankAccount.label}, range: ${dateRange.first}, ${dateRange.second}") transaction { BankAccountTransactionEntity.find { BankAccountTransactionsTable.account eq bankAccount.id and diff --git a/util/src/main/kotlin/Ebics.kt b/util/src/main/kotlin/Ebics.kt @@ -110,7 +110,16 @@ private fun getNonce(size: Int): ByteArray { private fun getXmlDate(d: ZonedDateTime): XMLGregorianCalendar { return DatatypeFactory.newInstance() - .newXMLGregorianCalendar(d.year, d.monthValue, d.dayOfMonth, 0, 0, 0, 0, d.offset.totalSeconds / 60) + .newXMLGregorianCalendar( + d.year, + d.monthValue, + d.dayOfMonth, + 0, + 0, + 0, + 0, + d.offset.totalSeconds / 60 + ) } private fun makeOrderParams(orderParams: EbicsOrderParams): EbicsRequest.OrderParams {