Search in sources :

Example 61 with CenterBO

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

the class CenterPersistence method findBySystemId.

@SuppressWarnings("unchecked")
public CenterBO findBySystemId(String globalCustNum) throws PersistenceException {
    Map<String, String> queryParameters = new HashMap<String, String>();
    CenterBO center = null;
    queryParameters.put("globalCustNum", globalCustNum);
    List<CenterBO> queryResult = executeNamedQuery(NamedQueryConstants.GET_CENTER_BY_SYSTEMID, queryParameters);
    if (null != queryResult && queryResult.size() > 0) {
        center = queryResult.get(0);
    }
    return center;
}
Also used : HashMap(java.util.HashMap) CenterBO(org.mifos.customers.center.business.CenterBO)

Example 62 with CenterBO

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

the class CenterCustAction method update.

// NOTE - manage->preview->update
@CloseSession
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward update(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    CenterBO centerFromSession = (CenterBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
    CenterCustActionForm actionForm = (CenterCustActionForm) form;
    AddressDto dto = null;
    if (actionForm.getAddress() != null) {
        dto = Address.toDto(actionForm.getAddress());
    }
    CenterUpdate centerUpdate = new CenterUpdate(centerFromSession.getCustomerId(), actionForm.getDisplayName(), centerFromSession.getVersionNo(), actionForm.getLoanOfficerIdValue(), actionForm.getExternalId(), actionForm.getMfiJoiningDate(), dto, actionForm.getCustomFields(), actionForm.getCustomerPositions());
    try {
        this.centerServiceFacade.updateCenter(centerUpdate);
    } catch (BusinessRuleException e) {
        throw new ApplicationException(e.getMessageKey(), e);
    }
    return mapping.findForward(ActionForwards.update_success.toString());
}
Also used : BusinessRuleException(org.mifos.service.BusinessRuleException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) CenterCustActionForm(org.mifos.customers.center.struts.actionforms.CenterCustActionForm) CenterUpdate(org.mifos.dto.domain.CenterUpdate) CenterBO(org.mifos.customers.center.business.CenterBO) AddressDto(org.mifos.dto.domain.AddressDto) CloseSession(org.mifos.framework.util.helpers.CloseSession) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 63 with CenterBO

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

the class CenterCustAction method get.

@TransactionDemarcate(saveToken = true)
public ActionForward get(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    CenterInformationDto centerInformationDto;
    try {
        centerInformationDto = this.centerServiceFacade.getCenterInformationDto(((CenterCustActionForm) form).getGlobalCustNum());
    } catch (MifosRuntimeException e) {
        if (e.getCause() instanceof ApplicationException) {
            throw (ApplicationException) e.getCause();
        }
        throw e;
    }
    SessionUtils.removeThenSetAttribute("centerInformationDto", centerInformationDto, request);
    // John W - 'BusinessKey' attribute used by breadcrumb but is not in associated jsp
    CenterBO centerBO = (CenterBO) this.customerDao.findCustomerById(centerInformationDto.getCenterDisplay().getCustomerId());
    SessionUtils.removeThenSetAttribute(Constants.BUSINESS_KEY, centerBO, request);
    setCurrentPageUrl(request, centerBO);
    setQuestionGroupInstances(request, centerBO);
    return mapping.findForward(ActionForwards.get_success.toString());
}
Also used : ApplicationException(org.mifos.framework.exceptions.ApplicationException) CenterCustActionForm(org.mifos.customers.center.struts.actionforms.CenterCustActionForm) CenterBO(org.mifos.customers.center.business.CenterBO) CenterInformationDto(org.mifos.dto.domain.CenterInformationDto) MifosRuntimeException(org.mifos.core.MifosRuntimeException) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 64 with CenterBO

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

the class CustomerServiceImpl method updateCustomerStatus.

@Override
public final void updateCustomerStatus(UserContext userContext, CustomerStatusUpdate customerStatusUpdate) throws CustomerException {
    CustomerBO customer = this.customerDao.findCustomerById(customerStatusUpdate.getCustomerId());
    customer.validateVersion(customerStatusUpdate.getVersionNum());
    customer.updateDetails(userContext);
    checkPermission(customer, userContext, customerStatusUpdate.getNewStatus(), customerStatusUpdate.getCustomerStatusFlag());
    Short oldStatusId = customer.getCustomerStatus().getId();
    CustomerStatus oldStatus = CustomerStatus.fromInt(oldStatusId);
    PersonnelBO loggedInUser = this.personnelDao.findPersonnelById(userContext.getId());
    CustomerNoteEntity customerNote = new CustomerNoteEntity(customerStatusUpdate.getNotes(), new Date(), loggedInUser, customer);
    if (customer.isGroup()) {
        GroupBO group = (GroupBO) customer;
        updateGroupStatus(group, oldStatus, customerStatusUpdate.getNewStatus(), customerStatusUpdate.getCustomerStatusFlag(), customerNote);
    } else if (customer.isClient()) {
        ClientBO client = (ClientBO) customer;
        updateClientStatus(client, oldStatus, customerStatusUpdate.getNewStatus(), customerStatusUpdate.getCustomerStatusFlag(), customerNote);
    } else {
        CenterBO center = (CenterBO) customer;
        updateCenterStatus(center, customerStatusUpdate.getNewStatus(), customerStatusUpdate.getCustomerStatusFlag(), customerNote);
    }
}
Also used : CustomerNoteEntity(org.mifos.customers.business.CustomerNoteEntity) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) CustomerStatus(org.mifos.customers.util.helpers.CustomerStatus) ClientBO(org.mifos.customers.client.business.ClientBO) CustomerBO(org.mifos.customers.business.CustomerBO) GroupBO(org.mifos.customers.group.business.GroupBO) CenterBO(org.mifos.customers.center.business.CenterBO) Date(java.util.Date) LocalDate(org.joda.time.LocalDate)

Example 65 with CenterBO

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

the class AccountBOIntegrationTest method testGetPastInstallments.

@Test
public void testGetPastInstallments() {
    MeetingBO meeting = TestObjectFactory.createMeeting(TestObjectFactory.getTypicalMeeting());
    CenterBO centerBO = TestObjectFactory.createWeeklyFeeCenter("Center_Active", meeting);
    StaticHibernateUtil.flushAndClearSession();
    centerBO = TestObjectFactory.getCenter(centerBO.getCustomerId());
    for (AccountActionDateEntity actionDate : centerBO.getCustomerAccount().getAccountActionDates()) {
        actionDate.setActionDate(offSetCurrentDate(4));
        break;
    }
    List<AccountActionDateEntity> pastInstallments = centerBO.getCustomerAccount().getPastInstallments();
    Assert.assertNotNull(pastInstallments);
    Assert.assertEquals(1, pastInstallments.size());
    centerBO = null;
}
Also used : MeetingBO(org.mifos.application.meeting.business.MeetingBO) CenterBO(org.mifos.customers.center.business.CenterBO) 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