use of org.mifos.domain.builders.SavingsAccountBuilder in project head by mifos.
the class GroupValidationTest method givenAnActiveSavingsAccountExistsOnClientOfGroupGroupTransferToCenterShouldFailValidation.
@Test
public void givenAnActiveSavingsAccountExistsOnClientOfGroupGroupTransferToCenterShouldFailValidation() {
// setup
CenterBO center = new CenterBuilder().build();
GroupBO group = new GroupBuilder().withParentCustomer(center).build();
ClientBO client = new ClientBuilder().withParentCustomer(group).active().buildForUnitTests();
group.addChild(client);
SavingsBO savings = new SavingsAccountBuilder().active().withCustomer(group).build();
client.addAccount(savings);
// exercise test
try {
group.validateNoActiveAccountsExist();
fail("should fail validation");
} catch (CustomerException e) {
assertThat(e.getKey(), is(CustomerConstants.ERRORS_CHILDREN_HAS_ACTIVE_ACCOUNT));
}
}
use of org.mifos.domain.builders.SavingsAccountBuilder in project head by mifos.
the class SavingsScheduleIntegrationTest method createClientSavingsAccount.
public void createClientSavingsAccount() throws Exception {
meeting = new MeetingBuilder().customerMeeting().weekly().every(1).withStartDate(expectedFirstDepositDate).build();
IntegrationTestObjectMother.saveMeeting(meeting);
center = new CenterBuilder().with(meeting).withName("Center").with(sampleBranchOffice()).withLoanOfficer(testUser()).build();
IntegrationTestObjectMother.createCenter(center, meeting);
group = new GroupBuilder().withMeeting(meeting).withName("Group").withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withParentCustomer(center).build();
IntegrationTestObjectMother.createGroup(group, meeting);
client = new ClientBuilder().withMeeting(meeting).withName("Client 1").withOffice(sampleBranchOffice()).withLoanOfficer(testUser()).withParentCustomer(group).buildForIntegrationTests();
IntegrationTestObjectMother.createClient(client, meeting);
savingsProduct = new SavingsProductBuilder().mandatory().appliesToClientsOnly().buildForIntegrationTests();
HolidayDao holidayDao = ApplicationContextProvider.getBean(HolidayDao.class);
List<Holiday> holidays = holidayDao.findAllHolidaysThisYearAndNext(client.getOfficeId());
savingsAccount = new SavingsAccountBuilder().withSavingsProduct(savingsProduct).withCustomer(client).with(holidays).build();
IntegrationTestObjectMother.saveSavingsProductAndAssociatedSavingsAccounts(savingsProduct, savingsAccount);
}
use of org.mifos.domain.builders.SavingsAccountBuilder in project head by mifos.
the class SavingsAdjustmentTest method accountActivitysRecordAdjustmentOfLastTransactionWithAReversalAndWithdrawalTransactions.
@Test
public void accountActivitysRecordAdjustmentOfLastTransactionWithAReversalAndWithdrawalTransactions() {
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
List<SavingsActivityEntity> activitysBefore = new ArrayList<SavingsActivityEntity>(savingsAccount.getSavingsActivityDetails());
assertThat(activitysBefore.size(), is(1));
// exercise test
savingsAccount.adjustLastUserAction(amountAdjustedTo, adjustmentNote, updatedBy);
// verification
List<SavingsActivityEntity> activitysAfter = new ArrayList<SavingsActivityEntity>(savingsAccount.getSavingsActivityDetails());
assertThat(activitysAfter.size(), is(3));
}
use of org.mifos.domain.builders.SavingsAccountBuilder in project head by mifos.
the class SavingsAdjustmentTest method accountActivitysRecordAdjustmentOfLastTransactionWithAReversalAndDepositTransactions.
@Test
public void accountActivitysRecordAdjustmentOfLastTransactionWithAReversalAndDepositTransactions() {
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
List<SavingsActivityEntity> activitysBefore = new ArrayList<SavingsActivityEntity>(savingsAccount.getSavingsActivityDetails());
assertThat(activitysBefore.size(), is(1));
// exercise test
savingsAccount.adjustLastUserAction(amountAdjustedTo, adjustmentNote, updatedBy);
// verification
List<SavingsActivityEntity> activitysAfter = new ArrayList<SavingsActivityEntity>(savingsAccount.getSavingsActivityDetails());
assertThat(activitysAfter.size(), is(3));
}
use of org.mifos.domain.builders.SavingsAccountBuilder in project head by mifos.
the class SavingsAdjustmentTest method cannotAdjustLastTransactionToSameMonetaryAmount.
@Test
public void cannotAdjustLastTransactionToSameMonetaryAmount() {
Money amountAdjustedTo = TestUtils.createMoney("15");
savingsAccount = new SavingsAccountBuilder().active().withSavingsProduct(savingsProduct).withCustomer(client).withDepositOf("15").build();
// exercise test
boolean result = savingsAccount.isAdjustPossibleOnTrxn(amountAdjustedTo, savingsAccount.getLastPmnt());
// verification
assertFalse(result);
}
Aggregations