commit e928ab9106f28b66e7608e36a7c6f39e8ca8c50d
parent 7be61e5457e17a6f9626137b7d5d0beb8e8b37ec
Author: Marcello Stanisci <stanisci.m@gmail.com>
Date: Sat, 7 Dec 2019 04:44:59 +0100
format amount
Diffstat:
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
@@ -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
@@ -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",