FINERACT-1785: Specified due date charges/fees cannot be applied on disbursement date
This commit is contained in:
committed by
Arnold Gálovics
parent
ab51b2a4cc
commit
dafd4c3436
+12
-4
@@ -45,14 +45,14 @@ public class LoanRepaymentScheduleProcessingWrapper {
|
|||||||
final Money feeChargesDueForRepaymentPeriod = cumulativeFeeChargesDueWithin(startDate, period.getDueDate(), loanCharges,
|
final Money feeChargesDueForRepaymentPeriod = cumulativeFeeChargesDueWithin(startDate, period.getDueDate(), loanCharges,
|
||||||
currency, period, totalPrincipal, totalInterest, !period.isRecalculatedInterestComponent());
|
currency, period, totalPrincipal, totalInterest, !period.isRecalculatedInterestComponent());
|
||||||
final Money feeChargesWaivedForRepaymentPeriod = cumulativeFeeChargesWaivedWithin(startDate, period.getDueDate(), loanCharges,
|
final Money feeChargesWaivedForRepaymentPeriod = cumulativeFeeChargesWaivedWithin(startDate, period.getDueDate(), loanCharges,
|
||||||
currency, !period.isRecalculatedInterestComponent());
|
currency, !period.isRecalculatedInterestComponent(), period.isFirstPeriod());
|
||||||
final Money feeChargesWrittenOffForRepaymentPeriod = cumulativeFeeChargesWrittenOffWithin(startDate, period.getDueDate(),
|
final Money feeChargesWrittenOffForRepaymentPeriod = cumulativeFeeChargesWrittenOffWithin(startDate, period.getDueDate(),
|
||||||
loanCharges, currency, !period.isRecalculatedInterestComponent());
|
loanCharges, currency, !period.isRecalculatedInterestComponent());
|
||||||
|
|
||||||
final Money penaltyChargesDueForRepaymentPeriod = cumulativePenaltyChargesDueWithin(startDate, period.getDueDate(), loanCharges,
|
final Money penaltyChargesDueForRepaymentPeriod = cumulativePenaltyChargesDueWithin(startDate, period.getDueDate(), loanCharges,
|
||||||
currency, period, totalPrincipal, totalInterest, !period.isRecalculatedInterestComponent());
|
currency, period, totalPrincipal, totalInterest, !period.isRecalculatedInterestComponent());
|
||||||
final Money penaltyChargesWaivedForRepaymentPeriod = cumulativePenaltyChargesWaivedWithin(startDate, period.getDueDate(),
|
final Money penaltyChargesWaivedForRepaymentPeriod = cumulativePenaltyChargesWaivedWithin(startDate, period.getDueDate(),
|
||||||
loanCharges, currency, !period.isRecalculatedInterestComponent());
|
loanCharges, currency, !period.isRecalculatedInterestComponent(), period.isFirstPeriod());
|
||||||
final Money penaltyChargesWrittenOffForRepaymentPeriod = cumulativePenaltyChargesWrittenOffWithin(startDate,
|
final Money penaltyChargesWrittenOffForRepaymentPeriod = cumulativePenaltyChargesWrittenOffWithin(startDate,
|
||||||
period.getDueDate(), loanCharges, currency, !period.isRecalculatedInterestComponent());
|
period.getDueDate(), loanCharges, currency, !period.isRecalculatedInterestComponent());
|
||||||
|
|
||||||
@@ -129,7 +129,8 @@ public class LoanRepaymentScheduleProcessingWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Money cumulativeFeeChargesWaivedWithin(final LocalDate periodStart, final LocalDate periodEnd,
|
private Money cumulativeFeeChargesWaivedWithin(final LocalDate periodStart, final LocalDate periodEnd,
|
||||||
final Set<LoanCharge> loanCharges, final MonetaryCurrency currency, boolean isInstallmentChargeApplicable) {
|
final Set<LoanCharge> loanCharges, final MonetaryCurrency currency, boolean isInstallmentChargeApplicable,
|
||||||
|
boolean isFirstPeriod) {
|
||||||
|
|
||||||
Money cumulative = Money.zero(currency);
|
Money cumulative = Money.zero(currency);
|
||||||
|
|
||||||
@@ -142,6 +143,9 @@ public class LoanRepaymentScheduleProcessingWrapper {
|
|||||||
}
|
}
|
||||||
} else if (loanCharge.isDueForCollectionFromAndUpToAndIncluding(periodStart, periodEnd)) {
|
} else if (loanCharge.isDueForCollectionFromAndUpToAndIncluding(periodStart, periodEnd)) {
|
||||||
cumulative = cumulative.plus(loanCharge.getAmountWaived(currency));
|
cumulative = cumulative.plus(loanCharge.getAmountWaived(currency));
|
||||||
|
// Special case for Loan Charges (Due Date) added the same disbursement date
|
||||||
|
} else if (isFirstPeriod && periodStart.equals(loanCharge.getDueDate())) {
|
||||||
|
cumulative = cumulative.plus(loanCharge.getAmountWaived(currency));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -223,7 +227,8 @@ public class LoanRepaymentScheduleProcessingWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Money cumulativePenaltyChargesWaivedWithin(final LocalDate periodStart, final LocalDate periodEnd,
|
private Money cumulativePenaltyChargesWaivedWithin(final LocalDate periodStart, final LocalDate periodEnd,
|
||||||
final Set<LoanCharge> loanCharges, final MonetaryCurrency currency, boolean isInstallmentChargeApplicable) {
|
final Set<LoanCharge> loanCharges, final MonetaryCurrency currency, boolean isInstallmentChargeApplicable,
|
||||||
|
boolean isFirstPeriod) {
|
||||||
|
|
||||||
Money cumulative = Money.zero(currency);
|
Money cumulative = Money.zero(currency);
|
||||||
|
|
||||||
@@ -236,6 +241,9 @@ public class LoanRepaymentScheduleProcessingWrapper {
|
|||||||
}
|
}
|
||||||
} else if (loanCharge.isDueForCollectionFromAndUpToAndIncluding(periodStart, periodEnd)) {
|
} else if (loanCharge.isDueForCollectionFromAndUpToAndIncluding(periodStart, periodEnd)) {
|
||||||
cumulative = cumulative.plus(loanCharge.getAmountWaived(currency));
|
cumulative = cumulative.plus(loanCharge.getAmountWaived(currency));
|
||||||
|
// Special case for Loan Charges (Due Date) added the same disbursement date
|
||||||
|
} else if (isFirstPeriod && periodStart.equals(loanCharge.getDueDate())) {
|
||||||
|
cumulative = cumulative.plus(loanCharge.getAmountWaived(currency));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -218,10 +218,10 @@ public class LoanChargeSpecificDueDateTest {
|
|||||||
|
|
||||||
// evaluate the outstanding
|
// evaluate the outstanding
|
||||||
getLoansLoanIdResponse = loanTransactionHelper.getLoan(requestSpec, responseSpec, loanId);
|
getLoansLoanIdResponse = loanTransactionHelper.getLoan(requestSpec, responseSpec, loanId);
|
||||||
validateLoanAccount(getLoansLoanIdResponse, Double.valueOf(principalAmount), Double.valueOf("10.00"), true);
|
validateLoanAccount(getLoansLoanIdResponse, Double.valueOf(principalAmount), Double.valueOf("0.00"), true);
|
||||||
|
|
||||||
// Make a full repayment to close the Loan
|
// Make a full repayment to close the Loan
|
||||||
Float amount = Float.valueOf("1010.00");
|
Float amount = Float.valueOf("1000.00");
|
||||||
PostLoansLoanIdTransactionsResponse loanIdTransactionsResponse = loanTransactionHelper.makeLoanRepayment(operationDate, amount,
|
PostLoansLoanIdTransactionsResponse loanIdTransactionsResponse = loanTransactionHelper.makeLoanRepayment(operationDate, amount,
|
||||||
loanId);
|
loanId);
|
||||||
assertNotNull(loanIdTransactionsResponse);
|
assertNotNull(loanIdTransactionsResponse);
|
||||||
|
|||||||
Reference in New Issue
Block a user