Skip to content

Commit

Permalink
FINERACT-2152: Backdated and multiple interest pauses
Browse files Browse the repository at this point in the history
  • Loading branch information
oleksii-novikov-onix authored and galovics committed Jan 25, 2025
1 parent af37e07 commit 69fed07
Show file tree
Hide file tree
Showing 6 changed files with 189 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class LoanInterestPauseStepDef extends AbstractStepDef {
@Autowired
private LoanInterestPauseApi loanInterestPauseApi;

@And("Customer creates interest pause with start date {string} and end date {string}")
@And("Create interest pause period with start date {string} and end date {string}")
public void createInterestPause(final String startDate, final String endDate) throws IOException {
final Response<PostLoansResponse> loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
assert loanResponse.body() != null;
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.fineract.portfolio.interestpauses.service;

import org.apache.fineract.portfolio.loanaccount.domain.LoanTransaction;

public interface AccountTransfersService {

void updateLoanTransaction(Long loanTransactionId, LoanTransaction newLoanTransaction);

}
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,15 @@
import org.apache.fineract.infrastructure.core.domain.ExternalId;
import org.apache.fineract.infrastructure.core.exception.GeneralPlatformDomainRuleException;
import org.apache.fineract.infrastructure.core.exception.PlatformApiDataValidationException;
import org.apache.fineract.portfolio.loanaccount.domain.ChangedTransactionDetail;
import org.apache.fineract.portfolio.loanaccount.domain.Loan;
import org.apache.fineract.portfolio.loanaccount.domain.LoanAccountDomainService;
import org.apache.fineract.portfolio.loanaccount.domain.LoanRepositoryWrapper;
import org.apache.fineract.portfolio.loanaccount.domain.LoanTermVariations;
import org.apache.fineract.portfolio.loanaccount.domain.LoanTransaction;
import org.apache.fineract.portfolio.loanaccount.rescheduleloan.domain.LoanTermVariationsRepository;
import org.apache.fineract.portfolio.loanaccount.service.LoanAssembler;
import org.apache.fineract.portfolio.loanaccount.service.ReplayedTransactionBusinessEventService;
import org.springframework.transaction.annotation.Transactional;

@AllArgsConstructor
Expand All @@ -54,6 +58,9 @@ public class InterestPauseWritePlatformServiceImpl implements InterestPauseWrite
private final LoanTermVariationsRepository loanTermVariationsRepository;
private final LoanRepositoryWrapper loanRepositoryWrapper;
private final LoanAssembler loanAssembler;
private final LoanAccountDomainService loanAccountDomainService;
private final AccountTransfersService accountTransfersService;
private final ReplayedTransactionBusinessEventService replayedTransactionBusinessEventService;

@Override
public CommandProcessingResult createInterestPause(final ExternalId loanExternalId, final String startDateString,
Expand Down Expand Up @@ -146,7 +153,14 @@ private CommandProcessingResult processInterestPause(final Loan loan, final Loca
final LoanTermVariations savedVariation = loanTermVariationsRepository.saveAndFlush(variation);

loan.getLoanTermVariations().add(savedVariation);
loan.reprocessTransactions();
final ChangedTransactionDetail changedTransactionDetail = loan.reprocessTransactions();
if (changedTransactionDetail != null) {
for (final Map.Entry<Long, LoanTransaction> mapEntry : changedTransactionDetail.getNewTransactionMappings().entrySet()) {
loanAccountDomainService.saveLoanTransactionWithDataIntegrityViolationChecks(mapEntry.getValue());
accountTransfersService.updateLoanTransaction(mapEntry.getKey(), mapEntry.getValue());
}
replayedTransactionBusinessEventService.raiseTransactionReplayedEvents(changedTransactionDetail);
}

return new CommandProcessingResultBuilder().withEntityId(savedVariation.getId()).build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
import org.apache.fineract.portfolio.account.PortfolioAccountType;
import org.apache.fineract.portfolio.account.data.AccountTransferDTO;
import org.apache.fineract.portfolio.account.domain.AccountTransferDetails;
import org.apache.fineract.portfolio.loanaccount.domain.LoanTransaction;
import org.apache.fineract.portfolio.interestpauses.service.AccountTransfersService;

public interface AccountTransfersWritePlatformService {
public interface AccountTransfersWritePlatformService extends AccountTransfersService {

CommandProcessingResult create(JsonCommand command);

Expand All @@ -36,8 +36,6 @@ public interface AccountTransfersWritePlatformService {

void reverseAllTransactions(Long accountId, PortfolioAccountType accountTypeId);

void updateLoanTransaction(Long loanTransactionId, LoanTransaction newLoanTransaction);

CommandProcessingResult refundByTransfer(JsonCommand command);

void reverseTransfersWithFromAccountTransactions(Collection<Long> fromTransactionIds, PortfolioAccountType accountTypeId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
import org.apache.fineract.portfolio.fund.service.FundReadPlatformService;
import org.apache.fineract.portfolio.group.domain.GroupRepositoryWrapper;
import org.apache.fineract.portfolio.group.service.GroupReadPlatformService;
import org.apache.fineract.portfolio.interestpauses.service.AccountTransfersService;
import org.apache.fineract.portfolio.interestpauses.service.InterestPauseReadPlatformService;
import org.apache.fineract.portfolio.interestpauses.service.InterestPauseReadPlatformServiceImpl;
import org.apache.fineract.portfolio.interestpauses.service.InterestPauseWritePlatformService;
Expand Down Expand Up @@ -471,7 +472,10 @@ public InterestPauseReadPlatformService interestPauseReadPlatformService(LoanTer
@Bean
@ConditionalOnMissingBean(InterestPauseWritePlatformService.class)
public InterestPauseWritePlatformService interestPauseWritePlatformService(LoanTermVariationsRepository loanTermVariationsRepository,
LoanRepositoryWrapper loanRepositoryWrapper, LoanAssembler loanAssembler) {
return new InterestPauseWritePlatformServiceImpl(loanTermVariationsRepository, loanRepositoryWrapper, loanAssembler);
LoanRepositoryWrapper loanRepositoryWrapper, LoanAssembler loanAssembler, LoanAccountDomainService loanAccountDomainService,
AccountTransfersService accountTransfersService,
ReplayedTransactionBusinessEventService replayedTransactionBusinessEventService) {
return new InterestPauseWritePlatformServiceImpl(loanTermVariationsRepository, loanRepositoryWrapper, loanAssembler,
loanAccountDomainService, accountTransfersService, replayedTransactionBusinessEventService);
}
}

0 comments on commit 69fed07

Please sign in to comment.