Search in sources :

Example 6 with CenterBO

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

the class LoanBOTestUtils method getLoanAccount.

private LoanBO getLoanAccount(final AccountState state, final Date startDate) {
    MeetingBO meeting = TestObjectFactory.createMeeting(TestObjectFactory.getNewMeetingForToday(WEEKLY, EVERY_WEEK, CUSTOMER_MEETING));
    CenterBO center = TestObjectFactory.createWeeklyFeeCenter(this.getClass().getSimpleName() + " Center", meeting);
    GroupBO group = TestObjectFactory.createWeeklyFeeGroupUnderCenter(this.getClass().getSimpleName() + " Group", CustomerStatus.GROUP_ACTIVE, center);
    LoanOfferingBO loanOffering = TestObjectFactory.createLoanOffering(startDate, meeting);
    final int disbursalType = 3;
    return TestObjectFactory.createLoanAccountWithDisbursement("99999999999", group, state, startDate, loanOffering, disbursalType);
}
Also used : MeetingBO(org.mifos.application.meeting.business.MeetingBO) LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO) CenterBO(org.mifos.customers.center.business.CenterBO) GroupBO(org.mifos.customers.group.business.GroupBO)

Example 7 with CenterBO

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

the class GroupServiceFacadeWebTier method createNewGroup.

@Override
public CustomerDetailsDto createNewGroup(GroupCreationDetail groupCreationDetail, MeetingDto meetingDto) {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = toUserContext(user);
    OfficeBO userOffice = this.officeDao.findOfficeById(userContext.getBranchId());
    userContext.setBranchGlobalNum(userOffice.getGlobalOfficeNum());
    GroupBO group;
    try {
        List<AccountFeesEntity> feesForCustomerAccount = convertFeeViewsToAccountFeeEntities(groupCreationDetail.getFeesToApply());
        PersonnelBO formedBy = this.personnelDao.findPersonnelById(groupCreationDetail.getLoanOfficerId());
        Short officeId;
        String groupName = groupCreationDetail.getDisplayName();
        CustomerStatus customerStatus = CustomerStatus.fromInt(groupCreationDetail.getCustomerStatus());
        String externalId = groupCreationDetail.getExternalId();
        boolean trained = groupCreationDetail.isTrained();
        DateTime trainedOn = groupCreationDetail.getTrainedOn();
        DateTime mfiJoiningDate = groupCreationDetail.getMfiJoiningDate();
        DateTime activationDate = groupCreationDetail.getActivationDate();
        AddressDto dto = groupCreationDetail.getAddressDto();
        Address address = null;
        if (dto != null) {
            address = new Address(dto.getLine1(), dto.getLine2(), dto.getLine3(), dto.getCity(), dto.getState(), dto.getCountry(), dto.getZip(), dto.getPhoneNumber());
        }
        MeetingBO groupMeeting = null;
        if (meetingDto != null) {
            groupMeeting = new MeetingFactory().create(meetingDto);
            groupMeeting.setUserContext(userContext);
        }
        if (ClientRules.getCenterHierarchyExists()) {
            CenterBO parentCustomer = this.customerDao.findCenterBySystemId(groupCreationDetail.getParentSystemId());
            //                loanOfficerId = parentCustomer.getPersonnel().getPersonnelId();
            officeId = parentCustomer.getOffice().getOfficeId();
            groupMeeting = parentCustomer.getCustomerMeetingValue();
            group = GroupBO.createGroupWithCenterAsParent(userContext, groupName, formedBy, parentCustomer, address, externalId, trained, trainedOn, customerStatus, mfiJoiningDate, activationDate);
        } else {
            // create group without center as parent
            Short loanOfficerId = groupCreationDetail.getLoanOfficerId() != null ? groupCreationDetail.getLoanOfficerId() : userContext.getId();
            officeId = groupCreationDetail.getOfficeId();
            OfficeBO office = this.officeDao.findOfficeById(groupCreationDetail.getOfficeId());
            PersonnelBO loanOfficer = this.personnelDao.findPersonnelById(loanOfficerId);
            int numberOfCustomersInOfficeAlready = customerDao.retrieveLastSearchIdValueForNonParentCustomersInOffice(officeId);
            group = GroupBO.createGroupAsTopOfCustomerHierarchy(userContext, groupName, formedBy, groupMeeting, loanOfficer, office, address, externalId, trained, trainedOn, customerStatus, numberOfCustomersInOfficeAlready, mfiJoiningDate, activationDate);
        }
        try {
            personnelDao.checkAccessPermission(userContext, group.getOfficeId(), group.getLoanOfficerId());
        } catch (AccountException e) {
            throw new MifosRuntimeException("Access denied!", e);
        }
        this.customerService.createGroup(group, groupMeeting, feesForCustomerAccount);
        return new CustomerDetailsDto(group.getCustomerId(), group.getGlobalCustNum());
    } catch (CustomerException e) {
        throw new BusinessRuleException(e.getKey(), e);
    }
}
Also used : CustomerException(org.mifos.customers.exceptions.CustomerException) Address(org.mifos.framework.business.util.Address) UserContext(org.mifos.security.util.UserContext) MeetingBO(org.mifos.application.meeting.business.MeetingBO) CenterBO(org.mifos.customers.center.business.CenterBO) MifosUser(org.mifos.security.MifosUser) CustomerAddressDto(org.mifos.dto.domain.CustomerAddressDto) AddressDto(org.mifos.dto.domain.AddressDto) MeetingFactory(org.mifos.application.meeting.business.MeetingFactory) DateTime(org.joda.time.DateTime) BusinessRuleException(org.mifos.service.BusinessRuleException) AccountException(org.mifos.accounts.exceptions.AccountException) OfficeBO(org.mifos.customers.office.business.OfficeBO) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) CustomerStatus(org.mifos.customers.util.helpers.CustomerStatus) GroupBO(org.mifos.customers.group.business.GroupBO) CustomerDetailsDto(org.mifos.dto.domain.CustomerDetailsDto) AccountFeesEntity(org.mifos.accounts.business.AccountFeesEntity) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 8 with CenterBO

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

the class GroupServiceFacadeWebTier method transferGroupToCenter.

@Override
public CustomerDetailDto transferGroupToCenter(String groupSystemId, String centerSystemId, Integer previousGroupVersionNo) {
    try {
        MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        UserContext userContext = toUserContext(user);
        CenterBO transferToCenter = this.customerDao.findCenterBySystemId(centerSystemId);
        transferToCenter.updateDetails(userContext);
        GroupBO group = this.customerDao.findGroupBySystemId(groupSystemId);
        group.updateDetails(userContext);
        checkVersionMismatch(previousGroupVersionNo, group.getVersionNo());
        String groupGlobalCustNum = this.customerService.transferGroupTo(group, transferToCenter);
        GroupBO transferedGroup = this.customerDao.findGroupBySystemId(groupGlobalCustNum);
        return transferedGroup.toCustomerDetailDto();
    } catch (ApplicationException e) {
        throw new BusinessRuleException(e.getKey(), e);
    }
}
Also used : BusinessRuleException(org.mifos.service.BusinessRuleException) ApplicationException(org.mifos.framework.exceptions.ApplicationException) UserContext(org.mifos.security.util.UserContext) CenterBO(org.mifos.customers.center.business.CenterBO) GroupBO(org.mifos.customers.group.business.GroupBO) MifosUser(org.mifos.security.MifosUser)

Example 9 with CenterBO

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

the class DashboardServiceFacadeWebTier method centerBOtoDashboardDetailDtos.

private List<DashboardDetailDto> centerBOtoDashboardDetailDtos(List<CenterBO> centerBOList) {
    List<DashboardDetailDto> groupDtoList = new ArrayList<DashboardDetailDto>();
    DashboardDetailDto dto;
    for (CenterBO centerBO : centerBOList) {
        dto = new DashboardDetailDto();
        dto.setGlobalNumber(centerBO.getGlobalCustNum());
        dto.setState(centerBO.getCustomerStatus().getName());
        dto.setUrl("viewCenterDetails.ftl?globalCustNum=" + dto.getGlobalNumber());
        dto.setLoanOfficer(centerBO.getPersonnel().getDisplayName());
        dto.setBalance(centerBO.getLoanBalance(Money.getDefaultCurrency()).toString());
        dto.setDisplayName(centerBO.getDisplayName());
        groupDtoList.add(dto);
    }
    return groupDtoList;
}
Also used : DashboardDetailDto(org.mifos.dto.domain.DashboardDetailDto) ArrayList(java.util.ArrayList) CenterBO(org.mifos.customers.center.business.CenterBO)

Example 10 with CenterBO

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

the class CenterCustAction method manage.

// NOTE edit center details
@TransactionDemarcate(joinToken = true)
public ActionForward manage(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    CenterCustActionForm actionForm = (CenterCustActionForm) form;
    actionForm.clearActionFormFields();
    CenterBO center = (CenterBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
    final Integer centerId = center.getCustomerId();
    center = this.customerDao.findCenterBySystemId(center.getGlobalCustNum());
    SessionUtils.setAttribute(Constants.BUSINESS_KEY, null, request);
    CenterDto centerDto = this.centerServiceFacade.retrieveCenterDetailsForUpdate(centerId);
    actionForm.setLoanOfficerId(centerDto.getLoanOfficerIdAsString());
    actionForm.setCustomerId(centerDto.getCustomerIdAsString());
    actionForm.setGlobalCustNum(centerDto.getGlobalCustNum());
    actionForm.setExternalId(centerDto.getExternalId());
    actionForm.setMfiJoiningDate(centerDto.getMfiJoiningDateAsString());
    actionForm.setMfiJoiningDate(centerDto.getMfiJoiningDate().getDayOfMonth(), centerDto.getMfiJoiningDate().getMonthOfYear(), centerDto.getMfiJoiningDate().getYear());
    actionForm.setAddress(center.getAddress());
    actionForm.setCustomerPositions(centerDto.getCustomerPositionViews());
    actionForm.setCustomFields(new ArrayList<CustomFieldDto>());
    SessionUtils.setAttribute(Constants.BUSINESS_KEY, center, request);
    SessionUtils.setCollectionAttribute(CustomerConstants.LOAN_OFFICER_LIST, centerDto.getActiveLoanOfficersForBranch(), request);
    SessionUtils.setCollectionAttribute(CustomerConstants.CUSTOM_FIELDS_LIST, new ArrayList<CustomFieldDto>(), request);
    SessionUtils.setCollectionAttribute(CustomerConstants.POSITIONS, centerDto.getCustomerPositionViews(), request);
    SessionUtils.setCollectionAttribute(CustomerConstants.CLIENT_LIST, centerDto.getClientList(), request);
    return mapping.findForward(ActionForwards.manage_success.toString());
}
Also used : CenterCustActionForm(org.mifos.customers.center.struts.actionforms.CenterCustActionForm) CustomFieldDto(org.mifos.dto.domain.CustomFieldDto) CenterBO(org.mifos.customers.center.business.CenterBO) CenterDto(org.mifos.dto.domain.CenterDto) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

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