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");
}
Aggregations