aboutsummaryrefslogtreecommitdiff
path: root/sandbox/src/main/kotlin/tech/libeufin/sandbox/bankAccount.kt
diff options
context:
space:
mode:
authorMS <ms@taler.net>2023-03-07 19:37:54 +0100
committerMS <ms@taler.net>2023-03-07 19:39:37 +0100
commiteb734259ce107e8850e4f50c881be91847e5778c (patch)
tree14e3bb67f2cd27c4e444d543a31783e1ff7e7dbe /sandbox/src/main/kotlin/tech/libeufin/sandbox/bankAccount.kt
parent7e013b1fbdb10a27e65fc4cbc4f77d6d84413962 (diff)
downloadlibeufin-eb734259ce107e8850e4f50c881be91847e5778c.tar.gz
libeufin-eb734259ce107e8850e4f50c881be91847e5778c.tar.bz2
libeufin-eb734259ce107e8850e4f50c881be91847e5778c.zip
Balances and GET /accounts.
Including the max debit allowed per account and removing the "GET /accounts" filter for the accounts without a cash-out target.
Diffstat (limited to 'sandbox/src/main/kotlin/tech/libeufin/sandbox/bankAccount.kt')
-rw-r--r--sandbox/src/main/kotlin/tech/libeufin/sandbox/bankAccount.kt16
1 files changed, 16 insertions, 0 deletions
diff --git a/sandbox/src/main/kotlin/tech/libeufin/sandbox/bankAccount.kt b/sandbox/src/main/kotlin/tech/libeufin/sandbox/bankAccount.kt
index d194178c..5bd45a6f 100644
--- a/sandbox/src/main/kotlin/tech/libeufin/sandbox/bankAccount.kt
+++ b/sandbox/src/main/kotlin/tech/libeufin/sandbox/bankAccount.kt
@@ -32,6 +32,22 @@ fun maybeDebit(
return false
}
+fun getMaxDebitForUser(username: String): Int {
+ val bank = getDefaultDemobank()
+ if (username == "admin") return bank.bankDebtLimit
+ return bank.usersDebtLimit
+
+
+}
+
+fun getBalanceForJson(value: BigDecimal, currency: String): BalanceJson {
+ return BalanceJson(
+ amount = "${currency}:${value.abs()}",
+ credit_debit_indicator = if (value < BigDecimal.ZERO) "DBIT" else "CRDT"
+ )
+
+}
+
/**
* The last balance is the one mentioned in the bank account's
* last statement. If the bank account does not have any statement