MIFOSX-2004:changed to get the loan id with the type of association
This commit is contained in:
+4
-4
@@ -13,9 +13,9 @@ import org.springframework.data.repository.query.Param;
|
|||||||
public interface AccountAssociationsRepository extends JpaRepository<AccountAssociations, Long>,
|
public interface AccountAssociationsRepository extends JpaRepository<AccountAssociations, Long>,
|
||||||
JpaSpecificationExecutor<AccountAssociations> {
|
JpaSpecificationExecutor<AccountAssociations> {
|
||||||
|
|
||||||
@Query("from AccountAssociations aa where aa.loanAccount.id= :loanId")
|
@Query("from AccountAssociations aa where aa.loanAccount.id= :loanId and aa.associationType = :associationType")
|
||||||
AccountAssociations findByLoanId(@Param("loanId") Long loanId);
|
AccountAssociations findByLoanIdAndType(@Param("loanId") Long loanId, @Param("associationType") Integer accountAssociationType);
|
||||||
|
|
||||||
@Query("from AccountAssociations aa where aa.savingsAccount.id= :savingsId")
|
@Query("from AccountAssociations aa where aa.savingsAccount.id= :savingsId and aa.associationType = :associationType")
|
||||||
AccountAssociations findBySavingsId(@Param("savingsId") Long savingsId);
|
AccountAssociations findBySavingsIdAndType(@Param("savingsId") Long savingsId, @Param("associationType") Integer accountAssociationType);
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -685,7 +685,8 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
|
|||||||
// Save linked account information
|
// Save linked account information
|
||||||
final String linkAccountIdParamName = "linkAccountId";
|
final String linkAccountIdParamName = "linkAccountId";
|
||||||
final Long savingsAccountId = command.longValueOfParameterNamed(linkAccountIdParamName);
|
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;
|
boolean isLinkedAccPresent = false;
|
||||||
if (savingsAccountId == null) {
|
if (savingsAccountId == null) {
|
||||||
if (accountAssociations != null) {
|
if (accountAssociations != null) {
|
||||||
|
|||||||
+5
-3
@@ -50,6 +50,7 @@ import org.mifosplatform.organisation.workingdays.domain.WorkingDaysRepositoryWr
|
|||||||
import org.mifosplatform.portfolio.account.PortfolioAccountType;
|
import org.mifosplatform.portfolio.account.PortfolioAccountType;
|
||||||
import org.mifosplatform.portfolio.account.data.AccountTransferDTO;
|
import org.mifosplatform.portfolio.account.data.AccountTransferDTO;
|
||||||
import org.mifosplatform.portfolio.account.data.PortfolioAccountData;
|
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.AccountAssociations;
|
||||||
import org.mifosplatform.portfolio.account.domain.AccountAssociationsRepository;
|
import org.mifosplatform.portfolio.account.domain.AccountAssociationsRepository;
|
||||||
import org.mifosplatform.portfolio.account.domain.AccountTransferDetailRepository;
|
import org.mifosplatform.portfolio.account.domain.AccountTransferDetailRepository;
|
||||||
@@ -436,7 +437,8 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
|||||||
private void createStandingInstruction(Loan loan) {
|
private void createStandingInstruction(Loan loan) {
|
||||||
|
|
||||||
if (loan.shouldCreateStandingInstructionAtDisbursement()) {
|
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) {
|
if (accountAssociations != null) {
|
||||||
|
|
||||||
@@ -2634,8 +2636,8 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
|||||||
final String errorMessage = "loan.product.does.not.support.multiple.disbursals";
|
final String errorMessage = "loan.product.does.not.support.multiple.disbursals";
|
||||||
throw new LoanMultiDisbursementException(LoanApiConstants.disbursementDataParameterName, errorMessage);
|
throw new LoanMultiDisbursementException(LoanApiConstants.disbursementDataParameterName, errorMessage);
|
||||||
}
|
}
|
||||||
if(loan.isSubmittedAndPendingApproval() || loan.isClosed() || loan.isClosedWrittenOff() || loan.status().isClosedObligationsMet() ||
|
if (loan.isSubmittedAndPendingApproval() || loan.isClosed() || loan.isClosedWrittenOff() || loan.status().isClosedObligationsMet()
|
||||||
loan.status().isOverpaid()){
|
|| loan.status().isOverpaid()) {
|
||||||
final String errorMessage = "cannot.modify.tranches.if.loan.is.pendingapproval.closed.overpaid.writtenoff";
|
final String errorMessage = "cannot.modify.tranches.if.loan.is.pendingapproval.closed.overpaid.writtenoff";
|
||||||
throw new LoanMultiDisbursementException(LoanApiConstants.disbursementDataParameterName, errorMessage);
|
throw new LoanMultiDisbursementException(LoanApiConstants.disbursementDataParameterName, errorMessage);
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -364,7 +364,8 @@ public class DepositApplicationProcessWritePlatformServiceJpaRepositoryImpl impl
|
|||||||
|
|
||||||
// Save linked account information
|
// Save linked account information
|
||||||
final Long savingsAccountId = command.longValueOfParameterNamed(DepositsApiConstants.linkedAccountParamName);
|
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 (savingsAccountId == null) {
|
||||||
if (accountAssociations != null) {
|
if (accountAssociations != null) {
|
||||||
if (this.fromJsonHelper.parameterExists(DepositsApiConstants.linkedAccountParamName, command.parsedJson())) {
|
if (this.fromJsonHelper.parameterExists(DepositsApiConstants.linkedAccountParamName, command.parsedJson())) {
|
||||||
|
|||||||
Reference in New Issue
Block a user