fineract-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nazeer1100...@apache.org
Subject incubator-fineract git commit: [FINERACT-211] Corrected code to avoid detached entity persist exception
Date Wed, 24 Aug 2016 11:29:48 GMT
Repository: incubator-fineract
Updated Branches:
  refs/heads/develop f33b58308 -> ff58f74d7


[FINERACT-211] Corrected code to avoid detached entity persist exception


Project: http://git-wip-us.apache.org/repos/asf/incubator-fineract/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-fineract/commit/ff58f74d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-fineract/tree/ff58f74d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-fineract/diff/ff58f74d

Branch: refs/heads/develop
Commit: ff58f74d79e5ac62e304c00624fa9497e4ff1df9
Parents: f33b583
Author: Adi Narayana Raju <adi.raju@confluxtechnologies.com>
Authored: Wed Aug 24 15:35:21 2016 +0530
Committer: Adi Narayana Raju <adi.raju@confluxtechnologies.com>
Committed: Wed Aug 24 15:35:21 2016 +0530

----------------------------------------------------------------------
 ...andingInstructionWritePlatformServiceImpl.java | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/ff58f74d/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/service/StandingInstructionWritePlatformServiceImpl.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/service/StandingInstructionWritePlatformServiceImpl.java
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/service/StandingInstructionWritePlatformServiceImpl.java
index 6cb3c4a..8a19139 100755
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/service/StandingInstructionWritePlatformServiceImpl.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/account/service/StandingInstructionWritePlatformServiceImpl.java
@@ -233,17 +233,21 @@ public class StandingInstructionWritePlatformServiceImpl implements
StandingInst
             }
 
             if (isDueForTransfer && transactionAmount != null && transactionAmount.compareTo(BigDecimal.ZERO)
> 0) {
-                final AccountTransferDetails accountTransferDetails = this.accountTransferDetailRepository.findOne(data.accountDetailId());
                 final SavingsAccount fromSavingsAccount = null;
                 final boolean isRegularTransaction = true;
                 final boolean isExceptionForBalanceCheck = false;
-                accountTransferDetails.accountTransferStandingInstruction().updateLatsRunDate(transactionDate.toDate());
                 AccountTransferDTO accountTransferDTO = new AccountTransferDTO(transactionDate,
transactionAmount, data.fromAccountType(),
                         data.toAccountType(), data.fromAccount().accountId(), data.toAccount().accountId(),
data.name()
                                 + " Standing instruction trasfer ", null, null, null, null,
data.toTransferType(), null, null, data
-                                .transferType().getValue(), accountTransferDetails, null,
null, null, null, fromSavingsAccount,
+                                .transferType().getValue(), null, null, null, null, null,
fromSavingsAccount,
                         isRegularTransaction, isExceptionForBalanceCheck);
-                transferAmount(sb, accountTransferDTO, data.getId());
+                final boolean transferCompleted = transferAmount(sb, accountTransferDTO,
data.getId());
+
+                if(transferCompleted){
+                    final String updateQuery = "UPDATE m_account_transfer_standing_instructions
SET last_run_date = ? where id = ?";
+                    this.jdbcTemplate.update(updateQuery, transactionDate.toDate(), data.getId());
+                }
+
             }
         }
         if (sb.length() > 0) { throw new JobExecutionException(sb.toString()); }
@@ -254,7 +258,8 @@ public class StandingInstructionWritePlatformServiceImpl implements StandingInst
      * @param sb
      * @param accountTransferDTO
      */
-    private void transferAmount(final StringBuilder sb, final AccountTransferDTO accountTransferDTO,
final Long instructionId) {
+    private boolean transferAmount(final StringBuilder sb, final AccountTransferDTO accountTransferDTO,
final Long instructionId) {
+        boolean transferCompleted = true;
         StringBuffer errorLog = new StringBuffer();
         StringBuffer updateQuery = new StringBuffer(
                 "INSERT INTO `m_account_transfer_standing_instructions_history` (`standing_instruction_id`,
`status`, `amount`,`execution_time`, `error_log`) VALUES (");
@@ -284,6 +289,7 @@ public class StandingInstructionWritePlatformServiceImpl implements StandingInst
         }
         updateQuery.append(instructionId).append(",");
         if (errorLog.length() > 0) {
+            transferCompleted = false;
             updateQuery.append("'failed'").append(",");
         } else {
             updateQuery.append("'success'").append(",");
@@ -292,6 +298,6 @@ public class StandingInstructionWritePlatformServiceImpl implements StandingInst
         updateQuery.append(", now(),");
         updateQuery.append("'").append(errorLog.toString()).append("')");
         this.jdbcTemplate.update(updateQuery.toString());
-
+        return transferCompleted;
     }
 }
\ No newline at end of file


Mime
View raw message