use of org.mifos.domain.builders.SavingsProductBuilder in project head by mifos.
the class SavingsBOTest method overpayingMandatoryOrVoluntaryDepositAmountCausesAnExcessTransactionToBeCreated.
@Ignore
@Test
public void overpayingMandatoryOrVoluntaryDepositAmountCausesAnExcessTransactionToBeCreated() throws AccountException {
// setup
SavingsOfferingBO savingsProduct = new SavingsProductBuilder().mandatory().buildForUnitTests();
savingsAccount = savingsAccountBuilder.withSavingsProduct(savingsProduct).build();
final SavingsScheduleEntity unpaidSaving1 = new SavingsScheduleBuilder().withAccount(savingsAccount).withCustomer(payingCustomer).build();
final List<SavingsScheduleEntity> unpaidDepositsForPayingCustomer = Arrays.asList(unpaidSaving1);
final Money zero = new Money(defaultCurrency);
SavingsOfferingBO manSavingsProduct = new SavingsProductBuilder().mandatory().buildForUnitTests();
savingsAccount = savingsAccountBuilder.withSavingsProduct(manSavingsProduct).withBalanceOf(zero).withPayments(unpaidDepositsForPayingCustomer).buildForUnitTests();
final Money amountToDeposit = new Money(TestUtils.RUPEE, "100.0");
final Date dateOfDeposit = new DateTime().toDate();
final Money excessDepositAmount = new Money(TestUtils.RUPEE, "25.0");
final Money expectedTotalBalance = amountToDeposit.add(zero);
// stubbing
when(accountPayment.getAmount()).thenReturn(amountToDeposit);
when(accountPayment.getPaymentDate()).thenReturn(dateOfDeposit);
when(paymentStrategy.makeScheduledPayments(accountPayment, unpaidDepositsForPayingCustomer, payingCustomer, SavingsType.MANDATORY, zero)).thenReturn(excessDepositAmount);
// exercise test
savingsAccount.deposit(accountPayment, payingCustomer);
// verification
verify(this.savingsTransactionActivityHelper).createSavingsTrxnForDeposit(accountPayment, excessDepositAmount, payingCustomer, null, expectedTotalBalance);
}
use of org.mifos.domain.builders.SavingsProductBuilder in project head by mifos.
the class SavingsBOTest method shouldPayOffAnyPaymentsAssociatedWithPayingCustomerAndMandatorySavingsAccount.
@Ignore
@Test
public void shouldPayOffAnyPaymentsAssociatedWithPayingCustomerAndMandatorySavingsAccount() throws AccountException {
// setup
SavingsOfferingBO savingsProduct = new SavingsProductBuilder().mandatory().buildForUnitTests();
savingsAccount = savingsAccountBuilder.withSavingsProduct(savingsProduct).buildForUnitTests();
final SavingsScheduleEntity unpaidSaving1 = new SavingsScheduleBuilder().withAccount(savingsAccount).withCustomer(payingCustomer).build();
final List<SavingsScheduleEntity> unpaidDepositsForPayingCustomer = Arrays.asList(unpaidSaving1);
final Money zero = new Money(defaultCurrency);
SavingsOfferingBO manSavingsProduct = new SavingsProductBuilder().mandatory().buildForUnitTests();
savingsAccount = savingsAccountBuilder.withSavingsProduct(manSavingsProduct).withBalanceOf(zero).withPayments(unpaidDepositsForPayingCustomer).buildForUnitTests();
final Money amountToDeposit = new Money(TestUtils.RUPEE, "100.0");
final Date dateOfDeposit = new DateTime().toDate();
// stubbing
when(accountPayment.getAmount()).thenReturn(amountToDeposit);
when(accountPayment.getPaymentDate()).thenReturn(dateOfDeposit);
// exercise test
savingsAccount.deposit(accountPayment, payingCustomer);
// verification
verify(paymentStrategy).makeScheduledPayments(accountPayment, unpaidDepositsForPayingCustomer, payingCustomer, SavingsType.MANDATORY, zero);
}
use of org.mifos.domain.builders.SavingsProductBuilder 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.SavingsProductBuilder 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.SavingsProductBuilder 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