Merge branch 'MIFOSX-2004' of https://github.com/venkatconflux/mifosx into venkatconflux-MIFOSX-2004

This commit is contained in:
Vishwas Babu A J
2015-05-10 17:29:41 -07:00
4 changed files with 11 additions and 7 deletions
@@ -13,9 +13,9 @@ import org.springframework.data.repository.query.Param;
public interface AccountAssociationsRepository extends JpaRepository<AccountAssociations, Long>,
JpaSpecificationExecutor<AccountAssociations> {
@Query("from AccountAssociations aa where aa.loanAccount.id= :loanId")
AccountAssociations findByLoanId(@Param("loanId") Long loanId);
@Query("from AccountAssociations aa where aa.loanAccount.id= :loanId and aa.associationType = :associationType")
AccountAssociations findByLoanIdAndType(@Param("loanId") Long loanId, @Param("associationType") Integer accountAssociationType);
@Query("from AccountAssociations aa where aa.savingsAccount.id= :savingsId")
AccountAssociations findBySavingsId(@Param("savingsId") Long savingsId);
@Query("from AccountAssociations aa where aa.savingsAccount.id= :savingsId and aa.associationType = :associationType")
AccountAssociations findBySavingsIdAndType(@Param("savingsId") Long savingsId, @Param("associationType") Integer accountAssociationType);
}
@@ -685,7 +685,8 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
// Save linked account information
final String linkAccountIdParamName = "linkAccountId";
final Long savingsAccountId = command.longValueOfParameterNamed(linkAccountIdParamName);
AccountAssociations accountAssociations = this.accountAssociationsRepository.findByLoanId(loanId);
AccountAssociations accountAssociations = this.accountAssociationsRepository.findByLoanIdAndType(loanId,
AccountAssociationType.LINKED_ACCOUNT_ASSOCIATION.getValue());
boolean isLinkedAccPresent = false;
if (savingsAccountId == null) {
if (accountAssociations != null) {
@@ -50,6 +50,7 @@ import org.mifosplatform.organisation.workingdays.domain.WorkingDaysRepositoryWr
import org.mifosplatform.portfolio.account.PortfolioAccountType;
import org.mifosplatform.portfolio.account.data.AccountTransferDTO;
import org.mifosplatform.portfolio.account.data.PortfolioAccountData;
import org.mifosplatform.portfolio.account.domain.AccountAssociationType;
import org.mifosplatform.portfolio.account.domain.AccountAssociations;
import org.mifosplatform.portfolio.account.domain.AccountAssociationsRepository;
import org.mifosplatform.portfolio.account.domain.AccountTransferDetailRepository;
@@ -436,7 +437,8 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
private void createStandingInstruction(Loan loan) {
if (loan.shouldCreateStandingInstructionAtDisbursement()) {
AccountAssociations accountAssociations = this.accountAssociationRepository.findByLoanId(loan.getId());
AccountAssociations accountAssociations = this.accountAssociationRepository.findByLoanIdAndType(loan.getId(),
AccountAssociationType.LINKED_ACCOUNT_ASSOCIATION.getValue());
if (accountAssociations != null) {
@@ -364,7 +364,8 @@ public class DepositApplicationProcessWritePlatformServiceJpaRepositoryImpl impl
// Save linked account information
final Long savingsAccountId = command.longValueOfParameterNamed(DepositsApiConstants.linkedAccountParamName);
AccountAssociations accountAssociations = this.accountAssociationsRepository.findBySavingsId(accountId);
AccountAssociations accountAssociations = this.accountAssociationsRepository.findBySavingsIdAndType(accountId,
AccountAssociationType.LINKED_ACCOUNT_ASSOCIATION.getValue());
if (savingsAccountId == null) {
if (accountAssociations != null) {
if (this.fromJsonHelper.parameterExists(DepositsApiConstants.linkedAccountParamName, command.parsedJson())) {