mirror of
https://github.com/OpenBankProject/OBP-API.git
synced 2026-02-06 16:56:56 +00:00
parent
b1407e9274
commit
474bd2de91
@ -422,5 +422,6 @@ object ToSchemify {
|
||||
MappedTransactionType,
|
||||
MappedMeeting,
|
||||
MappedUserCustomerLink,
|
||||
MappedKafkaBankAccountData,
|
||||
MappedEntitlement)
|
||||
}
|
||||
|
||||
@ -289,6 +289,8 @@ object KafkaMappedConnector extends Connector with CreateViewImpls with Loggable
|
||||
val acc = List((bankId, accountID)).toSet
|
||||
if ((accResp diff acc).size > 0) throw new Exception(ErrorMessages.InvalidGetBankAccountConnectorResponse)
|
||||
|
||||
createMappedAccountDataIfNotExisting(r.bank, r.id, r.label)
|
||||
|
||||
Full(new KafkaBankAccount(r))
|
||||
}
|
||||
|
||||
@ -311,7 +313,9 @@ object KafkaMappedConnector extends Connector with CreateViewImpls with Loggable
|
||||
}
|
||||
if ((accRes.toSet diff accts.toSet).size > 0) throw new Exception(ErrorMessages.InvalidGetBankAccountsConnectorResponse)
|
||||
|
||||
r.map { t => new KafkaBankAccount(t) }
|
||||
r.map { t =>
|
||||
createMappedAccountDataIfNotExisting(t.bank, t.id, t.label)
|
||||
new KafkaBankAccount(t) }
|
||||
}
|
||||
|
||||
private def getAccountByNumber(bankId : BankId, number : String) : Box[AccountType] = {
|
||||
@ -327,6 +331,7 @@ object KafkaMappedConnector extends Connector with CreateViewImpls with Loggable
|
||||
val r = {
|
||||
cachedAccount.getOrElseUpdate( argList.toString, () => process(reqId, "getBankAccount", argList).extract[KafkaInboundAccount])
|
||||
}
|
||||
createMappedAccountDataIfNotExisting(r.bank, r.id, r.label)
|
||||
Full(new KafkaBankAccount(r))
|
||||
}
|
||||
|
||||
@ -698,17 +703,26 @@ object KafkaMappedConnector extends Connector with CreateViewImpls with Loggable
|
||||
}
|
||||
}
|
||||
|
||||
private def createMappedAccountDataIfNotExisting(bankId: String, accountId: String, label: String) : Boolean = {
|
||||
MappedKafkaBankAccountData.find(By(MappedKafkaBankAccountData.accountId, accountId),
|
||||
By(MappedKafkaBankAccountData.bankId, bankId)) match {
|
||||
case Empty =>
|
||||
val data = new MappedKafkaBankAccountData
|
||||
data.setAccountId(accountId)
|
||||
data.setBankId(bankId)
|
||||
data.setLabel(label)
|
||||
data.save()
|
||||
true
|
||||
case _ =>
|
||||
logger.info(s"account data with id $accountId at bank with id $bankId already exists. No need to create a new one.")
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
End of bank account creation
|
||||
*/
|
||||
|
||||
/*
|
||||
Cash api
|
||||
*/
|
||||
|
||||
/*
|
||||
End of cash api
|
||||
*/
|
||||
|
||||
/*
|
||||
Transaction importer api
|
||||
@ -830,11 +844,11 @@ object KafkaMappedConnector extends Connector with CreateViewImpls with Loggable
|
||||
val result = for {
|
||||
acc <- getBankAccount(bankId, accountID)
|
||||
bank <- getBank(bankId)
|
||||
d <- MappedKafkaBankAccountData.find(By(MappedKafkaBankAccountData.accountId, accountID.value), By(MappedKafkaBankAccountData.bankId, bank.bankId.value))
|
||||
} yield {
|
||||
//acc.label = label
|
||||
true
|
||||
}
|
||||
|
||||
d.setLabel(label)
|
||||
d.save()
|
||||
}
|
||||
result.getOrElse(false)
|
||||
}
|
||||
|
||||
@ -936,13 +950,20 @@ object KafkaMappedConnector extends Connector with CreateViewImpls with Loggable
|
||||
def balance : BigDecimal = BigDecimal(r.balance.amount)
|
||||
def currency : String = r.balance.currency
|
||||
def name : String = r.owners.head
|
||||
def label : String = r.number // Temp (label should be writable so customer can change)
|
||||
def swift_bic : Option[String] = Some("swift_bic") //TODO
|
||||
def iban : Option[String] = Some(r.IBAN)
|
||||
def number : String = r.number
|
||||
def bankId : BankId = BankId(r.bank)
|
||||
def lastUpdate : Date = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.ENGLISH).parse(today.getTime.toString)
|
||||
def accountHolder : String = r.owners.head
|
||||
|
||||
// Fields modifiable from OBP are stored in mapper
|
||||
def label : String = (for {
|
||||
d <- MappedKafkaBankAccountData.find(By(MappedKafkaBankAccountData.accountId, r.id))
|
||||
} yield {
|
||||
d.getLabel
|
||||
}).getOrElse(r.number)
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,25 @@
|
||||
package code.model.dataAccess
|
||||
|
||||
import net.liftweb.mapper._
|
||||
|
||||
class MappedKafkaBankAccountData extends LongKeyedMapper[MappedKafkaBankAccountData] with IdPK with CreatedUpdated {
|
||||
|
||||
override def getSingleton = MappedKafkaBankAccountData
|
||||
|
||||
object bankId extends MappedString(this, 255)
|
||||
def getBankId = bankId.get
|
||||
def setBankId(value: String) = bankId.set(value)
|
||||
|
||||
object accountId extends MappedString(this, 255)
|
||||
def getAccountId = accountId.get
|
||||
def setAccountId(value: String) = accountId.set(value)
|
||||
|
||||
object accountLabel extends MappedString(this, 255)
|
||||
def getLabel = accountLabel.get
|
||||
def setLabel(value: String) = accountLabel.set(value)
|
||||
|
||||
}
|
||||
|
||||
object MappedKafkaBankAccountData extends MappedKafkaBankAccountData with LongKeyedMetaMapper[MappedKafkaBankAccountData] {
|
||||
override def dbIndexes = UniqueIndex(bankId, accountId) :: super.dbIndexes
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user