Search in sources :

Example 1 with ApplyAdjustmentActionForm

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

the class ApplyAdjustment method editAdjustment.

@TransactionDemarcate(joinToken = true)
public ActionForward editAdjustment(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    ApplyAdjustmentActionForm appAdjustActionForm = (ApplyAdjustmentActionForm) form;
    boolean isRevert = Boolean.parseBoolean(request.getParameter(Constants.ADJUSTMENT_IS_REVERT));
    appAdjustActionForm.setAdjustcheckbox(isRevert);
    request.setAttribute("method", "loadAdjustment");
    return mapping.findForward("loadadjustment_success");
}
Also used : ApplyAdjustmentActionForm(org.mifos.accounts.struts.actionforms.ApplyAdjustmentActionForm) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 2 with ApplyAdjustmentActionForm

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

the class ApplyAdjustment method divide.

@TransactionDemarcate(joinToken = true)
public ActionForward divide(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    ApplyAdjustmentActionForm applyAdjustmentActionForm = (ApplyAdjustmentActionForm) form;
    Integer parentAccountId = getBizService().findBySystemId(applyAdjustmentActionForm.getGlobalAccountNum()).getAccountId();
    Integer parentPaymentId = applyAdjustmentActionForm.getPaymentId();
    BigDecimal newAmount = new BigDecimal(applyAdjustmentActionForm.getAmount());
    if (applyAdjustmentActionForm.getAdjustcheckbox()) {
        newAmount = BigDecimal.ZERO;
    }
    List<GroupLoanMemberAdjustmentDto> memberAdjustmentDtoList = this.groupLoanService.retrieveMemberAdjustmentDtos(parentAccountId, parentPaymentId, newAmount);
    applyAdjustmentActionForm.setMemberAdjustmentDtoList(memberAdjustmentDtoList);
    return mapping.findForward("divideadjustment_success");
}
Also used : ApplyAdjustmentActionForm(org.mifos.accounts.struts.actionforms.ApplyAdjustmentActionForm) BigDecimal(java.math.BigDecimal) GroupLoanMemberAdjustmentDto(org.mifos.dto.screen.GroupLoanMemberAdjustmentDto) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 3 with ApplyAdjustmentActionForm

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

the class ApplyAdjustment method applyAdjustment.

@TransactionDemarcate(validateAndResetToken = true)
@CloseSession
public ActionForward applyAdjustment(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    request.setAttribute("method", "applyAdjustment");
    ApplyAdjustmentActionForm appAdjustActionForm = (ApplyAdjustmentActionForm) form;
    Integer paymentId = appAdjustActionForm.getPaymentId();
    checkVersionMismatchForAccountBO(request, appAdjustActionForm);
    UserContext userContext = (UserContext) SessionUtils.getAttribute(Constants.USER_CONTEXT_KEY, request.getSession());
    try {
        if (paymentId == null) {
            accountServiceFacade.applyAdjustment(appAdjustActionForm.getGlobalAccountNum(), appAdjustActionForm.getAdjustmentNote(), userContext.getId());
        } else {
            AdjustedPaymentDto adjustedPaymentDto = appAdjustActionForm.getPaymentData();
            if (appAdjustActionForm.isGroupLoanMember()) {
                accountServiceFacade.applyMemberAccountHistoricalAdjustment(appAdjustActionForm.getGlobalAccountNum(), paymentId, appAdjustActionForm.getAdjustmentNote(), userContext.getId(), adjustedPaymentDto);
            } else {
                accountServiceFacade.applyHistoricalAdjustment(appAdjustActionForm.getGlobalAccountNum(), paymentId, appAdjustActionForm.getAdjustmentNote(), userContext.getId(), adjustedPaymentDto);
            }
        }
    } catch (MifosRuntimeException e) {
        request.setAttribute("method", "previewAdjustment");
        throw (Exception) e.getCause();
    }
    resetActionFormFields(appAdjustActionForm);
    return mapping.findForward("applyadj_success");
}
Also used : ApplyAdjustmentActionForm(org.mifos.accounts.struts.actionforms.ApplyAdjustmentActionForm) AdjustedPaymentDto(org.mifos.dto.domain.AdjustedPaymentDto) UserContext(org.mifos.security.util.UserContext) MifosRuntimeException(org.mifos.core.MifosRuntimeException) CloseSession(org.mifos.framework.util.helpers.CloseSession) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 4 with ApplyAdjustmentActionForm

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

the class ApplyAdjustment method previewAdjustment.

@TransactionDemarcate(joinToken = true)
public ActionForward previewAdjustment(ActionMapping mapping, @SuppressWarnings("unused") ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    ApplyAdjustmentActionForm appAdjustActionForm = (ApplyAdjustmentActionForm) form;
    appAdjustActionForm.setAdjustData(!appAdjustActionForm.getAdjustcheckbox());
    if (appAdjustActionForm.isAdjustData()) {
        @SuppressWarnings("unchecked") List<ListItem<Short>> paymentTypes = (List<ListItem<Short>>) SessionUtils.getAttribute(MasterConstants.PAYMENT_TYPE, request);
        Short elementType = Short.valueOf(appAdjustActionForm.getPaymentType());
        for (ListItem<Short> item : paymentTypes) {
            if (item.getId().equals(elementType)) {
                SessionUtils.setAttribute(Constants.ADJUSTMENT_PAYMENT_TYPE, item.getDisplayValue(), request);
            }
        }
    }
    if (appAdjustActionForm.getNewAmounts() != null && !appAdjustActionForm.getNewAmounts().isEmpty()) {
        BigDecimal newAmount = BigDecimal.ZERO;
        for (String memberNewAmountString : appAdjustActionForm.getNewAmounts().values()) {
            BigDecimal memberNewAmount = BigDecimal.ZERO;
            if (!StringUtils.isBlank(memberNewAmountString)) {
                memberNewAmount = new BigDecimal(memberNewAmountString);
            }
            newAmount = newAmount.add(memberNewAmount);
        }
        appAdjustActionForm.setAmount(newAmount.toString());
    }
    request.setAttribute("method", "previewAdjustment");
    return mapping.findForward("previewadj_success");
}
Also used : ApplyAdjustmentActionForm(org.mifos.accounts.struts.actionforms.ApplyAdjustmentActionForm) ArrayList(java.util.ArrayList) List(java.util.List) ListItem(org.mifos.application.servicefacade.ListItem) BigDecimal(java.math.BigDecimal) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 5 with ApplyAdjustmentActionForm

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

the class ApplyAdjustment method listPossibleAdjustments.

@TransactionDemarcate(joinToken = true)
public ActionForward listPossibleAdjustments(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    ApplyAdjustmentActionForm appAdjustActionForm = (ApplyAdjustmentActionForm) form;
    this.resetActionFormFields(appAdjustActionForm);
    AccountBO accnt = getBizService().findBySystemId(appAdjustActionForm.getGlobalAccountNum());
    boolean decliningRecalculation = false;
    if (accnt instanceof LoanBO) {
        LoanBO loan = (LoanBO) accnt;
        if (loan.getInterestType().getId().equals(InterestType.DECLINING_PB.getValue())) {
            decliningRecalculation = true;
        }
    }
    List<AccountPaymentEntity> payments = accnt.getAccountPayments();
    ArrayList<AdjustablePaymentDto> adjustablePayments = new ArrayList<AdjustablePaymentDto>();
    int i = 1;
    for (AccountPaymentEntity payment : payments) {
        //ommit disbursal payment
        if (!payment.getAmount().equals(Money.zero()) && i != payments.size()) {
            AdjustablePaymentDto adjustablePaymentDto = new AdjustablePaymentDto(payment.getPaymentId(), payment.getAmount(), payment.getPaymentType().getName(), payment.getPaymentDate(), payment.getReceiptDate(), payment.getReceiptNumber());
            adjustablePayments.add(adjustablePaymentDto);
            if (decliningRecalculation) {
                //only last payment
                break;
            }
        }
        i++;
    }
    SessionUtils.setAttribute(Constants.BUSINESS_KEY, accnt, request);
    SessionUtils.setAttribute(Constants.POSSIBLE_ADJUSTMENTS, adjustablePayments, request);
    request.setAttribute("method", "loadAdjustment");
    return mapping.findForward("loadadjustments_success");
}
Also used : AccountBO(org.mifos.accounts.business.AccountBO) ApplyAdjustmentActionForm(org.mifos.accounts.struts.actionforms.ApplyAdjustmentActionForm) AdjustablePaymentDto(org.mifos.accounts.business.AdjustablePaymentDto) LoanBO(org.mifos.accounts.loan.business.LoanBO) AccountPaymentEntity(org.mifos.accounts.business.AccountPaymentEntity) ArrayList(java.util.ArrayList) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Aggregations

ApplyAdjustmentActionForm (org.mifos.accounts.struts.actionforms.ApplyAdjustmentActionForm)8 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)8 AccountBO (org.mifos.accounts.business.AccountBO)3 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)3 BigDecimal (java.math.BigDecimal)2 ArrayList (java.util.ArrayList)2 ListItem (org.mifos.application.servicefacade.ListItem)2 UserContext (org.mifos.security.util.UserContext)2 Date (java.util.Date)1 List (java.util.List)1 AdjustablePaymentDto (org.mifos.accounts.business.AdjustablePaymentDto)1 LoanBO (org.mifos.accounts.loan.business.LoanBO)1 MifosRuntimeException (org.mifos.core.MifosRuntimeException)1 AdjustedPaymentDto (org.mifos.dto.domain.AdjustedPaymentDto)1 GroupLoanMemberAdjustmentDto (org.mifos.dto.screen.GroupLoanMemberAdjustmentDto)1 CloseSession (org.mifos.framework.util.helpers.CloseSession)1