Search in sources :

Example 66 with CenterBO

use of org.mifos.customers.center.business.CenterBO in project head by mifos.

the class AccountBOIntegrationTest method testGetAllInstallments.

@Test
public void testGetAllInstallments() {
    MeetingBO meeting = TestObjectFactory.createMeeting(TestObjectFactory.getTypicalMeeting());
    CenterBO centerBO = TestObjectFactory.createWeeklyFeeCenter("Center_Active", meeting);
    StaticHibernateUtil.flushAndClearSession();
    centerBO = TestObjectFactory.getCenter(centerBO.getCustomerId());
    List<AccountActionDateEntity> allInstallments = centerBO.getCustomerAccount().getAllInstallments();
    Assert.assertNotNull(allInstallments);
    Assert.assertEquals(10, allInstallments.size());
    centerBO = null;
}
Also used : MeetingBO(org.mifos.application.meeting.business.MeetingBO) CenterBO(org.mifos.customers.center.business.CenterBO) Test(org.junit.Test)

Example 67 with CenterBO

use of org.mifos.customers.center.business.CenterBO in project head by mifos.

the class CenterServiceFacadeWebTier method initializeCenterStates.

@Override
public void initializeCenterStates(String centerGlobalNum) {
    CenterBO center = this.customerDao.findCenterBySystemId(centerGlobalNum);
    try {
        List<ListElement> savingsStatesList = new ArrayList<ListElement>();
        AccountStateMachines.getInstance().initializeCenterStates();
        List<CustomerStatusEntity> statusList = AccountStateMachines.getInstance().getCenterStatusList(center.getCustomerStatus());
        for (CustomerStatusEntity customerState : statusList) {
            savingsStatesList.add(new ListElement(customerState.getId().intValue(), customerState.getName()));
        }
    } catch (StatesInitializationException e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : ArrayList(java.util.ArrayList) ListElement(org.mifos.dto.screen.ListElement) CenterBO(org.mifos.customers.center.business.CenterBO) StatesInitializationException(org.mifos.framework.exceptions.StatesInitializationException) CustomerStatusEntity(org.mifos.customers.business.CustomerStatusEntity) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 68 with CenterBO

use of org.mifos.customers.center.business.CenterBO in project head by mifos.

the class CustomerPersistence method findBySystemId.

/**
     * @deprecated use {@link CustomerDao#findCenterBySystemId(String)}.
     */
@Deprecated
public CustomerBO findBySystemId(final String globalCustNum, final Short levelId) throws PersistenceException {
    Map<String, String> queryParameters = new HashMap<String, String>();
    CustomerBO customer = null;
    queryParameters.put("globalCustNum", globalCustNum);
    if (levelId.shortValue() == CustomerLevel.CENTER.getValue()) {
        List<CenterBO> queryResult = executeNamedQuery(NamedQueryConstants.GET_CENTER_BY_SYSTEMID, queryParameters);
        if (null != queryResult && queryResult.size() > 0) {
            customer = queryResult.get(0);
            initializeCustomer(customer);
        }
    } else if (levelId.shortValue() == CustomerLevel.GROUP.getValue()) {
        List<GroupBO> queryResult = executeNamedQuery(NamedQueryConstants.GET_GROUP_BY_SYSTEMID, queryParameters);
        if (null != queryResult && queryResult.size() > 0) {
            customer = queryResult.get(0);
            initializeCustomer(customer);
        }
    } else if (levelId.shortValue() == CustomerLevel.CLIENT.getValue()) {
        List<ClientBO> queryResult = executeNamedQuery(NamedQueryConstants.GET_CLIENT_BY_SYSTEMID, queryParameters);
        if (null != queryResult && queryResult.size() > 0) {
            customer = queryResult.get(0);
            initializeCustomer(customer);
        }
    }
    return customer;
}
Also used : HashMap(java.util.HashMap) ClientBO(org.mifos.customers.client.business.ClientBO) CustomerBO(org.mifos.customers.business.CustomerBO) CenterBO(org.mifos.customers.center.business.CenterBO) List(java.util.List) ArrayList(java.util.ArrayList)

Example 69 with CenterBO

use of org.mifos.customers.center.business.CenterBO in project head by mifos.

the class CenterCustActionForm method validateFields.

/*
     * Validation is done in the order that the fields appear on the UI.
     *
     * @see org.mifos.customers.struts.actionforms.CustomerActionForm#
     * validateFields(javax.servlet.http.HttpServletRequest, java.lang.String)
     */
@Override
protected ActionErrors validateFields(HttpServletRequest request, String method) throws ApplicationException {
    ActionErrors errors = new ActionErrors();
    if (method.equals(Methods.preview.toString())) {
        validateName(errors);
        validateLO(errors);
        validateMeeting(request, errors);
    } else if (method.equals(Methods.editPreview.toString())) {
        validateName(errors);
        CenterBO center = (CenterBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
        if (center.isActive()) {
            validateLO(errors);
        }
    }
    if (method.equals(Methods.preview.toString()) || method.equals(Methods.editPreview.toString())) {
        validateMfiJoiningDate(request, errors);
        validateConfigurableMandatoryFields(request, errors, EntityType.CENTER);
        validateCustomFieldsForCustomers(request, errors);
    }
    // fees are only editable in preview and come last
    if (method.equals(Methods.preview.toString())) {
        validateFees(request, errors);
    }
    return errors;
}
Also used : CenterBO(org.mifos.customers.center.business.CenterBO) ActionErrors(org.apache.struts.action.ActionErrors)

Example 70 with CenterBO

use of org.mifos.customers.center.business.CenterBO in project head by mifos.

the class CenterCreationTest method createsCenterWithCustomerAccount.

@Test
public void createsCenterWithCustomerAccount() throws Exception {
    // setup
    OfficeBO withOffice = new OfficeBO(new Short("1"), "testOffice", new Integer("1"), new Short("1"));
    CenterBO center = new CenterBuilder().withLoanOfficer(anyLoanOfficer()).with(withOffice).build();
    center.setCustomerDao(customerDao);
    List<AccountFeesEntity> accountFees = new ArrayList<AccountFeesEntity>();
    // stub
    CalendarEvent upcomingCalendarEvents = new CalendarEventBuilder().build();
    when(holidayDao.findCalendarEventsForThisYearAndNext((short) 1)).thenReturn(upcomingCalendarEvents);
    when(customerAccountFactory.create(center, accountFees, meeting, upcomingCalendarEvents)).thenReturn(customerAccount);
    when(customerAccount.getType()).thenReturn(AccountTypes.CUSTOMER_ACCOUNT);
    // exercise test
    customerService.createCenter(center, meeting, accountFees);
    // verification
    assertThat(center.getCustomerAccount(), is(customerAccount));
}
Also used : OfficeBO(org.mifos.customers.office.business.OfficeBO) ArrayList(java.util.ArrayList) CenterBO(org.mifos.customers.center.business.CenterBO) CenterBuilder(org.mifos.domain.builders.CenterBuilder) CalendarEvent(org.mifos.calendar.CalendarEvent) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) CalendarEventBuilder(org.mifos.domain.builders.CalendarEventBuilder) Test(org.junit.Test)

Aggregations

CenterBO (org.mifos.customers.center.business.CenterBO)117 Test (org.junit.Test)91 CenterBuilder (org.mifos.domain.builders.CenterBuilder)82 DateTime (org.joda.time.DateTime)47 MeetingBO (org.mifos.application.meeting.business.MeetingBO)46 GroupBO (org.mifos.customers.group.business.GroupBO)45 ArrayList (java.util.ArrayList)43 MeetingBuilder (org.mifos.domain.builders.MeetingBuilder)43 AccountFeesEntity (org.mifos.accounts.business.AccountFeesEntity)39 GroupBuilder (org.mifos.domain.builders.GroupBuilder)35 CustomerException (org.mifos.customers.exceptions.CustomerException)22 OfficeBO (org.mifos.customers.office.business.OfficeBO)21 ClientBO (org.mifos.customers.client.business.ClientBO)19 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)19 UserContext (org.mifos.security.util.UserContext)18 CalendarEventBuilder (org.mifos.domain.builders.CalendarEventBuilder)15 ClientBuilder (org.mifos.domain.builders.ClientBuilder)13 LocalDate (org.joda.time.LocalDate)12 Ignore (org.junit.Ignore)12 AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)12