Search in sources :

Example 16 with SavingsProductBuilder

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);
}
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 17 with SavingsProductBuilder

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);
}
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 SavingsProductBuilder

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));
}
Also used : SavingsProductBuilder(org.mifos.domain.builders.SavingsProductBuilder) CustomerHierarchyParams(org.mifos.application.servicefacade.CustomerHierarchyParams) CollectionSheetCustomerSavingsAccountDto(org.mifos.application.servicefacade.CollectionSheetCustomerSavingsAccountDto) SavingsAccountBuilder(org.mifos.domain.builders.SavingsAccountBuilder) LocalDate(org.joda.time.LocalDate) Test(org.junit.Test)

Example 19 with SavingsProductBuilder

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);
}
Also used : SavingsProductBuilder(org.mifos.domain.builders.SavingsProductBuilder) MeetingBO(org.mifos.application.meeting.business.MeetingBO) SavingsOfferingBO(org.mifos.accounts.productdefinition.business.SavingsOfferingBO) MeetingBuilder(org.mifos.domain.builders.MeetingBuilder) SavingsAccountBuilder(org.mifos.domain.builders.SavingsAccountBuilder) DateTime(org.joda.time.DateTime) Before(org.junit.Before)

Example 20 with SavingsProductBuilder

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;
}
Also used : SavingsProductBuilder(org.mifos.domain.builders.SavingsProductBuilder) SavingsOfferingBO(org.mifos.accounts.productdefinition.business.SavingsOfferingBO) SavingsBO(org.mifos.accounts.savings.business.SavingsBO) SavingsAccountBuilder(org.mifos.domain.builders.SavingsAccountBuilder)

Aggregations

SavingsProductBuilder (org.mifos.domain.builders.SavingsProductBuilder)32 Test (org.junit.Test)26 SavingsAccountBuilder (org.mifos.domain.builders.SavingsAccountBuilder)19 SavingsOfferingBO (org.mifos.accounts.productdefinition.business.SavingsOfferingBO)14 Money (org.mifos.framework.util.helpers.Money)14 SavingsBO (org.mifos.accounts.savings.business.SavingsBO)9 LocalDate (org.joda.time.LocalDate)6 AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)6 DateTime (org.joda.time.DateTime)5 Before (org.junit.Before)4 CollectionSheetCustomerSavingDto (org.mifos.application.servicefacade.CollectionSheetCustomerSavingDto)4 ClientBuilder (org.mifos.domain.builders.ClientBuilder)4 Date (java.util.Date)3 Ignore (org.junit.Ignore)3 SavingsScheduleEntity (org.mifos.accounts.savings.business.SavingsScheduleEntity)3 MeetingBuilder (org.mifos.domain.builders.MeetingBuilder)3 SavingsScheduleBuilder (org.mifos.domain.builders.SavingsScheduleBuilder)3 MeetingBO (org.mifos.application.meeting.business.MeetingBO)2 RecommendedAmntUnitEntity (org.mifos.accounts.productdefinition.business.RecommendedAmntUnitEntity)1 Holiday (org.mifos.application.holiday.business.Holiday)1