use of org.mifos.framework.exceptions.ServiceException in project head by mifos.
the class AccountApplyPaymentActionForm method validateModeOfPaymentSecurity.
private void validateModeOfPaymentSecurity(HttpServletRequest request, ActionErrors errors) {
UserContext userContext = (UserContext) SessionUtils.getAttribute(Constants.USER_CONTEXT_KEY, request.getSession());
AccountBO account = null;
Short personnelId = userContext.getId();
try {
if (accountId != null) {
account = new AccountBusinessService().getAccount(Integer.valueOf(accountId));
if (account.getPersonnel() != null) {
personnelId = account.getPersonnel().getPersonnelId();
}
}
} catch (NumberFormatException e) {
throw new MifosRuntimeException(e);
} catch (ServiceException e) {
throw new MifosRuntimeException(e);
}
if (getPaymentTypeId().equals("4") && !ActivityMapper.getInstance().isModeOfPaymentSecurity(userContext, personnelId)) {
errors.add(AccountConstants.LOAN_TRANSFER_PERMISSION, new ActionMessage(AccountConstants.LOAN_TRANSFER_PERMISSION, getLocalizedMessage("accounts.mode_of_payment_permission")));
}
}
use of org.mifos.framework.exceptions.ServiceException in project head by mifos.
the class BranchReportHelper method execute.
@Override
public void execute(long timeInMillis) throws BatchJobException {
Session session = StaticHibernateUtil.getSessionTL();
StaticHibernateUtil.startTransaction();
Date runDate = new Date(timeInMillis);
try {
removeExistingBranchReportsForGivenRunDate(runDate);
populateBranchReportBatch(session, runDate);
StaticHibernateUtil.commitTransaction();
} catch (HibernateException e) {
StaticHibernateUtil.rollbackTransaction();
throw new BatchJobException(e);
} catch (ServiceException e) {
throw new BatchJobException(e);
}
}
use of org.mifos.framework.exceptions.ServiceException in project head by mifos.
the class AccountBusinessService method getAppllicableFees.
public List<ApplicableCharge> getAppllicableFees(Integer accountId, UserContext userContext) throws ServiceException {
List<ApplicableCharge> applicableChargeList = null;
try {
AccountBO account = getlegacyAccountDao().getAccount(accountId);
FeeCategory categoryType = getCategoryType(account.getCustomer());
if (account.getType() == AccountTypes.LOAN_ACCOUNT || account.getType() == AccountTypes.GROUP_LOAN_ACCOUNT) {
applicableChargeList = getLoanApplicableCharges(getlegacyAccountDao().getAllApplicableFees(accountId, FeeCategory.LOAN), userContext, (LoanBO) account);
} else if (account.getType() == AccountTypes.CUSTOMER_ACCOUNT) {
if (account.getCustomer().getCustomerMeeting() == null) {
throw new ServiceException(AccountExceptionConstants.APPLY_CAHRGE_NO_CUSTOMER_MEETING_EXCEPTION);
}
applicableChargeList = getCustomerApplicableCharges(getlegacyAccountDao().getAllApplicableFees(accountId, categoryType), userContext, ((CustomerAccountBO) account).getCustomer().getCustomerMeeting().getMeeting().getMeetingDetails().getRecurrenceType().getRecurrenceId());
}
addMiscFeeAndPenalty(applicableChargeList);
} catch (PersistenceException pe) {
throw new ServiceException(pe);
}
return applicableChargeList;
}
use of org.mifos.framework.exceptions.ServiceException in project head by mifos.
the class WebTierAccountServiceFacade method applyMemberAccountHistoricalAdjustment.
/**
* adjustment for member account payment has to be handled along with parent account payments and other members payments.
* This method prepares data and run applyHistoricalAdjustment so adjustment will be made for parent payment context.
*/
@Override
@PreAuthorize("isFullyAuthenticated()")
public void applyMemberAccountHistoricalAdjustment(String memberGlobalAccountNum, Integer memberPaymentId, String adjustmentNote, Short personnelId, AdjustedPaymentDto adjustedPaymentDto) {
try {
LoanBO memberAccount = (LoanBO) accountBusinessService.findBySystemId(memberGlobalAccountNum);
LoanBO parentAccount = memberAccount.getParentAccount();
if (parentAccount == null) {
throw new AccountException(LoanExceptionConstants.NO_PARENT_ACCOUNT_EXCEPTION);
}
AccountPaymentEntity parentPaymentEntity = memberAccount.findParentPaymentByMemberPaymentId(memberPaymentId);
List<AdjustedPaymentDto> membersAdjustedPaymentDtoList = new ArrayList<AdjustedPaymentDto>();
for (AccountPaymentEntity memberPayment : parentPaymentEntity.getMemberPayments()) {
if (memberPayment.getAccount().getAccountId().equals(memberAccount.getAccountId())) {
membersAdjustedPaymentDtoList.add(new AdjustedPaymentDto(adjustedPaymentDto.getAmount(), adjustedPaymentDto.getPaymentDate(), adjustedPaymentDto.getPaymentType(), memberAccount.getAccountId()));
} else {
membersAdjustedPaymentDtoList.add(new AdjustedPaymentDto(memberPayment.getAmount().getAmount().toString(), adjustedPaymentDto.getPaymentDate(), adjustedPaymentDto.getPaymentType(), memberPayment.getAccount().getAccountId()));
}
}
BigDecimal parentAmountSubstraction = memberAccount.findPaymentById(memberPaymentId).getAmount().getAmount().subtract((new BigDecimal(adjustedPaymentDto.getAmount())));
String newParentAmount = parentPaymentEntity.getAmount().getAmount().subtract(parentAmountSubstraction).toString();
AdjustedPaymentDto parentAdjustedPaymentDto = new AdjustedPaymentDto(newParentAmount, adjustedPaymentDto.getPaymentDate(), adjustedPaymentDto.getPaymentType(), parentAccount.getAccountId(), membersAdjustedPaymentDtoList);
this.applyHistoricalAdjustment(parentAccount.getGlobalAccountNum(), parentPaymentEntity.getPaymentId(), adjustmentNote, personnelId, parentAdjustedPaymentDto);
} catch (ServiceException e) {
throw new MifosRuntimeException(e);
} catch (AccountException e) {
throw new MifosRuntimeException(e);
}
}
use of org.mifos.framework.exceptions.ServiceException in project head by mifos.
the class WebTierAccountServiceFacade method getActiveSavingsAccountsForClientByLoanId.
@Override
public List<SavingsDetailDto> getActiveSavingsAccountsForClientByLoanId(Integer loanAccountId) {
try {
AccountBO account = accountBusinessService.getAccount(loanAccountId);
CustomerDto customer = account.getCustomer().toCustomerDto();
List<SavingsDetailDto> savingsInUse = clientServiceFacade.retrieveSavingsInUseForClient(customer.getCustomerId());
List<SavingsDetailDto> accountsForTransfer = new ArrayList<SavingsDetailDto>();
if (savingsInUse != null) {
for (SavingsDetailDto savingsAccount : savingsInUse) {
if (savingsAccount.getAccountStateId().equals(AccountState.SAVINGS_ACTIVE.getValue())) {
accountsForTransfer.add(savingsAccount);
}
}
}
return accountsForTransfer;
} catch (ServiceException e) {
throw new MifosRuntimeException(e);
}
}
Aggregations