Merge branch 'FINERACT-475' into develop

This commit is contained in:
Nazeer Hussain Shaik
2017-07-13 16:05:42 +05:30
6 changed files with 28 additions and 15 deletions
@@ -35,15 +35,17 @@ public class DisbursementData implements Comparable<DisbursementData> {
@SuppressWarnings("unused")
private final String loanChargeId;
private final BigDecimal chargeAmount;
private final BigDecimal waivedChargeAmount;
public DisbursementData(Long id, final LocalDate expectedDisbursementDate, final LocalDate actualDisbursementDate,
final BigDecimal principalDisbursed, final String loanChargeId, BigDecimal chargeAmount) {
final BigDecimal principalDisbursed, final String loanChargeId, BigDecimal chargeAmount, BigDecimal waivedChargeAmount) {
this.id = id;
this.expectedDisbursementDate = expectedDisbursementDate;
this.actualDisbursementDate = actualDisbursementDate;
this.principal = principalDisbursed;
this.loanChargeId = loanChargeId;
this.chargeAmount = chargeAmount;
this.waivedChargeAmount = waivedChargeAmount;
}
public LocalDate disbursementDate() {
@@ -83,4 +85,12 @@ public class DisbursementData implements Comparable<DisbursementData> {
return target != null && target.isAfter(fromNotInclusive) && !target.isAfter(upToAndInclusive);
}
public BigDecimal getWaivedChargeAmount() {
if(this.waivedChargeAmount == null){
return BigDecimal.ZERO;
}
return this.waivedChargeAmount;
}
}
@@ -75,6 +75,7 @@ public class RepaymentScheduleRelatedLoanData {
}
public DisbursementData disbursementData() {
return new DisbursementData(null, this.expectedDisbursementDate, this.actualDisbursementDate, this.principal, null, null);
BigDecimal waivedChargeAmount = null;
return new DisbursementData(null, this.expectedDisbursementDate, this.actualDisbursementDate, this.principal, null, null, waivedChargeAmount);
}
}
@@ -5576,9 +5576,9 @@ public class Loan extends AbstractPersistableCustom<Long> {
if (loanDisbursementDetails.actualDisbursementDate() != null) {
actualDisbursementDate = new LocalDate(loanDisbursementDetails.actualDisbursementDate());
}
BigDecimal waivedChargeAmount = null;
disbursementData.add(new DisbursementData(loanDisbursementDetails.getId(), expectedDisbursementDate, actualDisbursementDate,
loanDisbursementDetails.principal(), null, null));
loanDisbursementDetails.principal(), null, null, waivedChargeAmount));
}
return disbursementData;
@@ -119,7 +119,8 @@ public class LoanDisbursementDetails extends AbstractPersistableCustom<Long> {
if (this.actualDisbursementDate != null) {
actualDisburseDate = new LocalDate(this.actualDisbursementDate);
}
return new DisbursementData(getId(), expectedDisburseDate, actualDisburseDate, this.principal, null, null);
BigDecimal waivedChargeAmount = null;
return new DisbursementData(getId(), expectedDisburseDate, actualDisburseDate, this.principal, null, null, waivedChargeAmount);
}
public void updateActualDisbursementDate(Date actualDisbursementDate) {
@@ -515,7 +515,8 @@ public class LoanScheduleAssembler {
&& StringUtils.isNotBlank((jsonObject.get(LoanApiConstants.disbursementPrincipalParameterName).getAsString()))) {
principal = jsonObject.getAsJsonPrimitive(LoanApiConstants.disbursementPrincipalParameterName).getAsBigDecimal();
}
disbursementDatas.add(new DisbursementData(null, expectedDisbursementDate, null, principal, null, null));
BigDecimal waivedChargeAmount = null;
disbursementDatas.add(new DisbursementData(null, expectedDisbursementDate, null, principal, null, null, waivedChargeAmount));
i++;
} while (i < disbursementDataArray.size());
}
@@ -62,7 +62,6 @@ import org.apache.fineract.portfolio.calendar.data.CalendarData;
import org.apache.fineract.portfolio.calendar.domain.CalendarEntityType;
import org.apache.fineract.portfolio.calendar.service.CalendarReadPlatformService;
import org.apache.fineract.portfolio.charge.data.ChargeData;
import org.apache.fineract.portfolio.charge.domain.ChargeCalculationType;
import org.apache.fineract.portfolio.charge.domain.ChargeTimeType;
import org.apache.fineract.portfolio.charge.service.ChargeReadPlatformService;
import org.apache.fineract.portfolio.client.data.ClientData;
@@ -93,8 +92,6 @@ import org.apache.fineract.portfolio.loanaccount.data.PaidInAdvanceData;
import org.apache.fineract.portfolio.loanaccount.data.RepaymentScheduleRelatedLoanData;
import org.apache.fineract.portfolio.loanaccount.data.ScheduleGeneratorDTO;
import org.apache.fineract.portfolio.loanaccount.domain.Loan;
import org.apache.fineract.portfolio.loanaccount.domain.LoanCharge;
import org.apache.fineract.portfolio.loanaccount.domain.LoanInstallmentCharge;
import org.apache.fineract.portfolio.loanaccount.domain.LoanRepaymentScheduleInstallment;
import org.apache.fineract.portfolio.loanaccount.domain.LoanRepaymentScheduleTransactionProcessorFactory;
import org.apache.fineract.portfolio.loanaccount.domain.LoanRepositoryWrapper;
@@ -1056,7 +1053,10 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
@Override
public LoanScheduleData extractData(final ResultSet rs) throws SQLException, DataAccessException {
BigDecimal waivedChargeAmount = BigDecimal.ZERO;
for (DisbursementData disbursementDetail : disbursementData) {
waivedChargeAmount = waivedChargeAmount.add(disbursementDetail.getWaivedChargeAmount());
}
final LoanSchedulePeriodData disbursementPeriod = LoanSchedulePeriodData.disbursementOnlyPeriod(
this.disbursement.disbursementDate(), this.disbursement.amount(), this.totalFeeChargesDueAtDisbursement,
this.disbursement.isDisbursed());
@@ -1095,9 +1095,9 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
Money totalOutstanding = Money.zero(monCurrency);
// update totals with details of fees charged during disbursement
totalFeeChargesCharged = totalFeeChargesCharged.plus(disbursementPeriod.feeChargesDue());
totalRepaymentExpected = totalRepaymentExpected.plus(disbursementPeriod.feeChargesDue());
totalRepayment = totalRepayment.plus(disbursementPeriod.feeChargesPaid());
totalFeeChargesCharged = totalFeeChargesCharged.plus(disbursementPeriod.feeChargesDue().subtract(waivedChargeAmount));
totalRepaymentExpected = totalRepaymentExpected.plus(disbursementPeriod.feeChargesDue()).minus(waivedChargeAmount);
totalRepayment = totalRepayment.plus(disbursementPeriod.feeChargesPaid()).minus(waivedChargeAmount);
totalOutstanding = totalOutstanding.plus(disbursementPeriod.feeChargesDue()).minus(disbursementPeriod.feeChargesPaid());
Integer loanTermInDays = Integer.valueOf(0);
@@ -1121,7 +1121,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
disbursementChargeAmount, data.isDisbursed());
} else {
periodData = LoanSchedulePeriodData.disbursementOnlyPeriod(data.disbursementDate(), data.amount(),
disbursementChargeAmount.add(data.getChargeAmount()), data.isDisbursed());
disbursementChargeAmount.add(data.getChargeAmount()).subtract(waivedChargeAmount), data.isDisbursed());
}
if (periodData != null) {
periods.add(periodData);
@@ -1543,7 +1543,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
final BigDecimal waivedAmount = rs.getBigDecimal("waivedAmount");
if (chargeAmount != null && waivedAmount != null) chargeAmount = chargeAmount.subtract(waivedAmount);
final DisbursementData disbursementData = new DisbursementData(id, expectedDisbursementdate, actualDisbursementdate, principal,
loanChargeId, chargeAmount);
loanChargeId, chargeAmount, waivedAmount);
return disbursementData;
}