Revert "add latest dump, add patch for updating currency symbols in reference data. add quick one liner to test daily interest calculation for declining works as per example from shiva of hugo tech."

This reverts commit 5fefc02752.
This commit is contained in:
Keith Woodlock
2012-04-28 02:16:16 +01:00
parent 5fefc02752
commit 5aaf33b094
5 changed files with 7 additions and 1072 deletions
@@ -818,8 +818,7 @@ public class ReadPlatformServiceImpl implements ReadPlatformService {
@Override
public LoanProductData retrieveLoanProduct(final Long loanProductId) {
// TODO - switch back to retrieve all allowed organisation currencies
List<CurrencyData> allowedCurrencies = retrieveAllPlatformCurrencies();
List<CurrencyData> allowedCurrencies = retrieveAllowedCurrencies();
LoanProductMapper rm = new LoanProductMapper(allowedCurrencies);
String sql = "select " + rm.loanProductSchema() + " where lp.id = ?";
@@ -959,15 +958,13 @@ public class ReadPlatformServiceImpl implements ReadPlatformService {
@Override
public List<EnumOptionReadModel> retrieveInterestFrequencyOptions() {
EnumOptionReadModel daily = new EnumOptionReadModel("Daily",
PeriodFrequencyType.DAYS.getValue().longValue());
EnumOptionReadModel perWeek = new EnumOptionReadModel("Per week",
PeriodFrequencyType.WEEKS.getValue().longValue());
EnumOptionReadModel perMonth = new EnumOptionReadModel("Per month",
PeriodFrequencyType.MONTHS.getValue().longValue());
EnumOptionReadModel perYear = new EnumOptionReadModel("Per year",
PeriodFrequencyType.YEARS.getValue().longValue());
List<EnumOptionReadModel> repaymentFrequencyOptions = Arrays.asList(daily,
List<EnumOptionReadModel> repaymentFrequencyOptions = Arrays.asList(
perWeek, perMonth, perYear);
return repaymentFrequencyOptions;
}
@@ -6,7 +6,6 @@ import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.List;
import org.joda.time.Days;
import org.joda.time.LocalDate;
import org.mifosng.data.CurrencyData;
import org.mifosng.data.LoanSchedule;
@@ -47,11 +46,6 @@ public class DecliningBalanceEqualInstallmentsLoanScheduleGenerator implements
.divide(BigDecimal.valueOf(Double.valueOf("100.0")), mc)
.multiply(BigDecimal.valueOf(loanScheduleInfo.getRepayEvery()));
BigDecimal dailyInterestRate = loanScheduleInfo.getAnnualNominalInterestRate()
.divide(BigDecimal.valueOf(Long.valueOf(365)), mc)
.divide(BigDecimal.valueOf(Double.valueOf("100.0")), mc)
.multiply(BigDecimal.valueOf(loanScheduleInfo.getRepayEvery()));
double interestRateFraction = periodicInterestRate.doubleValue();
double futureValue = 0;
@@ -78,14 +72,7 @@ public class DecliningBalanceEqualInstallmentsLoanScheduleGenerator implements
int installmentNumber = 1;
for (LocalDate scheduledDueDate : scheduledDates) {
// number of days from startDate to this scheduledDate
int daysInPeriod = Days.daysBetween(startDate.toDateMidnight().toDateTime(), scheduledDueDate.toDateMidnight().toDateTime()).getDays();
BigDecimal interestRateToApply = dailyInterestRate.multiply(BigDecimal.valueOf(Long.valueOf(daysInPeriod)));
Money interestDueBasedOnDays = outstandingBalance.multiplyRetainScale(interestRateToApply, RoundingMode.HALF_EVEN);
Money interestPerInstallment = interestDueBasedOnDays; //outstandingBalance.multiplyRetainScale(periodicInterestRate, RoundingMode.HALF_EVEN);
Money interestPerInstallment = outstandingBalance.multiplyRetainScale(periodicInterestRate, RoundingMode.HALF_EVEN);
Money principalPerInstallment = totalDuePerInstallment.minus(interestPerInstallment);
if (interestCalculationGraceOnRepaymentPeriodFraction >= Integer.valueOf(1).doubleValue()) {