add provider project source.

This commit is contained in:
Keith Woodlock
2012-04-20 11:50:23 +01:00
parent ceb30e8012
commit c1e5474f1e
252 changed files with 20100 additions and 0 deletions
@@ -0,0 +1,376 @@
package org.mifosng.platform.loan.domain;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.junit.Assert.assertThat;
import java.util.ArrayList;
import java.util.List;
import org.joda.time.LocalDate;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mifosng.data.CurrencyData;
import org.mifosng.data.DerivedLoanData;
import org.mifosng.data.LoanRepaymentData;
import org.mifosng.data.LoanRepaymentPeriodData;
import org.mifosng.data.LoanRepaymentScheduleData;
import org.mifosng.data.MoneyData;
import org.mifosng.platform.currency.domain.MonetaryCurrency;
import org.mifosng.platform.currency.domain.Money;
import org.mockito.runners.MockitoJUnitRunner;
@RunWith(MockitoJUnitRunner.class)
public class DerivedLoanDataProcessorTest {
private DerivedLoanDataProcessor loanDataProcessor = new DerivedLoanDataProcessor();
private MonetaryCurrency cfaCurrency = new MonetaryCurrencyBuilder().withCode("XOF").withDigitsAfterDecimal(0).build();
private Money arrearsTolerance = new MoneyBuilder().with(cfaCurrency).with("0.0").build();
@Test
public void shouldDeriveLoanRepaymentScheduleWithSingleRepaymentPeriodAndRepaymentInFull() {
List<LoanRepaymentScheduleInstallment> repaymentScheduleWithSinglePeriod = new ArrayList<LoanRepaymentScheduleInstallment>();
LoanRepaymentScheduleInstallment firstRepaymentPeriod = new LoanRepaymentScheduleInstallmentBuilder(cfaCurrency)
.withPrincipal("1000")
.withInterest("10")
.withDueDate(LocalDate.now())
.build();
repaymentScheduleWithSinglePeriod.add(firstRepaymentPeriod);
List<LoanTransaction> singleRepaymentInFull = new ArrayList<LoanTransaction>();
Money fullAmount = new MoneyBuilder().with(cfaCurrency).with("1010").build();
LoanTransaction fullRepayment = new LoanTransactionBuilder().with(fullAmount).build();
singleRepaymentInFull.add(fullRepayment);
// exercise test
DerivedLoanData derivedData = loanDataProcessor.process(repaymentScheduleWithSinglePeriod, singleRepaymentInFull, asCurrencyData(cfaCurrency), arrearsTolerance);
// verification
assertThat(derivedData, is(notNullValue()));
LoanRepaymentScheduleData repaymentSchedule = derivedData.getRepaymentSchedule();
assertThat(repaymentSchedule, is(notNullValue()));
List<LoanRepaymentPeriodData> periods = repaymentSchedule.getPeriods();
assertThat(periods, is(notNullValue()));
assertThat(periods.size(), is(1));
LoanRepaymentPeriodData periodData = periods.get(0);
MoneyData expectedPrincipal = moneyDataFrom(new MoneyBuilder().with(cfaCurrency).with("1000").build());
MoneyData expectedPrincipalPaid = moneyDataFrom(new MoneyBuilder().with(cfaCurrency).with("1000").build());
MoneyData expectedPrincipalOutstanding = moneyDataFrom(new MoneyBuilder().with(cfaCurrency).with("0").build());
MoneyData expectedInterest = moneyDataFrom(new MoneyBuilder().with(cfaCurrency).with("10").build());
MoneyData expectedInterestPaid = moneyDataFrom(new MoneyBuilder().with(cfaCurrency).with("10").build());
MoneyData expectedInterestOutstanding = moneyDataFrom(new MoneyBuilder().with(cfaCurrency).with("0").build());
MoneyData expectedTotal = moneyDataFrom(new MoneyBuilder().with(cfaCurrency).with("1010").build());
assertThat(periodData.getPrincipal(), is(expectedPrincipal));
assertThat(periodData.getPrincipalPaid(), is(expectedPrincipalPaid));
assertThat(periodData.getPrincipalOutstanding(), is(expectedPrincipalOutstanding));
assertThat(periodData.getInterest(), is(expectedInterest));
assertThat(periodData.getInterestPaid(), is(expectedInterestPaid));
assertThat(periodData.getInterestOutstanding(), is(expectedInterestOutstanding));
// assert repayments are ok
List<LoanRepaymentData> loanRepayments = derivedData.getLoanRepayments();
assertThat(loanRepayments, is(notNullValue()));
assertThat(loanRepayments.size(), is(1));
LoanRepaymentData firstRepayment = loanRepayments.get(0);
assertThat(firstRepayment.getPrincipal(), is(expectedPrincipalPaid));
assertThat(firstRepayment.getInterest(), is(expectedInterestPaid));
assertThat(firstRepayment.getTotal(), is(expectedTotal));
}
private CurrencyData asCurrencyData(MonetaryCurrency currency) {
return new CurrencyData(currency.getCode(), "", currency.getDigitsAfterDecimal(), "CFA", "");
}
@Test
public void shouldDeriveLoanRepaymentScheduleWithSingleRepaymentPeriodAndPartialRepayment() {
List<LoanRepaymentScheduleInstallment> repaymentScheduleWithSinglePeriod = new ArrayList<LoanRepaymentScheduleInstallment>();
LoanRepaymentScheduleInstallment firstRepaymentPeriod = new LoanRepaymentScheduleInstallmentBuilder(cfaCurrency)
.withPrincipal("1000")
.withInterest("10")
.withDueDate(LocalDate.now())
.build();
repaymentScheduleWithSinglePeriod.add(firstRepaymentPeriod);
List<LoanTransaction> singlePartialRepayment = new ArrayList<LoanTransaction>();
Money partialAmount = new MoneyBuilder().with(cfaCurrency).with("510").build();
LoanTransaction partialRepayment = new LoanTransactionBuilder().with(partialAmount).build();
singlePartialRepayment.add(partialRepayment);
// exercise test
DerivedLoanData derivedData = loanDataProcessor.process(repaymentScheduleWithSinglePeriod, singlePartialRepayment, asCurrencyData(cfaCurrency), arrearsTolerance);
// verification
assertThat(derivedData, is(notNullValue()));
LoanRepaymentScheduleData repaymentSchedule = derivedData.getRepaymentSchedule();
assertThat(repaymentSchedule, is(notNullValue()));
List<LoanRepaymentPeriodData> periods = repaymentSchedule.getPeriods();
assertThat(periods, is(notNullValue()));
assertThat(periods.size(), is(1));
LoanRepaymentPeriodData periodData = periods.get(0);
MoneyData expectedPrincipal = moneyDataFrom(new MoneyBuilder().with(cfaCurrency).with("1000").build());
MoneyData expectedPrincipalPaid = moneyDataFrom(new MoneyBuilder().with(cfaCurrency).with("500").build());
MoneyData expectedPrincipalOutstanding = moneyDataFrom(new MoneyBuilder().with(cfaCurrency).with("500").build());
MoneyData expectedInterest = moneyDataFrom(new MoneyBuilder().with(cfaCurrency).with("10").build());
MoneyData expectedInterestPaid = moneyDataFrom(new MoneyBuilder().with(cfaCurrency).with("10").build());
MoneyData expectedInterestOutstanding = moneyDataFrom(new MoneyBuilder().with(cfaCurrency).with("0").build());
MoneyData expectedTotal = moneyDataFrom(new MoneyBuilder().with(cfaCurrency).with("510").build());
assertThat(periodData.getPrincipal(), is(expectedPrincipal));
assertThat(periodData.getPrincipalPaid(), is(expectedPrincipalPaid));
assertThat(periodData.getPrincipalOutstanding(), is(expectedPrincipalOutstanding));
assertThat(periodData.getInterest(), is(expectedInterest));
assertThat(periodData.getInterestPaid(), is(expectedInterestPaid));
assertThat(periodData.getInterestOutstanding(), is(expectedInterestOutstanding));
// assert repayments are ok
List<LoanRepaymentData> loanRepayments = derivedData.getLoanRepayments();
assertThat(loanRepayments, is(notNullValue()));
assertThat(loanRepayments.size(), is(1));
LoanRepaymentData firstRepayment = loanRepayments.get(0);
assertThat(firstRepayment.getPrincipal(), is(expectedPrincipalPaid));
assertThat(firstRepayment.getInterest(), is(expectedInterestPaid));
assertThat(firstRepayment.getTotal(), is(expectedTotal));
}
@Test
public void shouldDeriveLoanRepaymentScheduleWithSingleRepaymentPeriodAndPartialRepaymentLessThanInterestComponent() {
List<LoanRepaymentScheduleInstallment> repaymentScheduleWithSinglePeriod = new ArrayList<LoanRepaymentScheduleInstallment>();
LoanRepaymentScheduleInstallment firstRepaymentPeriod = new LoanRepaymentScheduleInstallmentBuilder(cfaCurrency)
.withPrincipal("1000")
.withInterest("10")
.withDueDate(LocalDate.now())
.build();
repaymentScheduleWithSinglePeriod.add(firstRepaymentPeriod);
List<LoanTransaction> singlePartialRepayment = new ArrayList<LoanTransaction>();
Money partialAmount = new MoneyBuilder().with(cfaCurrency).with("5").build();
LoanTransaction partialRepayment = new LoanTransactionBuilder().with(partialAmount).build();
singlePartialRepayment.add(partialRepayment);
// exercise test
DerivedLoanData derivedData = loanDataProcessor.process(repaymentScheduleWithSinglePeriod, singlePartialRepayment, asCurrencyData(cfaCurrency), arrearsTolerance);
// verification
assertThat(derivedData, is(notNullValue()));
LoanRepaymentScheduleData repaymentSchedule = derivedData.getRepaymentSchedule();
assertThat(repaymentSchedule, is(notNullValue()));
List<LoanRepaymentPeriodData> periods = repaymentSchedule.getPeriods();
assertThat(periods, is(notNullValue()));
assertThat(periods.size(), is(1));
LoanRepaymentPeriodData periodData = periods.get(0);
MoneyData expectedPrincipal = moneyDataFrom(new MoneyBuilder().with(cfaCurrency).with("1000").build());
MoneyData expectedPrincipalPaid = moneyDataFrom(new MoneyBuilder().with(cfaCurrency).with("0").build());
MoneyData expectedPrincipalOutstanding = moneyDataFrom(new MoneyBuilder().with(cfaCurrency).with("1000").build());
MoneyData expectedInterest = moneyDataFrom(new MoneyBuilder().with(cfaCurrency).with("10").build());
MoneyData expectedInterestPaid = moneyDataFrom(new MoneyBuilder().with(cfaCurrency).with("5").build());
MoneyData expectedInterestOutstanding = moneyDataFrom(new MoneyBuilder().with(cfaCurrency).with("5").build());
MoneyData expectedTotal = moneyDataFrom(new MoneyBuilder().with(cfaCurrency).with("5").build());
assertThat(periodData.getPrincipal(), is(expectedPrincipal));
assertThat(periodData.getPrincipalPaid(), is(expectedPrincipalPaid));
assertThat(periodData.getPrincipalOutstanding(), is(expectedPrincipalOutstanding));
assertThat(periodData.getInterest(), is(expectedInterest));
assertThat(periodData.getInterestPaid(), is(expectedInterestPaid));
assertThat(periodData.getInterestOutstanding(), is(expectedInterestOutstanding));
// assert repayments are ok
List<LoanRepaymentData> loanRepayments = derivedData.getLoanRepayments();
assertThat(loanRepayments, is(notNullValue()));
assertThat(loanRepayments.size(), is(1));
LoanRepaymentData firstRepayment = loanRepayments.get(0);
assertThat(firstRepayment.getPrincipal(), is(expectedPrincipalPaid));
assertThat(firstRepayment.getInterest(), is(expectedInterestPaid));
assertThat(firstRepayment.getTotal(), is(expectedTotal));
}
@Test
public void shouldDeriveLoanRepaymentScheduleWithSingleRepaymentPeriodAndOverPayment() {
List<LoanRepaymentScheduleInstallment> repaymentScheduleWithSinglePeriod = new ArrayList<LoanRepaymentScheduleInstallment>();
LoanRepaymentScheduleInstallment firstRepaymentPeriod = new LoanRepaymentScheduleInstallmentBuilder(cfaCurrency)
.withPrincipal("1000")
.withInterest("10")
.withDueDate(LocalDate.now())
.build();
repaymentScheduleWithSinglePeriod.add(firstRepaymentPeriod);
List<LoanTransaction> singleOverRepayment = new ArrayList<LoanTransaction>();
Money partialAmount = new MoneyBuilder().with(cfaCurrency).with("1200").build();
LoanTransaction overRepayment = new LoanTransactionBuilder().with(partialAmount).build();
singleOverRepayment.add(overRepayment);
// exercise test
DerivedLoanData derivedData = loanDataProcessor.process(repaymentScheduleWithSinglePeriod, singleOverRepayment, asCurrencyData(cfaCurrency), arrearsTolerance);
// verification
assertThat(derivedData, is(notNullValue()));
LoanRepaymentScheduleData repaymentSchedule = derivedData.getRepaymentSchedule();
assertThat(repaymentSchedule, is(notNullValue()));
List<LoanRepaymentPeriodData> periods = repaymentSchedule.getPeriods();
assertThat(periods, is(notNullValue()));
assertThat(periods.size(), is(1));
LoanRepaymentPeriodData periodData = periods.get(0);
MoneyData expectedPrincipal = moneyDataFrom(new MoneyBuilder().with(cfaCurrency).with("1000").build());
MoneyData expectedPrincipalPaid = moneyDataFrom(new MoneyBuilder().with(cfaCurrency).with("1000").build());
MoneyData expectedPrincipalOutstanding = moneyDataFrom(new MoneyBuilder().with(cfaCurrency).with("0").build());
MoneyData expectedInterest = moneyDataFrom(new MoneyBuilder().with(cfaCurrency).with("10").build());
MoneyData expectedInterestPaid = moneyDataFrom(new MoneyBuilder().with(cfaCurrency).with("10").build());
MoneyData expectedInterestOutstanding = moneyDataFrom(new MoneyBuilder().with(cfaCurrency).with("0").build());
MoneyData expectedTotal = moneyDataFrom(new MoneyBuilder().with(cfaCurrency).with("1010").build());
MoneyData expectedOverpayment = moneyDataFrom(new MoneyBuilder().with(cfaCurrency).with("190").build());
assertThat(periodData.getPrincipal(), is(expectedPrincipal));
assertThat(periodData.getPrincipalPaid(), is(expectedPrincipalPaid));
assertThat(periodData.getPrincipalOutstanding(), is(expectedPrincipalOutstanding));
assertThat(periodData.getInterest(), is(expectedInterest));
assertThat(periodData.getInterestPaid(), is(expectedInterestPaid));
assertThat(periodData.getInterestOutstanding(), is(expectedInterestOutstanding));
// assert repayments are ok
List<LoanRepaymentData> loanRepayments = derivedData.getLoanRepayments();
assertThat(loanRepayments, is(notNullValue()));
assertThat(loanRepayments.size(), is(1));
LoanRepaymentData firstRepayment = loanRepayments.get(0);
assertThat(firstRepayment.getPrincipal(), is(expectedPrincipalPaid));
assertThat(firstRepayment.getInterest(), is(expectedInterestPaid));
assertThat(firstRepayment.getTotal(), is(expectedTotal));
assertThat(firstRepayment.getOverpaid(), is(expectedOverpayment));
}
@Test
public void shouldDeriveLoanRepaymentScheduleWithTwoRepaymentPeriodAndOneSinglePayment() {
List<LoanRepaymentScheduleInstallment> repaymentScheduleWithSinglePeriod = new ArrayList<LoanRepaymentScheduleInstallment>();
LoanRepaymentScheduleInstallment firstRepaymentPeriod = new LoanRepaymentScheduleInstallmentBuilder(cfaCurrency)
.withPrincipal("1000")
.withInterest("10")
.withDueDate(LocalDate.now())
.build();
LoanRepaymentScheduleInstallment secondRepaymentPeriod = new LoanRepaymentScheduleInstallmentBuilder(cfaCurrency)
.withPrincipal("1000")
.withInterest("10")
.withDueDate(LocalDate.now().plusWeeks(1))
.build();
repaymentScheduleWithSinglePeriod.add(firstRepaymentPeriod);
repaymentScheduleWithSinglePeriod.add(secondRepaymentPeriod);
List<LoanTransaction> singleRepayment = new ArrayList<LoanTransaction>();
Money partialAmount = new MoneyBuilder().with(cfaCurrency).with("1200").build();
LoanTransaction overRepaymentForFirstPeriod = new LoanTransactionBuilder().with(partialAmount).build();
singleRepayment.add(overRepaymentForFirstPeriod);
// exercise test
DerivedLoanData derivedData = loanDataProcessor.process(repaymentScheduleWithSinglePeriod, singleRepayment, asCurrencyData(cfaCurrency), arrearsTolerance);
// verification
assertThat(derivedData, is(notNullValue()));
LoanRepaymentScheduleData repaymentSchedule = derivedData.getRepaymentSchedule();
assertThat(repaymentSchedule, is(notNullValue()));
List<LoanRepaymentPeriodData> periods = repaymentSchedule.getPeriods();
assertThat(periods, is(notNullValue()));
assertThat(periods.size(), is(2));
LoanRepaymentPeriodData firstPeriod = periods.get(0);
MoneyData expectedPrincipal = moneyDataFrom(new MoneyBuilder().with(cfaCurrency).with("1000").build());
MoneyData expectedPrincipalPaid = moneyDataFrom(new MoneyBuilder().with(cfaCurrency).with("1000").build());
MoneyData expectedPrincipalOutstanding = moneyDataFrom(new MoneyBuilder().with(cfaCurrency).with("0").build());
MoneyData expectedInterest = moneyDataFrom(new MoneyBuilder().with(cfaCurrency).with("10").build());
MoneyData expectedInterestPaid = moneyDataFrom(new MoneyBuilder().with(cfaCurrency).with("10").build());
MoneyData expectedInterestOutstanding = moneyDataFrom(new MoneyBuilder().with(cfaCurrency).with("0").build());
assertThat(firstPeriod.getPrincipal(), is(expectedPrincipal));
assertThat(firstPeriod.getPrincipalPaid(), is(expectedPrincipalPaid));
assertThat(firstPeriod.getPrincipalOutstanding(), is(expectedPrincipalOutstanding));
assertThat(firstPeriod.getInterest(), is(expectedInterest));
assertThat(firstPeriod.getInterestPaid(), is(expectedInterestPaid));
assertThat(firstPeriod.getInterestOutstanding(), is(expectedInterestOutstanding));
LoanRepaymentPeriodData secondPeriod = periods.get(1);
expectedPrincipal = moneyDataFrom(new MoneyBuilder().with(cfaCurrency).with("1000").build());
expectedPrincipalPaid = moneyDataFrom(new MoneyBuilder().with(cfaCurrency).with("180").build());
expectedPrincipalOutstanding = moneyDataFrom(new MoneyBuilder().with(cfaCurrency).with("820").build());
expectedInterest = moneyDataFrom(new MoneyBuilder().with(cfaCurrency).with("10").build());
expectedInterestPaid = moneyDataFrom(new MoneyBuilder().with(cfaCurrency).with("10").build());
expectedInterestOutstanding = moneyDataFrom(new MoneyBuilder().with(cfaCurrency).with("0").build());
assertThat(secondPeriod.getPrincipal(), is(expectedPrincipal));
assertThat(secondPeriod.getPrincipalPaid(), is(expectedPrincipalPaid));
assertThat(secondPeriod.getPrincipalOutstanding(), is(expectedPrincipalOutstanding));
assertThat(secondPeriod.getInterest(), is(expectedInterest));
assertThat(secondPeriod.getInterestPaid(), is(expectedInterestPaid));
assertThat(secondPeriod.getInterestOutstanding(), is(expectedInterestOutstanding));
// assert repayments are ok
List<LoanRepaymentData> loanRepayments = derivedData.getLoanRepayments();
assertThat(loanRepayments, is(notNullValue()));
assertThat(loanRepayments.size(), is(1));
LoanRepaymentData firstRepayment = loanRepayments.get(0);
assertThat(firstRepayment.getPrincipal(), is(moneyDataFrom(new MoneyBuilder().with(cfaCurrency).with("1180").build())));
assertThat(firstRepayment.getInterest(), is(moneyDataFrom(new MoneyBuilder().with(cfaCurrency).with("20").build())));
assertThat(firstRepayment.getTotal(), is(moneyDataFrom(new MoneyBuilder().with(cfaCurrency).with("1200").build())));
}
private MoneyData moneyDataFrom(Money money) {
CurrencyData currency = new CurrencyData(money.getCurrencyCode(), "", money.getCurrencyDigitsAfterDecimal(), "CFA", "");
return MoneyData.of(currency, money.getAmount());
}
}
@@ -0,0 +1,41 @@
package org.mifosng.platform.loan.domain;
import org.joda.time.LocalDate;
import org.mifosng.platform.currency.domain.MonetaryCurrency;
import org.mifosng.platform.currency.domain.Money;
public class LoanRepaymentScheduleInstallmentBuilder {
private Loan loan = null;
private Integer installmentNumber = Integer.valueOf(1);
private LocalDate from = LocalDate.now();
private LocalDate dueDate = LocalDate.now();
private MonetaryCurrency currencyDetail = new MonetaryCurrencyBuilder().build();
private Money principal = new MoneyBuilder().build();
private Money interest = new MoneyBuilder().build();
public LoanRepaymentScheduleInstallmentBuilder(MonetaryCurrency currencyDetail) {
this.currencyDetail = currencyDetail;
this.principal = new MoneyBuilder().with(currencyDetail).build();
this.interest = new MoneyBuilder().with(currencyDetail).build();
}
public LoanRepaymentScheduleInstallment build() {
return new LoanRepaymentScheduleInstallment(loan, installmentNumber, from, dueDate, principal.getAmount(), interest.getAmount());
}
public LoanRepaymentScheduleInstallmentBuilder withPrincipal(String withPrincipal) {
this.principal = new MoneyBuilder().with(currencyDetail).with(withPrincipal).build();
return this;
}
public LoanRepaymentScheduleInstallmentBuilder withInterest(String withInterest) {
this.interest = new MoneyBuilder().with(currencyDetail).with(withInterest).build();
return this;
}
public LoanRepaymentScheduleInstallmentBuilder withDueDate(LocalDate withDueDate) {
this.dueDate = withDueDate;
return this;
}
}
@@ -0,0 +1,21 @@
package org.mifosng.platform.loan.domain;
import org.joda.time.LocalDate;
import org.mifosng.platform.currency.domain.Money;
public class LoanTransactionBuilder {
private Money amount = new MoneyBuilder().build();
private LocalDate paymentDate = LocalDate.now();
public LoanTransaction build() {
return LoanTransaction.repayment(amount, paymentDate);
}
public LoanTransactionBuilder with(Money newAmount) {
this.amount = newAmount;
return this;
}
}
@@ -0,0 +1,23 @@
package org.mifosng.platform.loan.domain;
import org.mifosng.platform.currency.domain.MonetaryCurrency;
public class MonetaryCurrencyBuilder {
private String code = "XOF";
private int digitsAfterDecimal = 0;
public MonetaryCurrency build() {
return new MonetaryCurrency(code, digitsAfterDecimal);
}
public MonetaryCurrencyBuilder withCode(String withCode) {
this.code = withCode;
return this;
}
public MonetaryCurrencyBuilder withDigitsAfterDecimal(int withDigitsAfterDecimal) {
this.digitsAfterDecimal = withDigitsAfterDecimal;
return this;
}
}
@@ -0,0 +1,26 @@
package org.mifosng.platform.loan.domain;
import java.math.BigDecimal;
import org.mifosng.platform.currency.domain.MonetaryCurrency;
import org.mifosng.platform.currency.domain.Money;
public class MoneyBuilder {
private MonetaryCurrency currencyDetail = new MonetaryCurrencyBuilder().build();
private BigDecimal newAmount = BigDecimal.ZERO;
public Money build() {
return Money.of(currencyDetail, newAmount);
}
public MoneyBuilder with(MonetaryCurrency withDetail) {
this.currencyDetail = withDetail;
return this;
}
public MoneyBuilder with(String withAmount) {
this.newAmount = BigDecimal.valueOf(Double.valueOf(withAmount));
return this;
}
}
@@ -0,0 +1,27 @@
package org.mifosng.platform.loanschedule.domain;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.runners.MockitoJUnitRunner;
@RunWith(MockitoJUnitRunner.class)
public class PmtTest {
@Test
public void shouldCalculatePmt() {
double interestRateFraction = Double.valueOf("0.0175");
double numberOfPayments = Double.valueOf("12");
double principal = Double.valueOf("-144300");
double futureValue = Double.valueOf("0");
boolean type = false;
double payment = DecliningBalanceEqualInstallmentsLoanScheduleGenerator.pmt(interestRateFraction, numberOfPayments, principal, futureValue, type);
assertThat(payment, is(Double.valueOf("13436.317553939027")));
}
}
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<Context>
<Resource type="javax.sql.DataSource"
name="jdbc/mifosng"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/mifosngprovider"
username="root"
password="mysql"
validationQuery="select 1"
maxActive="10"
maxIdle="4"
/>
<Resource type="javax.sql.DataSource"
name="jdbc/SourceDB"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/mifos_test"
username="root"
password="mysql"
validationQuery="select 1"
maxActive="10"
maxIdle="4"
/>
<Resource type="javax.sql.DataSource"
name="jdbc/DestinationDB"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/mifos_test_dwh"
username="root"
password="mysql"
validationQuery="select 1"
maxActive="10"
maxIdle="4"
/>
</Context>