libeufin

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

commit a2b41d28c5759bf01744de3cffc95ef8226aadc7
parent 7bdc61500245953689cf0aafae019eda1c539986
Author: Antoine A <>
Date:   Wed, 13 Nov 2024 17:00:45 +0100

nexus: add import cmd

Diffstat:
Mbank/src/main/kotlin/tech/libeufin/bank/db/ExchangeDAO.kt | 1-
Mnexus/src/main/kotlin/tech/libeufin/nexus/cli/Testing.kt | 22+++++++++++++++++++++-
Mnexus/src/main/kotlin/tech/libeufin/nexus/iso20022/camt.kt | 1-
3 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/bank/src/main/kotlin/tech/libeufin/bank/db/ExchangeDAO.kt b/bank/src/main/kotlin/tech/libeufin/bank/db/ExchangeDAO.kt @@ -276,7 +276,6 @@ class ExchangeDAO(private val db: Database) { ); """ ) { - println(metadata) setBytes(1, metadata.key.raw) setString(2, subject) setLong(3, amount.value) diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/cli/Testing.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/cli/Testing.kt @@ -307,9 +307,29 @@ class ExportCmt: CliktCommand("export") { } } +class ImportCmt: CliktCommand("import") { + override fun help(context: Context) = "Import EBICS camt files" + + private val common by CommonOption() + private val source by argument().file() + + override fun run() = cliCmd(logger, common.log) { + nexusConfig(common.config).withDb { db, cfg -> + var nbTx: Int = 0 + source.inputStream().use { xml -> + parseTx(xml, cfg.currency, cfg.ebics.dialect).forEach { tx -> + registerTransaction(db, cfg.ingest, tx) + nbTx += 1 + } + } + println("Imported $nbTx transactions from $source") + } + } +} + class TestingCmd : CliktCommand("testing") { init { - subcommands(FakeIncoming(), ListCmd(), EbicsDownload(), TxCheck(), Wss(), ExportCmt()) + subcommands(FakeIncoming(), ListCmd(), EbicsDownload(), TxCheck(), Wss(), ExportCmt(), ImportCmt()) } override fun help(context: Context) = "Testing helper commands" diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/iso20022/camt.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/iso20022/camt.kt @@ -178,7 +178,6 @@ private fun XmlDestructor.amount(acceptedCurrency: String) = one("Amt") { } else { "$currency:$amount" } - println(concat) TalerAmount(concat) }