Search in sources :

Example 16 with SavingsAccountBuilder

use of org.mifos.domain.builders.SavingsAccountBuilder in project head by mifos.

the class SavingsAdjustmentTest method accountBalanceIsUpdatedWhenLastDepositIsAdjusted.

@Test
public void accountBalanceIsUpdatedWhenLastDepositIsAdjusted() {
    savingsAccount = new SavingsAccountBuilder().active().withSavingsProduct(savingsProduct).withCustomer(client).withBalanceOf(TestUtils.createMoney("0")).withDepositOf("15").build();
    Money amountAdjustedTo = TestUtils.createMoney("25");
    String adjustmentNote = "testAdjustment";
    PersonnelBO updatedBy = new PersonnelBuilder().build();
    // pre verification
    assertThat(savingsAccount.getSavingsBalance(), is(TestUtils.createMoney(15)));
    // exercise test
    savingsAccount.adjustLastUserAction(amountAdjustedTo, adjustmentNote, updatedBy);
    // verification
    assertThat(savingsAccount.getSavingsBalance(), is(TestUtils.createMoney(25)));
}
Also used : PersonnelBuilder(org.mifos.domain.builders.PersonnelBuilder) Money(org.mifos.framework.util.helpers.Money) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) SavingsAccountBuilder(org.mifos.domain.builders.SavingsAccountBuilder) Test(org.junit.Test)

Example 17 with SavingsAccountBuilder

use of org.mifos.domain.builders.SavingsAccountBuilder in project head by mifos.

the class SavingsAdjustmentTest method accountBalanceIsUpdatedWhenLastWithdrawalIsAdjusted.

@Test
public void accountBalanceIsUpdatedWhenLastWithdrawalIsAdjusted() {
    savingsAccount = new SavingsAccountBuilder().active().withSavingsProduct(savingsProduct).withCustomer(client).withBalanceOf(TestUtils.createMoney("100")).withWithdrawalOf("15").build();
    Money amountAdjustedTo = TestUtils.createMoney("25");
    String adjustmentNote = "testAdjustment";
    PersonnelBO updatedBy = new PersonnelBuilder().build();
    // pre verification
    assertThat(savingsAccount.getSavingsBalance(), is(TestUtils.createMoney(85)));
    // exercise test
    savingsAccount.adjustLastUserAction(amountAdjustedTo, adjustmentNote, updatedBy);
    // verification
    assertThat(savingsAccount.getSavingsBalance(), is(TestUtils.createMoney(75)));
}
Also used : PersonnelBuilder(org.mifos.domain.builders.PersonnelBuilder) Money(org.mifos.framework.util.helpers.Money) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) SavingsAccountBuilder(org.mifos.domain.builders.SavingsAccountBuilder) Test(org.junit.Test)

Example 18 with SavingsAccountBuilder

use of org.mifos.domain.builders.SavingsAccountBuilder in project head by mifos.

the class SavingsAdjustmentTest method cannotAdjustLastTransactionThatIsNotADepositOrWithdrawal.

@Test
public void cannotAdjustLastTransactionThatIsNotADepositOrWithdrawal() {
    Money amountAdjustedTo = TestUtils.createMoney("25");
    savingsAccount = new SavingsAccountBuilder().active().withSavingsProduct(savingsProduct).withCustomer(client).build();
    // exercise test
    boolean result = savingsAccount.isAdjustPossibleOnTrxn(amountAdjustedTo, savingsAccount.getLastPmnt());
    // verification
    assertFalse(result);
}
Also used : Money(org.mifos.framework.util.helpers.Money) SavingsAccountBuilder(org.mifos.domain.builders.SavingsAccountBuilder) Test(org.junit.Test)

Example 19 with SavingsAccountBuilder

use of org.mifos.domain.builders.SavingsAccountBuilder in project head by mifos.

the class SavingsAdjustmentTest method cannotAdjustLastTransactionWhenItsAWithdrawalThatExceedsSavingsProductMaxWithdrawalAmount.

@Test
public void cannotAdjustLastTransactionWhenItsAWithdrawalThatExceedsSavingsProductMaxWithdrawalAmount() {
    savingsProduct = new SavingsProductBuilder().mandatory().withMandatoryAmount("33.0").withMaxWithdrawalAmount(TestUtils.createMoney("50")).appliesToClientsOnly().buildForUnitTests();
    savingsAccount = new SavingsAccountBuilder().active().withSavingsProduct(savingsProduct).withCustomer(client).withBalanceOf(TestUtils.createMoney("100")).withWithdrawalOf("15").build();
    Money withdrawalAdjustment = TestUtils.createMoney("60");
    // exercise test
    boolean result = savingsAccount.isAdjustPossibleOnTrxn(withdrawalAdjustment, savingsAccount.getLastPmnt());
    // verification
    assertFalse(result);
}
Also used : Money(org.mifos.framework.util.helpers.Money) SavingsProductBuilder(org.mifos.domain.builders.SavingsProductBuilder) SavingsAccountBuilder(org.mifos.domain.builders.SavingsAccountBuilder) Test(org.junit.Test)

Example 20 with SavingsAccountBuilder

use of org.mifos.domain.builders.SavingsAccountBuilder in project head by mifos.

the class SavingsAdjustmentTest method savingsPerformanceDetailsAreUpdatedWhenLastDepositIsAdjusted.

@Test
public void savingsPerformanceDetailsAreUpdatedWhenLastDepositIsAdjusted() {
    savingsAccount = new SavingsAccountBuilder().active().withSavingsProduct(savingsProduct).withCustomer(client).withBalanceOf(TestUtils.createMoney("0")).withDepositOf("15").build();
    Money amountAdjustedTo = TestUtils.createMoney("25");
    String adjustmentNote = "testAdjustment";
    PersonnelBO updatedBy = new PersonnelBuilder().build();
    // pre verification
    assertThat(savingsAccount.getSavingsPerformance().getTotalDeposits(), is(TestUtils.createMoney(15)));
    // exercise test
    savingsAccount.adjustLastUserAction(amountAdjustedTo, adjustmentNote, updatedBy);
    // verification
    assertThat(savingsAccount.getSavingsPerformance().getTotalDeposits(), is(TestUtils.createMoney(25)));
}
Also used : PersonnelBuilder(org.mifos.domain.builders.PersonnelBuilder) Money(org.mifos.framework.util.helpers.Money) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) SavingsAccountBuilder(org.mifos.domain.builders.SavingsAccountBuilder) Test(org.junit.Test)

Aggregations

SavingsAccountBuilder (org.mifos.domain.builders.SavingsAccountBuilder)45 Test (org.junit.Test)41 Money (org.mifos.framework.util.helpers.Money)21 SavingsProductBuilder (org.mifos.domain.builders.SavingsProductBuilder)19 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)18 PersonnelBuilder (org.mifos.domain.builders.PersonnelBuilder)18 DateTime (org.joda.time.DateTime)11 SavingsBO (org.mifos.accounts.savings.business.SavingsBO)11 SavingsOfferingBO (org.mifos.accounts.productdefinition.business.SavingsOfferingBO)10 LocalDate (org.joda.time.LocalDate)8 InterestCalculationPeriodResult (org.mifos.accounts.savings.interest.InterestCalculationPeriodResult)8 InterestCalculationPeriodResultBuilder (org.mifos.accounts.savings.interest.InterestCalculationPeriodResultBuilder)8 InterestPostingPeriodResult (org.mifos.accounts.savings.interest.InterestPostingPeriodResult)8 InterestPostingPeriodResultBuilder (org.mifos.accounts.savings.interest.InterestPostingPeriodResultBuilder)8 InterestScheduledEvent (org.mifos.accounts.savings.interest.schedule.InterestScheduledEvent)8 MonthlyOnLastDayOfMonthInterestScheduledEvent (org.mifos.accounts.savings.interest.schedule.internal.MonthlyOnLastDayOfMonthInterestScheduledEvent)8 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)7 ClientBuilder (org.mifos.domain.builders.ClientBuilder)7 AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)6 ArrayList (java.util.ArrayList)5