FINERACT-158 FINERACT-166 Fix

This commit is contained in:
Nazeer Hussain Shaik
2017-05-18 11:21:41 +05:30
parent 582ef5de6c
commit 0d7cf3a284
3 changed files with 24 additions and 6 deletions
@@ -3196,7 +3196,7 @@ public class Loan extends AbstractPersistableCustom<Long> {
boolean isAllChargesPaid = true; boolean isAllChargesPaid = true;
for (final LoanCharge loanCharge : this.charges) { for (final LoanCharge loanCharge : this.charges) {
if (loanCharge.isActive() && !(loanCharge.isPaid() || loanCharge.isWaived())) { if (loanCharge.isActive() && loanCharge.amount().compareTo(BigDecimal.ZERO) == 1 && !(loanCharge.isPaid() || loanCharge.isWaived())) {
isAllChargesPaid = false; isAllChargesPaid = false;
break; break;
} }
@@ -4744,6 +4744,9 @@ public class Loan extends AbstractPersistableCustom<Long> {
if (loanCharge.isInstalmentFee()) { if (loanCharge.isInstalmentFee()) {
List<LoanRepaymentScheduleInstallment> installments = getRepaymentScheduleInstallments() ; List<LoanRepaymentScheduleInstallment> installments = getRepaymentScheduleInstallments() ;
for (final LoanRepaymentScheduleInstallment installment : installments) { for (final LoanRepaymentScheduleInstallment installment : installments) {
if(installment.isRecalculatedInterestComponent()){
continue;
}
BigDecimal amount = BigDecimal.ZERO; BigDecimal amount = BigDecimal.ZERO;
if (loanCharge.getChargeCalculation().isFlat()) { if (loanCharge.getChargeCalculation().isFlat()) {
amount = loanCharge.amountOrPercentage(); amount = loanCharge.amountOrPercentage();
@@ -210,10 +210,15 @@ public abstract class AbstractLoanScheduleGenerator implements LoanScheduleGener
// this block is to generate the schedule till the specified // this block is to generate the schedule till the specified
// date(used for calculating preclosure) // date(used for calculating preclosure)
boolean isCompletePeriod = true;
if (scheduleParams.getScheduleTillDate() != null && !scheduledDueDate.isBefore(scheduleParams.getScheduleTillDate())) { if (scheduleParams.getScheduleTillDate() != null && !scheduledDueDate.isBefore(scheduleParams.getScheduleTillDate())) {
if(!scheduledDueDate.isEqual(scheduleParams.getScheduleTillDate())){
isCompletePeriod = false;
}
scheduledDueDate = scheduleParams.getScheduleTillDate(); scheduledDueDate = scheduleParams.getScheduleTillDate();
isNextRepaymentAvailable = false; isNextRepaymentAvailable = false;
} }
if (loanApplicationTerms.isInterestRecalculationEnabled()) { if (loanApplicationTerms.isInterestRecalculationEnabled()) {
populateCompoundingDatesInPeriod(scheduleParams.getPeriodStartDate(), scheduledDueDate, loanApplicationTerms, populateCompoundingDatesInPeriod(scheduleParams.getPeriodStartDate(), scheduledDueDate, loanApplicationTerms,
holidayDetailDTO, scheduleParams, loanCharges, currency); holidayDetailDTO, scheduleParams, loanCharges, currency);
@@ -313,7 +318,7 @@ public abstract class AbstractLoanScheduleGenerator implements LoanScheduleGener
scheduleParams.getPeriodStartDate(), scheduledDueDate, currentPeriodParams.getPrincipalForThisPeriod(), scheduleParams.getPeriodStartDate(), scheduledDueDate, currentPeriodParams.getPrincipalForThisPeriod(),
scheduleParams.getOutstandingBalance(), currentPeriodParams.getInterestForThisPeriod(), scheduleParams.getOutstandingBalance(), currentPeriodParams.getInterestForThisPeriod(),
currentPeriodParams.getFeeChargesForInstallment(), currentPeriodParams.getPenaltyChargesForInstallment(), currentPeriodParams.getFeeChargesForInstallment(), currentPeriodParams.getPenaltyChargesForInstallment(),
totalInstallmentDue, false); totalInstallmentDue, !isCompletePeriod);
addLoanRepaymentScheduleInstallment(scheduleParams.getInstallments(), installment); addLoanRepaymentScheduleInstallment(scheduleParams.getInstallments(), installment);
// apply loan transactions on installments to identify early/late // apply loan transactions on installments to identify early/late
@@ -531,7 +536,17 @@ public abstract class AbstractLoanScheduleGenerator implements LoanScheduleGener
final ScheduleCurrentPeriodParams currentPeriodParams, final Money lastTotalOutstandingInterestPaymentDueToGrace, final ScheduleCurrentPeriodParams currentPeriodParams, final Money lastTotalOutstandingInterestPaymentDueToGrace,
final LocalDate transactionDate, final LoanScheduleModelPeriod installment, Set<LoanCharge> loanCharges) { final LocalDate transactionDate, final LoanScheduleModelPeriod installment, Set<LoanCharge> loanCharges) {
LoanScheduleModelPeriod modifiedInstallment = installment; LoanScheduleModelPeriod modifiedInstallment = installment;
if (!scheduleParams.getOutstandingBalance().isGreaterThan(currentPeriodParams.getInterestForThisPeriod()) Money oustanding = scheduleParams.getOutstandingBalance();
PrincipalInterest tempPrincipalInterest = new PrincipalInterest(currentPeriodParams.getPrincipalForThisPeriod(),
currentPeriodParams.getInterestForThisPeriod(), null);
oustanding = oustanding.minus(cumulativeFeeChargesDueWithin(transactionDate,
scheduledDueDate, loanCharges, totalInterestChargedForFullLoanTerm.getCurrency(), tempPrincipalInterest, scheduleParams.getPrincipalToBeScheduled(),
scheduleParams.getTotalCumulativeInterest(), true));
oustanding = oustanding.minus(cumulativePenaltyChargesDueWithin(transactionDate,
scheduledDueDate, loanCharges, totalInterestChargedForFullLoanTerm.getCurrency(), tempPrincipalInterest, scheduleParams.getPrincipalToBeScheduled(),
scheduleParams.getTotalCumulativeInterest(), true));
if (!oustanding.isGreaterThan(currentPeriodParams.getInterestForThisPeriod())
&& !scheduledDueDate.equals(transactionDate)) { && !scheduledDueDate.equals(transactionDate)) {
final Collection<LoanTermVariationsData> interestRates = loanApplicationTerms.getLoanTermVariations().getInterestRateChanges(); final Collection<LoanTermVariationsData> interestRates = loanApplicationTerms.getLoanTermVariations().getInterestRateChanges();
LocalDate calculateTill = transactionDate; LocalDate calculateTill = transactionDate;
@@ -436,7 +436,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
private BigDecimal adjustPrepayInstallmentCharge(Loan loan, final LocalDate onDate) { private BigDecimal adjustPrepayInstallmentCharge(Loan loan, final LocalDate onDate) {
BigDecimal chargeAmount = BigDecimal.ZERO; BigDecimal chargeAmount = BigDecimal.ZERO;
for(LoanCharge loanCharge: loan.charges()){ /*for(LoanCharge loanCharge: loan.charges()){
if(loanCharge.isInstalmentFee() && loanCharge.getCharge().getChargeCalculation()==ChargeCalculationType.FLAT.getValue()){ if(loanCharge.isInstalmentFee() && loanCharge.getCharge().getChargeCalculation()==ChargeCalculationType.FLAT.getValue()){
for (LoanRepaymentScheduleInstallment installment : loan.getRepaymentScheduleInstallments()) { for (LoanRepaymentScheduleInstallment installment : loan.getRepaymentScheduleInstallments()) {
if(onDate.isBefore(installment.getDueDate())){ if(onDate.isBefore(installment.getDueDate())){
@@ -449,7 +449,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
} }
} }
} }
} }*/
return chargeAmount; return chargeAmount;
} }