use of org.mifos.dto.screen.SavingsAdjustmentReferenceDto in project head by mifos.
the class SavingsApplyAdjustmentAction method load.
@TransactionDemarcate(joinToken = true)
public ActionForward load(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
clearActionForm(form);
doCleanUp(request);
UserContext uc = (UserContext) SessionUtils.getAttribute(Constants.USER_CONTEXT_KEY, request.getSession());
SavingsBO savings = (SavingsBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
SessionUtils.removeAttribute(Constants.BUSINESS_KEY, request);
Long savingsId = Long.valueOf(savings.getAccountId());
savings = this.savingsDao.findById(savingsId);
savings.setUserContext(uc);
String paymentIdParam = request.getParameter("paymentId");
Integer paymentId;
if (paymentIdParam == null) {
AccountPaymentEntity payment = savings.getLastPmnt();
paymentId = (payment == null) ? null : payment.getPaymentId();
} else {
paymentId = Integer.valueOf(paymentIdParam);
}
SavingsAdjustmentReferenceDto savingsAdjustmentDto = this.savingsServiceFacade.retrieveAdjustmentReferenceData(savingsId, paymentId);
if (savingsAdjustmentDto.isDepositOrWithdrawal()) {
AccountPaymentEntity payment = (paymentId == null) ? savings.findMostRecentPaymentByPaymentDate() : savings.findPaymentById(paymentId);
AccountActionEntity accountAction = legacyMasterDao.getPersistentObject(AccountActionEntity.class, new SavingsHelper().getPaymentActionType(payment));
Hibernate.initialize(savings.findMostRecentPaymentByPaymentDate().getAccountTrxns());
SessionUtils.setAttribute(SavingsConstants.ACCOUNT_ACTION, accountAction, request);
SessionUtils.setAttribute(SavingsConstants.CLIENT_NAME, savingsAdjustmentDto.getClientName(), request);
SessionUtils.setAttribute(SavingsConstants.IS_LAST_PAYMENT_VALID, Constants.YES, request);
SessionUtils.setAttribute(SavingsConstants.ADJUSTMENT_AMOUNT, payment.getAmount().getAmount(), request);
SavingsApplyAdjustmentActionForm actionForm = (SavingsApplyAdjustmentActionForm) form;
actionForm.setPaymentId(paymentId);
actionForm.setTrxnDate(new LocalDate(payment.getPaymentDate()));
} else {
SessionUtils.setAttribute(SavingsConstants.IS_LAST_PAYMENT_VALID, Constants.NO, request);
}
SessionUtils.setAttribute(Constants.BUSINESS_KEY, savings, request);
return mapping.findForward("load_success");
}
use of org.mifos.dto.screen.SavingsAdjustmentReferenceDto in project head by mifos.
the class SavingsServiceFacadeWebTier method retrieveAdjustmentReferenceData.
@Override
public SavingsAdjustmentReferenceDto retrieveAdjustmentReferenceData(Long savingsId, Integer paymentId) {
SavingsBO savings = savingsDao.findById(savingsId);
AccountPaymentEntity payment = (paymentId == null) ? null : savings.findPaymentById(paymentId);
String clientName = null;
String amount = null;
boolean depositOrWithdrawal = false;
if (payment != null) {
amount = payment.getAmount().toString();
depositOrWithdrawal = payment.isSavingsDepositOrWithdrawal();
}
if (!savings.getCustomer().isClient() && payment != null) {
CustomerBO customer = null;
for (AccountTrxnEntity accountTrxn : payment.getAccountTrxns()) {
customer = accountTrxn.getCustomer();
break;
}
if (customer != null && customer.isClient()) {
clientName = customer.getDisplayName();
}
}
return new SavingsAdjustmentReferenceDto(clientName, amount, depositOrWithdrawal);
}
Aggregations