FINERACT-1692: Allow disbursement transaction when the loan is fully paid/overpaid

This commit is contained in:
Adam Saghy
2022-08-19 18:26:03 +02:00
committed by Arnold Gálovics
parent 9d8b2d38c5
commit d2e56edba6
34 changed files with 393 additions and 168 deletions
@@ -26,6 +26,7 @@ import java.security.InvalidParameterException;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
@@ -44,6 +45,7 @@ import org.apache.fineract.infrastructure.sms.domain.SmsMessageRepository;
import org.apache.fineract.infrastructure.sms.scheduler.SmsMessageScheduledJobService; import org.apache.fineract.infrastructure.sms.scheduler.SmsMessageScheduledJobService;
import org.apache.fineract.organisation.office.domain.Office; import org.apache.fineract.organisation.office.domain.Office;
import org.apache.fineract.organisation.office.domain.OfficeRepository; import org.apache.fineract.organisation.office.domain.OfficeRepository;
import org.apache.fineract.organisation.office.exception.OfficeNotFoundException;
import org.apache.fineract.portfolio.businessevent.BusinessEventListener; import org.apache.fineract.portfolio.businessevent.BusinessEventListener;
import org.apache.fineract.portfolio.businessevent.domain.client.ClientActivateBusinessEvent; import org.apache.fineract.portfolio.businessevent.domain.client.ClientActivateBusinessEvent;
import org.apache.fineract.portfolio.businessevent.domain.client.ClientRejectBusinessEvent; import org.apache.fineract.portfolio.businessevent.domain.client.ClientRejectBusinessEvent;
@@ -58,6 +60,7 @@ import org.apache.fineract.portfolio.businessevent.service.BusinessEventNotifier
import org.apache.fineract.portfolio.client.domain.Client; import org.apache.fineract.portfolio.client.domain.Client;
import org.apache.fineract.portfolio.group.domain.Group; import org.apache.fineract.portfolio.group.domain.Group;
import org.apache.fineract.portfolio.group.domain.GroupRepository; import org.apache.fineract.portfolio.group.domain.GroupRepository;
import org.apache.fineract.portfolio.group.exception.GroupNotFoundException;
import org.apache.fineract.portfolio.loanaccount.domain.Loan; import org.apache.fineract.portfolio.loanaccount.domain.Loan;
import org.apache.fineract.portfolio.loanaccount.domain.LoanTransaction; import org.apache.fineract.portfolio.loanaccount.domain.LoanTransaction;
import org.apache.fineract.portfolio.loanaccount.exception.InvalidLoanTypeException; import org.apache.fineract.portfolio.loanaccount.exception.InvalidLoanTypeException;
@@ -169,13 +172,16 @@ public class SmsCampaignDomainServiceImpl implements SmsCampaignDomainService {
throw new InvalidLoanTypeException("Loan Type cannot be Invalid for the Triggered Sms Campaign"); throw new InvalidLoanTypeException("Loan Type cannot be Invalid for the Triggered Sms Campaign");
} }
if (loan.isGroupLoan()) { if (loan.isGroupLoan()) {
Group group = this.groupRepository.findById(loan.getGroupId()).orElse(null); Group group = this.groupRepository.findById(loan.getGroupId())
.orElseThrow(() -> new GroupNotFoundException(loan.getGroupId()));
groupClients.addAll(group.getClientMembers()); groupClients.addAll(group.getClientMembers());
} else { } else {
groupClients.add(loan.client()); groupClients.add(loan.client());
} }
HashMap<String, String> campaignParams = new ObjectMapper().readValue(smsCampaign.getParamValue(), HashMap<String, String> campaignParams = new ObjectMapper().readValue(smsCampaign.getParamValue(),
new TypeReference<HashMap<String, String>>() {}); new TypeReference<>() {
});
if (groupClients.size() > 0) { if (groupClients.size() > 0) {
for (Client client : groupClients) { for (Client client : groupClients) {
@@ -189,7 +195,9 @@ public class SmsCampaignDomainServiceImpl implements SmsCampaignDomainService {
} }
if (spkeycheck && !(value.equals("-1") || spvalue.equals(value))) { if (spkeycheck && !(value.equals("-1") || spvalue.equals(value))) {
if (key.equals("officeId")) { if (key.equals("officeId")) {
Office campaignOffice = this.officeRepository.findById(Long.valueOf(value)).orElse(null); Long officeId = Long.valueOf(value);
Office campaignOffice = this.officeRepository.findById(Long.valueOf(value))
.orElseThrow(() -> new OfficeNotFoundException(officeId));
if (campaignOffice.doesNotHaveAnOfficeInHierarchyWithId(client.getOffice().getId())) { if (campaignOffice.doesNotHaveAnOfficeInHierarchyWithId(client.getOffice().getId())) {
throw new SmsRuntimeException("error.msg.no.office", "Office not found for the id"); throw new SmsRuntimeException("error.msg.no.office", "Office not found for the id");
} }
@@ -208,10 +216,8 @@ public class SmsCampaignDomainServiceImpl implements SmsCampaignDomainService {
} }
SmsMessage smsMessage = SmsMessage.pendingSms(null, null, client, null, message, mobileNumber, smsCampaign, SmsMessage smsMessage = SmsMessage.pendingSms(null, null, client, null, message, mobileNumber, smsCampaign,
smsCampaign.isNotification()); smsCampaign.isNotification());
Collection<SmsMessage> messages = new ArrayList<>();
messages.add(smsMessage);
Map<SmsCampaign, Collection<SmsMessage>> smsDataMap = new HashMap<>(); Map<SmsCampaign, Collection<SmsMessage>> smsDataMap = new HashMap<>();
smsDataMap.put(smsCampaign, messages); smsDataMap.put(smsCampaign, Collections.singletonList(smsMessage));
this.smsMessageScheduledJobService.sendTriggeredMessages(smsDataMap); this.smsMessageScheduledJobService.sendTriggeredMessages(smsDataMap);
} }
} }
@@ -234,7 +240,9 @@ public class SmsCampaignDomainServiceImpl implements SmsCampaignDomainService {
final SavingsAccount savingsAccount = savingsTransaction.getSavingsAccount(); final SavingsAccount savingsAccount = savingsTransaction.getSavingsAccount();
final Client client = savingsAccount.getClient(); final Client client = savingsAccount.getClient();
HashMap<String, String> campaignParams = new ObjectMapper().readValue(smsCampaign.getParamValue(), HashMap<String, String> campaignParams = new ObjectMapper().readValue(smsCampaign.getParamValue(),
new TypeReference<HashMap<String, String>>() {}); new TypeReference<>() {
});
HashMap<String, Object> smsParams = processSavingsTransactionDataForSms(savingsTransaction, client); HashMap<String, Object> smsParams = processSavingsTransactionDataForSms(savingsTransaction, client);
for (String key : campaignParams.keySet()) { for (String key : campaignParams.keySet()) {
String value = campaignParams.get(key); String value = campaignParams.get(key);
@@ -245,7 +253,9 @@ public class SmsCampaignDomainServiceImpl implements SmsCampaignDomainService {
} }
if (spkeycheck && !(value.equals("-1") || spvalue.equals(value))) { if (spkeycheck && !(value.equals("-1") || spvalue.equals(value))) {
if (key.equals("officeId")) { if (key.equals("officeId")) {
Office campaignOffice = this.officeRepository.findById(Long.valueOf(value)).orElse(null); Long officeId = Long.valueOf(value);
Office campaignOffice = this.officeRepository.findById(officeId)
.orElseThrow(() -> new OfficeNotFoundException(officeId));
if (campaignOffice.doesNotHaveAnOfficeInHierarchyWithId(client.getOffice().getId())) { if (campaignOffice.doesNotHaveAnOfficeInHierarchyWithId(client.getOffice().getId())) {
throw new SmsRuntimeException("error.msg.no.office", "Office not found for the id"); throw new SmsRuntimeException("error.msg.no.office", "Office not found for the id");
} }
@@ -308,7 +318,7 @@ public class SmsCampaignDomainServiceImpl implements SmsCampaignDomainService {
smsParams.put("lastname", client.getLastname()); smsParams.put("lastname", client.getLastname());
smsParams.put("FullName", client.getDisplayName()); smsParams.put("FullName", client.getDisplayName());
smsParams.put("mobileNo", client.mobileNo()); smsParams.put("mobileNo", client.mobileNo());
smsParams.put("LoanAmount", loan.getPrincpal()); smsParams.put("LoanAmount", loan.getPrincipal());
smsParams.put("LoanOutstanding", loanTransaction.getOutstandingLoanBalance()); smsParams.put("LoanOutstanding", loanTransaction.getOutstandingLoanBalance());
smsParams.put("loanId", loan.getId()); smsParams.put("loanId", loan.getId());
smsParams.put("LoanAccountId", loan.getAccountNumber()); smsParams.put("LoanAccountId", loan.getAccountNumber());
@@ -340,7 +350,7 @@ public class SmsCampaignDomainServiceImpl implements SmsCampaignDomainService {
// {{balance}} // {{balance}}
// transactionDate // transactionDate
HashMap<String, Object> smsParams = new HashMap<String, Object>(); HashMap<String, Object> smsParams = new HashMap<>();
SavingsAccount savingsAccount = savingsAccountTransaction.getSavingsAccount(); SavingsAccount savingsAccount = savingsAccountTransaction.getSavingsAccount();
DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("MMM:d:yyyy"); DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("MMM:d:yyyy");
smsParams.put("clientId", client.getId()); smsParams.put("clientId", client.getId());
@@ -69,7 +69,7 @@ public interface ConfigurationDomainService {
LocalDate retrieveOrganisationStartDate(); LocalDate retrieveOrganisationStartDate();
boolean isPaymnetypeApplicableforDisbursementCharge(); boolean isPaymentTypeApplicableForDisbursementCharge();
boolean isInterestChargedFromDateSameAsDisbursementDate(); boolean isInterestChargedFromDateSameAsDisbursementDate();
@@ -245,7 +245,7 @@ public class ConfigurationDomainServiceJpa implements ConfigurationDomainService
} }
@Override @Override
public boolean isPaymnetypeApplicableforDisbursementCharge() { public boolean isPaymentTypeApplicableForDisbursementCharge() {
final String propertyName = "paymenttype-applicable-for-disbursement-charges"; final String propertyName = "paymenttype-applicable-for-disbursement-charges";
final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData(propertyName); final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData(propertyName);
return property.isEnabled(); return property.isEnabled();
@@ -372,13 +372,13 @@ public class ConfigurationDomainServiceJpa implements ConfigurationDomainService
final String propertyName = "allow-backdated-transaction-before-interest-posting-date-for-days"; final String propertyName = "allow-backdated-transaction-before-interest-posting-date-for-days";
final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData(propertyName); final GlobalConfigurationPropertyData property = getGlobalConfigurationPropertyData(propertyName);
if (property.getValue() == null) { if (property.getValue() == null) {
return Long.valueOf(0); return 0L;
} }
return property.getValue(); return property.getValue();
} }
@Cacheable(value = "configByName", key = "T(org.apache.fineract.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier().concat(#propertyName)") @Cacheable(value = "configByName", key = "T(org.apache.fineract.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier().concat(#propertyName)")
private GlobalConfigurationPropertyData getGlobalConfigurationPropertyData(final String propertyName) { public GlobalConfigurationPropertyData getGlobalConfigurationPropertyData(final String propertyName) {
String identifier = ThreadLocalContextUtil.getTenant().getTenantIdentifier(); String identifier = ThreadLocalContextUtil.getTenant().getTenantIdentifier();
String key = identifier + "_" + propertyName; String key = identifier + "_" + propertyName;
if (!configurations.containsKey(key)) { if (!configurations.containsKey(key)) {
@@ -55,7 +55,7 @@ public class DefaultLoanLifecycleStateMachine implements LoanLifecycleStateMachi
} }
break; break;
case LOAN_DISBURSED: case LOAN_DISBURSED:
if (from.hasStateOf(LoanStatus.APPROVED)) { if (anyOfAllowedWhenComingFrom(from, LoanStatus.APPROVED, LoanStatus.CLOSED_OBLIGATIONS_MET, LoanStatus.OVERPAID)) {
newState = stateOf(LoanStatus.ACTIVE, this.allowedLoanStatuses); newState = stateOf(LoanStatus.ACTIVE, this.allowedLoanStatuses);
} }
break; break;
@@ -902,7 +902,7 @@ public class Loan extends AbstractAuditableWithUTCDateTimeCustom {
if (isMultiDisburmentLoan() && loanCharge.isDisbursementCharge()) { if (isMultiDisburmentLoan() && loanCharge.isDisbursementCharge()) {
amount = getTotalAllTrancheDisbursementAmount().getAmount().add(totalInterestCharged); amount = getTotalAllTrancheDisbursementAmount().getAmount().add(totalInterestCharged);
} else { } else {
amount = getPrincpal().getAmount().add(totalInterestCharged); amount = getPrincipal().getAmount().add(totalInterestCharged);
} }
break; break;
case PERCENT_OF_INTEREST: case PERCENT_OF_INTEREST:
@@ -912,7 +912,7 @@ public class Loan extends AbstractAuditableWithUTCDateTimeCustom {
if (loanCharge.getTrancheDisbursementCharge() != null) { if (loanCharge.getTrancheDisbursementCharge() != null) {
amount = loanCharge.getTrancheDisbursementCharge().getloanDisbursementDetails().principal(); amount = loanCharge.getTrancheDisbursementCharge().getloanDisbursementDetails().principal();
} else { } else {
amount = getPrincpal().getAmount(); amount = getPrincipal().getAmount();
} }
break; break;
default: default:
@@ -1306,7 +1306,6 @@ public class Loan extends AbstractAuditableWithUTCDateTimeCustom {
if (loanTransaction.getInterestPortion(getCurrency()).isGreaterThanZero()) { if (loanTransaction.getInterestPortion(getCurrency()).isGreaterThanZero()) {
if (loanTransaction.getInterestPortion(getCurrency()).isNotEqualTo(interestApplied)) { if (loanTransaction.getInterestPortion(getCurrency()).isNotEqualTo(interestApplied)) {
loanTransaction.reverse(); loanTransaction.reverse();
final LocalDateTime currentDateTime = DateUtils.getLocalDateTimeOfTenant();
final LoanTransaction interestAppliedTransaction = LoanTransaction.accrueInterest(getOffice(), this, interestApplied, final LoanTransaction interestAppliedTransaction = LoanTransaction.accrueInterest(getOffice(), this, interestApplied,
getDisbursementDate()); getDisbursementDate());
addLoanTransaction(interestAppliedTransaction); addLoanTransaction(interestAppliedTransaction);
@@ -2537,7 +2536,9 @@ public class Loan extends AbstractAuditableWithUTCDateTimeCustom {
LoanStatus.fromInt(this.loanStatus)); LoanStatus.fromInt(this.loanStatus));
boolean isMultiTrancheDisburse = false; boolean isMultiTrancheDisburse = false;
if (LoanStatus.fromInt(this.loanStatus).isActive() && isAllTranchesNotDisbursed()) { LoanStatus actualLoanStatus = LoanStatus.fromInt(this.loanStatus);
if ((actualLoanStatus.isActive() || actualLoanStatus.isClosedObligationsMet() || actualLoanStatus.isOverpaid())
&& isAllTranchesNotDisbursed()) {
LoanDisbursementDetails details = fetchLastDisburseDetail(); LoanDisbursementDetails details = fetchLastDisburseDetail();
if (details != null) { if (details != null) {
@@ -2550,7 +2551,7 @@ public class Loan extends AbstractAuditableWithUTCDateTimeCustom {
} }
isMultiTrancheDisburse = true; isMultiTrancheDisburse = true;
} }
return !statusEnum.hasStateOf(LoanStatus.fromInt(this.loanStatus)) || isMultiTrancheDisburse; return !statusEnum.hasStateOf(actualLoanStatus) || isMultiTrancheDisburse;
} }
public Money adjustDisburseAmount(final JsonCommand command, final LocalDate actualDisbursementDate) { public Money adjustDisburseAmount(final JsonCommand command, final LocalDate actualDisbursementDate) {
@@ -4021,9 +4022,9 @@ public class Loan extends AbstractAuditableWithUTCDateTimeCustom {
} }
private boolean isAllTranchesNotDisbursed() { private boolean isAllTranchesNotDisbursed() {
return this.loanProduct.isMultiDisburseLoan() LoanStatus actualLoanStatus = LoanStatus.fromInt(this.loanStatus);
&& (LoanStatus.fromInt(this.loanStatus).isActive() || LoanStatus.fromInt(this.loanStatus).isApproved()) return this.loanProduct.isMultiDisburseLoan() && (actualLoanStatus.isActive() || actualLoanStatus.isApproved()
&& isDisbursementAllowed(); || actualLoanStatus.isClosedObligationsMet() || actualLoanStatus.isOverpaid()) && isDisbursementAllowed();
} }
private boolean hasDisbursementTransaction() { private boolean hasDisbursementTransaction() {
@@ -4193,7 +4194,7 @@ public class Loan extends AbstractAuditableWithUTCDateTimeCustom {
return this.interestChargedFromDate; return this.interestChargedFromDate;
} }
public Money getPrincpal() { public Money getPrincipal() {
return this.loanRepaymentScheduleDetail.getPrincipal(); return this.loanRepaymentScheduleDetail.getPrincipal();
} }
@@ -6399,7 +6400,7 @@ public class Loan extends AbstractAuditableWithUTCDateTimeCustom {
} }
} }
} else { } else {
amount = getPrincpal().getAmount(); amount = getPrincipal().getAmount();
} }
} }
return amount; return amount;
@@ -158,7 +158,7 @@ public class LoanCharge extends AbstractPersistableCustom {
if (command.hasParameter("principal")) { if (command.hasParameter("principal")) {
amountPercentageAppliedTo = command.bigDecimalValueOfParameterNamed("principal"); amountPercentageAppliedTo = command.bigDecimalValueOfParameterNamed("principal");
} else { } else {
amountPercentageAppliedTo = loan.getPrincpal().getAmount(); amountPercentageAppliedTo = loan.getPrincipal().getAmount();
} }
break; break;
case PERCENT_OF_AMOUNT_AND_INTEREST: case PERCENT_OF_AMOUNT_AND_INTEREST:
@@ -166,7 +166,7 @@ public class LoanCharge extends AbstractPersistableCustom {
amountPercentageAppliedTo = command.bigDecimalValueOfParameterNamed("principal") amountPercentageAppliedTo = command.bigDecimalValueOfParameterNamed("principal")
.add(command.bigDecimalValueOfParameterNamed("interest")); .add(command.bigDecimalValueOfParameterNamed("interest"));
} else { } else {
amountPercentageAppliedTo = loan.getPrincpal().getAmount().add(loan.getTotalInterest()); amountPercentageAppliedTo = loan.getPrincipal().getAmount().add(loan.getTotalInterest());
} }
break; break;
case PERCENT_OF_INTEREST: case PERCENT_OF_INTEREST:
@@ -448,11 +448,11 @@ public class LoanCharge extends AbstractPersistableCustom {
} }
} }
} else { } else {
amountPercentageAppliedTo = this.loan.getPrincpal().getAmount(); amountPercentageAppliedTo = this.loan.getPrincipal().getAmount();
} }
break; break;
case PERCENT_OF_AMOUNT_AND_INTEREST: case PERCENT_OF_AMOUNT_AND_INTEREST:
amountPercentageAppliedTo = this.loan.getPrincpal().getAmount().add(this.loan.getTotalInterest()); amountPercentageAppliedTo = this.loan.getPrincipal().getAmount().add(this.loan.getTotalInterest());
break; break;
case PERCENT_OF_INTEREST: case PERCENT_OF_INTEREST:
amountPercentageAppliedTo = this.loan.getTotalInterest(); amountPercentageAppliedTo = this.loan.getTotalInterest();
@@ -99,7 +99,7 @@ public class GuarantorDomainServiceImpl implements GuarantorDomainService {
@Override @Override
public void validateGuarantorBusinessRules(Loan loan) { public void validateGuarantorBusinessRules(Loan loan) {
LoanProduct loanProduct = loan.loanProduct(); LoanProduct loanProduct = loan.loanProduct();
BigDecimal principal = loan.getPrincpal().getAmount(); BigDecimal principal = loan.getPrincipal().getAmount();
if (loanProduct.isHoldGuaranteeFundsEnabled()) { if (loanProduct.isHoldGuaranteeFundsEnabled()) {
LoanProductGuaranteeDetails guaranteeData = loanProduct.getLoanProductGuaranteeDetails(); LoanProductGuaranteeDetails guaranteeData = loanProduct.getLoanProductGuaranteeDetails();
final List<Guarantor> existGuarantorList = this.guarantorRepository.findByLoan(loan); final List<Guarantor> existGuarantorList = this.guarantorRepository.findByLoan(loan);
@@ -241,8 +241,8 @@ public class GuarantorDomainServiceImpl implements GuarantorDomainService {
releaseLoanIds.put(loanId, guarantorFundingDetails.getId()); releaseLoanIds.put(loanId, guarantorFundingDetails.getId());
try { try {
BigDecimal remainingAmount = guarantorFundingDetails.getAmountRemaining(); BigDecimal remainingAmount = guarantorFundingDetails.getAmountRemaining();
if (loan.getGuaranteeAmount().compareTo(loan.getPrincpal().getAmount()) > 0) { if (loan.getGuaranteeAmount().compareTo(loan.getPrincipal().getAmount()) > 0) {
remainingAmount = remainingAmount.multiply(loan.getPrincpal().getAmount()).divide(loan.getGuaranteeAmount(), remainingAmount = remainingAmount.multiply(loan.getPrincipal().getAmount()).divide(loan.getGuaranteeAmount(),
MoneyHelper.getRoundingMode()); MoneyHelper.getRoundingMode());
} }
AccountTransferDTO accountTransferDTO = new AccountTransferDTO(transactionDate, remainingAmount, fromAccountType, AccountTransferDTO accountTransferDTO = new AccountTransferDTO(transactionDate, remainingAmount, fromAccountType,
@@ -393,7 +393,7 @@ public class GuarantorDomainServiceImpl implements GuarantorDomainService {
BigDecimal amountForRelease = loanTransaction.getPrincipalPortion(); BigDecimal amountForRelease = loanTransaction.getPrincipalPortion();
BigDecimal totalGuaranteeAmount = loan.getGuaranteeAmount(); BigDecimal totalGuaranteeAmount = loan.getGuaranteeAmount();
BigDecimal principal = loan.getPrincpal().getAmount(); BigDecimal principal = loan.getPrincipal().getAmount();
if ((amountForRelease != null) && (totalGuaranteeAmount != null)) { if ((amountForRelease != null) && (totalGuaranteeAmount != null)) {
amountForRelease = amountForRelease.multiply(totalGuaranteeAmount).divide(principal, MoneyHelper.getRoundingMode()); amountForRelease = amountForRelease.multiply(totalGuaranteeAmount).divide(principal, MoneyHelper.getRoundingMode());
List<DepositAccountOnHoldTransaction> accountOnHoldTransactions = new ArrayList<>(); List<DepositAccountOnHoldTransaction> accountOnHoldTransactions = new ArrayList<>();
@@ -218,7 +218,7 @@ public class LoanScheduleCalculationPlatformServiceImpl implements LoanScheduleC
Collection<LoanRepaymentScheduleInstallment> installments = loan.getRepaymentScheduleInstallments(); Collection<LoanRepaymentScheduleInstallment> installments = loan.getRepaymentScheduleInstallments();
final List<LoanSchedulePeriodData> installmentData = new ArrayList<>(); final List<LoanSchedulePeriodData> installmentData = new ArrayList<>();
final MonetaryCurrency currency = loan.getCurrency(); final MonetaryCurrency currency = loan.getCurrency();
Money outstanding = loan.getPrincpal(); Money outstanding = loan.getPrincipal();
List<LoanDisbursementDetails> disbursementDetails = new ArrayList<>(); List<LoanDisbursementDetails> disbursementDetails = new ArrayList<>();
if (loan.isMultiDisburmentLoan()) { if (loan.isMultiDisburmentLoan()) {
@@ -166,6 +166,7 @@ import org.apache.fineract.portfolio.loanaccount.domain.LoanInterestRecalcualtio
import org.apache.fineract.portfolio.loanaccount.domain.LoanLifecycleStateMachine; import org.apache.fineract.portfolio.loanaccount.domain.LoanLifecycleStateMachine;
import org.apache.fineract.portfolio.loanaccount.domain.LoanOverdueInstallmentCharge; import org.apache.fineract.portfolio.loanaccount.domain.LoanOverdueInstallmentCharge;
import org.apache.fineract.portfolio.loanaccount.domain.LoanRepaymentScheduleInstallment; import org.apache.fineract.portfolio.loanaccount.domain.LoanRepaymentScheduleInstallment;
import org.apache.fineract.portfolio.loanaccount.domain.LoanRepaymentScheduleInstallmentRepository;
import org.apache.fineract.portfolio.loanaccount.domain.LoanRepaymentScheduleTransactionProcessorFactory; import org.apache.fineract.portfolio.loanaccount.domain.LoanRepaymentScheduleTransactionProcessorFactory;
import org.apache.fineract.portfolio.loanaccount.domain.LoanRepository; import org.apache.fineract.portfolio.loanaccount.domain.LoanRepository;
import org.apache.fineract.portfolio.loanaccount.domain.LoanRepositoryWrapper; import org.apache.fineract.portfolio.loanaccount.domain.LoanRepositoryWrapper;
@@ -266,6 +267,8 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
private final RepaymentWithPostDatedChecksAssembler repaymentWithPostDatedChecksAssembler; private final RepaymentWithPostDatedChecksAssembler repaymentWithPostDatedChecksAssembler;
private final PostDatedChecksRepository postDatedChecksRepository; private final PostDatedChecksRepository postDatedChecksRepository;
private final LoanRepaymentScheduleInstallmentRepository loanRepaymentScheduleInstallmentRepository;
private LoanLifecycleStateMachine defaultLoanLifecycleStateMachine() { private LoanLifecycleStateMachine defaultLoanLifecycleStateMachine() {
final List<LoanStatus> allowedLoanStatuses = Arrays.asList(LoanStatus.values()); final List<LoanStatus> allowedLoanStatuses = Arrays.asList(LoanStatus.values());
return new DefaultLoanLifecycleStateMachine(allowedLoanStatuses); return new DefaultLoanLifecycleStateMachine(allowedLoanStatuses);
@@ -307,16 +310,25 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
this.loanEventApiJsonValidator.validateDisbursementWithPostDatedChecks(command.json(), loanId); this.loanEventApiJsonValidator.validateDisbursementWithPostDatedChecks(command.json(), loanId);
} }
final Loan loan = this.loanAssembler.assembleFrom(loanId); Loan loan = this.loanAssembler.assembleFrom(loanId);
// Fail fast if client/group is not active or actual loan status disallows disbursal
checkClientOrGroupActive(loan);
if (loan.loanProduct().isDisallowExpectedDisbursements()) { if (loan.loanProduct().isDisallowExpectedDisbursements()) {
// create artificial 'tranche/expected disbursal' as current disburse code expects it for multi-disbursal List<LoanDisbursementDetails> filteredList = loan.getDisbursementDetails().stream()
// products .filter(disbursementDetails -> disbursementDetails.actualDisbursementDate() == null).toList();
final LocalDate artificialExpectedDate = loan.getExpectedDisbursedOnLocalDate(); // Check whether a new LoanDisbursementDetails is required
LoanDisbursementDetails disbursementDetail = new LoanDisbursementDetails(artificialExpectedDate, null, if (filteredList.isEmpty()) {
loan.getDisbursedAmount(), null); // create artificial 'tranche/expected disbursal' as current disburse code expects it for
disbursementDetail.updateLoan(loan); // multi-disbursal
loan.getDisbursementDetails().add(disbursementDetail); // products
final LocalDate artificialExpectedDate = loan.getExpectedDisbursedOnLocalDate();
LoanDisbursementDetails disbursementDetail = new LoanDisbursementDetails(artificialExpectedDate, null,
loan.getDisbursedAmount(), null);
disbursementDetail.updateLoan(loan);
loan.getDisbursementDetails().add(disbursementDetail);
}
} }
loan.validateAccountStatus(LoanEvent.LOAN_DISBURSED);
// Get disbursedAmount // Get disbursedAmount
final BigDecimal disbursedAmount = loan.getDisbursedAmount(); final BigDecimal disbursedAmount = loan.getDisbursedAmount();
@@ -348,7 +360,6 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
if (loanProduct.syncExpectedWithDisbursementDate()) { if (loanProduct.syncExpectedWithDisbursementDate()) {
syncExpectedDateWithActualDisbursementDate(loan, actualDisbursementDate); syncExpectedDateWithActualDisbursementDate(loan, actualDisbursementDate);
} }
checkClientOrGroupActive(loan);
final LocalDate nextPossibleRepaymentDate = loan.getNextPossibleRepaymentDateForRescheduling(); final LocalDate nextPossibleRepaymentDate = loan.getNextPossibleRepaymentDateForRescheduling();
final LocalDate rescheduledRepaymentDate = command.localDateValueOfParameterNamed("adjustRepaymentDate"); final LocalDate rescheduledRepaymentDate = command.localDateValueOfParameterNamed("adjustRepaymentDate");
@@ -382,13 +393,12 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
BigDecimal transactionAmount = command.bigDecimalValueOfParameterNamed("transactionAmount"); BigDecimal transactionAmount = command.bigDecimalValueOfParameterNamed("transactionAmount");
this.cashierTransactionDataValidator.validateOnLoanDisbursal(currentUser, loan.getCurrencyCode(), transactionAmount); this.cashierTransactionDataValidator.validateOnLoanDisbursal(currentUser, loan.getCurrencyCode(), transactionAmount);
} }
final Boolean isPaymnetypeApplicableforDisbursementCharge = configurationDomainService final boolean isPaymentTypeApplicableForDisbursementCharge = configurationDomainService
.isPaymnetypeApplicableforDisbursementCharge(); .isPaymentTypeApplicableForDisbursementCharge();
// Recalculate first repayment date based in actual disbursement date. // Recalculate first repayment date based in actual disbursement date.
updateLoanCounters(loan, actualDisbursementDate); updateLoanCounters(loan, actualDisbursementDate);
Money amountBeforeAdjust = loan.getPrincpal(); Money amountBeforeAdjust = loan.getPrincipal();
loan.validateAccountStatus(LoanEvent.LOAN_DISBURSED);
boolean canDisburse = loan.canDisburse(actualDisbursementDate); boolean canDisburse = loan.canDisburse(actualDisbursementDate);
ChangedTransactionDetail changedTransactionDetail = null; ChangedTransactionDetail changedTransactionDetail = null;
if (canDisburse) { if (canDisburse) {
@@ -401,7 +411,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
} }
Money disburseAmount = loan.adjustDisburseAmount(command, actualDisbursementDate); Money disburseAmount = loan.adjustDisburseAmount(command, actualDisbursementDate);
Money amountToDisburse = disburseAmount.copy(); Money amountToDisburse = disburseAmount.copy();
boolean recalculateSchedule = amountBeforeAdjust.isNotEqualTo(loan.getPrincpal()); boolean recalculateSchedule = amountBeforeAdjust.isNotEqualTo(loan.getPrincipal());
final String txnExternalId = command.stringValueOfParameterNamedAllowingNull("externalId"); final String txnExternalId = command.stringValueOfParameterNamedAllowingNull("externalId");
if (loan.isTopup() && loan.getClientId() != null) { if (loan.isTopup() && loan.getClientId() != null) {
@@ -456,7 +466,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
if (loan.repaymentScheduleDetail().isInterestRecalculationEnabled()) { if (loan.repaymentScheduleDetail().isInterestRecalculationEnabled()) {
createAndSaveLoanScheduleArchive(loan, scheduleGeneratorDTO); createAndSaveLoanScheduleArchive(loan, scheduleGeneratorDTO);
} }
if (isPaymnetypeApplicableforDisbursementCharge) { if (isPaymentTypeApplicableForDisbursementCharge) {
changedTransactionDetail = loan.disburse(currentUser, command, changes, scheduleGeneratorDTO, paymentDetail); changedTransactionDetail = loan.disburse(currentUser, command, changes, scheduleGeneratorDTO, paymentDetail);
} else { } else {
changedTransactionDetail = loan.disburse(currentUser, command, changes, scheduleGeneratorDTO, null); changedTransactionDetail = loan.disburse(currentUser, command, changes, scheduleGeneratorDTO, null);
@@ -465,7 +475,8 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
loan.adjustNetDisbursalAmount(amountToDisburse.getAmount()); loan.adjustNetDisbursalAmount(amountToDisburse.getAmount());
} }
if (!changes.isEmpty()) { if (!changes.isEmpty()) {
saveAndFlushLoanWithDataIntegrityViolationChecks(loan);
loan = saveAndFlushLoanWithDataIntegrityViolationChecks(loan);
final String noteText = command.stringValueOfParameterNamed("note"); final String noteText = command.stringValueOfParameterNamed("note");
if (StringUtils.isNotBlank(noteText)) { if (StringUtils.isNotBlank(noteText)) {
@@ -609,9 +620,17 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
} }
private void saveAndFlushLoanWithDataIntegrityViolationChecks(final Loan loan) { private Loan saveAndFlushLoanWithDataIntegrityViolationChecks(final Loan loan) {
/*
* Due to the "saveAndFlushLoanWithDataIntegrityViolationChecks" method the loan is saved and flushed in the
* middle of the transaction. EclipseLink is in some situations are saving inconsistently the newly created
* associations, like the newly created repayment schedule installments. The save and flush cannot be removed
* safely till any native queries are used as part of this transaction either. See:
* this.loanAccountDomainService.recalculateAccruals(loan);
*/
try { try {
this.loanRepositoryWrapper.saveAndFlush(loan); loanRepaymentScheduleInstallmentRepository.saveAll(loan.getRepaymentScheduleInstallments());
return this.loanRepositoryWrapper.saveAndFlush(loan);
} catch (final JpaSystemException | DataIntegrityViolationException e) { } catch (final JpaSystemException | DataIntegrityViolationException e) {
final Throwable realCause = e.getCause(); final Throwable realCause = e.getCause();
final List<ApiParameterError> dataValidationErrors = new ArrayList<>(); final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
@@ -623,6 +642,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist", "Validation errors exist.", throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist", "Validation errors exist.",
dataValidationErrors, e); dataValidationErrors, e);
} }
throw e;
} }
} }
@@ -664,7 +684,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
final LocalDate rescheduledRepaymentDate = null; final LocalDate rescheduledRepaymentDate = null;
for (final SingleDisbursalCommand singleLoanDisbursalCommand : disbursalCommand) { for (final SingleDisbursalCommand singleLoanDisbursalCommand : disbursalCommand) {
final Loan loan = this.loanAssembler.assembleFrom(singleLoanDisbursalCommand.getLoanId()); Loan loan = this.loanAssembler.assembleFrom(singleLoanDisbursalCommand.getLoanId());
final LocalDate actualDisbursementDate = command.localDateValueOfParameterNamed("actualDisbursementDate"); final LocalDate actualDisbursementDate = command.localDateValueOfParameterNamed("actualDisbursementDate");
// validate ActualDisbursement Date Against Expected Disbursement // validate ActualDisbursement Date Against Expected Disbursement
@@ -692,9 +712,9 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
boolean canDisburse = loan.canDisburse(actualDisbursementDate); boolean canDisburse = loan.canDisburse(actualDisbursementDate);
ChangedTransactionDetail changedTransactionDetail = null; ChangedTransactionDetail changedTransactionDetail = null;
if (canDisburse) { if (canDisburse) {
Money amountBeforeAdjust = loan.getPrincpal(); Money amountBeforeAdjust = loan.getPrincipal();
Money disburseAmount = loan.adjustDisburseAmount(command, actualDisbursementDate); Money disburseAmount = loan.adjustDisburseAmount(command, actualDisbursementDate);
boolean recalculateSchedule = amountBeforeAdjust.isNotEqualTo(loan.getPrincpal()); boolean recalculateSchedule = amountBeforeAdjust.isNotEqualTo(loan.getPrincipal());
final String txnExternalId = command.stringValueOfParameterNamedAllowingNull("externalId"); final String txnExternalId = command.stringValueOfParameterNamedAllowingNull("externalId");
if (isAccountTransfer) { if (isAccountTransfer) {
disburseLoanToSavings(loan, command, disburseAmount, paymentDetail); disburseLoanToSavings(loan, command, disburseAmount, paymentDetail);
@@ -716,7 +736,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
if (loan.repaymentScheduleDetail().isInterestRecalculationEnabled()) { if (loan.repaymentScheduleDetail().isInterestRecalculationEnabled()) {
createAndSaveLoanScheduleArchive(loan, scheduleGeneratorDTO); createAndSaveLoanScheduleArchive(loan, scheduleGeneratorDTO);
} }
if (configurationDomainService.isPaymnetypeApplicableforDisbursementCharge()) { if (configurationDomainService.isPaymentTypeApplicableForDisbursementCharge()) {
changedTransactionDetail = loan.disburse(currentUser, command, changes, scheduleGeneratorDTO, paymentDetail); changedTransactionDetail = loan.disburse(currentUser, command, changes, scheduleGeneratorDTO, paymentDetail);
} else { } else {
changedTransactionDetail = loan.disburse(currentUser, command, changes, scheduleGeneratorDTO, null); changedTransactionDetail = loan.disburse(currentUser, command, changes, scheduleGeneratorDTO, null);
@@ -724,7 +744,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
} }
if (!changes.isEmpty()) { if (!changes.isEmpty()) {
saveAndFlushLoanWithDataIntegrityViolationChecks(loan); loan = saveAndFlushLoanWithDataIntegrityViolationChecks(loan);
final String noteText = command.stringValueOfParameterNamed("note"); final String noteText = command.stringValueOfParameterNamed("note");
if (StringUtils.isNotBlank(noteText)) { if (StringUtils.isNotBlank(noteText)) {
@@ -800,7 +820,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
@Override @Override
public CommandProcessingResult undoLoanDisbursal(final Long loanId, final JsonCommand command) { public CommandProcessingResult undoLoanDisbursal(final Long loanId, final JsonCommand command) {
final Loan loan = this.loanAssembler.assembleFrom(loanId); Loan loan = this.loanAssembler.assembleFrom(loanId);
checkClientOrGroupActive(loan); checkClientOrGroupActive(loan);
businessEventNotifierService.notifyPreBusinessEvent(new LoanUndoDisbursalBusinessEvent(loan)); businessEventNotifierService.notifyPreBusinessEvent(new LoanUndoDisbursalBusinessEvent(loan));
removeLoanCycle(loan); removeLoanCycle(loan);
@@ -830,7 +850,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
BigDecimal netDisbursalAmount = loan.getApprovedPrincipal().subtract(loanOutstanding); BigDecimal netDisbursalAmount = loan.getApprovedPrincipal().subtract(loanOutstanding);
loan.adjustNetDisbursalAmount(netDisbursalAmount); loan.adjustNetDisbursalAmount(netDisbursalAmount);
} }
saveAndFlushLoanWithDataIntegrityViolationChecks(loan); loan = saveAndFlushLoanWithDataIntegrityViolationChecks(loan);
this.accountTransfersWritePlatformService.reverseAllTransactions(loanId, PortfolioAccountType.LOAN); this.accountTransfersWritePlatformService.reverseAllTransactions(loanId, PortfolioAccountType.LOAN);
String noteText = null; String noteText = null;
if (command.hasParameter("note")) { if (command.hasParameter("note")) {
@@ -1010,7 +1030,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
this.loanEventApiJsonValidator.validateTransaction(command.json()); this.loanEventApiJsonValidator.validateTransaction(command.json());
final Loan loan = this.loanAssembler.assembleFrom(loanId); Loan loan = this.loanAssembler.assembleFrom(loanId);
if (loan.status().isClosed() && loan.getLoanSubStatus() != null if (loan.status().isClosed() && loan.getLoanSubStatus() != null
&& loan.getLoanSubStatus().equals(LoanSubStatus.FORECLOSED.getValue())) { && loan.getLoanSubStatus().equals(LoanSubStatus.FORECLOSED.getValue())) {
final String defaultUserMessage = "The loan cannot reopend as it is foreclosed."; final String defaultUserMessage = "The loan cannot reopend as it is foreclosed.";
@@ -1076,7 +1096,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
defaultLoanLifecycleStateMachine(), transactionToAdjust, existingTransactionIds, existingReversedTransactionIds, defaultLoanLifecycleStateMachine(), transactionToAdjust, existingTransactionIds, existingReversedTransactionIds,
scheduleGeneratorDTO, reversalExternalId); scheduleGeneratorDTO, reversalExternalId);
if (newTransactionDetail.isGreaterThanZero(loan.getPrincpal().getCurrency())) { if (newTransactionDetail.isGreaterThanZero(loan.getPrincipal().getCurrency())) {
if (paymentDetail != null) { if (paymentDetail != null) {
this.paymentDetailWritePlatformService.persistPaymentDetail(paymentDetail); this.paymentDetailWritePlatformService.persistPaymentDetail(paymentDetail);
} }
@@ -1088,7 +1108,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
* time being, not a major issue for now as this loop is entered only in edge cases (when a adjustment is made * time being, not a major issue for now as this loop is entered only in edge cases (when a adjustment is made
* before the latest payment recorded against the loan) * before the latest payment recorded against the loan)
***/ ***/
saveAndFlushLoanWithDataIntegrityViolationChecks(loan); loan = saveAndFlushLoanWithDataIntegrityViolationChecks(loan);
if (changedTransactionDetail != null) { if (changedTransactionDetail != null) {
for (final Map.Entry<Long, LoanTransaction> mapEntry : changedTransactionDetail.getNewTransactionMappings().entrySet()) { for (final Map.Entry<Long, LoanTransaction> mapEntry : changedTransactionDetail.getNewTransactionMappings().entrySet()) {
this.loanTransactionRepository.save(mapEntry.getValue()); this.loanTransactionRepository.save(mapEntry.getValue());
@@ -1105,7 +1125,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
/** /**
* If a new transaction is not created, associate note with the transaction to be adjusted * If a new transaction is not created, associate note with the transaction to be adjusted
**/ **/
if (newTransactionDetail.isGreaterThanZero(loan.getPrincpal().getCurrency())) { if (newTransactionDetail.isGreaterThanZero(loan.getPrincipal().getCurrency())) {
note = Note.loanTransactionNote(loan, newTransactionDetail, noteText); note = Note.loanTransactionNote(loan, newTransactionDetail, noteText);
} else { } else {
note = Note.loanTransactionNote(loan, transactionToAdjust, noteText); note = Note.loanTransactionNote(loan, transactionToAdjust, noteText);
@@ -1131,7 +1151,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
this.loanAccountDomainService.recalculateAccruals(loan); this.loanAccountDomainService.recalculateAccruals(loan);
LoanAdjustTransactionBusinessEvent.Data eventData = new LoanAdjustTransactionBusinessEvent.Data(transactionToAdjust); LoanAdjustTransactionBusinessEvent.Data eventData = new LoanAdjustTransactionBusinessEvent.Data(transactionToAdjust);
if (newTransactionDetail.isRepaymentType() && newTransactionDetail.isGreaterThanZero(loan.getPrincpal().getCurrency())) { if (newTransactionDetail.isRepaymentType() && newTransactionDetail.isGreaterThanZero(loan.getPrincipal().getCurrency())) {
eventData.setNewTransactionDetail(newTransactionDetail); eventData.setNewTransactionDetail(newTransactionDetail);
} }
businessEventNotifierService.notifyPostBusinessEvent(new LoanAdjustTransactionBusinessEvent(eventData)); businessEventNotifierService.notifyPostBusinessEvent(new LoanAdjustTransactionBusinessEvent(eventData));
@@ -1157,7 +1177,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
final LocalDate transactionDate = command.localDateValueOfParameterNamed("transactionDate"); final LocalDate transactionDate = command.localDateValueOfParameterNamed("transactionDate");
final BigDecimal transactionAmount = command.bigDecimalValueOfParameterNamed("transactionAmount"); final BigDecimal transactionAmount = command.bigDecimalValueOfParameterNamed("transactionAmount");
final Loan loan = this.loanAssembler.assembleFrom(loanId); Loan loan = this.loanAssembler.assembleFrom(loanId);
checkClientOrGroupActive(loan); checkClientOrGroupActive(loan);
final List<Long> existingTransactionIds = new ArrayList<>(); final List<Long> existingTransactionIds = new ArrayList<>();
@@ -1192,7 +1212,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
* time being, not a major issue for now as this loop is entered only in edge cases (when a waiver is made * time being, not a major issue for now as this loop is entered only in edge cases (when a waiver is made
* before the latest payment recorded against the loan) * before the latest payment recorded against the loan)
***/ ***/
saveAndFlushLoanWithDataIntegrityViolationChecks(loan); loan = saveAndFlushLoanWithDataIntegrityViolationChecks(loan);
if (changedTransactionDetail != null) { if (changedTransactionDetail != null) {
for (final Map.Entry<Long, LoanTransaction> mapEntry : changedTransactionDetail.getNewTransactionMappings().entrySet()) { for (final Map.Entry<Long, LoanTransaction> mapEntry : changedTransactionDetail.getNewTransactionMappings().entrySet()) {
this.loanTransactionRepository.save(mapEntry.getValue()); this.loanTransactionRepository.save(mapEntry.getValue());
@@ -2961,7 +2981,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
} }
private CommandProcessingResult processLoanDisbursementDetail(final Loan loan, Long loanId, JsonCommand command, private CommandProcessingResult processLoanDisbursementDetail(Loan loan, Long loanId, JsonCommand command,
LoanDisbursementDetails loanDisbursementDetails) { LoanDisbursementDetails loanDisbursementDetails) {
final List<Long> existingTransactionIds = new ArrayList<>(); final List<Long> existingTransactionIds = new ArrayList<>();
final List<Long> existingReversedTransactionIds = new ArrayList<>(); final List<Long> existingReversedTransactionIds = new ArrayList<>();
@@ -2998,7 +3018,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
} }
} }
saveAndFlushLoanWithDataIntegrityViolationChecks(loan); loan = saveAndFlushLoanWithDataIntegrityViolationChecks(loan);
if (command.entityId() != null && changedTransactionDetail != null) { if (command.entityId() != null && changedTransactionDetail != null) {
for (Map.Entry<Long, LoanTransaction> mapEntry : changedTransactionDetail.getNewTransactionMappings().entrySet()) { for (Map.Entry<Long, LoanTransaction> mapEntry : changedTransactionDetail.getNewTransactionMappings().entrySet()) {
@@ -3275,7 +3295,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
@Transactional @Transactional
public CommandProcessingResult undoLastLoanDisbursal(Long loanId, JsonCommand command) { public CommandProcessingResult undoLastLoanDisbursal(Long loanId, JsonCommand command) {
final Loan loan = this.loanAssembler.assembleFrom(loanId); Loan loan = this.loanAssembler.assembleFrom(loanId);
final LocalDate recalculateFromDate = loan.getLastRepaymentDate(); final LocalDate recalculateFromDate = loan.getLastRepaymentDate();
validateIsMultiDisbursalLoanAndDisbursedMoreThanOneTranche(loan); validateIsMultiDisbursalLoanAndDisbursedMoreThanOneTranche(loan);
checkClientOrGroupActive(loan); checkClientOrGroupActive(loan);
@@ -3291,7 +3311,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
final Map<String, Object> changes = loan.undoLastDisbursal(scheduleGeneratorDTO, existingTransactionIds, final Map<String, Object> changes = loan.undoLastDisbursal(scheduleGeneratorDTO, existingTransactionIds,
existingReversedTransactionIds, loan); existingReversedTransactionIds, loan);
if (!changes.isEmpty()) { if (!changes.isEmpty()) {
saveAndFlushLoanWithDataIntegrityViolationChecks(loan); loan = saveAndFlushLoanWithDataIntegrityViolationChecks(loan);
String noteText = null; String noteText = null;
if (command.hasParameter("note")) { if (command.hasParameter("note")) {
noteText = command.stringValueOfParameterNamed("note"); noteText = command.stringValueOfParameterNamed("note");
@@ -271,7 +271,7 @@ public class AccountTransferTest {
LoanStatusChecker.verifyLoanIsApproved(toLoanStatusHashMap); LoanStatusChecker.verifyLoanIsApproved(toLoanStatusHashMap);
String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, toLoanID); String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, toLoanID);
toLoanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSAL_DATE, toLoanID, toLoanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount(LOAN_DISBURSAL_DATE, toLoanID,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LoanStatusChecker.verifyLoanIsActive(toLoanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(toLoanStatusHashMap);
@@ -391,7 +391,7 @@ public class AccountTransferTest {
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID); String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSAL_DATE, loanID, loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount(LOAN_DISBURSAL_DATE, loanID,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
@@ -165,7 +165,7 @@ public class AccountingScenarioIntegrationTest {
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
String loanDetails = this.loanTransactionHelper.getLoanDetails(requestSpec, responseSpec, loanID); String loanDetails = this.loanTransactionHelper.getLoanDetails(requestSpec, responseSpec, loanID);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(EXPECTED_DISBURSAL_DATE, loanID, loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount(EXPECTED_DISBURSAL_DATE, loanID,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
@@ -601,7 +601,7 @@ public class AccountingScenarioIntegrationTest {
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
String loanDetails = this.loanTransactionHelper.getLoanDetails(requestSpec, responseSpec, loanID); String loanDetails = this.loanTransactionHelper.getLoanDetails(requestSpec, responseSpec, loanID);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(EXPECTED_DISBURSAL_DATE, loanID, loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount(EXPECTED_DISBURSAL_DATE, loanID,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
@@ -725,7 +725,7 @@ public class AccountingScenarioIntegrationTest {
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
String loanDetails = this.loanTransactionHelper.getLoanDetails(requestSpec, responseSpec, loanID); String loanDetails = this.loanTransactionHelper.getLoanDetails(requestSpec, responseSpec, loanID);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(EXPECTED_DISBURSAL_DATE, loanID, loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount(EXPECTED_DISBURSAL_DATE, loanID,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
@@ -818,7 +818,7 @@ public class AccountingScenarioIntegrationTest {
zonedDate = currentDate.minusDays(2); zonedDate = currentDate.minusDays(2);
String loanDetails = this.loanTransactionHelper.getLoanDetails(requestSpec, responseSpec, loanID); String loanDetails = this.loanTransactionHelper.getLoanDetails(requestSpec, responseSpec, loanID);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID, loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount(LOAN_DISBURSEMENT_DATE, loanID,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
@@ -924,7 +924,7 @@ public class AccountingScenarioIntegrationTest {
todayDate.add(Calendar.DATE, -2); todayDate.add(Calendar.DATE, -2);
String loanDetails = this.loanTransactionHelper.getLoanDetails(requestSpec, responseSpec, loanID); String loanDetails = this.loanTransactionHelper.getLoanDetails(requestSpec, responseSpec, loanID);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID, loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount(LOAN_DISBURSEMENT_DATE, loanID,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
@@ -1026,7 +1026,7 @@ public class AccountingScenarioIntegrationTest {
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
String loanDetails = this.loanTransactionHelper.getLoanDetails(requestSpec, responseSpec, loanID); String loanDetails = this.loanTransactionHelper.getLoanDetails(requestSpec, responseSpec, loanID);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(EXPECTED_DISBURSAL_DATE, loanID, loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount(EXPECTED_DISBURSAL_DATE, loanID,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
@@ -75,7 +75,7 @@ public class ClientLoanChargeExternalIntegrationTest {
final Integer loanID = applyForLoanApplication(clientID, loanProductID, null, null, "12,000.00", collaterals); final Integer loanID = applyForLoanApplication(clientID, loanProductID, null, null, "12,000.00", collaterals);
HashMap loanStatusHashMap = this.loanTransactionHelper.approveLoan("20 September 2011", loanID); HashMap loanStatusHashMap = this.loanTransactionHelper.approveLoan("20 September 2011", loanID);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan("20 September 2011", loanID, "12,000.00"); loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount("20 September 2011", loanID, "12,000.00");
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
final Integer charge = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper final Integer charge = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper
@@ -105,7 +105,7 @@ public class ClientLoanChargeExternalIntegrationTest {
final Integer loanID = applyForLoanApplication(clientID, loanProductID, null, null, "12,000.00", collaterals); final Integer loanID = applyForLoanApplication(clientID, loanProductID, null, null, "12,000.00", collaterals);
HashMap loanStatusHashMap = this.loanTransactionHelper.approveLoan("20 September 2011", loanID); HashMap loanStatusHashMap = this.loanTransactionHelper.approveLoan("20 September 2011", loanID);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan("20 September 2011", loanID, "12,000.00"); loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount("20 September 2011", loanID, "12,000.00");
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
final Integer charge = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper final Integer charge = ChargesHelper.createCharges(requestSpec, responseSpec, ChargesHelper
@@ -460,7 +460,7 @@ public class ClientLoanChargeRefundIntegrationTest {
LOG.info("-------------------------------DISBURSE LOAN -------------------------------------------"); // LOG.info("-------------------------------DISBURSE LOAN -------------------------------------------"); //
// String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID); // String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(submitApproveDisburseDate, loanID, principal); loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount(submitApproveDisburseDate, loanID, principal);
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
return loanID; return loanID;
} }
@@ -153,7 +153,7 @@ public class ClientLoanCreditBalanceRefundandRepaymentTypeIntegrationTest {
LOG.info("-------------------------------DISBURSE LOAN -------------------------------------------"); // LOG.info("-------------------------------DISBURSE LOAN -------------------------------------------"); //
// String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID); // String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(submitApproveDisburseDate, loanID, principal); loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount(submitApproveDisburseDate, loanID, principal);
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
return loanID; return loanID;
} }
@@ -312,7 +312,7 @@ public class ClientLoanIntegrationTest {
// DISBURSE // DISBURSE
String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID); String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan("20 September 2011", loanID, "10000", loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount("20 September 2011", loanID, "10000",
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LOG.info("DISBURSE {}", loanStatusHashMap.toString()); LOG.info("DISBURSE {}", loanStatusHashMap.toString());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
@@ -353,7 +353,7 @@ public class ClientLoanIntegrationTest {
// DISBURSE on todays date so that loan can't be in arrears // DISBURSE on todays date so that loan can't be in arrears
String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID); String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID, "10000", loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount(LOAN_DISBURSEMENT_DATE, loanID, "10000",
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LOG.info("DISBURSE {}", loanStatusHashMap.toString()); LOG.info("DISBURSE {}", loanStatusHashMap.toString());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
@@ -500,7 +500,7 @@ public class ClientLoanIntegrationTest {
// DISBURSE // DISBURSE
String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID); String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan("20 September 2011", loanID, "10000", loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount("20 September 2011", loanID, "10000",
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LOG.info("DISBURSE {}", loanStatusHashMap.toString()); LOG.info("DISBURSE {}", loanStatusHashMap.toString());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
@@ -750,7 +750,7 @@ public class ClientLoanIntegrationTest {
// DISBURSE // DISBURSE
String loanDetail = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID); String loanDetail = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan("20 September 2011", loanID, "10000", loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount("20 September 2011", loanID, "10000",
JsonPath.from(loanDetail).get("netDisbursalAmount").toString()); JsonPath.from(loanDetail).get("netDisbursalAmount").toString());
LOG.info("DISBURSE {}", loanStatusHashMap.toString()); LOG.info("DISBURSE {}", loanStatusHashMap.toString());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
@@ -989,13 +989,13 @@ public class ClientLoanIntegrationTest {
// DISBURSE first Tranche // DISBURSE first Tranche
String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID); String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan("20 March 2014", loanID, loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount("20 March 2014", loanID,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LOG.info("DISBURSE {}", loanStatusHashMap); LOG.info("DISBURSE {}", loanStatusHashMap);
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
// DISBURSE Second Tranche // DISBURSE Second Tranche
loanStatusHashMap = this.loanTransactionHelper.disburseLoan("23 April 2014", loanID, loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount("23 April 2014", loanID,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LOG.info("DISBURSE {}", loanStatusHashMap.toString()); LOG.info("DISBURSE {}", loanStatusHashMap.toString());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
@@ -1590,7 +1590,7 @@ public class ClientLoanIntegrationTest {
LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------");
String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID); String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan("20 September 2011", loanID, loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount("20 September 2011", loanID,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
@@ -1781,7 +1781,7 @@ public class ClientLoanIntegrationTest {
LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------");
String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID); String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan("20 September 2011", loanID, loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount("20 September 2011", loanID,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
@@ -1973,7 +1973,7 @@ public class ClientLoanIntegrationTest {
LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------");
String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID); String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan("20 September 2011", loanID, loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount("20 September 2011", loanID,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
@@ -2161,7 +2161,7 @@ public class ClientLoanIntegrationTest {
LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------");
String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID); String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan("20 September 2011", loanID, loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount("20 September 2011", loanID,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
@@ -2370,7 +2370,7 @@ public class ClientLoanIntegrationTest {
LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------");
String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID); String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan("20 September 2011", loanID, loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount("20 September 2011", loanID,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
@@ -2568,7 +2568,7 @@ public class ClientLoanIntegrationTest {
LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------");
String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID); String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan("20 September 2011", loanID, loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount("20 September 2011", loanID,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
@@ -2773,7 +2773,7 @@ public class ClientLoanIntegrationTest {
LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------");
String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID); String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan("20 September 2011", loanID, loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount("20 September 2011", loanID,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
@@ -2975,7 +2975,7 @@ public class ClientLoanIntegrationTest {
LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------");
String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID); String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan("20 September 2011", loanID, loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount("20 September 2011", loanID,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
@@ -3179,7 +3179,7 @@ public class ClientLoanIntegrationTest {
LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------");
String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID); String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan("20 September 2011", loanID, loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount("20 September 2011", loanID,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
@@ -3400,7 +3400,7 @@ public class ClientLoanIntegrationTest {
LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------");
String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID); String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan("20 September 2011", loanID, loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount("20 September 2011", loanID,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
@@ -3551,7 +3551,7 @@ public class ClientLoanIntegrationTest {
LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------");
String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID); String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID, loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount(LOAN_DISBURSEMENT_DATE, loanID,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
@@ -3661,7 +3661,7 @@ public class ClientLoanIntegrationTest {
LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------");
String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID); String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID, loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount(LOAN_DISBURSEMENT_DATE, loanID,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
@@ -3746,7 +3746,7 @@ public class ClientLoanIntegrationTest {
LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------");
String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID); String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID, loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount(LOAN_DISBURSEMENT_DATE, loanID,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
@@ -3843,7 +3843,7 @@ public class ClientLoanIntegrationTest {
LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------");
String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID); String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID, loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount(LOAN_DISBURSEMENT_DATE, loanID,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
@@ -3977,7 +3977,7 @@ public class ClientLoanIntegrationTest {
LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------");
String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID); String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID, loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount(LOAN_DISBURSEMENT_DATE, loanID,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
@@ -4111,7 +4111,7 @@ public class ClientLoanIntegrationTest {
LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------");
String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID); String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID, loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount(LOAN_DISBURSEMENT_DATE, loanID,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
@@ -4205,7 +4205,7 @@ public class ClientLoanIntegrationTest {
LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------");
String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID); String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID, loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount(LOAN_DISBURSEMENT_DATE, loanID,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
@@ -4317,7 +4317,7 @@ public class ClientLoanIntegrationTest {
LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------");
String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID); String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID, loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount(LOAN_DISBURSEMENT_DATE, loanID,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
@@ -4418,7 +4418,7 @@ public class ClientLoanIntegrationTest {
LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------");
String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID); String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID, loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount(LOAN_DISBURSEMENT_DATE, loanID,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
@@ -4503,7 +4503,7 @@ public class ClientLoanIntegrationTest {
LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------");
String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID); String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID, loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount(LOAN_DISBURSEMENT_DATE, loanID,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
@@ -4593,7 +4593,7 @@ public class ClientLoanIntegrationTest {
LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------");
String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID); String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID, loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount(LOAN_DISBURSEMENT_DATE, loanID,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
@@ -4859,7 +4859,7 @@ public class ClientLoanIntegrationTest {
LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------");
String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID); String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(fourMonthsfromNow, loanID, loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount(fourMonthsfromNow, loanID,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
@@ -5044,7 +5044,7 @@ public class ClientLoanIntegrationTest {
LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------");
String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID); String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(fourMonthsfromNow, loanID, loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount(fourMonthsfromNow, loanID,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
@@ -5240,7 +5240,7 @@ public class ClientLoanIntegrationTest {
LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------");
String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID); String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(fourMonthsfromNow, loanID, loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount(fourMonthsfromNow, loanID,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
@@ -5472,7 +5472,7 @@ public class ClientLoanIntegrationTest {
LOG.info("----------------------------------- DISBURSE LOAN ----------------------------------------"); LOG.info("----------------------------------- DISBURSE LOAN ----------------------------------------");
String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID); String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan("20 September 2011", loanID, "10,000.00", loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount("20 September 2011", loanID, "10,000.00",
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LOG.info("DISBURSE {}", loanStatusHashMap); LOG.info("DISBURSE {}", loanStatusHashMap);
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
@@ -5540,7 +5540,7 @@ public class ClientLoanIntegrationTest {
LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------");
String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID); String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID, loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount(LOAN_DISBURSEMENT_DATE, loanID,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
@@ -5655,7 +5655,7 @@ public class ClientLoanIntegrationTest {
LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------");
String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID); String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(LOAN_DISBURSEMENT_DATE, loanID, loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount(LOAN_DISBURSEMENT_DATE, loanID,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
@@ -93,7 +93,7 @@ public class ClientLoanMultipleDisbursementsIntegrationTest {
.withNumberOfRepayments("4") // .withNumberOfRepayments("4") //
.withRepaymentEveryAfter("1") // .withRepaymentEveryAfter("1") //
.withRepaymentFrequencyTypeAsMonths() // .withRepaymentFrequencyTypeAsMonths() //
.withInterestRatePerPeriod("2") // .withInterestRatePerPeriod("0") //
.withAmortizationTypeAsEqualInstallments() // .withAmortizationTypeAsEqualInstallments() //
.withInterestTypeAsDecliningBalance() // .withInterestTypeAsDecliningBalance() //
.withInterestCalculationPeriodTypeSameAsRepaymentPeriod() // .withInterestCalculationPeriodTypeSameAsRepaymentPeriod() //
@@ -160,21 +160,21 @@ public class ClientLoanMultipleDisbursementsIntegrationTest {
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
LOG.info("-------------------------------DISBURSE 8 LOANS -------------------------------------------"); LOG.info("-------------------------------DISBURSE 8 LOANS -------------------------------------------");
loanStatusHashMap = this.loanTransactionHelper.disburseLoan("12 January 2021", loanID, "1"); loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount("12 January 2021", loanID, "1");
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan("12 January 2021", loanID, "2"); loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount("12 January 2021", loanID, "2");
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan("12 January 2021", loanID, "4"); loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount("12 January 2021", loanID, "4");
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan("13 January 2021", loanID, "8"); loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount("13 January 2021", loanID, "8");
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan("14 January 2021", loanID, "16"); loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount("14 January 2021", loanID, "16");
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan("14 January 2021", loanID, "32"); loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount("14 January 2021", loanID, "32");
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan("15 January 2021", loanID, "64"); loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount("15 January 2021", loanID, "64");
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan("15 January 2021", loanID, "128"); loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount("15 January 2021", loanID, "128");
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
ArrayList<HashMap> loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); ArrayList<HashMap> loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID);
@@ -200,7 +200,6 @@ public class ClientLoanMultipleDisbursementsIntegrationTest {
disbursalCount += 1; disbursalCount += 1;
totalPrincipalDisbursed = totalPrincipalDisbursed.add(principalDisbursed); totalPrincipalDisbursed = totalPrincipalDisbursed.add(principalDisbursed);
} }
// LOG.info(loanSchedule.get(i).toString());
} }
assertEquals(expectedDisbursals, disbursalCount, "Checking for eight disbursals"); assertEquals(expectedDisbursals, disbursalCount, "Checking for eight disbursals");
assertEquals(expectedTotalPrincipalDisbursed, totalPrincipalDisbursed, "Checking Principal Disburse is 255"); assertEquals(expectedTotalPrincipalDisbursed, totalPrincipalDisbursed, "Checking Principal Disburse is 255");
@@ -215,4 +214,184 @@ public class ClientLoanMultipleDisbursementsIntegrationTest {
} }
@Test
public void checkThatAllMultiDisbursalsAppearOnLoanScheduleAndOutStandingBalanceIsZeroButLoanGotReopenedTest() {
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec);
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, clientID);
/***
* Create loan product with allowing multiple disbursals
*/
boolean allowMultipleDisbursals = true;
final Integer loanProductID = createLoanProduct(allowMultipleDisbursals);
Assertions.assertNotNull(loanProductID);
/***
* Apply for loan application and verify loan status
*/
final String savingsId = null;
final String principal = "12,000.00";
LOG.info("-----------------------------------2 Tranches--------------------------------------");
List<HashMap> tranches = new ArrayList<>();
tranches.add(createTrancheDetail("01 January 2021", "1"));
tranches.add(createTrancheDetail("02 January 2021", "2"));
String submitDate = "01 January 2021";
final Integer loanID = applyForLoanApplicationWithTranches(clientID, loanProductID, savingsId, principal, tranches, submitDate);
Assertions.assertNotNull(loanID);
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------");
loanStatusHashMap = this.loanTransactionHelper.approveLoan("01 January 2021", loanID);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
LOG.info(
"-------------------------------DISBURSE 1, repay fully, disburse again LOANS -------------------------------------------");
loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithTransactionAmount("12 January 2021", loanID, "1");
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
HashMap repaymentDetails = this.loanTransactionHelper.makeRepayment("13 January 2021", 1.0f, loanID);
loanStatusHashMap = this.loanTransactionHelper.getLoanDetail(this.requestSpec, this.responseSpec, loanID, "status");
LoanStatusChecker.verifyLoanAccountIsClosed(loanStatusHashMap);
loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithTransactionAmount("14 January 2021", loanID, "2");
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
ArrayList<HashMap> loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID);
final int loanScheduleLineCount = loanSchedule.size();
final int expectedLoanScheduleLineCount = 3;
final int expectedDisbursals = 2;
final BigDecimal expectedTotalPrincipalDisbursed = BigDecimal.valueOf(3.0);
final BigDecimal expectedPrincipalDue = BigDecimal.valueOf(3.0);
final BigDecimal expectedPrincipalPaid = BigDecimal.valueOf(1.0);
final BigDecimal expectedPrincipalOutstanding = BigDecimal.valueOf(2.0);
final BigDecimal expectedPrincipalLoanBalanceOutstanding = BigDecimal.valueOf(0.0);
assertEquals(expectedLoanScheduleLineCount, loanScheduleLineCount, "Checking 3 lines in schedule");
int disbursalCount = 0;
BigDecimal totalPrincipalDisbursed = BigDecimal.ZERO;
// First 8 lines should be disbursals
for (int i = 0; i < loanScheduleLineCount - 1; i++) {
final Integer period = (Integer) loanSchedule.get(i).get("period");
final BigDecimal principalDisbursed = BigDecimal
.valueOf(Double.parseDouble(loanSchedule.get(i).get("principalDisbursed").toString()));
if (period == null) {
disbursalCount += 1;
totalPrincipalDisbursed = totalPrincipalDisbursed.add(principalDisbursed);
}
// LOG.info(loanSchedule.get(i).toString());
}
assertEquals(expectedDisbursals, disbursalCount, "Checking for 2 disbursals");
assertEquals(expectedTotalPrincipalDisbursed, totalPrincipalDisbursed, "Checking Principal Disburse is 3");
final BigDecimal principalDue = BigDecimal.valueOf(Double.parseDouble(loanSchedule.get(2).get("principalDue").toString()));
assertEquals(expectedPrincipalDue, principalDue, "Checking Principal Due is 3");
final BigDecimal principalPaid = BigDecimal.valueOf(Double.parseDouble(loanSchedule.get(2).get("principalPaid").toString()));
assertEquals(expectedPrincipalPaid, principalPaid, "Checking Principal Paid is 1");
final BigDecimal principalOutstanding = BigDecimal
.valueOf(Double.parseDouble(loanSchedule.get(2).get("principalOutstanding").toString()));
assertEquals(expectedPrincipalOutstanding, principalOutstanding, "Checking Principal Due is 2");
final BigDecimal principalLoanBalanceOutstanding = BigDecimal
.valueOf(Double.parseDouble(loanSchedule.get(2).get("principalLoanBalanceOutstanding").toString()));
assertEquals(expectedPrincipalLoanBalanceOutstanding, principalLoanBalanceOutstanding,
"Checking Principal Loan Balance Outstanding is zero");
}
@Test
public void checkThatAllMultiDisbursalsAppearOnLoanScheduleAndOutStandingBalanceIsZeroButLoanGotReopenedFromOverPaidTest() {
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec);
final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec);
ClientHelper.verifyClientCreatedOnServer(this.requestSpec, this.responseSpec, clientID);
/***
* Create loan product with allowing multiple disbursals
*/
boolean allowMultipleDisbursals = true;
final Integer loanProductID = createLoanProduct(allowMultipleDisbursals);
Assertions.assertNotNull(loanProductID);
/***
* Apply for loan application and verify loan status
*/
final String savingsId = null;
final String principal = "12,000.00";
LOG.info("-----------------------------------2 Tranches--------------------------------------");
List<HashMap> tranches = new ArrayList<>();
tranches.add(createTrancheDetail("01 January 2021", "1"));
tranches.add(createTrancheDetail("02 January 2021", "2"));
String submitDate = "01 January 2021";
final Integer loanID = applyForLoanApplicationWithTranches(clientID, loanProductID, savingsId, principal, tranches, submitDate);
Assertions.assertNotNull(loanID);
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------");
loanStatusHashMap = this.loanTransactionHelper.approveLoan("01 January 2021", loanID);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
LOG.info(
"-------------------------------DISBURSE 1, repay fully, disburse again LOANS -------------------------------------------");
loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithTransactionAmount("12 January 2021", loanID, "1");
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
HashMap repaymentDetails = this.loanTransactionHelper.makeRepayment("13 January 2021", 2.0f, loanID);
loanStatusHashMap = this.loanTransactionHelper.getLoanDetail(this.requestSpec, this.responseSpec, loanID, "status");
LoanStatusChecker.verifyLoanAccountIsOverPaid(loanStatusHashMap);
loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithTransactionAmount("14 January 2021", loanID, "2");
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
ArrayList<HashMap> loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID);
final int loanScheduleLineCount = loanSchedule.size();
final int expectedLoanScheduleLineCount = 3;
final int expectedDisbursals = 2;
final BigDecimal expectedTotalPrincipalDisbursed = BigDecimal.valueOf(3.0);
final BigDecimal expectedPrincipalDue = BigDecimal.valueOf(3.0);
final BigDecimal expectedPrincipalPaid = BigDecimal.valueOf(2.0);
final BigDecimal expectedPrincipalOutstanding = BigDecimal.valueOf(1.0);
final BigDecimal expectedPrincipalLoanBalanceOutstanding = BigDecimal.valueOf(0.0);
assertEquals(expectedLoanScheduleLineCount, loanScheduleLineCount, "Checking nine lines in schedule");
int disbursalCount = 0;
BigDecimal totalPrincipalDisbursed = BigDecimal.ZERO;
// First 8 lines should be disbursals
for (int i = 0; i < loanScheduleLineCount - 1; i++) {
final Integer period = (Integer) loanSchedule.get(i).get("period");
final BigDecimal principalDisbursed = BigDecimal
.valueOf(Double.parseDouble(loanSchedule.get(i).get("principalDisbursed").toString()));
if (period == null) {
disbursalCount += 1;
totalPrincipalDisbursed = totalPrincipalDisbursed.add(principalDisbursed);
}
// LOG.info(loanSchedule.get(i).toString());
}
assertEquals(expectedDisbursals, disbursalCount, "Checking for 2 disbursals");
assertEquals(expectedTotalPrincipalDisbursed, totalPrincipalDisbursed, "Checking Principal Disburse is 3");
final BigDecimal principalDue = BigDecimal.valueOf(Double.parseDouble(loanSchedule.get(2).get("principalDue").toString()));
assertEquals(expectedPrincipalDue, principalDue, "Checking Principal Due is 3");
final BigDecimal principalPaid = BigDecimal.valueOf(Double.parseDouble(loanSchedule.get(2).get("principalPaid").toString()));
assertEquals(expectedPrincipalPaid, principalPaid, "Checking Principal Paid is 1");
final BigDecimal principalOutstanding = BigDecimal
.valueOf(Double.parseDouble(loanSchedule.get(2).get("principalOutstanding").toString()));
assertEquals(expectedPrincipalOutstanding, principalOutstanding, "Checking Principal Due is 2");
final BigDecimal principalLoanBalanceOutstanding = BigDecimal
.valueOf(Double.parseDouble(loanSchedule.get(2).get("principalLoanBalanceOutstanding").toString()));
assertEquals(expectedPrincipalLoanBalanceOutstanding, principalLoanBalanceOutstanding,
"Checking Principal Loan Balance Outstanding is zero");
}
} }
@@ -160,7 +160,8 @@ public class ClientLoanNonTrancheMultipleDisbursementsIntegrationTest {
LOG.info("-------------------------------DISBURSE non-tranch multi-disbursal loan ----------"); LOG.info("-------------------------------DISBURSE non-tranch multi-disbursal loan ----------");
final String netDisbursedAmt = null; final String netDisbursedAmt = null;
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(submitDate, loanID, approved.toString(), netDisbursedAmt); loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount(submitDate, loanID, approved.toString(),
netDisbursedAmt);
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID);
@@ -173,7 +174,8 @@ public class ClientLoanNonTrancheMultipleDisbursementsIntegrationTest {
LOG.info("------------------------------- 2nd DISBURSE non-tranch multi-disbursal loan ----------"); LOG.info("------------------------------- 2nd DISBURSE non-tranch multi-disbursal loan ----------");
final Float anotherDisbursalAmount = 900.00f; final Float anotherDisbursalAmount = 900.00f;
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(submitDate, loanID, anotherDisbursalAmount.toString(), netDisbursedAmt); loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount(submitDate, loanID,
anotherDisbursalAmount.toString(), netDisbursedAmt);
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID);
@@ -188,8 +190,8 @@ public class ClientLoanNonTrancheMultipleDisbursementsIntegrationTest {
LOG.info("------------------------------- 3rd DISBURSE non-tranch multi-disbursal loan ----------"); LOG.info("------------------------------- 3rd DISBURSE non-tranch multi-disbursal loan ----------");
final Float thirdDisbursalAmount = 500.00f; final Float thirdDisbursalAmount = 500.00f;
String thirdDisbursalDate = "03 February 2021"; String thirdDisbursalDate = "03 February 2021";
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(thirdDisbursalDate, loanID, thirdDisbursalAmount.toString(), loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount(thirdDisbursalDate, loanID,
netDisbursedAmt); thirdDisbursalAmount.toString(), netDisbursedAmt);
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID); loanSchedule = this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec, this.responseSpec, loanID);
@@ -77,7 +77,7 @@ public class ConcurrencyIntegrationTest {
final Integer loanID = applyForLoanApplication(clientID, loanProductID, "12,000.00"); final Integer loanID = applyForLoanApplication(clientID, loanProductID, "12,000.00");
this.loanTransactionHelper.approveLoan("20 September 2011", loanID); this.loanTransactionHelper.approveLoan("20 September 2011", loanID);
String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID); String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID);
this.loanTransactionHelper.disburseLoan("20 September 2011", loanID, "12,000.00", this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount("20 September 2011", loanID, "12,000.00",
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
ExecutorService executor = Executors.newFixedThreadPool(MYTHREADS); ExecutorService executor = Executors.newFixedThreadPool(MYTHREADS);
Calendar date = Calendar.getInstance(); Calendar date = Calendar.getInstance();
@@ -159,7 +159,7 @@ public class DisbursalAndRepaymentScheduleTest {
// Test for loan account approved can be disbursed // Test for loan account approved can be disbursed
String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, this.loanId); String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, this.loanId);
this.loanTransactionHelper.disburseLoan(disbursalDate, this.loanId, this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount(disbursalDate, this.loanId,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, this.loanId); loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, this.loanId);
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
@@ -317,7 +317,7 @@ public class DisbursalAndRepaymentScheduleTest {
// Test for loan account approved can be disbursed // Test for loan account approved can be disbursed
String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, this.loanId); String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, this.loanId);
this.loanTransactionHelper.disburseLoan(disbursalDate, this.loanId, this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount(disbursalDate, this.loanId,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, this.loanId); loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, this.loanId);
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
@@ -138,7 +138,7 @@ public class GroupTest {
this.loanTransactionHelper.approveLoan("20 September 2014", loanId); this.loanTransactionHelper.approveLoan("20 September 2014", loanId);
String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanId); String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanId);
this.loanTransactionHelper.disburseLoan("20 September 2014", loanId, this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount("20 September 2014", loanId,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
final HashMap assignStaffAndInheritStaffForClientAccounts = (HashMap) GroupHelper.assignStaffInheritStaffForClientAccounts( final HashMap assignStaffAndInheritStaffForClientAccounts = (HashMap) GroupHelper.assignStaffInheritStaffForClientAccounts(
@@ -108,7 +108,8 @@ public class LoanApplicationUndoLastTrancheTest {
// DISBURSE A LOAN // DISBURSE A LOAN
String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID); String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID);
this.loanTransactionHelper.disburseLoan(disbursalDate, loanID, JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount(disbursalDate, loanID,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
// VALIDATE THE LOAN IS ACTIVE STATUS // VALIDATE THE LOAN IS ACTIVE STATUS
@@ -121,7 +122,8 @@ public class LoanApplicationUndoLastTrancheTest {
LOG.info("-------------Make repayment 3-----------"); LOG.info("-------------Make repayment 3-----------");
this.loanTransactionHelper.makeRepayment("01 June 2014", Float.valueOf("204"), loanID); this.loanTransactionHelper.makeRepayment("01 June 2014", Float.valueOf("204"), loanID);
// DISBURSE A SECOND TRANCHE // DISBURSE A SECOND TRANCHE
this.loanTransactionHelper.disburseLoan("23 June 2014", loanID, JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount("23 June 2014", loanID,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
// UNDO LAST TRANCHE // UNDO LAST TRANCHE
Float disbursedAmount = this.loanTransactionHelper.undoLastDisbursal(loanID); Float disbursedAmount = this.loanTransactionHelper.undoLastDisbursal(loanID);
validateDisbursedAmount(disbursedAmount); validateDisbursedAmount(disbursedAmount);
@@ -96,7 +96,7 @@ public class LoanDisbursalDateValidationTest {
// DISBURSE A LOAN // DISBURSE A LOAN
String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID); String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID);
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
List<HashMap> disbursalError = (List<HashMap>) this.loanTransactionHelper.disburseLoan(disbursalDate, loanID, List<HashMap> disbursalError = (List<HashMap>) this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount(disbursalDate, loanID,
this.responseForbiddenError, JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); this.responseForbiddenError, JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
Assertions.assertEquals(disbursalError.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE), Assertions.assertEquals(disbursalError.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE),
@@ -218,7 +218,7 @@ public class LoanRescheduleOnDecliningBalanceLoanTest {
if (this.loanId != null) { if (this.loanId != null) {
String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, this.loanId); String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, this.loanId);
this.loanTransactionHelper.disburseLoan(disburseDate, this.loanId, this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount(disburseDate, this.loanId,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LOG.info("Successfully disbursed loan (ID: {} )", this.loanId); LOG.info("Successfully disbursed loan (ID: {} )", this.loanId);
} }
@@ -169,7 +169,7 @@ public class LoanRescheduleRequestTest {
if (this.loanId != null) { if (this.loanId != null) {
String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, this.loanId); String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, this.loanId);
this.loanTransactionHelper.disburseLoan(this.dateString, this.loanId, this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount(this.dateString, this.loanId,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LOG.info("Successfully disbursed loan (ID: {} )", this.loanId); LOG.info("Successfully disbursed loan (ID: {} )", this.loanId);
} }
@@ -126,7 +126,7 @@ public class LoanRescheduleWithAdvancePaymentTest {
if (this.loanId != null) { if (this.loanId != null) {
String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, this.loanId); String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, this.loanId);
this.loanTransactionHelper.disburseLoan(disburseDate, this.loanId, this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount(disburseDate, this.loanId,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LOG.info("Successfully disbursed loan (ID: {} )", this.loanId); LOG.info("Successfully disbursed loan (ID: {} )", this.loanId);
} }
@@ -146,7 +146,8 @@ public class LoanReschedulingWithinCenterTest {
// Test for loan account approved can be disbursed // Test for loan account approved can be disbursed
String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanId); String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanId);
this.loanTransactionHelper.disburseLoan(disbursalDate, loanId, JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount(disbursalDate, loanId,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanId); loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanId);
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
@@ -299,7 +300,8 @@ public class LoanReschedulingWithinCenterTest {
// DISBURSE A FIRST TRANCHE // DISBURSE A FIRST TRANCHE
String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID); String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID);
this.loanTransactionHelper.disburseLoan(disbursementDate, loanID, JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount(disbursementDate, loanID,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID); loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
LOG.info("---------------------------------CHANGING GROUP MEETING DATE ------------------------------------------"); LOG.info("---------------------------------CHANGING GROUP MEETING DATE ------------------------------------------");
@@ -99,7 +99,7 @@ public class LoanTransactionAuditingIntegrationTest {
LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------"); LOG.info("-----------------------------------APPROVE LOAN-----------------------------------------");
loanStatusHashMap = this.loanTransactionHelper.approveLoan("11 July 2022", loanID); loanStatusHashMap = this.loanTransactionHelper.approveLoan("11 July 2022", loanID);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan("11 July 2022", loanID, "10000"); loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount("11 July 2022", loanID, "10000");
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
OffsetDateTime now = OffsetDateTime.now(ZoneId.of("Asia/Kolkata")); OffsetDateTime now = OffsetDateTime.now(ZoneId.of("Asia/Kolkata"));
@@ -106,7 +106,7 @@ public class LoanWithWaiveInterestAndWriteOffIntegrationTest {
// DISBURSE // DISBURSE
String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID); String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(DISBURSEMENT_DATE, loanID, loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount(DISBURSEMENT_DATE, loanID,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LOG.info("DISBURSE {}", loanStatusHashMap.toString()); LOG.info("DISBURSE {}", loanStatusHashMap.toString());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
@@ -120,7 +120,7 @@ public class LoanWithWaiveInterestAndWriteOffIntegrationTest {
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
// DIBURSE AGAIN // DIBURSE AGAIN
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(DISBURSEMENT_DATE, loanID, loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount(DISBURSEMENT_DATE, loanID,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LOG.info("DISBURSE {}", loanStatusHashMap); LOG.info("DISBURSE {}", loanStatusHashMap);
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
@@ -168,7 +168,7 @@ public class LoanWithWaiveInterestAndWriteOffIntegrationTest {
// DISBURSE // DISBURSE
String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID); String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(DISBURSEMENT_DATE, loanID, loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount(DISBURSEMENT_DATE, loanID,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LOG.info("DISBURSE {}", loanStatusHashMap); LOG.info("DISBURSE {}", loanStatusHashMap);
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
@@ -117,7 +117,7 @@ public class MinimumDaysBetweenDisbursalAndFirstRepaymentTest {
// Test for loan account approved can be disbursed // Test for loan account approved can be disbursed
String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, this.loanId); String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, this.loanId);
this.loanTransactionHelper.disburseLoan(disbursalDate, this.loanId, this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount(disbursalDate, this.loanId,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, this.loanId); loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, this.loanId);
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
@@ -275,7 +275,8 @@ public class NotesTest {
this.loanTransactionHelper.approveLoan("02 April 2012", loanId); this.loanTransactionHelper.approveLoan("02 April 2012", loanId);
String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanId); String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanId);
this.loanTransactionHelper.disburseLoan("02 April 2012", loanId, JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount("02 April 2012", loanId,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
HashMap repayment = this.loanTransactionHelper.makeRepayment("02 April 2012", 100.0f, loanId); HashMap repayment = this.loanTransactionHelper.makeRepayment("02 April 2012", 100.0f, loanId);
Integer loanTransactionId = (Integer) repayment.get("resourceId"); Integer loanTransactionId = (Integer) repayment.get("resourceId");
Assertions.assertNotNull(loanTransactionId); Assertions.assertNotNull(loanTransactionId);
@@ -299,7 +300,8 @@ public class NotesTest {
this.loanTransactionHelper.approveLoan("02 April 2012", loanId); this.loanTransactionHelper.approveLoan("02 April 2012", loanId);
String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanId); String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanId);
this.loanTransactionHelper.disburseLoan("02 April 2012", loanId, JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount("02 April 2012", loanId,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
HashMap repayment = this.loanTransactionHelper.makeRepayment("02 April 2012", 100.0f, loanId); HashMap repayment = this.loanTransactionHelper.makeRepayment("02 April 2012", 100.0f, loanId);
Integer loanTransactionId = (Integer) repayment.get("resourceId"); Integer loanTransactionId = (Integer) repayment.get("resourceId");
Assertions.assertNotNull(loanTransactionId); Assertions.assertNotNull(loanTransactionId);
@@ -332,7 +334,8 @@ public class NotesTest {
this.loanTransactionHelper.approveLoan("02 April 2012", loanId); this.loanTransactionHelper.approveLoan("02 April 2012", loanId);
String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanId); String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanId);
this.loanTransactionHelper.disburseLoan("02 April 2012", loanId, JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount("02 April 2012", loanId,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
HashMap repayment = this.loanTransactionHelper.makeRepayment("02 April 2012", 100.0f, loanId); HashMap repayment = this.loanTransactionHelper.makeRepayment("02 April 2012", 100.0f, loanId);
Integer loanTransactionId = (Integer) repayment.get("resourceId"); Integer loanTransactionId = (Integer) repayment.get("resourceId");
Assertions.assertNotNull(loanTransactionId); Assertions.assertNotNull(loanTransactionId);
@@ -249,7 +249,7 @@ public class SchedulerJobsTestResults {
Assertions.assertEquals(1, chargesPendingState.size()); Assertions.assertEquals(1, chargesPendingState.size());
String loanDetails = this.loanTransactionHelper.getLoanDetails(requestSpec, responseSpec, loanID); String loanDetails = this.loanTransactionHelper.getLoanDetails(requestSpec, responseSpec, loanID);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(AccountTransferTest.LOAN_DISBURSAL_DATE, loanID, loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount(AccountTransferTest.LOAN_DISBURSAL_DATE, loanID,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
final HashMap summaryBefore = this.savingsAccountHelper.getSavingsSummary(savingsId); final HashMap summaryBefore = this.savingsAccountHelper.getSavingsSummary(savingsId);
@@ -291,7 +291,7 @@ public class SchedulerJobsTestResults {
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
String loanDetails = this.loanTransactionHelper.getLoanDetails(requestSpec, responseSpec, loanID); String loanDetails = this.loanTransactionHelper.getLoanDetails(requestSpec, responseSpec, loanID);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(AccountTransferTest.LOAN_DISBURSAL_DATE, loanID, loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount(AccountTransferTest.LOAN_DISBURSAL_DATE, loanID,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
@@ -440,7 +440,7 @@ public class SchedulerJobsTestResults {
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
String loanDetails = loanTransactionHelper.getLoanDetails(requestSpec, responseSpec, loanID); String loanDetails = loanTransactionHelper.getLoanDetails(requestSpec, responseSpec, loanID);
loanStatusHashMap = loanTransactionHelper.disburseLoan(AccountTransferTest.LOAN_DISBURSAL_DATE, loanID, loanStatusHashMap = loanTransactionHelper.disburseLoanWithNetDisbursalAmount(AccountTransferTest.LOAN_DISBURSAL_DATE, loanID,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
@@ -570,8 +570,8 @@ public class SchedulerJobsTestResults {
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
String loanDetails = this.loanTransactionHelper.getLoanDetails(requestSpec, responseSpec, loanID); String loanDetails = this.loanTransactionHelper.getLoanDetails(requestSpec, responseSpec, loanID);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(AccountTransferTest.LOAN_APPROVAL_DATE_PLUS_ONE, loanID, loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount(AccountTransferTest.LOAN_APPROVAL_DATE_PLUS_ONE,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); loanID, JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
String JobName = "Apply penalty to overdue loans"; String JobName = "Apply penalty to overdue loans";
@@ -617,8 +617,8 @@ public class SchedulerJobsTestResults {
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
String loanDetails = this.loanTransactionHelper.getLoanDetails(requestSpec, responseSpec, loanID); String loanDetails = this.loanTransactionHelper.getLoanDetails(requestSpec, responseSpec, loanID);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(AccountTransferTest.LOAN_APPROVAL_DATE_PLUS_ONE, loanID, loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount(AccountTransferTest.LOAN_APPROVAL_DATE_PLUS_ONE,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); loanID, JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
String JobName = "Apply penalty to overdue loans"; String JobName = "Apply penalty to overdue loans";
@@ -669,8 +669,8 @@ public class SchedulerJobsTestResults {
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap); LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
String loanDetails = this.loanTransactionHelper.getLoanDetails(requestSpec, responseSpec, loanID); String loanDetails = this.loanTransactionHelper.getLoanDetails(requestSpec, responseSpec, loanID);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(AccountTransferTest.LOAN_APPROVAL_DATE_PLUS_ONE, loanID, loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount(AccountTransferTest.LOAN_APPROVAL_DATE_PLUS_ONE,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); loanID, JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
final Boolean isNPABefore = (Boolean) this.loanTransactionHelper.getLoanDetail(requestSpec, responseSpec, loanID, "isNPA"); final Boolean isNPABefore = (Boolean) this.loanTransactionHelper.getLoanDetail(requestSpec, responseSpec, loanID, "isNPA");
@@ -97,7 +97,7 @@ public class ProvisioningIntegrationTest {
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap); LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------");
String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID); String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan("20 September 2011", loanID, loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount("20 September 2011", loanID,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
Assertions.assertNotNull(loanID); Assertions.assertNotNull(loanID);
@@ -151,7 +151,7 @@ public class LoanTransactionHelper {
return response; return response;
} }
public Object getLoanDetail(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final Integer loanID, public <T> T getLoanDetail(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, final Integer loanID,
final String param) { final String param) {
final String URL = "/fineract-provider/api/v1/loans/" + loanID + "?associations=all&" + Utils.TENANT_IDENTIFIER; final String URL = "/fineract-provider/api/v1/loans/" + loanID + "?associations=all&" + Utils.TENANT_IDENTIFIER;
return Utils.performServerGet(requestSpec, responseSpec, URL, param); return Utils.performServerGet(requestSpec, responseSpec, URL, param);
@@ -232,11 +232,16 @@ public class LoanTransactionHelper {
return performLoanTransaction(createLoanOperationURL(UNDO_APPROVAL_LOAN_COMMAND, loanID), undoBodyJson); return performLoanTransaction(createLoanOperationURL(UNDO_APPROVAL_LOAN_COMMAND, loanID), undoBodyJson);
} }
public HashMap disburseLoan(final String date, final Integer loanID, final String netDisbursalAmount) { public HashMap disburseLoanWithNetDisbursalAmount(final String date, final Integer loanID, final String netDisbursalAmount) {
return performLoanTransaction(createLoanOperationURL(DISBURSE_LOAN_COMMAND, loanID), return performLoanTransaction(createLoanOperationURL(DISBURSE_LOAN_COMMAND, loanID),
getDisburseLoanAsJSON(date, null, netDisbursalAmount)); getDisburseLoanAsJSON(date, null, netDisbursalAmount));
} }
public HashMap disburseLoanWithTransactionAmount(final String date, final Integer loanID, final String transactionAmount) {
return performLoanTransaction(createLoanOperationURL(DISBURSE_LOAN_COMMAND, loanID),
getDisburseLoanAsJSON(date, transactionAmount, null));
}
public HashMap disburseLoanWithPostDatedChecks(final String date, final Integer loanId, final BigDecimal transactionAmount, public HashMap disburseLoanWithPostDatedChecks(final String date, final Integer loanId, final BigDecimal transactionAmount,
final List<HashMap> postDatedChecks) { final List<HashMap> postDatedChecks) {
return performLoanTransaction(createLoanOperationURL(DISBURSE_LOAN_COMMAND, loanId), return performLoanTransaction(createLoanOperationURL(DISBURSE_LOAN_COMMAND, loanId),
@@ -264,12 +269,13 @@ public class LoanTransactionHelper {
getDisburseLoanWithRepaymentRescheduleAsJSON(date, null, adjustRepaymentDate)); getDisburseLoanWithRepaymentRescheduleAsJSON(date, null, adjustRepaymentDate));
} }
public HashMap disburseLoan(final String date, final Integer loanID, final String disburseAmt, final String netDisbursalAmount) { public HashMap disburseLoanWithNetDisbursalAmount(final String date, final Integer loanID, final String disburseAmt,
final String netDisbursalAmount) {
return performLoanTransaction(createLoanOperationURL(DISBURSE_LOAN_COMMAND, loanID), return performLoanTransaction(createLoanOperationURL(DISBURSE_LOAN_COMMAND, loanID),
getDisburseLoanAsJSON(date, disburseAmt, netDisbursalAmount)); getDisburseLoanAsJSON(date, disburseAmt, netDisbursalAmount));
} }
public Object disburseLoan(final String date, final Integer loanID, ResponseSpecification responseValidationError, public Object disburseLoanWithNetDisbursalAmount(final String date, final Integer loanID, ResponseSpecification responseValidationError,
final String netDisbursalAmount) { final String netDisbursalAmount) {
return performLoanTransaction(createLoanOperationURL(DISBURSE_LOAN_COMMAND, loanID), return performLoanTransaction(createLoanOperationURL(DISBURSE_LOAN_COMMAND, loanID),
getDisburseLoanAsJSON(date, null, netDisbursalAmount), responseValidationError); getDisburseLoanAsJSON(date, null, netDisbursalAmount), responseValidationError);
@@ -181,7 +181,7 @@ public class GuarantorTest {
LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------");
String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID); String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(loanDisbursementDate, loanID, loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount(loanDisbursementDate, loanID,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
@@ -377,7 +377,7 @@ public class GuarantorTest {
LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------");
String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID); String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(loanDisbursementDate, loanID, loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount(loanDisbursementDate, loanID,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
@@ -483,7 +483,7 @@ public class GuarantorTest {
LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------");
String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID); String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(loanDisbursementDate, loanID, loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount(loanDisbursementDate, loanID,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
@@ -559,7 +559,7 @@ public class GuarantorTest {
LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------");
String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID); String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(loanDisbursementDate, loanID, loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount(loanDisbursementDate, loanID,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
@@ -631,7 +631,7 @@ public class GuarantorTest {
LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------"); LOG.info("-------------------------------DISBURSE LOAN-------------------------------------------");
String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID); String loanDetails = this.loanTransactionHelper.getLoanDetails(this.requestSpec, this.responseSpec, loanID);
loanStatusHashMap = this.loanTransactionHelper.disburseLoan(loanDisbursementDate, loanID, loanStatusHashMap = this.loanTransactionHelper.disburseLoanWithNetDisbursalAmount(loanDisbursementDate, loanID,
JsonPath.from(loanDetails).get("netDisbursalAmount").toString()); JsonPath.from(loanDetails).get("netDisbursalAmount").toString());
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap); LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);