Search in sources :

Example 11 with AccountApplyPaymentActionForm

use of org.mifos.accounts.struts.actionforms.AccountApplyPaymentActionForm in project head by mifos.

the class AccountApplyGroupPaymentAction method divide.

@TransactionDemarcate(joinToken = true)
public ActionForward divide(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    AccountApplyPaymentActionForm actionForm = (AccountApplyPaymentActionForm) form;
    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()));
    }
    List<LoanBO> memberInfos = getMemberAccountsInformation(actionForm.getAccountId());
    SessionUtils.setCollectionAttribute("memberInfos", memberInfos, request);
    return mapping.findForward(ActionForwards.load_success.toString());
}
Also used : LoanBO(org.mifos.accounts.loan.business.LoanBO) GroupIndividualLoanDto(org.mifos.dto.domain.GroupIndividualLoanDto) AccountApplyPaymentActionForm(org.mifos.accounts.struts.actionforms.AccountApplyPaymentActionForm) BigDecimal(java.math.BigDecimal) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 12 with AccountApplyPaymentActionForm

use of org.mifos.accounts.struts.actionforms.AccountApplyPaymentActionForm in project head by mifos.

the class AccountApplyGroupPaymentAction method preview.

@TransactionDemarcate(joinToken = true)
public ActionForward preview(ActionMapping mapping, @SuppressWarnings("unused") ActionForm form, @SuppressWarnings("unused") HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    AccountApplyPaymentActionForm accountApplyPaymentActionForm = (AccountApplyPaymentActionForm) form;
    Double oldAmmount = Double.valueOf(accountApplyPaymentActionForm.getAmount());
    Double newAmounts = 0.0;
    if (accountApplyPaymentActionForm.getMemberType().equals("member")) {
        accountApplyPaymentActionForm.setAmount(oldAmmount.toString());
    } else if (!accountApplyPaymentActionForm.getIndividualValues().isEmpty()) {
        for (String amount : accountApplyPaymentActionForm.getIndividualValues().values()) {
            newAmounts += Double.valueOf(amount);
        }
        if (!oldAmmount.equals(newAmounts)) {
            accountApplyPaymentActionForm.setAmount(newAmounts.toString());
        }
    }
    return mapping.findForward(ActionForwards.preview_success.toString());
}
Also used : AccountApplyPaymentActionForm(org.mifos.accounts.struts.actionforms.AccountApplyPaymentActionForm) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 13 with AccountApplyPaymentActionForm

use of org.mifos.accounts.struts.actionforms.AccountApplyPaymentActionForm in project head by mifos.

the class AccountApplyPaymentAction 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());
    return mapping.findForward(ActionForwards.load_success.toString());
}
Also used : UserReferenceDto(org.mifos.dto.domain.UserReferenceDto) UserContext(org.mifos.security.util.UserContext) AccountReferenceDto(org.mifos.dto.domain.AccountReferenceDto) AccountPaymentDto(org.mifos.accounts.servicefacade.AccountPaymentDto) AccountApplyPaymentActionForm(org.mifos.accounts.struts.actionforms.AccountApplyPaymentActionForm) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 14 with AccountApplyPaymentActionForm

use of org.mifos.accounts.struts.actionforms.AccountApplyPaymentActionForm in project head by mifos.

the class AccountApplyPaymentAction 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;
    Integer accountId = Integer.valueOf(actionForm.getAccountId());
    String paymentType = request.getParameter(Constants.INPUT);
    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)) {
        paymentTypeDto = getLoanPaymentTypeDtoForId(Short.valueOf(actionForm.getPaymentTypeId()));
    } else {
        paymentTypeDto = getFeePaymentTypeDtoForId(Short.valueOf(actionForm.getPaymentTypeId()));
    }
    AccountPaymentParametersDto 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()) {
        if (accountPaymentDto.getAccountType().equals(AccountTypeDto.LOAN_ACCOUNT)) {
            findForward = mapping.findForward(getForward("PRINT"));
        } else {
            request.getSession().setAttribute("clientSystemId", accountPaymentDto.getCustomerDto().getGlobalCustNum());
            findForward = mapping.findForward(getForward("PRINT_CLIENT"));
        }
    } else {
        findForward = mapping.findForward(getForward(((AccountApplyPaymentActionForm) form).getInput()));
    }
    return findForward;
}
Also used : UserReferenceDto(org.mifos.dto.domain.UserReferenceDto) UserContext(org.mifos.security.util.UserContext) AccountReferenceDto(org.mifos.dto.domain.AccountReferenceDto) PaymentTypeDto(org.mifos.dto.domain.PaymentTypeDto) AccountPaymentParametersDto(org.mifos.dto.domain.AccountPaymentParametersDto) AccountPaymentDto(org.mifos.accounts.servicefacade.AccountPaymentDto) AccountApplyPaymentActionForm(org.mifos.accounts.struts.actionforms.AccountApplyPaymentActionForm) BigDecimal(java.math.BigDecimal) ActionForward(org.apache.struts.action.ActionForward) CloseSession(org.mifos.framework.util.helpers.CloseSession) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 15 with AccountApplyPaymentActionForm

use of org.mifos.accounts.struts.actionforms.AccountApplyPaymentActionForm in project head by mifos.

the class AccountApplyPaymentAction 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());
}
Also used : AccountApplyPaymentActionForm(org.mifos.accounts.struts.actionforms.AccountApplyPaymentActionForm) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Aggregations

AccountApplyPaymentActionForm (org.mifos.accounts.struts.actionforms.AccountApplyPaymentActionForm)21 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)14 AccountPaymentDto (org.mifos.accounts.servicefacade.AccountPaymentDto)7 UserContext (org.mifos.security.util.UserContext)7 AccountReferenceDto (org.mifos.dto.domain.AccountReferenceDto)6 UserReferenceDto (org.mifos.dto.domain.UserReferenceDto)6 BigDecimal (java.math.BigDecimal)5 Test (org.junit.Test)4 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)4 ActionForward (org.apache.struts.action.ActionForward)3 LoanBO (org.mifos.accounts.loan.business.LoanBO)3 AccountPaymentParametersDto (org.mifos.dto.domain.AccountPaymentParametersDto)3 PaymentTypeDto (org.mifos.dto.domain.PaymentTypeDto)3 CloseSession (org.mifos.framework.util.helpers.CloseSession)3 Money (org.mifos.framework.util.helpers.Money)3 GroupIndividualLoanDto (org.mifos.dto.domain.GroupIndividualLoanDto)2 Date (java.util.Date)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 AccountBO (org.mifos.accounts.business.AccountBO)1 PageExpiredException (org.mifos.framework.exceptions.PageExpiredException)1