mirror of
https://github.com/OpenBankProject/OBP-API.git
synced 2026-02-06 13:46:49 +00:00
refactor/add BankAccountBalance class and update related references
This commit is contained in:
parent
06dbe542d7
commit
00bd381310
@ -1129,6 +1129,7 @@ object ToSchemify {
|
||||
CustomerAccountLink,
|
||||
TransactionIdMapping,
|
||||
RegulatedEntityAttribute,
|
||||
BankAccountBalance
|
||||
)
|
||||
|
||||
// start grpc server
|
||||
|
||||
@ -990,7 +990,7 @@ object LocalMappedConnector extends Connector with MdcLoggable {
|
||||
label = bankAccount.label,
|
||||
bankId = bankAccount.bankId.value,
|
||||
accountRoutings = bankAccount.accountRoutings.map(accountRounting => AccountRouting(accountRounting.scheme, accountRounting.address)),
|
||||
balances = List(BankAccountBalance(AmountOfMoney(bankAccount.currency, bankAccount.balance.toString),"OpeningBooked")),
|
||||
balances = List(OneAccountBalance(AmountOfMoney(bankAccount.currency, bankAccount.balance.toString),"OpeningBooked")),
|
||||
overallBalance = AmountOfMoney(bankAccount.currency, bankAccount.balance.toString),
|
||||
overallBalanceDate = now
|
||||
)
|
||||
|
||||
@ -1071,7 +1071,7 @@ trait RabbitMQConnector_vOct2024 extends Connector with MdcLoggable {
|
||||
bankId=bankIdExample.value,
|
||||
accountRoutings=List( AccountRouting(scheme=accountRoutingSchemeExample.value,
|
||||
address=accountRoutingAddressExample.value)),
|
||||
balances=List( BankAccountBalance(balance= AmountOfMoney(currency=balanceCurrencyExample.value,
|
||||
balances=List( OneAccountBalance(balance= AmountOfMoney(currency=balanceCurrencyExample.value,
|
||||
amount=balanceAmountExample.value),
|
||||
balanceType="string")),
|
||||
overallBalance= AmountOfMoney(currency=currencyExample.value,
|
||||
|
||||
@ -1098,7 +1098,7 @@ trait RestConnector_vMar2019 extends Connector with MdcLoggable {
|
||||
bankId=bankIdExample.value,
|
||||
accountRoutings=List( AccountRouting(scheme=accountRoutingSchemeExample.value,
|
||||
address=accountRoutingAddressExample.value)),
|
||||
balances=List( BankAccountBalance(balance= AmountOfMoney(currency=balanceCurrencyExample.value,
|
||||
balances=List( OneAccountBalance(balance= AmountOfMoney(currency=balanceCurrencyExample.value,
|
||||
amount=balanceAmountExample.value),
|
||||
balanceType="string")),
|
||||
overallBalance= AmountOfMoney(currency=currencyExample.value,
|
||||
|
||||
@ -1078,7 +1078,7 @@ trait StoredProcedureConnector_vDec2019 extends Connector with MdcLoggable {
|
||||
bankId=bankIdExample.value,
|
||||
accountRoutings=List( AccountRouting(scheme=accountRoutingSchemeExample.value,
|
||||
address=accountRoutingAddressExample.value)),
|
||||
balances=List( BankAccountBalance(balance= AmountOfMoney(currency=balanceCurrencyExample.value,
|
||||
balances=List( OneAccountBalance(balance= AmountOfMoney(currency=balanceCurrencyExample.value,
|
||||
amount=balanceAmountExample.value),
|
||||
balanceType="string")),
|
||||
overallBalance= AmountOfMoney(currency=currencyExample.value,
|
||||
|
||||
@ -0,0 +1,29 @@
|
||||
package code.model.dataAccess
|
||||
|
||||
import com.openbankproject.commons.model._
|
||||
import net.liftweb.common.Box
|
||||
import net.liftweb.mapper._
|
||||
import code.util.Helper
|
||||
|
||||
class BankAccountBalance extends BankAccountBalanceTrait with LongKeyedMapper[BankAccountBalance] with CreatedUpdated with IdPK{
|
||||
|
||||
override def getSingleton = BankAccountBalance
|
||||
|
||||
object AccountId_ extends MappedLongForeignKey(this, MappedBankAccount)
|
||||
object BalanceType extends MappedString(this, 255)
|
||||
//this is the smallest unit of currency! eg. cents, yen, pence, øre, etc.
|
||||
object BalanceAmount extends MappedLong(this)
|
||||
|
||||
val foreignMappedBankAccount: Box[MappedBankAccount] = AccountId_.foreign
|
||||
val foreignMappedBankAccountCurrency = foreignMappedBankAccount.map(_.currency).getOrElse("EUR")
|
||||
|
||||
override def accountId : AccountId = {
|
||||
foreignMappedBankAccount.map(_.accountId).getOrElse(AccountId(""))
|
||||
}
|
||||
override def balanceType: String = BalanceType.get
|
||||
override def balanceAmount: BigDecimal = Helper.smallestCurrencyUnitToBigDecimal(BalanceAmount.get, foreignMappedBankAccountCurrency)
|
||||
|
||||
|
||||
}
|
||||
|
||||
object BankAccountBalance extends BankAccountBalance with LongKeyedMetaMapper[BankAccountBalance] {}
|
||||
@ -228,6 +228,12 @@ trait BankAccount{
|
||||
def attributes : Option[List[Attribute]] = None
|
||||
}
|
||||
|
||||
trait BankAccountBalanceTrait {
|
||||
def accountId : AccountId
|
||||
def balanceType: String
|
||||
def balanceAmount: BigDecimal
|
||||
}
|
||||
|
||||
//This class is used for propagate the BankAccount as the parameters over different methods.
|
||||
case class BankAccountInMemory(
|
||||
//BankAccount Trait
|
||||
@ -383,12 +389,12 @@ case class AccountBalances(
|
||||
label: String,
|
||||
bankId: String,
|
||||
accountRoutings: List[AccountRouting],
|
||||
balances: List[BankAccountBalance],
|
||||
balances: List[OneAccountBalance],
|
||||
overallBalance: AmountOfMoney,
|
||||
overallBalanceDate: Date
|
||||
)
|
||||
|
||||
case class BankAccountBalance(
|
||||
case class OneAccountBalance(
|
||||
balance: AmountOfMoney,
|
||||
balanceType: String,
|
||||
)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user