Skip to content

Commit

Permalink
Merge pull request #1197 from fiterlatam/fix/FSF-56
Browse files Browse the repository at this point in the history
Fix FSF-56
  • Loading branch information
BrianMuhimbura authored Oct 9, 2024
2 parents 4914ebe + 76914a0 commit bb321b0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ public BatchData mapRow(final ResultSet rs, final int rowNum) throws SQLExceptio

@Override
public Page<ChequeData> retrieveAll(final ChequeSearchParams chequeSearchParams, PaginationParameters parameters) {
final Set<String> supportedOrderByValues = new HashSet<>(List.of("chequeNo"));
final Set<String> supportedOrderByValues = new HashSet<>(List.of("chequeNo", "batchNo", "batchNo, chequeNo", "chequeNo, batchNo"));
this.paginationParametersDataValidator.validateParameterValues(parameters, supportedOrderByValues, "cheques");
final StringBuilder sqlBuilder = new StringBuilder(200);
sqlBuilder.append("SELECT ").append(this.sqlGenerator.calcFoundRows()).append(" ");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,9 @@
import org.apache.fineract.infrastructure.core.api.JsonCommand;
import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
import org.apache.fineract.infrastructure.core.data.CommandProcessingResultBuilder;
import org.apache.fineract.infrastructure.core.data.PaginationParameters;
import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper;
import org.apache.fineract.infrastructure.core.serialization.JsonParserHelper;
import org.apache.fineract.infrastructure.core.service.DateUtils;
import org.apache.fineract.infrastructure.core.service.Page;
import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
import org.apache.fineract.organisation.agency.domain.Agency;
import org.apache.fineract.organisation.bankAccount.domain.BankAccount;
Expand All @@ -57,7 +55,6 @@
import org.apache.fineract.organisation.bankcheque.command.UpdateChequeCommand;
import org.apache.fineract.organisation.bankcheque.command.VoidChequeCommand;
import org.apache.fineract.organisation.bankcheque.data.ChequeData;
import org.apache.fineract.organisation.bankcheque.data.ChequeSearchParams;
import org.apache.fineract.organisation.bankcheque.domain.BankChequeStatus;
import org.apache.fineract.organisation.bankcheque.domain.Batch;
import org.apache.fineract.organisation.bankcheque.domain.Cheque;
Expand Down Expand Up @@ -221,17 +218,12 @@ public CommandProcessingResult reassignCheque(final Long chequeId, JsonCommand c
throw new BankChequeException("status", "invalid.loan.status.for.cheque.reassignment");
}

final PaginationParameters parameters = PaginationParameters.instance(null, null, null, null, null);
final ChequeSearchParams chequeSearchParams = ChequeSearchParams.builder().chequeId(reassignChequeCommand.getOldChequeId()).build();
final Page<ChequeData> cheques = this.chequeReadPlatformService.retrieveAll(chequeSearchParams, parameters);
if (!CollectionUtils.isEmpty(cheques.getPageItems())) {
final ChequeData chequeData = cheques.getPageItems().get(0);
if (chequeData.getId().equals(reassignChequeCommand.getOldChequeId()) && chequeData.getLoanAccId() != null) {
final Long loanId = chequeData.getLoanAccId();
final Loan loan = this.loanRepositoryWrapper.findOneWithNotFoundDetection(loanId);
loan.setCheque(newCheque);
this.loanRepositoryWrapper.saveAndFlush(loan);
}
final ChequeData chequeData = this.chequeReadPlatformService.retrieveChequeById(oldCheque.getId());
if (chequeData != null && chequeData.getLoanAccId() != null) {
final Long loanId = chequeData.getLoanAccId();
final Loan loan = this.loanRepositoryWrapper.findOneWithNotFoundDetection(loanId);
loan.setCheque(newCheque);
this.loanRepositoryWrapper.saveAndFlush(loan);
}
final String newChequeDescription = "Emitido por sustitución de Desembolso cheque " + oldCheque.getChequeNo();
final String oldChequeDescription = "Cheque anulado por proceso de Reasignación, cheque nuevo " + newCheque.getChequeNo();
Expand Down

0 comments on commit bb321b0

Please sign in to comment.