FINERACT-1839 Accounting for CBR Reversal
- [x] Accrual and Cash Processor support - [x] Integration test - [x] Sonarlint code smell fix
This commit is contained in:
+33
@@ -53,6 +53,7 @@ import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import org.apache.fineract.accounting.glaccount.domain.GLAccountType;
|
||||
import org.apache.fineract.client.models.BusinessDateRequest;
|
||||
import org.apache.fineract.client.models.GetJournalEntriesTransactionIdResponse;
|
||||
import org.apache.fineract.client.models.GetLoanTransactionRelation;
|
||||
import org.apache.fineract.client.models.GetLoansLoanIdLoanTransactionRelation;
|
||||
import org.apache.fineract.client.models.GetLoansLoanIdRepaymentPeriod;
|
||||
@@ -60,6 +61,7 @@ import org.apache.fineract.client.models.GetLoansLoanIdResponse;
|
||||
import org.apache.fineract.client.models.GetLoansLoanIdSummary;
|
||||
import org.apache.fineract.client.models.GetLoansLoanIdTransactions;
|
||||
import org.apache.fineract.client.models.GetLoansLoanIdTransactionsTransactionIdResponse;
|
||||
import org.apache.fineract.client.models.JournalEntryTransactionItem;
|
||||
import org.apache.fineract.client.models.PostChargesRequest;
|
||||
import org.apache.fineract.client.models.PostChargesResponse;
|
||||
import org.apache.fineract.client.models.PostClientsResponse;
|
||||
@@ -7197,6 +7199,18 @@ public class ClientLoanIntegrationTest {
|
||||
assertEquals(LocalDate.of(2022, 10, 10), loanDetails.getTransactions().get(3).getDate());
|
||||
assertEquals(0.0, loanDetails.getTransactions().get(3).getOutstandingLoanBalance());
|
||||
|
||||
GetJournalEntriesTransactionIdResponse journalEntriesForTransaction = journalEntryHelper
|
||||
.getJournalEntries("L" + loanDetails.getTransactions().get(3).getId());
|
||||
List<JournalEntryTransactionItem> journalItems = journalEntriesForTransaction.getPageItems();
|
||||
assertEquals(2, journalItems.size());
|
||||
assertEquals(200.0,
|
||||
journalItems.stream()
|
||||
.filter(j -> "DEBIT".equalsIgnoreCase(j.getEntryType().getValue())
|
||||
&& j.getGlAccountId().equals(overpaymentAccount.getAccountID().longValue()))
|
||||
.findFirst().get().getAmount());
|
||||
assertEquals(200.0, journalItems.stream().filter(j -> "CREDIT".equalsIgnoreCase(j.getEntryType().getValue())
|
||||
&& j.getGlAccountId().equals(assetAccount.getAccountID().longValue())).findFirst().get().getAmount());
|
||||
|
||||
this.loanTransactionHelper.reverseLoanTransaction(loanDetails.getId(), loanDetails.getTransactions().get(1).getId(),
|
||||
new PostLoansLoanIdTransactionsTransactionIdRequest().dateFormat("dd MMMM yyyy").transactionAmount(0.0)
|
||||
.transactionDate("10 October 2022").locale("en"));
|
||||
@@ -7232,6 +7246,25 @@ public class ClientLoanIntegrationTest {
|
||||
assertEquals(100.0, loanDetails.getRepaymentSchedule().getPeriods().get(2).getPrincipalPaid());
|
||||
assertEquals(100.0, loanDetails.getRepaymentSchedule().getPeriods().get(2).getPrincipalOutstanding());
|
||||
|
||||
journalEntriesForTransaction = journalEntryHelper.getJournalEntries("L" + loanDetails.getTransactions().get(3).getId());
|
||||
journalItems = journalEntriesForTransaction.getPageItems();
|
||||
assertEquals(3, journalItems.size());
|
||||
assertEquals(1,
|
||||
journalItems.stream().filter(item -> item.getAmount() == 200.0d)
|
||||
.filter(j -> "CREDIT".equalsIgnoreCase(j.getEntryType().getValue())
|
||||
&& j.getGlAccountId().equals(assetAccount.getAccountID().longValue()))
|
||||
.count());
|
||||
assertEquals(1,
|
||||
journalItems.stream().filter(item -> item.getAmount() == 100.0d)
|
||||
.filter(j -> "DEBIT".equalsIgnoreCase(j.getEntryType().getValue())
|
||||
&& j.getGlAccountId().equals(overpaymentAccount.getAccountID().longValue()))
|
||||
.count());
|
||||
assertEquals(1,
|
||||
journalItems.stream().filter(item -> item.getAmount() == 100.0d)
|
||||
.filter(j -> "DEBIT".equalsIgnoreCase(j.getEntryType().getValue())
|
||||
&& j.getGlAccountId().equals(assetAccount.getAccountID().longValue()))
|
||||
.count());
|
||||
|
||||
} finally {
|
||||
GlobalConfigurationHelper.updateIsAutomaticExternalIdGenerationEnabled(this.requestSpec, this.responseSpec, false);
|
||||
GlobalConfigurationHelper.updateIsBusinessDateEnabled(this.requestSpec, this.responseSpec, false);
|
||||
|
||||
Reference in New Issue
Block a user