diff options
author | Marcello Stanisci <stanisci.m@gmail.com> | 2020-03-31 18:24:58 +0200 |
---|---|---|
committer | Marcello Stanisci <stanisci.m@gmail.com> | 2020-03-31 18:24:58 +0200 |
commit | 8723a7107d0916ded72cdcf311ddc59f6343ecee (patch) | |
tree | 27c5455f4d4e7c9c99383d5c7e7d7ad8d98c06c1 /nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt | |
parent | 4c196b7c81db58b379c04071ecf48625e53e439a (diff) | |
download | libeufin-8723a7107d0916ded72cdcf311ddc59f6343ecee.tar.gz libeufin-8723a7107d0916ded72cdcf311ddc59f6343ecee.tar.bz2 libeufin-8723a7107d0916ded72cdcf311ddc59f6343ecee.zip |
Implement refunds, plus helpers.
However, the function that calculates the
refund amount is still WIP as it only echoes
back the original amount.
Diffstat (limited to 'nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt')
-rw-r--r-- | nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt b/nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt index 468e8f03..e39f521f 100644 --- a/nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt +++ b/nexus/src/main/kotlin/tech/libeufin/nexus/Helpers.kt @@ -28,4 +28,20 @@ fun chunkString(input: String): String { fun expectId(param: String?): String { return param ?: throw NexusError(HttpStatusCode.BadRequest, "Bad ID given") +} + +/* Needs a transaction{} block to be called */ +fun expectIdTransaction(param: String?): EbicsSubscriberEntity { + if (param == null) { + throw NexusError(HttpStatusCode.BadRequest, "Null Id given") + } + return EbicsSubscriberEntity.findById(param) ?: throw NexusError(HttpStatusCode.NotFound, "Subscriber: $param not found") +} + +/* Needs a transaction{} block to be called */ +fun expectAcctidTransaction(param: String?): EbicsAccountInfoEntity { + if (param == null) { + throw NexusError(HttpStatusCode.BadRequest, "Null Acctid given") + } + return EbicsAccountInfoEntity.findById(param) ?: throw NexusError(HttpStatusCode.NotFound, "Account: $param not found") }
\ No newline at end of file |