libeufin

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

commit 75bd4dcf3697c40ffd5ce02d34b8e60a60da67cf
parent 18126f198507f27cc0853375006d30d3a6231fdf
Author: MS <ms@taler.net>
Date:   Wed, 15 Feb 2023 12:39:51 +0100

addressing #6988

Diffstat:
Mcli/tests/launch_services.sh | 5++++-
Mnexus/src/main/kotlin/tech/libeufin/nexus/bankaccount/BankAccount.kt | 3++-
Mnexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsNexus.kt | 46+++++++++++++++++++++++++++++++++-------------
3 files changed, 39 insertions(+), 15 deletions(-)

diff --git a/cli/tests/launch_services.sh b/cli/tests/launch_services.sh @@ -27,7 +27,7 @@ echo -n Delete previous data... rm -f $DB_PATH echo DONE echo -n Configure the default demobank with MANA... -libeufin-sandbox config --currency MANA default +libeufin-sandbox config --with-signup-bonus --currency MANA default echo DONE echo -n Start the bank... export LIBEUFIN_SANDBOX_ADMIN_PASSWORD=foo @@ -100,4 +100,7 @@ libeufin-cli facades \ --currency TESTKUDOS --facade-name test-facade \ wwwconn www-nexus echo OK +echo -n "Ticking, to let statements be generated..." +libeufin-sandbox camt053tick +echo OK read -p "Press Enter to terminate..." diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/bankaccount/BankAccount.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/bankaccount/BankAccount.kt @@ -423,7 +423,8 @@ suspend fun fetchBankAccountTransactions( } /** * Collects transactions from the bank and stores the (camt) - * document into the database. + * document into the database. This function tries to download + * both reports AND statements even if the first one fails. */ getConnectionPlugin(res.connectionType).fetchTransactions( fetchSpec, diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsNexus.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/ebics/EbicsNexus.kt @@ -427,8 +427,15 @@ class EbicsBankConnectionProtocol: BankConnectionProtocol { } } } + /** + * Will be filled with fetch instructions, according + * to the parameters received from the client. + */ val specs = mutableListOf<EbicsFetchSpec>() - + /** + * 'level' indicates whether to fetch statements and/or reports, + * whereas 'p' usually carries a date range. + */ fun addForLevel(l: FetchLevel, p: EbicsOrderParams) { when (l) { FetchLevel.ALL -> { @@ -443,7 +450,7 @@ class EbicsBankConnectionProtocol: BankConnectionProtocol { } } } - + // Figuring out what time range to put in the fetch instructions. when (fetchSpec) { is FetchSpecLatestJson -> { val p = EbicsStandardOrderParams() @@ -458,6 +465,11 @@ class EbicsBankConnectionProtocol: BankConnectionProtocol { ) addForLevel(fetchSpec.level, p) } + /** + * This branch differentiates the last date of reports and + * statements and builds the fetch instructions for each of + * them. + */ is FetchSpecSinceLastJson -> { val pRep = EbicsStandardOrderParams( EbicsDateRange( @@ -476,6 +488,11 @@ class EbicsBankConnectionProtocol: BankConnectionProtocol { ) ) when (fetchSpec.level) { + /** + * This branch doesn't call the "addForLevel()" helper because + * that takes only ONE time range and would use it for both + * statements and reports. + */ FetchLevel.ALL -> { specs.add(EbicsFetchSpec("C52", pRep)) specs.add(EbicsFetchSpec("C53", pStmt)) @@ -489,17 +506,20 @@ class EbicsBankConnectionProtocol: BankConnectionProtocol { } } } - /** - * Downloads and stores the bank message into the database. No ingestion. - */ - for (spec in specs) - fetchEbicsC5x( - spec.orderType, - client, - bankConnectionId, - spec.orderParams, - subscriberDetails - ) + // Downloads and stores the bank message into the database. No ingestion. + for (spec in specs) { + try { + fetchEbicsC5x( + spec.orderType, + client, + bankConnectionId, + spec.orderParams, + subscriberDetails + ) + } catch (e: Exception) { + logger.warn("Fetching transactions (${spec.orderType}) excepted: ${e.message}.") + } + } } /** * Submit one Pain.001 for one payment initiations.