use of org.mifos.customers.client.business.ClientBO in project head by mifos.
the class PictureFormFile method updatePersonalInfo.
@CloseSession
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward updatePersonalInfo(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
ClientCustActionForm actionForm = (ClientCustActionForm) form;
ClientBO clientInSession = getClientFromSession(request);
Integer oldClientVersionNumber = clientInSession.getVersionNo();
Integer customerId = clientInSession.getCustomerId();
String clientStatus = clientInSession.getCustomerStatus().getName();
List<CustomFieldDto> customFields = new ArrayList<CustomFieldDto>();
short loanOfficerId = clientInSession.getCreatedBy();
final String clientSystemId = clientInSession.getGlobalCustNum();
ClientPersonalInfoDto clientPersonalInfo = this.clientServiceFacade.retrieveClientPersonalInfoForUpdate(clientSystemId, clientStatus, loanOfficerId);
AddressDto address = null;
if (actionForm.getAddress() != null) {
address = Address.toDto(actionForm.getAddress());
}
if (clientPersonalInfo.getCustomerDetail() != null) {
if (clientPersonalInfo.getCustomerDetail().getAddress() != null) {
if (clientPersonalInfo.getCustomerDetail().getAddress().getPhoneNumber() != null && (!clientPersonalInfo.getCustomerDetail().getAddress().getPhoneNumber().equals(address.getPhoneNumber()))) {
UserContext userContext = getUserContext(request);
if (!ActivityMapper.getInstance().isEditPhoneNumberPermitted(userContext, userContext.getBranchId())) {
throw new CustomerException(SecurityConstants.KEY_ACTIVITY_NOT_ALLOWED);
}
} else if (clientPersonalInfo.getCustomerDetail().getAddress().getPhoneNumber() == null && address.getPhoneNumber() != null && !address.getPhoneNumber().equals("")) {
UserContext userContext = getUserContext(request);
if (!ActivityMapper.getInstance().isEditPhoneNumberPermitted(userContext, userContext.getBranchId())) {
throw new CustomerException(SecurityConstants.KEY_ACTIVITY_NOT_ALLOWED);
}
}
} else if (address.getPhoneNumber() != null && !address.getPhoneNumber().equals("")) {
UserContext userContext = getUserContext(request);
if (!ActivityMapper.getInstance().isEditPhoneNumberPermitted(userContext, userContext.getBranchId())) {
throw new CustomerException(SecurityConstants.KEY_ACTIVITY_NOT_ALLOWED);
}
}
} else if (address.getPhoneNumber() != null && !address.getPhoneNumber().equals("")) {
UserContext userContext = getUserContext(request);
if (!ActivityMapper.getInstance().isEditPhoneNumberPermitted(userContext, userContext.getBranchId())) {
throw new CustomerException(SecurityConstants.KEY_ACTIVITY_NOT_ALLOWED);
}
}
ClientNameDetailDto spouseFather = null;
if (!ClientRules.isFamilyDetailsRequired()) {
spouseFather = actionForm.getSpouseName();
}
InputStream picture = null;
if (actionForm.getPicture() != null && StringUtils.isNotBlank(actionForm.getPicture().getFileName())) {
picture = actionForm.getCustomerPicture();
}
ClientNameDetailDto clientNameDetails = actionForm.getClientName();
ClientPersonalDetailDto clientDetail = actionForm.getClientDetailView();
String governmentId = actionForm.getGovernmentId();
String clientDisplayName = actionForm.getClientName().getDisplayName();
String dateOfBirth = actionForm.getDateOfBirth();
ClientPersonalInfoUpdate personalInfo = new ClientPersonalInfoUpdate(customerId, oldClientVersionNumber, customFields, address, clientDetail, clientNameDetails, spouseFather, picture, governmentId, clientDisplayName, dateOfBirth);
this.clientServiceFacade.updateClientPersonalInfo(personalInfo, clientStatus, loanOfficerId);
return mapping.findForward(ActionForwards.updatePersonalInfo_success.toString());
}
use of org.mifos.customers.client.business.ClientBO in project head by mifos.
the class PictureFormFile method editMfiInfo.
@TransactionDemarcate(joinToken = true)
public ActionForward editMfiInfo(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
ClientCustActionForm actionForm = (ClientCustActionForm) form;
actionForm.clearMostButNotAllFieldsOnActionForm();
ClientBO clientFromSession = getClientFromSession(request);
String clientSystemId = clientFromSession.getGlobalCustNum();
ClientMfiInfoDto mfiInfoDto = this.clientServiceFacade.retrieveMfiInfoForEdit(clientSystemId);
SessionUtils.setAttribute(GroupConstants.CENTER_HIERARCHY_EXIST, ClientRules.getCenterHierarchyExists(), request);
SessionUtils.setCollectionAttribute(CustomerConstants.LOAN_OFFICER_LIST, mfiInfoDto.getLoanOfficersList(), request);
actionForm.setGroupDisplayName(mfiInfoDto.getGroupDisplayName());
actionForm.setCenterDisplayName(mfiInfoDto.getCenterDisplayName());
actionForm.setLoanOfficerId(mfiInfoDto.getCustomerDetail().getLoanOfficerIdAsString());
actionForm.setCustomerId(mfiInfoDto.getCustomerDetail().getCustomerId().toString());
actionForm.setGlobalCustNum(mfiInfoDto.getCustomerDetail().getGlobalCustNum());
actionForm.setExternalId(mfiInfoDto.getCustomerDetail().getExternalId());
actionForm.setGroupFlag(mfiInfoDto.getClientDetail().getGroupFlagAsString());
actionForm.setParentGroupId(mfiInfoDto.getClientDetail().getParentGroupId().toString());
actionForm.setTrained(mfiInfoDto.getClientDetail().getTrainedAsString());
actionForm.setTrainedDate(mfiInfoDto.getClientDetail().getTrainedDate());
actionForm.setDateOfBirth(clientFromSession.getDateOfBirth());
ClientBO client = this.customerDao.findClientBySystemId(clientSystemId);
SessionUtils.removeThenSetAttribute(Constants.BUSINESS_KEY, client, request);
return mapping.findForward(ActionForwards.editMfiInfo_success.toString());
}
use of org.mifos.customers.client.business.ClientBO in project head by mifos.
the class ClientTransferAction method updateParent.
@CloseSession
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward updateParent(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
ClientTransferActionForm actionForm = (ClientTransferActionForm) form;
ClientBO clientInSession = (ClientBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
String globalCustNum = this.clientServiceFacade.transferClientToGroup(actionForm.getParentGroupIdValue(), clientInSession.getGlobalCustNum(), clientInSession.getVersionNo());
ClientBO client = this.customerDao.findClientBySystemId(globalCustNum);
SessionUtils.setAttribute(Constants.BUSINESS_KEY, client, request);
return mapping.findForward(ActionForwards.update_success.toString());
}
use of org.mifos.customers.client.business.ClientBO in project head by mifos.
the class LoanAccountActionStrutsTest method testShouldPopulateClientDetailsFromLoan.
@Test
public void testShouldPopulateClientDetailsFromLoan() throws Exception {
ClientBO clientMock1 = createMock(ClientBO.class);
expect(clientMock1.getCustomerId()).andReturn(1).anyTimes();
expect(clientMock1.getDisplayName()).andReturn("client 1");
ClientBO clientMock2 = createMock(ClientBO.class);
expect(clientMock2.getCustomerId()).andReturn(2).anyTimes();
expect(clientMock2.getDisplayName()).andReturn("client 2");
LoanBO loanMock = createMock(LoanBO.class);
expect(loanMock.getCustomer()).andReturn(clientMock1).anyTimes();
expect(loanMock.getBusinessActivityId()).andReturn(3);
expect(loanMock.getLoanAmount()).andReturn(new Money(getCurrency(), "100")).anyTimes();
LoanAccountDetailsDto clientDetails1 = new LoanAccountDetailsDto();
clientDetails1.setClientId("1");
clientDetails1.setClientName("client 1");
clientDetails1.setBusinessActivity("3");
clientDetails1.setLoanAmount("100.0");
LoanAccountDetailsDto clientDetails2 = new LoanAccountDetailsDto();
clientDetails2.setClientId("2");
clientDetails2.setClientName("client 2");
replay(clientMock1, clientMock2, loanMock);
List<LoanAccountDetailsDto> clientDetails = new LoanAccountAction().populateClientDetailsFromLoan(Arrays.asList(clientMock1, clientMock2), Arrays.asList(loanMock), new ArrayList<ValueListElement>());
Assert.assertEquals(Arrays.asList(clientDetails1, clientDetails2), clientDetails);
verify(clientMock1, clientMock2, loanMock);
}
use of org.mifos.customers.client.business.ClientBO in project head by mifos.
the class LoanAccountActionIndividualLoansIntegrationTest method testShouldCallDeleteMethodIfExistingMembersRemoved.
@Test
public void testShouldCallDeleteMethodIfExistingMembersRemoved() throws Exception {
GlimLoanUpdater glimLoanUpdaterMock = createMock(GlimLoanUpdater.class);
LoanAccountAction loanAccountAction = new LoanAccountAction(ApplicationContextProvider.getBean(LoanBusinessService.class), new ConfigurationBusinessService(), glimLoanUpdaterMock);
LoanBO loanMock = createMock(LoanBO.class);
Locale locale = Locale.ENGLISH;
expect(loanMock.getAccountId()).andReturn(2).anyTimes();
ClientBO customerMock = createMock(ClientBO.class);
expect(loanMock.getCustomer()).andReturn(customerMock).anyTimes();
expect(customerMock.getGlobalCustNum()).andReturn("3").anyTimes();
LoanAccountActionForm loanAccountActionForm = new LoanAccountActionForm();
List<LoanAccountDetailsDto> clientDetails = new ArrayList<LoanAccountDetailsDto>();
List<LoanBO> loans = new ArrayList<LoanBO>();
loans.add(loanMock);
glimLoanUpdaterMock.delete(loanMock);
expectLastCall().atLeastOnce();
replay(glimLoanUpdaterMock, loanMock, customerMock);
loanAccountAction.handleIndividualLoans(loanMock, loanAccountActionForm, true, clientDetails, loans, locale);
verify(glimLoanUpdaterMock, loanMock, customerMock);
}
Aggregations