libeufin

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

commit 2109595edd337422be4eb29cac520ce99c5599c0
parent 5005d9eb5a0dc893fb7bb451f0625950f86bd11d
Author: Marcello Stanisci <ms@taler.net>
Date:   Thu, 30 Apr 2020 18:28:05 +0200

fix time parser

Diffstat:
Mintegration-tests/test-ebics.py | 2--
Mnexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt | 14++------------
Mnexus/src/main/kotlin/tech/libeufin/nexus/Main.kt | 4++--
Msandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt | 1+
Mutil/src/main/kotlin/time.kt | 11++++++++---
Mutil/src/test/kotlin/CryptoUtilTest.kt | 1-
6 files changed, 13 insertions(+), 20 deletions(-)

diff --git a/integration-tests/test-ebics.py b/integration-tests/test-ebics.py @@ -179,5 +179,3 @@ resp = get( ) assert(resp.status_code == 200) assert(len(resp.json().get("payments")) == 1) - - diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt @@ -20,13 +20,6 @@ import java.time.ZonedDateTime import java.time.Instant import java.time.ZoneId -fun getSubscriberEntityFromNexusUserId(nexusUserId: String?): EbicsSubscriberEntity { - return transaction { - val nexusUser = extractNexusUser(expectId(nexusUserId)) - getEbicsSubscriberFromUser(nexusUser) - } -} - fun calculateRefund(amount: String): Amount { // fixme: must apply refund fees! return Amount(amount) @@ -449,8 +442,4 @@ fun userHasRights(nexusUser: NexusUserEntity, iban: String): Boolean { }.firstOrNull() } return row != null -} - -fun parseDate(date: String): DateTime { - return DateTime.parse(date, DateTimeFormat.forPattern("YYYY-MM-DD")) -} +} +\ No newline at end of file diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt @@ -273,7 +273,7 @@ fun main() { ret.payments.add( RawPayment( creditorIban = it.creditorIban, - debitorIban = "FIXME", + debitorIban = it.debitorIban, subject = it.subject, amount = "${it.currency}:${it.sum}", date = DateTime(it.date).toDashedDate() @@ -712,7 +712,7 @@ fun main() { currency = camt53doc.pickString("//*[local-name()='Ntry']//*[local-name()='Amt']/@Ccy") amount = camt53doc.pickString("//*[local-name()='Ntry']//*[local-name()='Amt']") status = camt53doc.pickString("//*[local-name()='Ntry']//*[local-name()='Sts']") - bookingDate = parseDate(camt53doc.pickString("//*[local-name()='BookgDt']//*[local-name()='Dt']")).millis + bookingDate = parseDashedDate(camt53doc.pickString("//*[local-name()='BookgDt']//*[local-name()='Dt']")).millis nexusUser = extractNexusUser(id) creditorName = camt53doc.pickString("//*[local-name()='RltdPties']//*[local-name()='Dbtr']//*[local-name()='Nm']") creditorIban = camt53doc.pickString("//*[local-name()='CdtrAcct']//*[local-name()='IBAN']") diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt @@ -164,6 +164,7 @@ fun buildCamtString(type: Int, history: MutableList<RawPayment>): MutableList<St history.forEach { val dashedDate = DateTime.parse(it.date).toDashedDate() val zonedDateTime = DateTime.now().toZonedString() + logger.debug("Dashed date for CAMT: $dashedDate") ret.add( constructXml(indent = true) { root("Document") { diff --git a/util/src/main/kotlin/time.kt b/util/src/main/kotlin/time.kt @@ -1,6 +1,7 @@ package tech.libeufin.util import org.joda.time.DateTime +import org.joda.time.format.DateTimeFormat import java.time.ZoneId import java.time.ZonedDateTime import java.time.format.DateTimeFormatter @@ -13,5 +14,10 @@ fun DateTime.toZonedString(): String { } fun DateTime.toDashedDate(): String { - return this.toString("Y-MM-dd") -} -\ No newline at end of file + return this.toString("y-MM-d") +} + +fun parseDashedDate(date: String): DateTime { + logger.debug("Parsing date: $date") + return DateTime.parse(date, DateTimeFormat.forPattern("y-M-d")) +} diff --git a/util/src/test/kotlin/CryptoUtilTest.kt b/util/src/test/kotlin/CryptoUtilTest.kt @@ -158,7 +158,6 @@ class CryptoUtilTest { // from Crockford32 encoding to binary. fun base32ToBytesTest() { val expectedEncoding = "C9P6YRG" - val blob = "blob".toByteArray(Charsets.UTF_8) assert(Base32Crockford.decode(expectedEncoding).toString(Charsets.UTF_8) == "blob") } }