gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libeufin] 09/11: fix time parser


From: gnunet
Subject: [libeufin] 09/11: fix time parser
Date: Thu, 30 Apr 2020 21:46:52 +0200

This is an automated email from the git hooks/post-receive script.

marcello pushed a commit to branch master
in repository libeufin.

commit 2109595edd337422be4eb29cac520ce99c5599c0
Author: Marcello Stanisci <address@hidden>
AuthorDate: Thu Apr 30 18:28:05 2020 +0200

    fix time parser
---
 integration-tests/test-ebics.py                             |  2 --
 nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt        | 13 +------------
 nexus/src/main/kotlin/tech/libeufin/nexus/Main.kt           |  4 ++--
 .../kotlin/tech/libeufin/sandbox/EbicsProtocolBackend.kt    |  1 +
 util/src/main/kotlin/time.kt                                | 10 ++++++++--
 util/src/test/kotlin/CryptoUtilTest.kt                      |  1 -
 6 files changed, 12 insertions(+), 19 deletions(-)

diff --git a/integration-tests/test-ebics.py b/integration-tests/test-ebics.py
index 10c873d..a0adfea 100755
--- 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
index 50018b5..40d7883 100644
--- 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
index 61ae1cc..460b4c2 100644
--- 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
index e31b44d..cad50ff 100644
--- 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
index e2d2df9..07fe4a7 100644
--- 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
index 705f443..da545bf 100644
--- 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")
     }
 }

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]