use of org.mifos.framework.util.helpers.TransactionDemarcate in project head by mifos.
the class AccountApplyGroupPaymentAction method load.
@TransactionDemarcate(joinToken = true)
public ActionForward load(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
UserContext userContext = getUserContext(request);
AccountApplyPaymentActionForm actionForm = (AccountApplyPaymentActionForm) form;
actionForm.setReceiptDate(null);
actionForm.setReceiptId(null);
actionForm.setPaymentTypeId(null);
actionForm.setTransactionDate(DateUtils.makeDateAsSentFromBrowser());
actionForm.setPrintReceipt(false);
actionForm.setTruePrintReceipt(false);
final AccountReferenceDto accountReferenceDto = new AccountReferenceDto(Integer.valueOf(actionForm.getAccountId()));
AccountPaymentDto accountPaymentDto = accountServiceFacade.getAccountPaymentInformation(accountReferenceDto.getAccountId(), request.getParameter(Constants.INPUT), userContext.getLocaleId(), new UserReferenceDto(userContext.getId()), DateUtils.getCurrentJavaDateTime());
setValuesInSession(request, actionForm, accountPaymentDto);
actionForm.setLastPaymentDate(accountPaymentDto.getLastPaymentDate());
actionForm.setAmount(accountPaymentDto.getTotalPaymentDue());
actionForm.setTransferPaymentTypeId(this.legacyAcceptedPaymentTypeDao.getSavingsTransferId());
LoanBO loan = loanDao.findById(accountReferenceDto.getAccountId());
if (loan.isGroupLoanAccountParent()) {
SessionUtils.setAttribute(LOAN_TYPE, PARENT, request);
} else if (loan.isGroupLoanAccountMember()) {
SessionUtils.setAttribute(LOAN_TYPE, MEMBER, request);
}
List<LoanBO> memberInfos = getMemberAccountsInformation(actionForm.getAccountId());
SessionUtils.setCollectionAttribute("memberInfos", memberInfos, request);
if (memberInfos.size() > 0) {
actionForm.getIndividualValues().clear();
List<GroupIndividualLoanDto> memberAccounts = groupLoanService.getMemberLoansAndDefaultPayments(Integer.valueOf(actionForm.getAccountId()), new BigDecimal(actionForm.getAmount()));
for (int i = 0; i < memberAccounts.size(); i++) {
actionForm.getIndividualValues().put(memberAccounts.get(i).getAccountId(), String.valueOf(memberAccounts.get(i).getDefaultAmount().doubleValue()));
}
}
return mapping.findForward(ActionForwards.load_success.toString());
}
use of org.mifos.framework.util.helpers.TransactionDemarcate in project head by mifos.
the class AccountApplyGroupPaymentAction method validate.
@TransactionDemarcate(joinToken = true)
public ActionForward validate(ActionMapping mapping, @SuppressWarnings("unused") ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
String method = (String) request.getAttribute("methodCalled");
String forward = null;
//workaround for checkbox problem
AccountApplyPaymentActionForm accountApplyPaymentActionForm = (AccountApplyPaymentActionForm) form;
accountApplyPaymentActionForm.setTruePrintReceipt(accountApplyPaymentActionForm.getPrintReceipt());
accountApplyPaymentActionForm.setPrintReceipt(false);
if (method != null) {
forward = method + "_failure";
}
return mapping.findForward(forward);
}
use of org.mifos.framework.util.helpers.TransactionDemarcate in project head by mifos.
the class AccountApplyGroupPaymentAction method applyPayment.
@TransactionDemarcate(validateAndResetToken = true)
@CloseSession
public ActionForward applyPayment(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
UserContext userContext = (UserContext) SessionUtils.getAttribute(Constants.USER_CONTEXT_KEY, request.getSession());
AccountApplyPaymentActionForm actionForm = (AccountApplyPaymentActionForm) form;
String paymentType = request.getParameter(Constants.INPUT);
Integer accountId;
if (actionForm.getAccountId().isEmpty() || actionForm.getAccountId() == null) {
accountId = loanDao.findByGlobalAccountNum(actionForm.getGlobalAccountNum()).getAccountId();
} else {
accountId = Integer.valueOf(actionForm.getAccountId());
}
UserReferenceDto userReferenceDto = new UserReferenceDto(userContext.getId());
AccountPaymentDto accountPaymentDto = accountServiceFacade.getAccountPaymentInformation(accountId, paymentType, userContext.getLocaleId(), userReferenceDto, actionForm.getTrxnDate());
validateAccountPayment(accountPaymentDto, accountId, request);
validateAmount(accountPaymentDto, actionForm.getAmount());
PaymentTypeDto paymentTypeDto;
String amount = actionForm.getAmount();
if (accountPaymentDto.getAccountType().equals(AccountTypeDto.LOAN_ACCOUNT) || accountPaymentDto.getAccountType().equals(AccountTypeDto.GROUP_LOAN_ACCOUNT)) {
paymentTypeDto = getLoanPaymentTypeDtoForId(Short.valueOf(actionForm.getPaymentTypeId()));
} else {
paymentTypeDto = getFeePaymentTypeDtoForId(Short.valueOf(actionForm.getPaymentTypeId()));
}
AccountPaymentParametersDto accountPaymentParametersDto;
if (isGroupParentAccount(accountId)) {
accountPaymentParametersDto = new AccountPaymentParametersDto(userReferenceDto, new AccountReferenceDto(accountId), new BigDecimal(amount), actionForm.getTrxnDateAsLocalDate(), paymentTypeDto, AccountConstants.NO_COMMENT, actionForm.getReceiptDateAsLocalDate(), actionForm.getReceiptId(), accountPaymentDto.getCustomerDto(), actionForm.getIndividualValues());
} else if (isGroupMemberAccount(accountId)) {
accountPaymentParametersDto = preparePaymentParametersDto(accountId, userReferenceDto, amount, actionForm, paymentTypeDto, userContext, paymentType);
} else {
accountPaymentParametersDto = new AccountPaymentParametersDto(userReferenceDto, new AccountReferenceDto(accountId), new BigDecimal(amount), actionForm.getTrxnDateAsLocalDate(), paymentTypeDto, AccountConstants.NO_COMMENT, actionForm.getReceiptDateAsLocalDate(), actionForm.getReceiptId(), accountPaymentDto.getCustomerDto());
}
if (paymentTypeDto.getValue().equals(this.legacyAcceptedPaymentTypeDao.getSavingsTransferId())) {
this.accountServiceFacade.makePaymentFromSavingsAcc(accountPaymentParametersDto, actionForm.getAccountForTransfer());
} else {
this.accountServiceFacade.makePayment(accountPaymentParametersDto);
}
request.getSession().setAttribute("globalAccountNum", ((AccountApplyPaymentActionForm) form).getGlobalAccountNum());
ActionForward findForward;
if (actionForm.getPrintReceipt()) {
findForward = mapping.findForward(getForward("PRINT"));
} else {
findForward = mapping.findForward(getForward(((AccountApplyPaymentActionForm) form).getInput()));
}
return findForward;
}
use of org.mifos.framework.util.helpers.TransactionDemarcate in project head by mifos.
the class AccountApplyGroupPaymentAction method previous.
@TransactionDemarcate(joinToken = true)
public ActionForward previous(ActionMapping mapping, @SuppressWarnings("unused") ActionForm form, @SuppressWarnings("unused") HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
//workaround for checkbox problem
AccountApplyPaymentActionForm accountApplyPaymentActionForm = (AccountApplyPaymentActionForm) form;
accountApplyPaymentActionForm.setTruePrintReceipt(accountApplyPaymentActionForm.getPrintReceipt());
accountApplyPaymentActionForm.setPrintReceipt(false);
return mapping.findForward(ActionForwards.previous_success.toString());
}
use of org.mifos.framework.util.helpers.TransactionDemarcate in project head by mifos.
the class AccountApplyPaymentAction method validate.
@TransactionDemarcate(joinToken = true)
public ActionForward validate(ActionMapping mapping, @SuppressWarnings("unused") ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
String method = (String) request.getAttribute("methodCalled");
String forward = null;
//workaround for checkbox problem
AccountApplyPaymentActionForm accountApplyPaymentActionForm = (AccountApplyPaymentActionForm) form;
accountApplyPaymentActionForm.setTruePrintReceipt(accountApplyPaymentActionForm.getPrintReceipt());
accountApplyPaymentActionForm.setPrintReceipt(false);
if (method != null) {
forward = method + "_failure";
}
return mapping.findForward(forward);
}
Aggregations