use of org.mifos.domain.builders.SavingsAccountBuilder in project head by mifos.
the class SavingsAdjustmentTest method canAdjustLastTransactionThatIsADeposit.
@Test
public void canAdjustLastTransactionThatIsADeposit() {
Money amountAdjustedTo = TestUtils.createMoney("25");
savingsAccount = new SavingsAccountBuilder().active().withSavingsProduct(savingsProduct).withCustomer(client).withDepositOf("15").build();
// exercise test
boolean result = savingsAccount.isAdjustPossibleOnTrxn(amountAdjustedTo, savingsAccount.getLastPmnt());
// verification
assertTrue(result);
}
use of org.mifos.domain.builders.SavingsAccountBuilder in project head by mifos.
the class CollectionSheetDaoHibernateIntegrationTest method testShouldFindSavingsDepositsforCustomerHierarchy.
@Test
public void testShouldFindSavingsDepositsforCustomerHierarchy() {
// setup
savingsProduct = new SavingsProductBuilder().mandatory().appliesToCentersOnly().withShortName("SP1").buildForIntegrationTests();
savingsAccount = new SavingsAccountBuilder().withSavingsProduct(savingsProduct).withCreatedBy(IntegrationTestObjectMother.testUser()).withCustomer(center).build();
IntegrationTestObjectMother.saveSavingsProductAndAssociatedSavingsAccounts(savingsProduct, savingsAccount);
savingsProduct2 = new SavingsProductBuilder().withName("product2").withShortName("SP2").mandatory().appliesToCentersOnly().buildForIntegrationTests();
savingsAccount2 = new SavingsAccountBuilder().withSavingsProduct(savingsProduct2).withCustomer(center).withCreatedBy(IntegrationTestObjectMother.testUser()).build();
IntegrationTestObjectMother.saveSavingsProductAndAssociatedSavingsAccounts(savingsProduct2, savingsAccount2);
final Integer customerAtTopOfHierarchyId = center.getCustomerId();
final Short branchId = center.getOffice().getOfficeId();
final String searchId = center.getSearchId() + ".%";
final LocalDate transactionDate = new LocalDate();
final CustomerHierarchyParams customerHierarchyParams = new CustomerHierarchyParams(customerAtTopOfHierarchyId, branchId, searchId, transactionDate);
// exercise test
final List<CollectionSheetCustomerSavingsAccountDto> allSavingsDeposits = collectionSheetDao.findAllSavingAccountsForCustomerHierarchy(customerHierarchyParams);
// verification
Assert.assertThat(allSavingsDeposits.size(), is(2));
}
use of org.mifos.domain.builders.SavingsAccountBuilder in project head by mifos.
the class GroupValidationTest method givenAnActiveSavingsAccountExistsGroupTransferToCenterShouldFailValidation.
@Test
public void givenAnActiveSavingsAccountExistsGroupTransferToCenterShouldFailValidation() {
// setup
CenterBO center = new CenterBuilder().build();
GroupBO group = new GroupBuilder().withParentCustomer(center).build();
SavingsBO savings = new SavingsAccountBuilder().active().withCustomer(group).build();
group.addAccount(savings);
// exercise test
try {
group.validateNoActiveAccountsExist();
fail("should fail validation");
} catch (CustomerException e) {
assertThat(e.getKey(), is(CustomerConstants.ERRORS_HAS_ACTIVE_ACCOUNT));
}
}
use of org.mifos.domain.builders.SavingsAccountBuilder in project head by mifos.
the class SavingsIntPostingHelperIntegrationTest method setUp.
@Before
public void setUp() throws Exception {
databaseCleaner.clean();
DateTime startOfFiscalYear = new DateTime().withDate(2010, 1, 1);
MeetingBO meetingFrequency = new MeetingBuilder().customerMeeting().startingFrom(startOfFiscalYear.toDate()).monthly().every(1).onDayOfMonth(1).build();
createCenterGroupClientHierarchy(meetingFrequency);
MeetingBO interestCalculationFrequency = new MeetingBuilder().savingsInterestCalulationSchedule().monthly().every(2).build();
IntegrationTestObjectMother.saveMeeting(interestCalculationFrequency);
MeetingBO interestPostingFrequency = new MeetingBuilder().savingsInterestPostingSchedule().monthly().every(2).build();
IntegrationTestObjectMother.saveMeeting(interestPostingFrequency);
SavingsOfferingBO mandatoryMinimumBalance = new SavingsProductBuilder().appliesToClientsOnly().withName("mandatoryMinimumBalance1").withShortName("mm01").mandatory().minimumBalance().withInterestCalculationSchedule(interestPostingFrequency).withInterestPostingSchedule(interestPostingFrequency).withMandatoryAmount("300").withInterestRate(Double.valueOf("12")).withMaxWithdrawalAmount(TestUtils.createMoney("200")).withMinAmountRequiredForInterestCalculation("200").buildForIntegrationTests();
IntegrationTestObjectMother.saveSavingsProducts(mandatoryMinimumBalance);
DateTime nextInterestPostingDate = new DateTime().minusDays(1);
savings1 = new SavingsAccountBuilder().active().withSavingsProduct(mandatoryMinimumBalance).withCustomer(client).withCreatedBy(IntegrationTestObjectMother.testUser()).withActivationDate(startOfFiscalYear).withNextInterestPostingDateOf(nextInterestPostingDate).withBalanceOf(TestUtils.createMoney("0")).withDepositOn("300", startOfFiscalYear).withDepositOn("200", startOfFiscalYear.plusMonths(1)).build();
IntegrationTestObjectMother.saveSavingsAccount(savings1);
}
use of org.mifos.domain.builders.SavingsAccountBuilder in project head by mifos.
the class TestCollectionSheetRetrieveSavingsAccountsUtils method createSavingsAccount.
public SavingsBO createSavingsAccount(CustomerBO customer, String shortName, String amount, boolean isVoluntary, boolean isPerIndividual) {
// johnw - unfortunately, in the current builder code, the settings for mandatory/voluntary and
// complete_group/per_individual are set at savings account level rather than at savings offering level as in
// the production system. However, this method creates a good savings account
SavingsProductBuilder savingsProductBuilder = new SavingsProductBuilder().withName(customer.getDisplayName()).withShortName(shortName);
if (customer.getCustomerLevel().getId().compareTo(CustomerLevel.CENTER.getValue()) == 0) {
savingsProductBuilder.appliesToCentersOnly();
}
if (customer.getCustomerLevel().getId().compareTo(CustomerLevel.GROUP.getValue()) == 0) {
savingsProductBuilder.appliesToGroupsOnly();
}
if (customer.getCustomerLevel().getId().compareTo(CustomerLevel.CLIENT.getValue()) == 0) {
savingsProductBuilder.appliesToClientsOnly();
}
SavingsOfferingBO savingsProduct = savingsProductBuilder.mandatory().withInterestRate(Double.valueOf("4.0")).buildForIntegrationTests();
if (isVoluntary) {
savingsProductBuilder.voluntary();
}
SavingsAccountBuilder savingsAccountBuilder = new SavingsAccountBuilder().withSavingsProduct(savingsProduct).withCustomer(customer).withCreatedBy(IntegrationTestObjectMother.testUser()).completeGroup().withRecommendedAmount(TestUtils.createMoney(amount));
if (isPerIndividual) {
savingsAccountBuilder.perIndividual();
}
SavingsBO savingsAccount = null;
if (customer.getCustomerLevel().getId().compareTo(CustomerLevel.CENTER.getValue()) == 0) {
savingsAccount = savingsAccountBuilder.buildJointSavingsAccount();
} else {
savingsAccount = savingsAccountBuilder.build();
}
IntegrationTestObjectMother.saveSavingsProductAndAssociatedSavingsAccounts(savingsProduct, savingsAccount);
return savingsAccount;
}
Aggregations