refactor/removed addBankAccount method

This commit is contained in:
hongwei 2024-10-28 10:25:46 +01:00
parent 856b9ee7c4
commit 59471c93df
6 changed files with 18 additions and 105 deletions

View File

@ -2275,31 +2275,6 @@ object NewStyle extends MdcLoggable{
) map {
i => (unboxFullOrFail(i._1, callContext, UnknownError, 400), i._2)
}
def addBankAccount(
bankId: BankId,
accountType: String,
accountLabel: String,
currency: String,
initialBalance: BigDecimal,
accountHolderName: String,
branchId: String,
accountRoutings: List[AccountRouting],
callContext: Option[CallContext]
): OBPReturnType[BankAccount] =
Connector.connector.vend.addBankAccount(
bankId: BankId,
accountType: String,
accountLabel: String,
currency: String,
initialBalance: BigDecimal,
accountHolderName: String,
branchId: String,
accountRoutings: List[AccountRouting],
callContext: Option[CallContext]
) map {
i => (unboxFullOrFail(i._1, callContext, UnknownError, 400), i._2)
}
def updateBankAccount(
bankId: BankId,

View File

@ -2608,8 +2608,9 @@ trait APIMethods400 extends MdcLoggable {
_ <- Helper.booleanToFuture(s"$AccountRoutingAlreadyExist (${alreadyExistingAccountRouting.mkString("; ")})", cc=callContext) {
alreadyExistingAccountRouting.isEmpty
}
(bankAccount,callContext) <- NewStyle.function.addBankAccount(
(bankAccount,callContext) <- NewStyle.function.createBankAccount(
bankId,
AccountId(APIUtil.generateUUID()),
accountType,
accountLabel,
currency,

View File

@ -795,18 +795,6 @@ trait Connector extends MdcLoggable {
/*
non-standard calls --do not make sense in the regular context but are used for e.g. tests
*/
def addBankAccount(
bankId: BankId,
accountType: String,
accountLabel: String,
currency: String,
initialBalance: BigDecimal,
accountHolderName: String,
branchId: String,
accountRoutings: List[AccountRouting],
callContext: Option[CallContext]
): OBPReturnType[Box[BankAccount]] = Future{(Failure(setUnimplementedError(nameOf(addBankAccount _))), callContext)}
def updateBankAccount(
@ -821,8 +809,6 @@ trait Connector extends MdcLoggable {
//generates an unused account number and then creates the sandbox account using that number
//TODO, this is new style method, it return future, but do not use it yet. only for messageDoc now.
def createBankAccount(
bankId: BankId,
accountId: AccountId,

View File

@ -375,33 +375,29 @@ object ConnectorBuilderUtil {
"validateChallengeAnswerC5",
"validateChallengeAnswerV2",
"getCounterpartyByIbanAndBankAccountId",
"getStatus",
"getChargeValue",
"saveTransactionRequestTransaction",
"saveTransactionRequestChallenge",
"getTransactionRequestTypes",
"updateAccountLabel",
"getProduct",
"createOrUpdateBranch",
"createOrUpdateAtm",
"createOrUpdateProduct",
"createOrUpdateFXRate",
"getTransactionRequestTypeCharges",
"getCounterpartyFromTransaction",
"getCounterpartiesFromTransaction",
"saveTransactionRequestStatusImpl"
).distinct
/**
* these connector methods have special parameter or return type
*/
val specialMethods = List(
"getPhysicalCards",
"createTransactionRequest",
"getStatus",
"getChargeValue",
"saveTransactionRequestTransaction",
"saveTransactionRequestChallenge",
"getTransactionRequests",
"getTransactionRequestTypes",
"createTransactionAfterChallenge",
"updateAccountLabel",
"getProduct",
"createOrUpdateBranch",
"createOrUpdateBank",
"createOrUpdateAtm",
"createOrUpdateProduct",
"createOrUpdateFXRate",
"getCurrentFxRate",
"getTransactionRequestTypeCharges",
"getCounterpartyFromTransaction",
"getCounterpartiesFromTransaction",
"saveTransactionRequestStatusImpl",
"getCurrentFxRate"
).distinct
val omitMethods = List(
@ -409,7 +405,6 @@ object ConnectorBuilderUtil {
// "deleteAttributeDefinition", // should not be auto generated
// "getAttributeDefinition", // should not be auto generated
// "createStandingOrder", // should not be auto generated
// "addBankAccount", // non-standard calls, should be used for test
//** the follow 5 methods should not be generated, should create manually
// "dynamicEntityProcess",

View File

@ -2098,47 +2098,6 @@ object LocalMappedConnector extends Connector with MdcLoggable {
}, callContext)
}
override def addBankAccount(
bankId: BankId,
accountType: String,
accountLabel: String,
currency: String,
initialBalance: BigDecimal,
accountHolderName: String,
branchId: String,
accountRoutings: List[AccountRouting],
callContext: Option[CallContext]
): OBPReturnType[Box[BankAccount]] = Future {
val accountId = AccountId(APIUtil.generateUUID())
val uniqueAccountNumber = {
def exists(number: String) = LocalMappedConnectorInternal.accountExists(bankId, number).openOrThrowException(attemptedToOpenAnEmptyBox)
def appendUntilOkay(number: String): String = {
val newNumber = number + Random.nextInt(10)
if (!exists(newNumber)) newNumber
else appendUntilOkay(newNumber)
}
//generates a random 8 digit account number
val firstTry = (Random.nextDouble() * 10E8).toInt.toString
appendUntilOkay(firstTry)
}
(LocalMappedConnectorInternal.createSandboxBankAccount(
bankId,
accountId,
uniqueAccountNumber,
accountType,
accountLabel,
currency,
initialBalance,
accountHolderName,
branchId: String, //added field in V220
accountRoutings
), callContext)
}
override def createBankAccount(
bankId: BankId,
accountId: AccountId,

View File

@ -1146,9 +1146,6 @@ case class InBoundCreateTransactionAfterChallenge(status: Status, data: Transact
override val inboundAdapterCallContext: InboundAdapterCallContext = InboundAdapterCallContext()
}
case class OutBoundAddBankAccount(outboundAdapterCallContext: OutboundAdapterCallContext, bankId: BankId, accountType: String, accountLabel: String, currency: String, initialBalance: BigDecimal, accountHolderName: String, branchId: String, accountRoutings: List[AccountRouting]) extends TopicTrait
case class InBoundAddBankAccount(inboundAdapterCallContext: InboundAdapterCallContext, status: Status, data: BankAccountCommons) extends InBoundTrait[BankAccountCommons]
case class BankAndBankAccount(bank: BankCommons, account: BankAccountCommons)
case class OutBoundCreateBankAndAccount(bankName: String, bankNationalIdentifier: String, accountNumber: String, accountType: String, accountLabel: String, currency: String, accountHolderName: String, branchId: String, accountRoutingScheme: String, accountRoutingAddress: String) extends TopicTrait
case class InBoundCreateBankAndAccount(status: Status, value: BankAndBankAccount) extends InBoundTrait[(Bank, BankAccount)] {