use of org.mifos.domain.builders.SavingsProductBuilder in project head by mifos.
the class SavingsWithdrawalTest method accountIsAlwaysSetToActiveWhenAWithdrawalIsMade.
@Test
public void accountIsAlwaysSetToActiveWhenAWithdrawalIsMade() throws AccountException {
// setup
savingsProduct = new SavingsProductBuilder().withMaxWithdrawalAmount(new Money(TestUtils.RUPEE, "50.0")).buildForUnitTests();
savingsAccount = savingsAccountBuilder.withSavingsProduct(savingsProduct).withBalanceOf(new Money(TestUtils.RUPEE, "80.0")).buildForUnitTests();
final Money amountToWithdraw = new Money(TestUtils.RUPEE, "25.0");
// stubbing
when(accountPayment.getAmount()).thenReturn(amountToWithdraw);
// exercise test
savingsAccount.withdraw(accountPayment, payingCustomer);
// verification
assertThat(savingsAccount.getAccountState().getId(), is(AccountState.SAVINGS_ACTIVE.getValue()));
}
use of org.mifos.domain.builders.SavingsProductBuilder in project head by mifos.
the class SavingsWithdrawalTest method throwsAccountExceptionWhenWithdrawalAmountExceedsMaxWithdrawalAllowedBySavingsProduct.
@Test(expected = AccountException.class)
public void throwsAccountExceptionWhenWithdrawalAmountExceedsMaxWithdrawalAllowedBySavingsProduct() throws AccountException {
// setup
savingsProduct = new SavingsProductBuilder().withMaxWithdrawalAmount(new Money(TestUtils.RUPEE, "50.0")).buildForUnitTests();
savingsAccount = savingsAccountBuilder.withSavingsProduct(savingsProduct).withBalanceOf(new Money(TestUtils.RUPEE, "80.0")).buildForUnitTests();
final Money amountToWithdraw = new Money(TestUtils.RUPEE, "75.0");
// stubbing
when(accountPayment.getAmount()).thenReturn(amountToWithdraw);
// exercise test
savingsAccount.withdraw(accountPayment, payingCustomer);
}
use of org.mifos.domain.builders.SavingsProductBuilder in project head by mifos.
the class SavingsWithdrawalTest method savingsPerformanceWithdrawalsIsIncrementedByTotalAmountWithdrawn.
@Test
public void savingsPerformanceWithdrawalsIsIncrementedByTotalAmountWithdrawn() throws AccountException {
// setup
final Money startingBalance = new Money(TestUtils.RUPEE, "80.0");
savingsProduct = new SavingsProductBuilder().withMaxWithdrawalAmount(new Money(TestUtils.RUPEE, "50.0")).buildForUnitTests();
savingsAccount = savingsAccountBuilder.withSavingsProduct(savingsProduct).withBalanceOf(startingBalance).buildForUnitTests();
final Money amountToWithdraw = new Money(TestUtils.RUPEE, "25.0");
// stubbing
when(accountPayment.getAmount()).thenReturn(amountToWithdraw);
// exercise test
savingsAccount.withdraw(accountPayment, payingCustomer);
// verification
assertThat(savingsAccount.getSavingsPerformance().getTotalWithdrawals(), is(amountToWithdraw));
}
use of org.mifos.domain.builders.SavingsProductBuilder in project head by mifos.
the class SavingsAccountSchedulesIntegrationTest method shouldGenerateSavingsAccountSchedulesForGroupOnlyWhenUsingCompleteGroupSetting.
@Test
public void shouldGenerateSavingsAccountSchedulesForGroupOnlyWhenUsingCompleteGroupSetting() throws Exception {
createCenterGroupClientHierarchy(aWeeklyMeeting);
SavingsOfferingBO savingsProduct = new SavingsProductBuilder().mandatory().withMandatoryAmount("33.0").appliesToGroupsOnly().trackedOnCompleteGroup().buildForIntegrationTests();
SavingsBO savingsAccount = new SavingsAccountBuilder().active().withActivationDate(mondayTwoWeeksAgo()).withSavingsProduct(savingsProduct).withCustomer(group).withCreatedBy(IntegrationTestObjectMother.testUser()).build();
IntegrationTestObjectMother.saveSavingsProductAndAssociatedSavingsAccounts(savingsProduct, savingsAccount);
List<AccountActionDateEntity> savingSchedules = savingsAccount.getAccountActionDatesSortedByInstallmentId();
for (AccountActionDateEntity savingSchedule : savingSchedules) {
assertThat("saving schedule should be generated for group only and not any of its clients", savingSchedule.getCustomer().getCustomerId(), is(group.getCustomerId()));
}
}
use of org.mifos.domain.builders.SavingsProductBuilder in project head by mifos.
the class SavingsAccountSchedulesIntegrationTest method shouldGenerateSavingsAccountSchedulesForClient.
@Test
public void shouldGenerateSavingsAccountSchedulesForClient() throws Exception {
createCenterGroupClientHierarchy(aWeeklyMeeting);
SavingsOfferingBO savingsProduct = new SavingsProductBuilder().mandatory().withMandatoryAmount("33.0").appliesToClientsOnly().buildForIntegrationTests();
SavingsBO savingsAccount = new SavingsAccountBuilder().active().withActivationDate(mondayTwoWeeksAgo()).withSavingsProduct(savingsProduct).withCustomer(client).withCreatedBy(IntegrationTestObjectMother.testUser()).build();
IntegrationTestObjectMother.saveSavingsProductAndAssociatedSavingsAccounts(savingsProduct, savingsAccount);
List<AccountActionDateEntity> savingSchedules = savingsAccount.getAccountActionDatesSortedByInstallmentId();
for (AccountActionDateEntity savingSchedule : savingSchedules) {
assertThat("saving schedule should be generated for individual client savings account", savingSchedule.getCustomer().getCustomerId(), is(client.getCustomerId()));
}
}
Aggregations