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