MIFOSX-2168 : changed transaction scope
This commit is contained in:
+2
-2
@@ -32,8 +32,6 @@ public interface SavingsAccountWritePlatformService {
|
||||
|
||||
CommandProcessingResult undoTransaction(Long savingsId, Long transactionId, boolean allowAccountTransferModification);
|
||||
|
||||
void postInterestForAccounts();
|
||||
|
||||
CommandProcessingResult adjustSavingsTransaction(Long savingsId, Long transactionId, JsonCommand command);
|
||||
|
||||
CommandProcessingResult close(Long savingsId, JsonCommand command);
|
||||
@@ -66,4 +64,6 @@ public interface SavingsAccountWritePlatformService {
|
||||
|
||||
void processPostActiveActions(SavingsAccount account, DateTimeFormatter fmt, Set<Long> existingTransactionIds,
|
||||
Set<Long> existingReversedTransactionIds);
|
||||
|
||||
void postInterest(SavingsAccount account);
|
||||
}
|
||||
+3
-14
@@ -37,8 +37,6 @@ import org.mifosplatform.infrastructure.core.data.DataValidatorBuilder;
|
||||
import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException;
|
||||
import org.mifosplatform.infrastructure.core.exception.PlatformServiceUnavailableException;
|
||||
import org.mifosplatform.infrastructure.core.service.DateUtils;
|
||||
import org.mifosplatform.infrastructure.jobs.annotation.CronTarget;
|
||||
import org.mifosplatform.infrastructure.jobs.service.JobName;
|
||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||
import org.mifosplatform.organisation.holiday.domain.HolidayRepositoryWrapper;
|
||||
import org.mifosplatform.organisation.monetary.domain.ApplicationCurrency;
|
||||
@@ -339,7 +337,7 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
||||
.build();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
|
||||
@Override
|
||||
public CommandProcessingResult postInterest(final Long savingsId) {
|
||||
|
||||
@@ -356,7 +354,8 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
||||
}
|
||||
|
||||
@Transactional
|
||||
private void postInterest(final SavingsAccount account) {
|
||||
@Override
|
||||
public void postInterest(final SavingsAccount account) {
|
||||
|
||||
final boolean isSavingsInterestPostingAtCurrentPeriodEnd = this.configurationDomainService
|
||||
.isSavingsInterestPostingAtCurrentPeriodEnd();
|
||||
@@ -385,16 +384,6 @@ public class SavingsAccountWritePlatformServiceJpaRepositoryImpl implements Savi
|
||||
}
|
||||
}
|
||||
|
||||
@CronTarget(jobName = JobName.POST_INTEREST_FOR_SAVINGS)
|
||||
@Override
|
||||
public void postInterestForAccounts() {
|
||||
final List<SavingsAccount> savingsAccounts = this.savingAccountRepository
|
||||
.findSavingAccountByStatus(SavingsAccountStatusType.ACTIVE.getValue());
|
||||
for (final SavingsAccount savingsAccount : savingsAccounts) {
|
||||
this.savingAccountAssembler.assignSavingAccountHelpers(savingsAccount);
|
||||
postInterest(savingsAccount);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandProcessingResult undoTransaction(final Long savingsId, final Long transactionId,
|
||||
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.portfolio.savings.service;
|
||||
|
||||
import org.mifosplatform.infrastructure.jobs.exception.JobExecutionException;
|
||||
|
||||
|
||||
public interface SavingsSchedularService {
|
||||
|
||||
void postInterestForAccounts() throws JobExecutionException;
|
||||
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.portfolio.savings.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.mifosplatform.infrastructure.jobs.annotation.CronTarget;
|
||||
import org.mifosplatform.infrastructure.jobs.exception.JobExecutionException;
|
||||
import org.mifosplatform.infrastructure.jobs.service.JobName;
|
||||
import org.mifosplatform.portfolio.savings.domain.SavingsAccount;
|
||||
import org.mifosplatform.portfolio.savings.domain.SavingsAccountAssembler;
|
||||
import org.mifosplatform.portfolio.savings.domain.SavingsAccountRepository;
|
||||
import org.mifosplatform.portfolio.savings.domain.SavingsAccountStatusType;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class SavingsSchedularServiceImpl implements SavingsSchedularService {
|
||||
|
||||
private final SavingsAccountAssembler savingAccountAssembler;
|
||||
private final SavingsAccountWritePlatformService savingsAccountWritePlatformService;
|
||||
private final SavingsAccountRepository savingAccountRepository;
|
||||
|
||||
@Autowired
|
||||
public SavingsSchedularServiceImpl(final SavingsAccountAssembler savingAccountAssembler,
|
||||
final SavingsAccountWritePlatformService savingsAccountWritePlatformService,
|
||||
final SavingsAccountRepository savingAccountRepository) {
|
||||
this.savingAccountAssembler = savingAccountAssembler;
|
||||
this.savingsAccountWritePlatformService = savingsAccountWritePlatformService;
|
||||
this.savingAccountRepository = savingAccountRepository;
|
||||
}
|
||||
|
||||
@CronTarget(jobName = JobName.POST_INTEREST_FOR_SAVINGS)
|
||||
@Override
|
||||
public void postInterestForAccounts() throws JobExecutionException {
|
||||
final List<SavingsAccount> savingsAccounts = this.savingAccountRepository.findSavingAccountByStatus(SavingsAccountStatusType.ACTIVE
|
||||
.getValue());
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for (final SavingsAccount savingsAccount : savingsAccounts) {
|
||||
try {
|
||||
this.savingAccountAssembler.assignSavingAccountHelpers(savingsAccount);
|
||||
this.savingsAccountWritePlatformService.postInterest(savingsAccount);
|
||||
} catch (Exception e) {
|
||||
Throwable realCause = e;
|
||||
if (e.getCause() != null) {
|
||||
realCause = e.getCause();
|
||||
}
|
||||
sb.append("failed to post interest for Savings with id " + savingsAccount.getId() + " with message "
|
||||
+ realCause.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
if (sb.length() > 0) { throw new JobExecutionException(sb.toString()); }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user