Tweaked NewStyle.function.isValidCurrencyISOCode

This commit is contained in:
Marko Milić 2019-03-05 07:55:46 +01:00
parent 36b96493c1
commit a5709e7dce
3 changed files with 7 additions and 7 deletions

View File

@ -412,6 +412,11 @@ object NewStyle {
assert(APIUtil.isValidCurrencyISOCode(currencyCode))
}
}
def isValidCurrencyISOCode(currencyCode: String, failMsg: String, callContext: Option[CallContext])= {
tryons(failMsg = failMsg,400, callContext) {
assert(APIUtil.isValidCurrencyISOCode(currencyCode))
}
}
def hasEntitlement(failMsg: String)(bankId: String, userId: String, role: ApiRole): Future[Box[Unit]] = {

View File

@ -430,9 +430,7 @@ trait APIMethods140 extends MdcLoggable with APIMethods130 with APIMethods121{
(bank, callContext ) <- NewStyle.function.getBank(bankId, callContext)
(fromAccount, callContext) <- NewStyle.function.getBankAccount(bankId, accountId, callContext)
failMsg = ErrorMessages.InvalidISOCurrencyCode.concat("Please specify a valid value for CURRENCY of your Bank Account. ")
_ <- NewStyle.function.tryons(failMsg, 400, callContext) {
assert(isValidCurrencyISOCode(fromAccount.currency))
}
_ <- NewStyle.function.isValidCurrencyISOCode(fromAccount.currency, failMsg, callContext)
view <- NewStyle.function.view(viewId, BankIdAccountId(fromAccount.bankId, fromAccount.accountId), callContext)
_ <- Helper.booleanToFuture(failMsg = UserNoPermissionAccessView) {
u.hasViewAccess(view)

View File

@ -713,10 +713,7 @@ trait APIMethods310 {
val value = httpParams.filter(_.name == amount).map(_.values.head).head
new java.math.BigDecimal(value)
}
_ <- Helper.booleanToFuture(failMsg = InvalidISOCurrencyCode) {
val currencyCode = httpParams.filter(_.name == currency).map(_.values.head).head
isValidCurrencyISOCode(currencyCode)
}
_ <- NewStyle.function.isValidCurrencyISOCode(httpParams.filter(_.name == currency).map(_.values.head).head, callContext)
_ <- NewStyle.function.moderatedBankAccount(account, view, Full(u))
} yield {
val ccy = httpParams.filter(_.name == currency).map(_.values.head).head