Search in sources :

Example 16 with SavingsOfferingBO

use of org.mifos.accounts.productdefinition.business.SavingsOfferingBO in project head by mifos.

the class SavingsProductDaoHibernateIntegrationTest method testShouldFindSavingsProductById.

@Test
public void testShouldFindSavingsProductById() {
    // setup
    SavingsOfferingBO savingsProduct = new SavingsProductBuilder().appliesToCentersOnly().mandatory().withName("product1").withShortName("1234").withMandatoryAmount("25").buildForIntegrationTests();
    IntegrationTestObjectMother.saveSavingsProducts(savingsProduct);
    // exercise test
    SavingsOfferingBO result = savingsProductDao.findById(savingsProduct.getPrdOfferingId().intValue());
    Money recommendedAmount = TestUtils.createMoney("25");
    RecommendedAmntUnitEntity recommendedAmntUnit = null;
    Money maxAmntWithdrawl = TestUtils.createMoney("100");
    Double interestRate = Double.valueOf("12");
    Money minAmountRequiredForInterestToBeCalculated = TestUtils.createMoney("100");
    LocalDate updateDate = new LocalDate();
    result.updateSavingsDetails(recommendedAmount, recommendedAmntUnit, maxAmntWithdrawl, interestRate, minAmountRequiredForInterestToBeCalculated, updateDate);
    IntegrationTestObjectMother.saveSavingsProducts(result);
    // assertion
    assertNotNull(result);
}
Also used : Money(org.mifos.framework.util.helpers.Money) SavingsProductBuilder(org.mifos.domain.builders.SavingsProductBuilder) SavingsOfferingBO(org.mifos.accounts.productdefinition.business.SavingsOfferingBO) RecommendedAmntUnitEntity(org.mifos.accounts.productdefinition.business.RecommendedAmntUnitEntity) LocalDate(org.joda.time.LocalDate) Test(org.junit.Test)

Example 17 with SavingsOfferingBO

use of org.mifos.accounts.productdefinition.business.SavingsOfferingBO 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);
}
Also used : SavingsScheduleBuilder(org.mifos.domain.builders.SavingsScheduleBuilder) Money(org.mifos.framework.util.helpers.Money) SavingsProductBuilder(org.mifos.domain.builders.SavingsProductBuilder) SavingsOfferingBO(org.mifos.accounts.productdefinition.business.SavingsOfferingBO) SavingsScheduleEntity(org.mifos.accounts.savings.business.SavingsScheduleEntity) Date(java.util.Date) LocalDate(org.joda.time.LocalDate) DateTime(org.joda.time.DateTime) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 18 with SavingsOfferingBO

use of org.mifos.accounts.productdefinition.business.SavingsOfferingBO 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);
}
Also used : SavingsScheduleBuilder(org.mifos.domain.builders.SavingsScheduleBuilder) Money(org.mifos.framework.util.helpers.Money) SavingsProductBuilder(org.mifos.domain.builders.SavingsProductBuilder) SavingsOfferingBO(org.mifos.accounts.productdefinition.business.SavingsOfferingBO) SavingsScheduleEntity(org.mifos.accounts.savings.business.SavingsScheduleEntity) Date(java.util.Date) LocalDate(org.joda.time.LocalDate) DateTime(org.joda.time.DateTime) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 19 with SavingsOfferingBO

use of org.mifos.accounts.productdefinition.business.SavingsOfferingBO in project head by mifos.

the class PrdOfferingPersistenceIntegrationTest method testGetMaxPrdOfferingWithProduct.

@Test
public void testGetMaxPrdOfferingWithProduct() throws PersistenceException {
    SavingsOfferingBO savingsOffering = new SavingsTestHelper().createSavingsOffering("fsaf6", "ads6");
    Assert.assertNotNull(new PrdOfferingPersistence().getMaxPrdOffering());
    savingsOffering = null;
}
Also used : SavingsOfferingBO(org.mifos.accounts.productdefinition.business.SavingsOfferingBO) SavingsTestHelper(org.mifos.accounts.savings.util.helpers.SavingsTestHelper) Test(org.junit.Test)

Example 20 with SavingsOfferingBO

use of org.mifos.accounts.productdefinition.business.SavingsOfferingBO in project head by mifos.

the class PrdOfferingPersistenceIntegrationTest method testGetPrdOfferingNameCountWithSameName.

@Test
public void testGetPrdOfferingNameCountWithSameName() throws PersistenceException {
    SavingsOfferingBO savingsOffering = new SavingsTestHelper().createSavingsOffering("Savings product", "ads6");
    Assert.assertEquals(Integer.valueOf("1"), new PrdOfferingPersistence().getProductOfferingNameCount("Savings product"));
    savingsOffering = null;
}
Also used : SavingsOfferingBO(org.mifos.accounts.productdefinition.business.SavingsOfferingBO) SavingsTestHelper(org.mifos.accounts.savings.util.helpers.SavingsTestHelper) Test(org.junit.Test)

Aggregations

SavingsOfferingBO (org.mifos.accounts.productdefinition.business.SavingsOfferingBO)63 Test (org.junit.Test)33 ArrayList (java.util.ArrayList)20 SavingsBO (org.mifos.accounts.savings.business.SavingsBO)17 SavingsProductBuilder (org.mifos.domain.builders.SavingsProductBuilder)14 MeetingBO (org.mifos.application.meeting.business.MeetingBO)11 LocalDate (org.joda.time.LocalDate)10 SavingsAccountBuilder (org.mifos.domain.builders.SavingsAccountBuilder)10 Date (java.util.Date)9 UserContext (org.mifos.security.util.UserContext)9 Date (java.sql.Date)8 DateTime (org.joda.time.DateTime)8 AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)8 AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)8 SavingsTestHelper (org.mifos.accounts.savings.util.helpers.SavingsTestHelper)8 MifosRuntimeException (org.mifos.core.MifosRuntimeException)8 CustomerException (org.mifos.customers.exceptions.CustomerException)7 Money (org.mifos.framework.util.helpers.Money)7 AccountException (org.mifos.accounts.exceptions.AccountException)6 LoanOfferingBO (org.mifos.accounts.productdefinition.business.LoanOfferingBO)5