Search in sources :

Example 1 with AdjustablePaymentDto

use of org.mifos.accounts.business.AdjustablePaymentDto 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

ArrayList (java.util.ArrayList)1 AccountBO (org.mifos.accounts.business.AccountBO)1 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)1 AdjustablePaymentDto (org.mifos.accounts.business.AdjustablePaymentDto)1 LoanBO (org.mifos.accounts.loan.business.LoanBO)1 ApplyAdjustmentActionForm (org.mifos.accounts.struts.actionforms.ApplyAdjustmentActionForm)1 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)1