Search in sources :

Example 21 with SavingsAccountBuilder

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);
}
Also used : Money(org.mifos.framework.util.helpers.Money) SavingsAccountBuilder(org.mifos.domain.builders.SavingsAccountBuilder) Test(org.junit.Test)

Example 22 with SavingsAccountBuilder

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));
}
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 23 with SavingsAccountBuilder

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));
    }
}
Also used : CustomerException(org.mifos.customers.exceptions.CustomerException) GroupBuilder(org.mifos.domain.builders.GroupBuilder) CenterBO(org.mifos.customers.center.business.CenterBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) GroupBO(org.mifos.customers.group.business.GroupBO) SavingsBO(org.mifos.accounts.savings.business.SavingsBO) SavingsAccountBuilder(org.mifos.domain.builders.SavingsAccountBuilder) Test(org.junit.Test)

Example 24 with SavingsAccountBuilder

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);
}
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 25 with SavingsAccountBuilder

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

SavingsAccountBuilder (org.mifos.domain.builders.SavingsAccountBuilder)45 Test (org.junit.Test)41 Money (org.mifos.framework.util.helpers.Money)21 SavingsProductBuilder (org.mifos.domain.builders.SavingsProductBuilder)19 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)18 PersonnelBuilder (org.mifos.domain.builders.PersonnelBuilder)18 DateTime (org.joda.time.DateTime)11 SavingsBO (org.mifos.accounts.savings.business.SavingsBO)11 SavingsOfferingBO (org.mifos.accounts.productdefinition.business.SavingsOfferingBO)10 LocalDate (org.joda.time.LocalDate)8 InterestCalculationPeriodResult (org.mifos.accounts.savings.interest.InterestCalculationPeriodResult)8 InterestCalculationPeriodResultBuilder (org.mifos.accounts.savings.interest.InterestCalculationPeriodResultBuilder)8 InterestPostingPeriodResult (org.mifos.accounts.savings.interest.InterestPostingPeriodResult)8 InterestPostingPeriodResultBuilder (org.mifos.accounts.savings.interest.InterestPostingPeriodResultBuilder)8 InterestScheduledEvent (org.mifos.accounts.savings.interest.schedule.InterestScheduledEvent)8 MonthlyOnLastDayOfMonthInterestScheduledEvent (org.mifos.accounts.savings.interest.schedule.internal.MonthlyOnLastDayOfMonthInterestScheduledEvent)8 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)7 ClientBuilder (org.mifos.domain.builders.ClientBuilder)7 AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)6 ArrayList (java.util.ArrayList)5