use of org.mifos.framework.exceptions.ServiceException in project head by mifos.
the class CenterServiceFacadeWebTier method retrieveAccountTransactionHistory.
@Override
public List<TransactionHistoryDto> retrieveAccountTransactionHistory(String globalAccountNum) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
try {
AccountBO account = new AccountBusinessService().findBySystemId(globalAccountNum);
CustomerBO customerBO = account.getCustomer();
account.updateDetails(userContext);
personnelDao.checkAccessPermission(userContext, customerBO.getOfficeId(), customerBO.getLoanOfficerId());
List<TransactionHistoryDto> transactionHistories = account.getTransactionHistoryView();
for (TransactionHistoryDto transactionHistoryDto : transactionHistories) {
transactionHistoryDto.setUserPrefferedPostedDate(DateUtils.getUserLocaleDate(userContext.getPreferredLocale(), transactionHistoryDto.getPostedDate().toString()));
transactionHistoryDto.setUserPrefferedTransactionDate(DateUtils.getUserLocaleDate(userContext.getPreferredLocale(), transactionHistoryDto.getTransactionDate().toString()));
}
return transactionHistories;
} catch (ServiceException e) {
throw new MifosRuntimeException(e);
} catch (AccountException e) {
throw new MifosRuntimeException("Access denied!", e);
}
}
use of org.mifos.framework.exceptions.ServiceException in project head by mifos.
the class CheckListServiceFacadeWebTier method retreiveAllAccountCheckLists.
@Override
public List<AccountCheckBoxItemDto> retreiveAllAccountCheckLists() {
try {
List<AccountCheckListBO> accountCheckLists = new CheckListBusinessService().retreiveAllAccountCheckLists();
List<AccountCheckBoxItemDto> dtoList = new ArrayList<AccountCheckBoxItemDto>();
for (AccountCheckListBO bo : accountCheckLists) {
String lookUpName = bo.getAccountStateEntity().getLookUpValue() != null ? bo.getAccountStateEntity().getLookUpValue().getLookUpName() : null;
AccountCheckBoxItemDto dto = new AccountCheckBoxItemDto(bo.getChecklistId(), bo.getChecklistName(), bo.getChecklistStatus(), null, lookUpName, bo.getAccountStateEntity().getId(), bo.getProductTypeEntity().getProductTypeID());
if (dto.getLookUpName() != null) {
dto.setName(ApplicationContextProvider.getBean(MessageLookup.class).lookup(dto.getLookUpName()));
}
dtoList.add(dto);
}
return dtoList;
} catch (ServiceException e) {
throw new MifosRuntimeException(e);
}
}
use of org.mifos.framework.exceptions.ServiceException 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.framework.exceptions.ServiceException in project head by mifos.
the class EditStatusAction method update.
@TransactionDemarcate(validateAndResetToken = true)
@CloseSession
public ActionForward update(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
UserContext userContext = getUserContext(request);
EditStatusActionForm editStatusActionForm = (EditStatusActionForm) form;
Integer accountId = Integer.valueOf(editStatusActionForm.getAccountId());
AccountBO accountBO = new AccountBusinessService().getAccount(accountId);
Short flagId = null;
Short newStatusId = null;
String updateComment = editStatusActionForm.getNotes();
if (StringUtils.isNotBlank(editStatusActionForm.getFlagId())) {
flagId = getShortValue(editStatusActionForm.getFlagId());
}
if (StringUtils.isNotBlank(editStatusActionForm.getNewStatusId())) {
newStatusId = getShortValue(editStatusActionForm.getNewStatusId());
}
Date trxnDate = editStatusActionForm.getTransactionDateValue(userContext.getPreferredLocale());
if (editStatusActionForm.getNewStatusId().equals(AccountState.LOAN_APPROVED) && !AccountingRules.isBackDatedApprovalAllowed()) {
trxnDate = new DateTimeService().getCurrentJavaDateTime();
}
checkPermission(accountBO, getUserContext(request), newStatusId, flagId);
if (accountBO.isLoanAccount() || accountBO.isGroupLoanAccount()) {
initializeLoanQuestionnaire(accountBO.getGlobalAccountNum(), newStatusId != null ? newStatusId.toString() : null);
loanQuestionnaire.saveResponses(request, editStatusActionForm, accountId);
//GLIM
List<LoanBO> individualLoans = this.loanDao.findIndividualLoans(accountId);
List<AccountUpdateStatus> updateStatus = new ArrayList<AccountUpdateStatus>(individualLoans.size() + 1);
updateStatus.add(new AccountUpdateStatus(accountId.longValue(), newStatusId, flagId, updateComment));
for (LoanBO individual : individualLoans) {
updateStatus.add(new AccountUpdateStatus(individual.getAccountId().longValue(), newStatusId, flagId, updateComment));
}
try {
if (individualLoans.size() == 0) {
this.loanAccountServiceFacade.updateSingleLoanAccountStatus(updateStatus.get(0), trxnDate);
} else {
this.loanAccountServiceFacade.updateSeveralLoanAccountStatuses(updateStatus, trxnDate);
}
} catch (AccessDeniedException e) {
throw new ServiceException(SecurityConstants.KEY_ACTIVITY_APPROVE_LOAN_NOT_ALLOWED);
}
return mapping.findForward(ActionForwards.loan_detail_page.toString());
}
if (accountBO.isSavingsAccount()) {
AccountUpdateStatus updateStatus = new AccountUpdateStatus(accountId.longValue(), newStatusId, flagId, updateComment);
this.savingsServiceFacade.updateSavingsAccountStatus(updateStatus);
return mapping.findForward(ActionForwards.savings_details_page.toString());
}
// nothing but loan of savings account should be detected. customer account status change goes through separate action.
return null;
}
use of org.mifos.framework.exceptions.ServiceException in project head by mifos.
the class WebTierAccountServiceFacade method applyCharge.
@Override
public void applyCharge(Integer accountId, Short chargeId, Double chargeAmount, boolean isPenaltyType) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
try {
AccountBO account = new AccountBusinessService().getAccount(accountId);
if (account instanceof LoanBO && !account.isGroupLoanAccount()) {
List<LoanBO> individualLoans = this.loanDao.findIndividualLoans(account.getAccountId());
if (individualLoans != null && individualLoans.size() > 0) {
for (LoanBO individual : individualLoans) {
individual.updateDetails(userContext);
if (isPenaltyType && !chargeId.equals(Short.valueOf(AccountConstants.MISC_PENALTY))) {
PenaltyBO penalty = this.penaltyDao.findPenaltyById(chargeId.intValue());
individual.addAccountPenalty(new AccountPenaltiesEntity(individual, penalty, chargeAmount));
} else {
FeeBO fee = this.feeDao.findById(chargeId);
if (fee instanceof RateFeeBO) {
individual.applyCharge(chargeId, chargeAmount);
} else {
Double radio = individual.getLoanAmount().getAmount().doubleValue() / ((LoanBO) account).getLoanAmount().getAmount().doubleValue();
individual.applyCharge(chargeId, chargeAmount * radio);
}
}
}
}
}
account.updateDetails(userContext);
CustomerLevel customerLevel = null;
if (account.isCustomerAccount()) {
customerLevel = account.getCustomer().getLevel();
}
if (account.getPersonnel() != null) {
checkPermissionForApplyCharges(account.getType(), customerLevel, userContext, account.getOffice().getOfficeId(), account.getPersonnel().getPersonnelId());
} else {
checkPermissionForApplyCharges(account.getType(), customerLevel, userContext, account.getOffice().getOfficeId(), userContext.getId());
}
this.transactionHelper.startTransaction();
if (isPenaltyType && account instanceof LoanBO) {
PenaltyBO penalty = this.penaltyDao.findPenaltyById(chargeId.intValue());
((LoanBO) account).addAccountPenalty(new AccountPenaltiesEntity(account, penalty, chargeAmount));
} else {
account.applyCharge(chargeId, chargeAmount);
}
this.transactionHelper.commitTransaction();
} catch (ServiceException e) {
this.transactionHelper.rollbackTransaction();
throw new MifosRuntimeException(e);
} catch (ApplicationException e) {
this.transactionHelper.rollbackTransaction();
throw new BusinessRuleException(e.getKey(), e);
}
}
Aggregations