use of org.mifos.customers.exceptions.CustomerException in project head by mifos.
the class GroupPersistence method saveGroup.
/**
* @deprecated - use {@link CustomerService#createGroup(GroupBO, org.mifos.application.meeting.business.MeetingBO, List)}.
* use {@link CustomerDao#save(org.mifos.customers.business.CustomerBO)}.
*/
@Deprecated
public void saveGroup(GroupBO groupBo) throws CustomerException {
CustomerPersistence customerPersistence = new CustomerPersistence();
customerPersistence.saveCustomer(groupBo);
try {
if (groupBo.getParentCustomer() != null) {
customerPersistence.createOrUpdate(groupBo.getParentCustomer());
}
} catch (PersistenceException pe) {
throw new CustomerException(CustomerConstants.CREATE_FAILED_EXCEPTION, pe);
}
}
use of org.mifos.customers.exceptions.CustomerException in project head by mifos.
the class ClientServiceFacadeWebTier method updateClientPersonalInfo.
@Override
public void updateClientPersonalInfo(ClientPersonalInfoUpdate personalInfo, String clientStatus, short loanOfficerId) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
try {
this.customerService.updateClientPersonalInfo(userContext, personalInfo);
} catch (CustomerException e) {
throw new BusinessRuleException(e.getKey(), e);
}
}
use of org.mifos.customers.exceptions.CustomerException in project head by mifos.
the class ClientServiceFacadeWebTier method createNewClient.
@Override
public CustomerDetailsDto createNewClient(ClientCreationDetail clientCreationDetail, MeetingDto meetingDto, List<SavingsDetailDto> allowedSavingProducts) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
OfficeBO userOffice = this.officeDao.findOfficeById(userContext.getBranchId());
userContext.setBranchGlobalNum(userOffice.getGlobalOfficeNum());
try {
ClientBO client = null;
List<AccountFeesEntity> feesForCustomerAccount = convertFeeViewsToAccountFeeEntities(clientCreationDetail.getFeesToApply());
List<SavingsOfferingBO> selectedOfferings = new ArrayList<SavingsOfferingBO>();
for (Short productId : clientCreationDetail.getSelectedSavingProducts()) {
if (productId != null) {
for (SavingsDetailDto savingsOffering : allowedSavingProducts) {
if (productId.equals(savingsOffering.getPrdOfferingId())) {
SavingsOfferingBO savingsProduct = savingsProductDao.findById(productId.intValue());
selectedOfferings.add(savingsProduct);
}
}
}
}
List<ClientInitialSavingsOfferingEntity> offeringsAssociatedInCreate = new ArrayList<ClientInitialSavingsOfferingEntity>();
for (SavingsOfferingBO offering : selectedOfferings) {
offeringsAssociatedInCreate.add(new ClientInitialSavingsOfferingEntity(null, offering));
}
Short personnelId = null;
Short officeId = null;
ClientNameDetailDto spouseNameDetailView = null;
if (ClientRules.isFamilyDetailsRequired()) {
// actionForm.setFamilyDateOfBirth();
// actionForm.constructFamilyDetails();
} else {
spouseNameDetailView = clientCreationDetail.getSpouseFatherName();
}
String secondMiddleName = null;
ClientNameDetailEntity clientNameDetailEntity = new ClientNameDetailEntity(null, secondMiddleName, clientCreationDetail.getClientNameDetailDto());
ClientNameDetailEntity spouseFatherNameDetailEntity = null;
if (spouseNameDetailView != null) {
spouseFatherNameDetailEntity = new ClientNameDetailEntity(null, secondMiddleName, spouseNameDetailView);
}
ClientDetailEntity clientDetailEntity = new ClientDetailEntity();
clientDetailEntity.updateClientDetails(clientCreationDetail.getClientPersonalDetailDto());
DateTime dob = new DateTime(clientCreationDetail.getDateOfBirth());
boolean trainedBool = clientCreationDetail.isTrained();
DateTime trainedDateTime = null;
if (clientCreationDetail.getTrainedDate() != null) {
trainedDateTime = new DateTime(clientCreationDetail.getTrainedDate());
}
String clientFirstName = clientCreationDetail.getClientNameDetailDto().getFirstName();
String clientLastName = clientCreationDetail.getClientNameDetailDto().getLastName();
String secondLastName = clientCreationDetail.getClientNameDetailDto().getSecondLastName();
CustomerStatus clientStatus = CustomerStatus.fromInt(clientCreationDetail.getClientStatus());
PersonnelBO formedBy = this.personnelDao.findPersonnelById(clientCreationDetail.getFormedBy());
Address address = null;
if (clientCreationDetail.getAddress() != null) {
AddressDto dto = clientCreationDetail.getAddress();
address = new Address(dto.getLine1(), dto.getLine2(), dto.getLine3(), dto.getCity(), dto.getState(), dto.getCountry(), dto.getZip(), dto.getPhoneNumber());
}
if (YesNoFlag.YES.getValue().equals(clientCreationDetail.getGroupFlag())) {
Integer parentGroupId = Integer.parseInt(clientCreationDetail.getParentGroupId());
CustomerBO group = this.customerDao.findCustomerById(parentGroupId);
if (group.getPersonnel() != null) {
personnelId = group.getPersonnel().getPersonnelId();
}
officeId = group.getOffice().getOfficeId();
client = ClientBO.createNewInGroupHierarchy(userContext, clientCreationDetail.getClientName(), clientStatus, new DateTime(clientCreationDetail.getMfiJoiningDate()), group, formedBy, clientNameDetailEntity, dob, clientCreationDetail.getGovernmentId(), trainedBool, trainedDateTime, clientCreationDetail.getGroupFlag(), clientFirstName, clientLastName, secondLastName, spouseFatherNameDetailEntity, clientDetailEntity, offeringsAssociatedInCreate, clientCreationDetail.getExternalId(), address, clientCreationDetail.getActivationDate());
if (ClientRules.isFamilyDetailsRequired()) {
client.setFamilyAndNameDetailSets(clientCreationDetail.getFamilyNames(), clientCreationDetail.getFamilyDetails());
}
this.customerService.createClient(client, client.getCustomerMeetingValue(), feesForCustomerAccount, selectedOfferings);
} else {
personnelId = clientCreationDetail.getLoanOfficerId();
officeId = clientCreationDetail.getOfficeId();
PersonnelBO loanOfficer = this.personnelDao.findPersonnelById(personnelId);
OfficeBO office = this.officeDao.findOfficeById(officeId);
int lastSearchIdCustomerValue = customerDao.retrieveLastSearchIdValueForNonParentCustomersInOffice(officeId);
MeetingBO clientMeeting = null;
if (meetingDto != null) {
clientMeeting = new MeetingFactory().create(meetingDto);
clientMeeting.setUserContext(userContext);
}
client = ClientBO.createNewOutOfGroupHierarchy(userContext, clientCreationDetail.getClientName(), clientStatus, new DateTime(clientCreationDetail.getMfiJoiningDate()), office, loanOfficer, clientMeeting, formedBy, clientNameDetailEntity, dob, clientCreationDetail.getGovernmentId(), trainedBool, trainedDateTime, clientCreationDetail.getGroupFlag(), clientFirstName, clientLastName, secondLastName, spouseFatherNameDetailEntity, clientDetailEntity, offeringsAssociatedInCreate, clientCreationDetail.getExternalId(), address, lastSearchIdCustomerValue);
if (ClientRules.isFamilyDetailsRequired()) {
client.setFamilyAndNameDetailSets(clientCreationDetail.getFamilyNames(), clientCreationDetail.getFamilyDetails());
}
try {
personnelDao.checkAccessPermission(userContext, client.getOfficeId(), client.getLoanOfficerId());
} catch (AccountException e) {
throw new MifosRuntimeException("Access denied!", e);
}
this.customerService.createClient(client, clientMeeting, feesForCustomerAccount, selectedOfferings);
}
clientPhotoService.create(client.getCustomerId().longValue(), clientCreationDetail.getPicture());
return new CustomerDetailsDto(client.getCustomerId(), client.getGlobalCustNum());
} catch (CustomerException e) {
throw new BusinessRuleException(e.getKey(), e.getValues(), e);
}
}
use of org.mifos.customers.exceptions.CustomerException in project head by mifos.
the class ClientServiceFacadeWebTier method updateClientMfiInfo.
@Override
public void updateClientMfiInfo(ClientMfiInfoUpdate clientMfiInfoUpdate) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
try {
this.customerService.updateClientMfiInfo(userContext, clientMfiInfoUpdate);
} catch (CustomerException e) {
throw new BusinessRuleException(e.getKey(), e);
}
}
use of org.mifos.customers.exceptions.CustomerException in project head by mifos.
the class CustomerServiceImpl method updateMeeting.
private boolean updateMeeting(final MeetingBO oldMeeting, final MeetingBO updatedDetails) throws CustomerException {
boolean isRegenerationOfSchedulesRequired = false;
try {
if (oldMeeting.isWeekly()) {
oldMeeting.setMeetingStartDate(updatedDetails.getMeetingStartDate());
WeekDay dayOfWeek = updatedDetails.getMeetingDetails().getWeekDay();
isRegenerationOfSchedulesRequired = oldMeeting.isDayOfWeekDifferent(dayOfWeek);
oldMeeting.update(dayOfWeek.getValue(), updatedDetails.getMeetingPlace());
oldMeeting.update(dayOfWeek, updatedDetails.getMeetingPlace());
} else if (oldMeeting.isDaily()) {
isRegenerationOfSchedulesRequired = false;
oldMeeting.update(updatedDetails.getMeetingPlace());
} else if (oldMeeting.isMonthlyOnDate()) {
isRegenerationOfSchedulesRequired = oldMeeting.isDayOfMonthDifferent(updatedDetails.getMeetingDetails().getDayNumber());
oldMeeting.update(updatedDetails.getMeetingDetails().getDayNumber(), updatedDetails.getMeetingPlace());
} else if (oldMeeting.isMonthly()) {
RankOfDay rankOfday = updatedDetails.getMeetingDetails().getWeekRank();
// WeekDay weekOfMonth = WeekDay.getWeekDay(updatedDetails.getMonthWeek());
WeekDay weekOfMonth = updatedDetails.getMeetingDetails().getWeekDay();
isRegenerationOfSchedulesRequired = oldMeeting.isWeekOfMonthDifferent(rankOfday, weekOfMonth);
oldMeeting.update(weekOfMonth, rankOfday, updatedDetails.getMeetingPlace());
}
} catch (MeetingException me) {
throw new CustomerException(me);
}
return isRegenerationOfSchedulesRequired;
}
Aggregations