use of org.mifos.accounts.business.service.AccountBusinessService in project head by mifos.
the class SavingsServiceFacadeWebTier method retrieveDepositWithdrawalReferenceData.
@Override
public DepositWithdrawalReferenceDto retrieveDepositWithdrawalReferenceData(Long savingsId, Integer customerId) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
try {
SavingsBO savingsAccount = savingsDao.findById(savingsId);
String depositDue = savingsAccount.getTotalPaymentDue(customerId).toString();
String withdrawalDue = "0";
List<ListElement> clients = new ArrayList<ListElement>();
if (savingsAccount.isGroupModelWithIndividualAccountability()) {
List<CustomerBO> activeAndOnHoldClients = new CustomerPersistence().getActiveAndOnHoldChildren(savingsAccount.getCustomer().getSearchId(), savingsAccount.getCustomer().getOfficeId(), CustomerLevel.CLIENT);
for (CustomerBO client : activeAndOnHoldClients) {
clients.add(new ListElement(client.getCustomerId(), client.getDisplayName()));
}
}
List<AccountActionEntity> trxnTypes = new ArrayList<AccountActionEntity>();
trxnTypes.add(new AccountBusinessService().getAccountAction(AccountActionTypes.SAVINGS_DEPOSIT.getValue(), userContext.getLocaleId()));
trxnTypes.add(new AccountBusinessService().getAccountAction(AccountActionTypes.SAVINGS_WITHDRAWAL.getValue(), userContext.getLocaleId()));
List<ListElement> transactionTypes = new ArrayList<ListElement>();
for (AccountActionEntity accountActionEntity : trxnTypes) {
LookUpValueEntity lookupValue = accountActionEntity.getLookUpValue();
String messageText = lookupValue.getMessageText();
if (StringUtils.isBlank(messageText)) {
messageText = ApplicationContextProvider.getBean(MessageLookup.class).lookup(lookupValue.getPropertiesKey());
}
transactionTypes.add(new ListElement(accountActionEntity.getId().intValue(), messageText));
}
List<ListElement> depositPaymentTypes = retrieveDepositPaymentTypes(userContext);
List<ListElement> withdrawalPaymentTypes = new ArrayList<ListElement>();
List<PaymentTypeEntity> withdrawalPaymentEntityTypes = legacyAcceptedPaymentTypeDao.getAcceptedPaymentTypesForATransaction(userContext.getLocaleId(), TrxnTypes.savings_withdrawal.getValue());
for (PaymentTypeEntity paymentTypeEntity : withdrawalPaymentEntityTypes) {
LookUpValueEntity lookupValue = paymentTypeEntity.getLookUpValue();
String messageText = lookupValue.getMessageText();
if (StringUtils.isBlank(messageText)) {
messageText = ApplicationContextProvider.getBean(MessageLookup.class).lookup(lookupValue.getPropertiesKey());
}
withdrawalPaymentTypes.add(new ListElement(paymentTypeEntity.getId().intValue(), messageText));
}
boolean backDatedTransactionsAllowed = AccountingRules.isBackDatedTxnAllowed();
LocalDate defaultTransactionDate = new LocalDate();
return new DepositWithdrawalReferenceDto(transactionTypes, depositPaymentTypes, withdrawalPaymentTypes, clients, backDatedTransactionsAllowed, defaultTransactionDate, depositDue, withdrawalDue);
} catch (ServiceException e) {
throw new MifosRuntimeException(e);
} catch (PersistenceException e) {
throw new MifosRuntimeException(e);
}
}
use of org.mifos.accounts.business.service.AccountBusinessService in project head by mifos.
the class LoanAccountServiceFacadeWebTier method removeLoanPenalty.
@Override
public void removeLoanPenalty(Integer loanId, Short penaltyId) {
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = toUserContext(user);
try {
AccountBO account = new AccountBusinessService().getAccount(loanId);
if (account instanceof LoanBO) {
LoanBO loanAccount = (LoanBO) account;
List<LoanBO> individualLoans = this.loanDao.findIndividualLoans(account.getAccountId());
if (individualLoans != null && individualLoans.size() > 0) {
for (LoanBO individual : individualLoans) {
individual.updateDetails(userContext);
individual.removePenalty(penaltyId, userContext.getId());
this.customerDao.save(individual);
}
}
account.updateDetails(userContext);
if (account.getPersonnel() != null) {
new AccountBusinessService().checkPermissionForRemovePenalties(account.getType(), account.getCustomer().getLevel(), userContext, account.getOffice().getOfficeId(), account.getPersonnel().getPersonnelId());
} else {
new AccountBusinessService().checkPermissionForRemovePenalties(account.getType(), account.getCustomer().getLevel(), userContext, account.getOffice().getOfficeId(), userContext.getId());
}
this.transactionHelper.startTransaction();
loanAccount.removePenalty(penaltyId, userContext.getId());
this.loanDao.save(loanAccount);
this.transactionHelper.commitTransaction();
}
} catch (ServiceException e) {
this.transactionHelper.rollbackTransaction();
throw new MifosRuntimeException(e);
} catch (AccountException e) {
this.transactionHelper.rollbackTransaction();
throw new MifosRuntimeException(e);
} finally {
this.transactionHelper.closeSession();
}
}
use of org.mifos.accounts.business.service.AccountBusinessService in project head by mifos.
the class ApplyChargeActionForm method validate.
@Override
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
Locale locale = getUserContext(request).getPreferredLocale();
ActionErrors errors = new ActionErrors();
String methodCalled = request.getParameter(MethodNameConstants.METHOD);
boolean groupLoanWithMembers = AccountingRules.isGroupLoanWithMembers();
AccountBusinessService service = new AccountBusinessService();
AccountBO accountBO = null;
if (groupLoanWithMembers) {
try {
accountBO = service.getAccount(Integer.valueOf(getAccountId()));
} catch (ServiceException e) {
throw new MifosRuntimeException(e);
}
}
if (groupLoanWithMembers && accountBO.isParentGroupLoanAccount()) {
if (methodCalled != null && methodCalled.equals("divide")) {
if (StringUtils.isNotBlank(selectedChargeFormula)) {
validateRate(errors, request);
}
validateAmount(errors, locale);
}
if (methodCalled != null && methodCalled.equals("update")) {
validateHashMap(errors);
}
if (!errors.isEmpty()) {
request.setAttribute(Globals.ERROR_KEY, errors);
if (methodCalled.equals("divide")) {
request.setAttribute("methodCalled", "update");
} else if (methodCalled.equals("update")) {
request.setAttribute("methodCalled", "create");
} else {
request.setAttribute("methodCalled", methodCalled);
}
}
} else {
if (null != methodCalled) {
if ((Methods.update.toString()).equals(methodCalled)) {
if (StringUtils.isNotBlank(selectedChargeFormula)) {
validateRate(errors, request);
}
validateAmount(errors, locale);
}
}
if (!errors.isEmpty()) {
request.setAttribute(Globals.ERROR_KEY, errors);
request.setAttribute("methodCalled", methodCalled);
}
}
return errors;
}
use of org.mifos.accounts.business.service.AccountBusinessService in project head by mifos.
the class BirtAdminDocumentUploadAction method updateSelectedStatus.
@TransactionDemarcate(joinToken = true)
private void updateSelectedStatus(HttpServletRequest request, BirtAdminDocumentUploadActionForm uploadForm) throws PageExpiredException, ServiceException {
List selectList = null;
if (uploadForm.getStatusList() != null) {
Short accountTypeId = Short.valueOf(uploadForm.getAccountTypeId());
if (accountTypeId.shortValue() <= 2) {
selectList = new ArrayList<AccountStateEntity>();
List<AccountStateEntity> masterList = new AccountBusinessService().retrieveAllActiveAccountStateList(AccountTypes.getAccountType(accountTypeId));
for (AccountStateEntity product : masterList) {
for (String productStatusId : uploadForm.getStatusList()) {
if (productStatusId != null && product.getId().intValue() == Integer.valueOf(productStatusId).intValue()) {
selectList.add(product);
}
}
}
} else {
Short currentLocaleId = (Short) SessionUtils.getAttribute("CURRENT_LOCALE_ID", request);
selectList = new ArrayList<AccountActionEntity>();
List<AccountActionEntity> masterList = getAvailableLoanTransactions(currentLocaleId);
for (String accountActionId : uploadForm.getStatusList()) {
AccountActionTypes accountActionType = AccountActionTypes.fromInt(Integer.valueOf(accountActionId));
AccountActionEntity accountAction = new AccountBusinessService().getAccountAction(accountActionType.getValue(), currentLocaleId);
if (masterList.contains(accountAction)) {
selectList.add(accountAction);
}
}
}
}
SessionUtils.setCollectionAttribute("SelectedStatus", selectList, request);
}
use of org.mifos.accounts.business.service.AccountBusinessService in project head by mifos.
the class NotesAction method load.
@TransactionDemarcate(joinToken = true)
public ActionForward load(ActionMapping mapping, ActionForm form, @SuppressWarnings("unused") HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
clearActionForm(form);
NotesActionForm notesActionForm = (NotesActionForm) form;
Integer accountId = Integer.valueOf(notesActionForm.getAccountId());
AccountBO account = new AccountBusinessService().getAccount(accountId);
if (account.isLoanAccount() || account.isGroupLoanAccount()) {
LoanAccountDetailDto loanAccountDto = this.loanAccountServiceFacade.retrieveLoanAccountNotes(accountId.longValue());
if (account.isLoanAccount()) {
notesActionForm.setAccountTypeId(AccountTypes.LOAN_ACCOUNT.getValue().toString());
} else {
notesActionForm.setAccountTypeId(AccountTypes.GROUP_LOAN_ACCOUNT.getValue().toString());
}
notesActionForm.setGlobalAccountNum(loanAccountDto.getGlobalAccountNum());
notesActionForm.setPrdOfferingName(loanAccountDto.getProductDetails().getPrdOfferingName());
} else if (account.isSavingsAccount()) {
SavingsAccountDetailDto savingsAccountDto = this.savingsServiceFacade.retrieveSavingsAccountNotes(accountId.longValue());
notesActionForm.setPrdOfferingName(savingsAccountDto.getProductDetails().getProductDetails().getName());
notesActionForm.setAccountTypeId(AccountTypes.SAVINGS_ACCOUNT.getValue().toString());
notesActionForm.setGlobalAccountNum(savingsAccountDto.getGlobalAccountNum());
}
return mapping.findForward(ActionForwards.load_success.toString());
}
Aggregations