in component-test/src/main/java/org/apache/fineract/cn/portfolio/TestAccountingInteractionInLoanWorkflow.java [725:788]
private void step3IImportCaseWhenAccountsExist(final LocalDateTime forDateTime) throws InterruptedException {
logger.info("step3IImportCaseWhenAccountsExist");
final BigDecimal currentPrincipal = BigDecimal.valueOf(2_000_00, MINOR_CURRENCY_UNIT_DIGITS);
final AccountAssignment customerLoanPrincipalAccountAssignment = new AccountAssignment();
customerLoanPrincipalAccountAssignment.setDesignator(AccountDesignators.CUSTOMER_LOAN_PRINCIPAL);
customerLoanPrincipalAccountAssignment.setAccountIdentifier(AccountingFixture.IMPORTED_CUSTOMER_LOAN_PRINCIPAL_ACCOUNT);
customerLoanPrincipalAccountAssignment.setAlternativeAccountNumber("external-system-sourced-customer-loan-principal-account-identifier");
final AccountAssignment customerLoanInterestAccountAssignment = new AccountAssignment();
customerLoanInterestAccountAssignment.setDesignator(AccountDesignators.CUSTOMER_LOAN_INTEREST);
customerLoanInterestAccountAssignment.setAccountIdentifier(AccountingFixture.IMPORTED_CUSTOMER_LOAN_INTEREST_ACCOUNT);
customerLoanInterestAccountAssignment.setAlternativeAccountNumber("external-system-sourced-customer-loan-interest-account-identifier");
final AccountAssignment customerLoanFeeAccountAssignment = new AccountAssignment();
customerLoanFeeAccountAssignment.setDesignator(AccountDesignators.CUSTOMER_LOAN_FEES);
customerLoanFeeAccountAssignment.setAccountIdentifier(AccountingFixture.IMPORTED_CUSTOMER_LOAN_FEES_ACCOUNT);
customerLoanFeeAccountAssignment.setAlternativeAccountNumber("external-system-sourced-customer-loan-fees-account-identifier");
final ArrayList<AccountAssignment> importAccountAssignments = new ArrayList<>();
importAccountAssignments.add(customerLoanPrincipalAccountAssignment);
importAccountAssignments.add(customerLoanInterestAccountAssignment);
importAccountAssignments.add(customerLoanFeeAccountAssignment);
final ImportParameters importParameters = new ImportParameters();
importParameters.setCaseAccountAssignments(importAccountAssignments);
importParameters.setPaymentSize(IMPORTED_NEXT_REPAYMENT_AMOUNT);
importParameters.setCreatedOn(DateConverter.toIsoString(forDateTime));
importParameters.setCurrentBalances(Collections.singletonMap(AccountDesignators.CUSTOMER_LOAN_PRINCIPAL, currentPrincipal));
importParameters.setStartOfTerm(DateConverter.toIsoString(forDateTime));
portfolioManager.executeImportCommand(product.getIdentifier(), customerCase.getIdentifier(), importParameters);
Assert.assertTrue(eventRecorder.wait(IndividualLoanEventConstants.IMPORT_INDIVIDUALLOAN_CASE, new IndividualLoanCommandEvent(product.getIdentifier(), customerCase.getIdentifier(), DateConverter.toIsoString(forDateTime))));
AccountingFixture.verifyLedgerCreation(
ledgerManager,
AccountingFixture.CUSTOMER_LOAN_LEDGER_IDENTIFIER,
AccountType.ASSET);
customerLoanPrincipalIdentifier = AccountingFixture.IMPORTED_CUSTOMER_LOAN_PRINCIPAL_ACCOUNT;
customerLoanInterestIdentifier = AccountingFixture.IMPORTED_CUSTOMER_LOAN_INTEREST_ACCOUNT;
customerLoanFeeIdentifier = AccountingFixture.IMPORTED_CUSTOMER_LOAN_FEES_ACCOUNT;
final CaseStatus changedCaseStatus = portfolioManager.getCaseStatus(product.getIdentifier(), customerCase.getIdentifier());
Assert.assertEquals(Case.State.ACTIVE.name(), changedCaseStatus.getCurrentState());
Assert.assertEquals(DateConverter.toIsoString(forDateTime), changedCaseStatus.getStartOfTerm());
Assert.assertEquals("2018-02-08T00:00:00Z", changedCaseStatus.getEndOfTerm());
checkNextActionsCorrect(product.getIdentifier(), customerCase.getIdentifier(),
Action.APPLY_INTEREST, Action.MARK_LATE, Action.ACCEPT_PAYMENT, Action.DISBURSE, Action.MARK_IN_ARREARS, Action.WRITE_OFF, Action.CLOSE);
expectedCurrentPrincipal = currentPrincipal;
updateBalanceMock();
final Case changedCase = portfolioManager.getCase(product.getIdentifier(), customerCase.getIdentifier());
final Map<String, String> designatorsAssignedForCase = changedCase.getAccountAssignments().stream()
.collect(Collectors.toMap(AccountAssignment::getDesignator, AccountAssignment::getAccountIdentifier));
Assert.assertEquals(
AccountingFixture.IMPORTED_CUSTOMER_LOAN_PRINCIPAL_ACCOUNT,
designatorsAssignedForCase.get(AccountDesignators.CUSTOMER_LOAN_PRINCIPAL));
Assert.assertEquals(
AccountingFixture.IMPORTED_CUSTOMER_LOAN_INTEREST_ACCOUNT,
designatorsAssignedForCase.get(AccountDesignators.CUSTOMER_LOAN_INTEREST));
Assert.assertEquals(
AccountingFixture.IMPORTED_CUSTOMER_LOAN_FEES_ACCOUNT,
designatorsAssignedForCase.get(AccountDesignators.CUSTOMER_LOAN_FEES));
}