Changed amt to -amt for transactions via kafka and obpjvm

This commit is contained in:
Petar Bozin 2017-01-24 22:47:59 +01:00
parent 113c44304d
commit 604354a9df
3 changed files with 6 additions and 10 deletions

1
.gitignore vendored
View File

@ -13,3 +13,4 @@ target
src/main/resources/
src/test/resources/
*.iml
src/main/resources/log4j.properties

View File

@ -444,12 +444,7 @@ object KafkaMappedConnector extends Connector with Loggable {
override def makePaymentImpl(fromAccount: AccountType, toAccount: AccountType, amt: BigDecimal, description : String): Box[TransactionId] = {
val fromTransAmt = -amt //from account balance should decrease
val toTransAmt = amt //to account balance should increase
//we need to save a copy of this payment as a transaction in each of the accounts involved, with opposite amounts
val sentTransactionId = saveTransaction(fromAccount, toAccount, fromTransAmt, description)
saveTransaction(toAccount, fromAccount, toTransAmt, description)
val sentTransactionId = saveTransaction(fromAccount, toAccount, -amt, description)
sentTransactionId
}
@ -468,7 +463,7 @@ object KafkaMappedConnector extends Connector with Loggable {
val currency = account.currency
//update the balance of the account for which a transaction is being created
val newAccountBalance : Long = account.balance.toLong + Helper.convertToSmallestCurrencyUnits(amt, account.currency)
//val newAccountBalance : Long = account.balance.toLong + Helper.convertToSmallestCurrencyUnits(amt, account.currency)
//account.balance = newAccountBalance
val req : Map[String,String] = Map(
@ -477,7 +472,7 @@ object KafkaMappedConnector extends Connector with Loggable {
"name" -> OBPUser.getCurrentUserUsername,
"accountId" -> account.accountId.value,
"currency" -> currency,
"amount" -> amt.toString,
"amount" -> (-amt).toString,
"otherAccountId" -> counterparty.accountId.value,
"otherAccountCurrency" -> counterparty.currency,
"transactionType" -> "AC"

View File

@ -556,7 +556,7 @@ object ObpJvmMappedConnector extends Connector with Loggable {
override def makePaymentImpl(fromAccount: AccountType, toAccount: AccountType, amt: BigDecimal, description : String): Box[TransactionId] = {
for {
sentTransactionId <- saveTransaction(fromAccount, toAccount, amt, description)
sentTransactionId <- saveTransaction(fromAccount, toAccount, -amt, description)
} yield {
sentTransactionId
}
@ -577,7 +577,7 @@ private def saveTransaction(fromAccount: AccountType, toAccount: AccountType, am
val accountId = fromAccount.accountId.value
val bankId = fromAccount.bankId.value
val currency = fromAccount.currency
val amount = amt.asInstanceOf[java.math.BigDecimal]
val amount = (-amt).asInstanceOf[java.math.BigDecimal]
val counterpartyId = toAccount.accountId.value
val newBalanceCurrency = toAccount.currency
val newBalanceAmount = toAccount.balance