use of org.mifos.service.BusinessRuleException in project head by mifos.
the class CheckListServiceFacadeWebTier method updateAccountChecklist.
@Override
public void updateAccountChecklist(Short checklistId, Short productId, Short stateId, Short checklistStatus, String checklistName, List<String> checklistDetails) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = new UserContextFactory().create(user);
try {
ProductTypeEntity productTypeEntity = null;
for (ProductTypeEntity prdTypeEntity : new ProductCategoryBusinessService().getProductTypes()) {
if (productId.equals(prdTypeEntity.getProductTypeID())) {
productTypeEntity = prdTypeEntity;
break;
}
}
hibernateTransactionHelper.startTransaction();
AccountStateEntity accountStateEntity = new AccountStateEntity(AccountState.fromShort(stateId));
AccountCheckListBO accountCheckList = (AccountCheckListBO) new CheckListPersistence().getCheckList(checklistId);
accountCheckList.update(productTypeEntity, accountStateEntity, checklistName, checklistStatus, checklistDetails, userContext.getLocaleId(), userContext.getId());
customerDao.save(accountCheckList);
hibernateTransactionHelper.commitTransaction();
} catch (ServiceException e) {
hibernateTransactionHelper.rollbackTransaction();
throw new MifosRuntimeException(e);
} catch (CheckListException e) {
hibernateTransactionHelper.rollbackTransaction();
throw new BusinessRuleException(e.getKey(), e);
} catch (PersistenceException e) {
hibernateTransactionHelper.rollbackTransaction();
throw new MifosRuntimeException(e);
} finally {
hibernateTransactionHelper.closeSession();
}
}
use of org.mifos.service.BusinessRuleException 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.service.BusinessRuleException in project head by mifos.
the class LoanAccountServiceFacadeWebTier method createNewMeetingForRepaymentDay.
private MeetingBO createNewMeetingForRepaymentDay(LocalDate disbursementDate, RecurringSchedule recurringSchedule, CustomerBO customer) {
MeetingBO newMeetingForRepaymentDay = null;
final int minDaysInterval = configurationPersistence.getConfigurationValueInteger(MIN_DAYS_BETWEEN_DISBURSAL_AND_FIRST_REPAYMENT_DAY);
final Date repaymentStartDate = disbursementDate.plusDays(minDaysInterval).toDateMidnight().toDateTime().toDate();
try {
if (recurringSchedule.isWeekly()) {
WeekDay weekDay = WeekDay.getWeekDay(recurringSchedule.getDay().shortValue());
Short recurEvery = recurringSchedule.getEvery().shortValue();
newMeetingForRepaymentDay = new MeetingBO(weekDay, recurEvery, repaymentStartDate, MeetingType.LOAN_INSTALLMENT, customer.getCustomerMeeting().getMeeting().getMeetingPlace());
} else if (recurringSchedule.isMonthly()) {
if (recurringSchedule.isMonthlyOnDayOfMonth()) {
Short dayOfMonth = recurringSchedule.getDay().shortValue();
Short dayRecurMonth = recurringSchedule.getEvery().shortValue();
newMeetingForRepaymentDay = new MeetingBO(dayOfMonth, dayRecurMonth, repaymentStartDate, MeetingType.LOAN_INSTALLMENT, customer.getCustomerMeeting().getMeeting().getMeetingPlace());
} else {
Short weekOfMonth = recurringSchedule.getDay().shortValue();
Short monthRank = recurringSchedule.getWeek().shortValue();
Short everyMonth = recurringSchedule.getEvery().shortValue();
newMeetingForRepaymentDay = new MeetingBO(weekOfMonth, everyMonth, repaymentStartDate, MeetingType.LOAN_INSTALLMENT, customer.getCustomerMeeting().getMeeting().getMeetingPlace(), monthRank);
}
} else {
Short recurEvery = recurringSchedule.getEvery().shortValue();
newMeetingForRepaymentDay = new MeetingBO(recurEvery, repaymentStartDate, MeetingType.LOAN_INSTALLMENT, customer.getCustomerMeeting().getMeeting().getMeetingPlace());
}
return newMeetingForRepaymentDay;
} catch (NumberFormatException nfe) {
throw new MifosRuntimeException(nfe);
} catch (MeetingException me) {
throw new BusinessRuleException(me.getKey(), me);
}
}
use of org.mifos.service.BusinessRuleException in project head by mifos.
the class LoanAccountServiceFacadeWebTier method retrieveMultipleLoanAccountDetails.
@Override
public MultipleLoanAccountDetailsDto retrieveMultipleLoanAccountDetails(String searchId, Short branchId, Integer productId) {
List<ClientBO> clients = this.customerDao.findActiveClientsUnderParent(searchId, branchId);
if (clients.isEmpty()) {
throw new BusinessRuleException(LoanConstants.NOSEARCHRESULTS);
}
LoanOfferingBO loanOffering = this.loanProductDao.findById(productId);
// FIXME - Refactor MultipleLoanCreationDto into proper Dto
List<MultipleLoanCreationDto> multipleLoanDetails = buildClientViewHelper(loanOffering, clients);
List<ValueListElement> allLoanPruposes = this.loanProductDao.findAllLoanPurposes();
boolean loanPendingApprovalStateEnabled = ProcessFlowRules.isLoanPendingApprovalStateEnabled();
return new MultipleLoanAccountDetailsDto(allLoanPruposes, loanPendingApprovalStateEnabled);
}
use of org.mifos.service.BusinessRuleException in project head by mifos.
the class LoanAccountServiceFacadeWebTier method updateLoanAccountStatus.
@Override
public String updateLoanAccountStatus(AccountUpdateStatus updateStatus, Date transactionDate) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
PersonnelBO loggedInUser = this.personnelDao.findPersonnelById(userContext.getId());
LoanBO loanAccount = this.loanDao.findById(updateStatus.getSavingsId().intValue());
loanAccount.updateDetails(userContext);
try {
this.transactionHelper.startTransaction();
this.transactionHelper.beginAuditLoggingFor(loanAccount);
AccountState newStatus = AccountState.fromShort(updateStatus.getNewStatusId());
loanAccount.changeStatus(newStatus, updateStatus.getFlagId(), updateStatus.getComment(), loggedInUser, transactionDate);
this.loanDao.save(loanAccount);
this.transactionHelper.commitTransaction();
return loanAccount.getGlobalAccountNum();
} catch (BusinessRuleException e) {
this.transactionHelper.rollbackTransaction();
throw new BusinessRuleException(e.getMessageKey(), e);
} catch (Exception e) {
this.transactionHelper.rollbackTransaction();
throw new MifosRuntimeException(e);
} finally {
this.transactionHelper.closeSession();
}
}
Aggregations