Search in sources :

Example 91 with SavingsBO

use of org.mifos.accounts.savings.business.SavingsBO in project head by mifos.

the class SavingsActionStrutsTest method createAndAddObjects.

private void createAndAddObjects() throws Exception {
    createInitialObjects();
    Date currentDate = new Date(System.currentTimeMillis());
    savingsOffering = TestObjectFactory.createSavingsProduct("sav prd1", "prd1", currentDate, RecommendedAmountUnit.COMPLETE_GROUP);
    SavingsBO savingsObj = new SavingsBO(userContext, savingsOffering, group, AccountState.SAVINGS_ACTIVE, savingsOffering.getRecommendedAmount(), getCustomFieldView());
    SessionUtils.setAttribute(Constants.BUSINESS_KEY, savingsObj, request);
    addRequestParameter("selectedPrdOfferingId", savingsOffering.getPrdOfferingId().toString());
}
Also used : SavingsBO(org.mifos.accounts.savings.business.SavingsBO) Date(java.util.Date)

Example 92 with SavingsBO

use of org.mifos.accounts.savings.business.SavingsBO in project head by mifos.

the class SavingsActionStrutsTest method testSuccessfulGetBySystemId.

@Test
public void testSuccessfulGetBySystemId() throws Exception {
    setMifosUserFromContext();
    createAndAddObjects(AccountState.SAVINGS_PARTIAL_APPLICATION);
    addRequestParameter("globalAccountNum", savings.getGlobalAccountNum());
    setRequestPathInfo("/savingsAction.do");
    addRequestParameter("method", "get");
    performNoErrors();
    verifyForward("get_success");
    SavingsBO savingsObj = (SavingsBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
    Assert.assertEquals(savings.getGlobalAccountNum(), savingsObj.getGlobalAccountNum());
    Assert.assertEquals(savingsOffering.getRecommendedAmount(), savingsObj.getRecommendedAmount());
    savingsOffering = null;
    Assert.assertNotNull(SessionUtils.getAttribute(MasterConstants.SAVINGS_TYPE, request));
    Assert.assertNotNull(SessionUtils.getAttribute(MasterConstants.RECOMMENDED_AMOUNT_UNIT, request));
    Assert.assertNotNull(SessionUtils.getAttribute(SavingsConstants.CUSTOM_FIELDS, request));
    Assert.assertNotNull(SessionUtils.getAttribute(SavingsConstants.RECENTY_ACTIVITY_DETAIL_PAGE, request));
    Assert.assertNotNull(SessionUtils.getAttribute(SavingsConstants.NOTES, request));
}
Also used : SavingsBO(org.mifos.accounts.savings.business.SavingsBO) Test(org.junit.Test)

Example 93 with SavingsBO

use of org.mifos.accounts.savings.business.SavingsBO in project head by mifos.

the class CenterActionStrutsTest method testGet.

@Test
public void testGet() throws Exception {
    setNonLoanOfficerMifosUser();
    MeetingBO meeting = TestObjectFactory.createMeeting(TestObjectFactory.getTypicalMeeting());
    center = TestObjectFactory.createWeeklyFeeCenter("Center", meeting);
    group = TestObjectFactory.createWeeklyFeeGroupUnderCenter("Group", CustomerStatus.GROUP_ACTIVE, center);
    savingsBO = getSavingsAccount("fsaf6", "ads6", center);
    StaticHibernateUtil.flushSession();
    setRequestPathInfo("/centerCustAction.do");
    addRequestParameter("method", "get");
    addRequestParameter("globalCustNum", center.getGlobalCustNum());
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    verifyForward(ActionForwards.get_success.toString());
    CustomerBO centerBO = (CenterBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
    Assert.assertNotNull(center);
    Assert.assertEquals(center.getCustomerId(), centerBO.getCustomerId());
    CenterInformationDto centerInformation = (CenterInformationDto) SessionUtils.getAttribute("centerInformationDto", request);
    List<CustomerDetailDto> children = centerInformation.getGroupsOtherThanClosedAndCancelled();
    Assert.assertNotNull(children);
    Assert.assertEquals(1, children.size());
    Assert.assertEquals("Size of the active accounts should be 1", 1, centerInformation.getSavingsAccountsInUse().size());
    StaticHibernateUtil.flushSession();
    center = TestObjectFactory.getCenter(center.getCustomerId());
    group = TestObjectFactory.getGroup(group.getCustomerId());
    savingsBO = TestObjectFactory.getObject(SavingsBO.class, savingsBO.getAccountId());
}
Also used : MeetingBO(org.mifos.application.meeting.business.MeetingBO) CustomerDetailDto(org.mifos.dto.domain.CustomerDetailDto) CustomerBO(org.mifos.customers.business.CustomerBO) CenterBO(org.mifos.customers.center.business.CenterBO) CenterInformationDto(org.mifos.dto.domain.CenterInformationDto) SavingsBO(org.mifos.accounts.savings.business.SavingsBO) Test(org.junit.Test)

Example 94 with SavingsBO

use of org.mifos.accounts.savings.business.SavingsBO in project head by mifos.

the class GroupPerformanceHistoryUsingCustomerServiceIntegrationTest method shouldGetTotalSavingsBalance.

@Test
public void shouldGetTotalSavingsBalance() throws Exception {
    // setup
    SavingsOfferingBO groupSavingsProduct = new SavingsProductBuilder().appliesToGroupsOnly().voluntary().withName("groupSavings").withShortName("GSP").buildForIntegrationTests();
    IntegrationTestObjectMother.createProduct(groupSavingsProduct);
    SavingsBO groupSavingsAccount = new SavingsAccountBuilder().withSavingsProduct(groupSavingsProduct).withCustomer(existingActiveClient).withCreatedBy(IntegrationTestObjectMother.testUser()).withSavingsOfficer(existingLoanOfficer).withBalanceOf(new Money(Money.getDefaultCurrency(), "200.0")).build();
    IntegrationTestObjectMother.saveSavingsAccount(groupSavingsAccount);
    SavingsOfferingBO clientSavingsProduct = new SavingsProductBuilder().appliesToClientsOnly().voluntary().withName("clientSavings").withShortName("CSP").buildForIntegrationTests();
    IntegrationTestObjectMother.createProduct(clientSavingsProduct);
    SavingsBO clientSavingsAccount = new SavingsAccountBuilder().withSavingsProduct(clientSavingsProduct).withCustomer(existingActiveClient).withCreatedBy(IntegrationTestObjectMother.testUser()).withSavingsOfficer(existingLoanOfficer).withBalanceOf(new Money(Money.getDefaultCurrency(), "550.0")).build();
    IntegrationTestObjectMother.saveSavingsAccount(clientSavingsAccount);
    existingGroup = customerDao.findGroupBySystemId(existingGroup.getGlobalCustNum());
    // exercise test
    Money savingsAmount = existingGroup.getGroupPerformanceHistory().getTotalSavingsAmount();
    // verification
    assertThat(savingsAmount.getAmountDoubleValue(), is(750.0));
}
Also used : Money(org.mifos.framework.util.helpers.Money) 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) Test(org.junit.Test)

Example 95 with SavingsBO

use of org.mifos.accounts.savings.business.SavingsBO in project head by mifos.

the class IntegrationTestObjectMother method saveSavingsProductAndAssociatedSavingsAccounts.

public static void saveSavingsProductAndAssociatedSavingsAccounts(final SavingsOfferingBO savingsProduct, final SavingsBO... relatedSavingsAccounts) {
    try {
        customerPersistence.createOrUpdate(savingsProduct);
        for (SavingsBO savingAccount : relatedSavingsAccounts) {
            customerPersistence.createOrUpdate(savingAccount);
        }
        StaticHibernateUtil.flushSession();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : MifosRuntimeException(org.mifos.core.MifosRuntimeException) SavingsBO(org.mifos.accounts.savings.business.SavingsBO) CustomerException(org.mifos.customers.exceptions.CustomerException) MifosRuntimeException(org.mifos.core.MifosRuntimeException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) AccountException(org.mifos.accounts.exceptions.AccountException)

Aggregations

SavingsBO (org.mifos.accounts.savings.business.SavingsBO)111 UserContext (org.mifos.security.util.UserContext)43 MifosRuntimeException (org.mifos.core.MifosRuntimeException)30 AccountException (org.mifos.accounts.exceptions.AccountException)28 LocalDate (org.joda.time.LocalDate)27 MifosUser (org.mifos.security.MifosUser)26 Test (org.junit.Test)25 Money (org.mifos.framework.util.helpers.Money)24 ArrayList (java.util.ArrayList)22 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)22 PersistenceException (org.mifos.framework.exceptions.PersistenceException)22 Date (java.util.Date)20 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)19 BusinessRuleException (org.mifos.service.BusinessRuleException)18 SavingsOfferingBO (org.mifos.accounts.productdefinition.business.SavingsOfferingBO)17 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)17 CustomerBO (org.mifos.customers.business.CustomerBO)15 AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)14 ServiceException (org.mifos.framework.exceptions.ServiceException)13 InvalidDateException (org.mifos.application.admin.servicefacade.InvalidDateException)12