gnunet-svn
[Top][All Lists]
Advanced

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

[libeufin] branch master updated: format amount


From: gnunet
Subject: [libeufin] branch master updated: format amount
Date: Sat, 07 Dec 2019 04:45:14 +0100

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

marcello pushed a commit to branch master
in repository libeufin.

The following commit(s) were added to refs/heads/master by this push:
     new e928ab9  format amount
e928ab9 is described below

commit e928ab9106f28b66e7608e36a7c6f39e8ca8c50d
Author: Marcello Stanisci <address@hidden>
AuthorDate: Sat Dec 7 04:44:59 2019 +0100

    format amount
---
 sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt | 10 ++++++----
 sandbox/src/main/python/libeufin-cli                  |  6 +++---
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt 
b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
index 4f95d55..e6701bd 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/Main.kt
@@ -122,8 +122,10 @@ inline fun <reified T> Document.toObject(): T {
     return m.unmarshal(this, T::class.java).value
 }
 
-fun sampleTransactions() {
+fun BigDecimal.signToString(): String {
 
+    return if (this.signum() > 0) "+" else ""
+    // minus sign is added by default already.
 }
 
 fun main() {
@@ -155,10 +157,10 @@ fun main() {
             bankCustomer = customerEntity
         }
 
-        for (i in listOf(1, 3, 9, 10)) {
+        for (i in listOf<Amount>(Amount(1), Amount(-3), Amount(9), 
Amount("6.02"))) {
             BankTransactionEntity.new {
                 counterpart = "IBAN"
-                amount = Amount(5 - i)
+                amount = i
                 subject = "transaction $i"
                 date = DateTime.now()
                 localCustomer = customerEntity
@@ -217,7 +219,7 @@ fun main() {
                         ret.history.add(
                             CustomerHistoryResponseElement(
                                 subject = it.subject,
-                                amount = "${it.amount.toString()} EUR",
+                                amount = 
"${it.amount.signToString()}${it.amount.toString()} EUR",
                                 counterpart = it.counterpart,
                                 date = it.date.toString("Y-M-d")
                             )
diff --git a/sandbox/src/main/python/libeufin-cli 
b/sandbox/src/main/python/libeufin-cli
index 977adc7..15caf19 100755
--- a/sandbox/src/main/python/libeufin-cli
+++ b/sandbox/src/main/python/libeufin-cli
@@ -29,7 +29,7 @@ def ebics():
     pass
 
 @cli.group()
-def nonebics():
+def native():
     pass
 
 @ebics.command(help="Restore private keys backup.")
@@ -298,7 +298,7 @@ def new(obj, user_id, partner_id, system_id, host_id, 
ebics_url):
 
     print(resp.content.decode("utf-8"))
 
-@nonebics.command(help="Ask the list of transactions related to one account")
+@native.command(help="Ask the list of transactions related to one account")
 @click.pass_obj
 @click.option(
     "--user-id",
@@ -319,7 +319,7 @@ def history(obj, user_id):
     print(resp.content.decode("utf-8"))
 
 
-@nonebics.command(help="Ask the balance for a given customer of the bank")
+@native.command(help="Ask the balance for a given customer of the bank")
 @click.pass_obj
 @click.option(
     "--user-id",

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



reply via email to

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