use of org.mifos.domain.builders.SavingsAccountBuilder in project head by mifos.
the class SavingsAdjustmentTest method canAdjustLastTransactionThatIsAWithdrawal.
@Test
public void canAdjustLastTransactionThatIsAWithdrawal() {
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("20");
// exercise test
boolean result = savingsAccount.isAdjustPossibleOnTrxn(withdrawalAdjustment, savingsAccount.getLastPmnt());
// verification
assertTrue(result);
}
use of org.mifos.domain.builders.SavingsAccountBuilder in project head by mifos.
the class SavingsAdjustmentTest method cannotAdjustLastTransactionOfAccountThatIsNotInActiveOrInactiveState.
@Test
public void cannotAdjustLastTransactionOfAccountThatIsNotInActiveOrInactiveState() {
Money amountAdjustedTo = TestUtils.createMoney("25");
savingsAccount = new SavingsAccountBuilder().asPendingApproval().withSavingsProduct(savingsProduct).withCustomer(client).build();
// exercise test
boolean result = savingsAccount.isAdjustPossibleOnTrxn(amountAdjustedTo, savingsAccount.getLastPmnt());
// verification
assertFalse(result);
}
use of org.mifos.domain.builders.SavingsAccountBuilder in project head by mifos.
the class SavingsAccountSchedulesIntegrationTest method shouldNotGenerateSavingsAccountSchedulesForGroupWithoutActiveClients.
@Test
public void shouldNotGenerateSavingsAccountSchedulesForGroupWithoutActiveClients() throws Exception {
createCenterAndGroupHierarchyWithNoClients(aWeeklyMeeting);
SavingsOfferingBO savingsProduct = new SavingsProductBuilder().mandatory().withMandatoryAmount("33.0").appliesToGroupsOnly().trackedPerIndividual().buildForIntegrationTests();
SavingsBO savingsAccount = new SavingsAccountBuilder().active().withActivationDate(mondayTwoWeeksAgo()).withSavingsProduct(savingsProduct).withCustomer(group).withCreatedBy(IntegrationTestObjectMother.testUser()).buildJointSavingsAccount();
IntegrationTestObjectMother.saveSavingsProductAndAssociatedSavingsAccounts(savingsProduct, savingsAccount);
List<AccountActionDateEntity> savingSchedules = savingsAccount.getAccountActionDatesSortedByInstallmentId();
assertTrue(savingSchedules.isEmpty());
}
use of org.mifos.domain.builders.SavingsAccountBuilder in project head by mifos.
the class SavingsPostInterestTest method whenPostingInterestASingleAccountTransactionIsAssociatedWithAccountPayment.
@Test
public void whenPostingInterestASingleAccountTransactionIsAssociatedWithAccountPayment() {
// setup
InterestScheduledEvent postingSchedule = new MonthlyOnLastDayOfMonthInterestScheduledEvent(1);
Money interestToBePosted = TestUtils.createMoney("100");
DateTime activationDate = new DateTime().withDate(2010, 7, 20);
DateTime nextInterestPostingDate = new DateTime().withDate(2010, 7, 31);
savingsAccount = new SavingsAccountBuilder().active().withActivationDate(activationDate).withNextInterestPostingDateOf(nextInterestPostingDate).withSavingsProduct(savingsProduct).withCustomer(client).build();
// pre verification
assertTrue(savingsAccount.getAccountPayments().isEmpty());
InterestCalculationPeriodResult calculationPeriod = new InterestCalculationPeriodResultBuilder().withCalculatedInterest("100").build();
InterestPostingPeriodResult interestPostingPeriodResult = new InterestPostingPeriodResultBuilder().from(nextInterestPostingDate.toLocalDate()).to(nextInterestPostingDate.toLocalDate()).with(calculationPeriod).build();
PersonnelBO createdBy = new PersonnelBuilder().build();
// exercise
savingsAccount.postInterest(postingSchedule, interestPostingPeriodResult, createdBy);
// verification
AccountPaymentEntity interestPostingPayment = savingsAccount.getAccountPayments().get(0);
assertFalse(interestPostingPayment.getAccountTrxns().isEmpty());
List<AccountTrxnEntity> accountTransactions = new ArrayList<AccountTrxnEntity>(interestPostingPayment.getAccountTrxns());
SavingsTrxnDetailEntity interestPostingTransaction = (SavingsTrxnDetailEntity) accountTransactions.get(0);
assertThat(interestPostingTransaction.getAccount(), is((AccountBO) savingsAccount));
assertThat(interestPostingTransaction.getAmount(), is(interestToBePosted));
assertThat(interestPostingTransaction.getInterestAmount(), is(interestToBePosted));
assertThat(interestPostingTransaction.getAccountActionEntity().getId(), is(AccountActionTypes.SAVINGS_INTEREST_POSTING.getValue()));
assertThat(new LocalDate(interestPostingTransaction.getActionDate()), is(nextInterestPostingDate.toLocalDate()));
assertThat(new LocalDate(interestPostingTransaction.getDueDate()), is(today()));
assertThat(datePartOf(interestPostingTransaction.getTrxnCreatedDate()), is(today()));
}
use of org.mifos.domain.builders.SavingsAccountBuilder in project head by mifos.
the class SavingsPostInterestTest method whenPostingInterestLastInterestPostingDateIsPopulated.
@Test
public void whenPostingInterestLastInterestPostingDateIsPopulated() {
// setup
InterestScheduledEvent postingSchedule = new MonthlyOnLastDayOfMonthInterestScheduledEvent(1);
DateTime activationDate = new DateTime().withDate(2010, 7, 20);
DateTime nextInterestPostingDate = new DateTime().withDate(2010, 7, 31);
savingsAccount = new SavingsAccountBuilder().active().withActivationDate(activationDate).withNextInterestPostingDateOf(nextInterestPostingDate).withSavingsProduct(savingsProduct).withCustomer(client).build();
// pre verification
assertThat(savingsAccount.getLastIntPostDate(), is(nullValue()));
InterestCalculationPeriodResult calculationPeriod = new InterestCalculationPeriodResultBuilder().withCalculatedInterest("100").build();
InterestPostingPeriodResult interestPostingPeriodResult = new InterestPostingPeriodResultBuilder().from(nextInterestPostingDate.toLocalDate()).to(nextInterestPostingDate.toLocalDate()).with(calculationPeriod).build();
PersonnelBO createdBy = new PersonnelBuilder().build();
// exercise
savingsAccount.postInterest(postingSchedule, interestPostingPeriodResult, createdBy);
// verification
assertThat(new LocalDate(savingsAccount.getLastIntPostDate()), is(nextInterestPostingDate.toLocalDate()));
}
Aggregations