use of org.mifos.framework.util.helpers.TransactionDemarcate in project head by mifos.
the class ApplyChargeAction method divide.
@TransactionDemarcate(joinToken = true)
public ActionForward divide(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
ApplyChargeActionForm chargeForm = (ApplyChargeActionForm) form;
chargeForm.getIndividualValues().clear();
Short feeId = Short.valueOf(chargeForm.getFeeId());
FeeBO fee = feeDao.findById(feeId);
String amount;
List<GroupIndividualLoanDto> memberAccounts = groupLoanService.getMemberLoansAndDefaultPayments(Integer.valueOf(chargeForm.getAccountId()), new BigDecimal(chargeForm.getCharge()));
if (null == fee || fee.getFeeType().equals(RateAmountFlag.AMOUNT)) {
for (int i = 0; i < memberAccounts.size(); i++) {
amount = String.valueOf(memberAccounts.get(i).getDefaultAmount().doubleValue());
chargeForm.getIndividualValues().put(memberAccounts.get(i).getAccountId(), amount);
}
} else {
for (int i = 0; i < memberAccounts.size(); i++) {
amount = chargeForm.getCharge();
chargeForm.getIndividualValues().put(memberAccounts.get(i).getAccountId(), amount);
}
}
List<LoanBO> memberInfos = getMemberAccountsInformation(chargeForm.getAccountId());
SessionUtils.setCollectionAttribute("memberInfos", memberInfos, request);
return mapping.findForward("divide");
}
use of org.mifos.framework.util.helpers.TransactionDemarcate in project head by mifos.
the class ApplyChargeAction method cancel.
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward cancel(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
request.removeAttribute(AccountConstants.APPLICABLE_CHARGE_LIST);
ApplyChargeActionForm applyChargeActionForm = (ApplyChargeActionForm) form;
Integer accountId = Integer.valueOf(applyChargeActionForm.getAccountId());
AccountTypeCustomerLevelDto accountTypeCustomerLevel = accountServiceFacade.getAccountTypeCustomerLevelDto(accountId);
return mapping.findForward(getDetailAccountPage(accountTypeCustomerLevel));
}
use of org.mifos.framework.util.helpers.TransactionDemarcate in project head by mifos.
the class ApplyChargeAction method load.
@TransactionDemarcate(joinToken = true)
public ActionForward load(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
ApplyChargeActionForm applyChargeActionForm = (ApplyChargeActionForm) form;
AccountBO account = ApplicationContextProvider.getBean(LegacyAccountDao.class).getAccount(Integer.valueOf(applyChargeActionForm.getAccountId()));
SessionUtils.setAttribute(Constants.BUSINESS_KEY, account, request);
SessionUtils.setAttribute(Constants.BUSINESS_KEY, account, request.getSession());
applyChargeActionForm.clear();
request.removeAttribute(AccountConstants.APPLICABLE_CHARGE_LIST);
Integer accountId = Integer.valueOf(request.getParameter("accountId"));
List<ApplicableCharge> applicableCharges = this.accountServiceFacade.getApplicableFees(accountId);
LoanBO loan = loanDao.findById(accountId);
if (loan != null) {
for (int i = applicableCharges.size() - 1; i >= 0; --i) {
if (applicableCharges.get(i).getFeeId().equals(AccountConstants.MISC_PENALTY)) {
applicableCharges.remove(i);
break;
}
}
applicableCharges.addAll(this.loanAccountServiceFacade.getApplicablePenalties(accountId));
}
SessionUtils.setCollectionAttribute(AccountConstants.APPLICABLE_CHARGE_LIST, applicableCharges, request);
if (null != loan && (null == loan.getParentAccount() && loan.isGroupLoanAccount())) {
SessionUtils.setAttribute(Constants.ACCOUNT_TYPE, "newGlim", request);
}
return mapping.findForward(ActionForwards.load_success.toString());
}
use of org.mifos.framework.util.helpers.TransactionDemarcate in project head by mifos.
the class EditStatusAction method load.
@TransactionDemarcate(joinToken = true)
public ActionForward load(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
EditStatusActionForm actionForm = (EditStatusActionForm) form;
actionForm.setSelectedItems(null);
actionForm.setNotes(null);
actionForm.setNewStatusId(null);
actionForm.setFlagId(null);
actionForm.setQuestionGroups(null);
actionForm.setTransactionDate(DateUtils.makeDateAsSentFromBrowser());
actionForm.setAllowBackDatedApprovals(AccountingRules.isBackDatedApprovalAllowed());
request.getSession().removeAttribute(Constants.BUSINESS_KEY);
UserContext userContext = getUserContext(request);
Integer accountId = Integer.valueOf(actionForm.getAccountId());
AccountBO accountBO = new AccountBusinessService().getAccount(accountId);
java.util.Date lastPaymentDate = new java.util.Date(0);
AccountPaymentEntity lastPayment = accountBO.findMostRecentNonzeroPaymentByPaymentDate();
if (lastPayment != null) {
lastPaymentDate = lastPayment.getPaymentDate();
}
actionForm.setLastPaymentDate(lastPaymentDate);
if (accountBO.isLoanAccount() || accountBO.isGroupLoanAccount()) {
// NOTE - not using dto values at present but available when ui is refactored away from jsp
AccountStatusDto accountStatuses = this.loanAccountServiceFacade.retrieveAccountStatuses(accountId.longValue());
LoanBO loanAccount = this.loanDao.findById(accountId);
EditStatusActionForm editStatusActionForm = (EditStatusActionForm) form;
editStatusActionForm.setAccountTypeId(AccountTypes.LOAN_ACCOUNT.getValue().toString());
editStatusActionForm.setCurrentStatusId(loanAccount.getAccountState().getId().toString());
editStatusActionForm.setGlobalAccountNum(loanAccount.getGlobalAccountNum());
editStatusActionForm.setAccountName(loanAccount.getLoanOffering().getPrdOfferingName());
if (loanAccount.isGroupLoanAccount() && loanAccount.getParentAccount() == null) {
editStatusActionForm.setInput("grouploan");
} else {
editStatusActionForm.setInput("loan");
}
if (loanAccount.getAccountState().getId().equals(Short.valueOf("2"))) {
List<AdminDocumentBO> allAdminDocuments = legacyAdminDocumentDao.getAllActiveAdminDocuments();
List<AdminDocumentBO> loanAdminDocuments = new ArrayList();
for (AdminDocumentBO adminDocumentBO : allAdminDocuments) {
List<AdminDocAccStateMixBO> admindoclist = legacyAdminDocAccStateMixDao.getMixByAdminDocuments(adminDocumentBO.getAdmindocId());
if (!loanAdminDocuments.contains(adminDocumentBO) && admindoclist.size() > 0 && admindoclist.get(0).getAccountStateID().getPrdType().getProductTypeID().equals(loanAccount.getType().getValue().shortValue())) {
for (AdminDocAccStateMixBO admindoc : admindoclist) {
if (admindoc.getAccountStateID().getId().shortValue() == loanAccount.getAccountState().getId().shortValue()) {
loanAdminDocuments.add(adminDocumentBO);
}
}
}
}
SessionUtils.setCollectionAttribute("editAccountStatusDocumentsList", loanAdminDocuments, request);
} else {
SessionUtils.setCollectionAttribute("editAccountStatusDocumentsList", null, request);
}
}
if (accountBO.isSavingsAccount()) {
// NOTE - not using dto values at present but available when ui is refactored away from jsp
AccountStatusDto accountStatuses = this.savingsServiceFacade.retrieveAccountStatuses(accountId.longValue());
SavingsBO savingsAccount = this.savingsDao.findById(accountId.longValue());
EditStatusActionForm editStatusActionForm = (EditStatusActionForm) form;
editStatusActionForm.setAccountTypeId(AccountTypes.SAVINGS_ACCOUNT.getValue().toString());
editStatusActionForm.setCurrentStatusId(savingsAccount.getAccountState().getId().toString());
editStatusActionForm.setGlobalAccountNum(savingsAccount.getGlobalAccountNum());
editStatusActionForm.setAccountName(savingsAccount.getSavingsOffering().getPrdOfferingName());
editStatusActionForm.setInput("savings");
}
List<AccountStateEntity> accountStatuses = new AccountBusinessService().getStatusList(accountBO.getAccountState(), accountBO.getType(), userContext.getLocaleId());
for (AccountStateEntity customerStatusEntity : accountStatuses) {
for (AccountStateFlagEntity flag : customerStatusEntity.getFlagSet()) {
String statusMessageText = ApplicationContextProvider.getBean(MessageLookup.class).lookup(flag.getLookUpValue().getPropertiesKey());
flag.setStatusFlagMessageText(statusMessageText);
}
}
SessionUtils.setAttribute(Constants.BUSINESS_KEY, accountBO, request);
SessionUtils.setCollectionAttribute(SavingsConstants.STATUS_LIST, accountStatuses, request);
return mapping.findForward(ActionForwards.load_success.toString());
}
use of org.mifos.framework.util.helpers.TransactionDemarcate in project head by mifos.
the class EditStatusAction method preview.
@TransactionDemarcate(joinToken = true)
public ActionForward preview(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
AccountBO accountBO = (AccountBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
EditStatusActionForm editStatusActionForm = (EditStatusActionForm) form;
// FIXME - ElsieF - KEITHW - is checklist functionality being removed from application?
List<AccountCheckListBO> checklist = new AccountBusinessService().getStatusChecklist(getShortValue(editStatusActionForm.getNewStatusId()), getShortValue(editStatusActionForm.getAccountTypeId()));
SessionUtils.setCollectionAttribute(SavingsConstants.STATUS_CHECK_LIST, checklist, request);
String newStatusId = editStatusActionForm.getNewStatusId();
String newStatusName = null;
if (StringUtils.isNotBlank(editStatusActionForm.getNewStatusId())) {
newStatusName = new AccountBusinessService().getStatusName(AccountState.fromShort(getShortValue(editStatusActionForm.getNewStatusId())), accountBO.getType());
}
SessionUtils.setAttribute(SavingsConstants.NEW_STATUS_NAME, newStatusName, request);
initializeLoanQuestionnaire(accountBO.getGlobalAccountNum(), newStatusId);
if (loanApproved(newStatusId) || loanClosed(newStatusId)) {
return loanQuestionnaire.fetchAppliedQuestions(mapping, editStatusActionForm, request, ActionForwards.preview_success);
}
return mapping.findForward(ActionForwards.preview_success.toString());
}
Aggregations