use of org.mifos.customers.client.business.ClientBO in project head by mifos.
the class GroupBO method updateSearchId.
/*
* This methed is used to regenerate the searchId for a group
* which has a bad searchId due to previous bugs (such as MIFOS-2737)
*/
public void updateSearchId() throws CustomerException {
generateSearchId();
update();
if (getChildren() != null) {
for (CustomerBO client : getChildren()) {
client.setUserContext(getUserContext());
((ClientBO) client).handleGroupTransfer();
}
}
}
use of org.mifos.customers.client.business.ClientBO in project head by mifos.
the class CustomerServiceImpl method transferClientTo.
@Override
public ClientBO transferClientTo(UserContext userContext, Integer groupId, String clientGlobalCustNum, Integer previousClientVersionNo) throws CustomerException {
ClientBO client = customerDao.findClientBySystemId(clientGlobalCustNum);
client.validateVersion(previousClientVersionNo);
client.validateIsSameGroup(groupId);
client.updateDetails(userContext);
GroupBO receivingGroup = (GroupBO) customerDao.findCustomerById(groupId);
client.validateReceivingGroup(receivingGroup);
client.validateForActiveAccounts();
client.validateForPeriodicFees();
if (client.getOfficeId() != receivingGroup.getOfficeId()) {
customerDao.checkPermissionforEditingClientOfficeMembership(client.getUserContext(), client);
}
CustomerBO oldParent = client.getParentCustomer();
try {
hibernateTransactionHelper.startTransaction();
hibernateTransactionHelper.beginAuditLoggingFor(client);
boolean regenerateSchedules = client.transferTo(receivingGroup);
if (oldParent != null) {
client.resetPositions(oldParent);
oldParent.updateDetails(client.getUserContext());
if (oldParent.getParentCustomer() != null) {
CustomerBO center = oldParent.getParentCustomer();
client.resetPositions(center);
center.setUserContext(client.getUserContext());
}
customerDao.save(oldParent);
}
receivingGroup.updateDetails(client.getUserContext());
customerDao.save(receivingGroup);
client.updateDetails(userContext);
customerDao.save(client);
hibernateTransactionHelper.flushAndClearSession();
if (regenerateSchedules) {
client = customerDao.findClientBySystemId(clientGlobalCustNum);
CalendarEvent calendarEvents = holidayDao.findCalendarEventsForThisYearAndNext(client.getOfficeId());
handleChangeInMeetingSchedule(client, calendarEvents.getWorkingDays(), calendarEvents.getHolidays());
}
hibernateTransactionHelper.commitTransaction();
return client;
} catch (ApplicationException e) {
this.hibernateTransactionHelper.rollbackTransaction();
throw new BusinessRuleException(e.getKey(), e);
} catch (Exception e) {
this.hibernateTransactionHelper.rollbackTransaction();
throw new MifosRuntimeException(e);
} finally {
this.hibernateTransactionHelper.closeSession();
}
}
use of org.mifos.customers.client.business.ClientBO in project head by mifos.
the class CustomerServiceImpl method updateClientPersonalInfo.
@Override
public final void updateClientPersonalInfo(UserContext userContext, ClientPersonalInfoUpdate personalInfo) throws CustomerException {
ClientBO client = (ClientBO) this.customerDao.findCustomerById(personalInfo.getCustomerId());
client.validateVersion(personalInfo.getOriginalClientVersionNumber());
client.updateDetails(userContext);
LocalDate currentDOB = new LocalDate(client.getDateOfBirth());
LocalDate newDOB = currentDOB;
try {
// updating Date of birth
// doesn''t sound normal but it can be required in certain cases
// see http://mifosforge.jira.com/browse/MIFOS-4368
newDOB = new LocalDate(DateUtils.getDateAsSentFromBrowser(personalInfo.getDateOfBirth()));
} catch (InvalidDateException e) {
throw new MifosRuntimeException(e);
}
if (!currentDOB.isEqual(newDOB)) {
customerDao.validateClientForDuplicateNameOrGovtId(personalInfo.getClientDisplayName(), newDOB.toDateMidnight().toDate(), null);
}
try {
hibernateTransactionHelper.startTransaction();
hibernateTransactionHelper.beginAuditLoggingFor(client);
client.updatePersonalInfo(personalInfo);
clientPhotoService.update(personalInfo.getCustomerId().longValue(), personalInfo.getPicture());
customerDao.save(client);
hibernateTransactionHelper.commitTransaction();
} catch (ApplicationException e) {
hibernateTransactionHelper.rollbackTransaction();
throw new CustomerException(e.getKey(), e);
} catch (Exception e) {
hibernateTransactionHelper.rollbackTransaction();
throw new MifosRuntimeException(e);
} finally {
hibernateTransactionHelper.commitTransaction();
}
}
use of org.mifos.customers.client.business.ClientBO in project head by mifos.
the class LoanAccountAction method findGovernmentId.
private String findGovernmentId(final Integer clientId) {
ClientBO client = (ClientBO) this.customerDao.findCustomerById(clientId);
String governmentId = client.getGovernmentId();
return StringUtils.isBlank(governmentId) ? "-" : governmentId;
}
use of org.mifos.customers.client.business.ClientBO in project head by mifos.
the class LoanAccountAction method populateClientDetailsFromLoan.
List<LoanAccountDetailsDto> populateClientDetailsFromLoan(final List<ClientBO> activeClientsUnderGroup, final List<LoanBO> individualLoans, final List<ValueListElement> businessActivities) {
List<LoanAccountDetailsDto> clientDetails = new ArrayList<LoanAccountDetailsDto>();
for (final ClientBO client : activeClientsUnderGroup) {
LoanAccountDetailsDto clientDetail = new LoanAccountDetailsDto();
clientDetail.setClientId(getStringValue(client.getCustomerId()));
clientDetail.setClientName(client.getDisplayName());
LoanBO loanAccount = (LoanBO) CollectionUtils.find(individualLoans, new Predicate() {
@Override
public boolean evaluate(final Object object) {
return client.getCustomerId().equals(((LoanBO) object).getCustomer().getCustomerId());
}
});
if (loanAccount != null) {
final Integer businessActivityId = loanAccount.getBusinessActivityId();
if (businessActivityId != null) {
clientDetail.setBusinessActivity(Integer.toString(businessActivityId));
ValueListElement businessActivityElement = (ValueListElement) CollectionUtils.find(businessActivities, new Predicate() {
@Override
public boolean evaluate(final Object object) {
return ((ValueListElement) object).getId().equals(businessActivityId);
}
});
if (businessActivityElement != null) {
clientDetail.setBusinessActivityName(businessActivityElement.getName());
}
}
clientDetail.setLoanAmount(loanAccount.getLoanAmount() != null ? loanAccount.getLoanAmount().toString() : "0.0");
}
clientDetails.add(clientDetail);
}
return clientDetails;
}
Aggregations