use of org.mifos.accounts.savings.business.SavingsBO in project head by mifos.
the class SavingsDepositWithdrawalAction method reLoad.
@TransactionDemarcate(joinToken = true)
public ActionForward reLoad(final ActionMapping mapping, final ActionForm form, final HttpServletRequest request, @SuppressWarnings("unused") final HttpServletResponse response) throws Exception {
UserContext uc = (UserContext) SessionUtils.getAttribute(Constants.USER_CONTEXT_KEY, request.getSession());
SavingsDepositWithdrawalActionForm actionForm = (SavingsDepositWithdrawalActionForm) form;
SavingsBO savingsInSession = (SavingsBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
if (actionForm.getTrxnTypeId() != null && actionForm.getTrxnTypeId() != Constants.EMPTY_STRING) {
Long savingsId = savingsInSession.getAccountId().longValue();
SavingsBO savings = this.savingsDao.findById(savingsId);
Integer customerId = savings.getCustomer().getCustomerId();
if (StringUtils.isNotBlank(actionForm.getCustomerId())) {
customerId = Integer.valueOf(actionForm.getCustomerId());
}
DepositWithdrawalReferenceDto depositWithdrawalReferenceDto = this.savingsServiceFacade.retrieveDepositWithdrawalReferenceData(savingsId, customerId);
Short trxnTypeId = Short.valueOf(actionForm.getTrxnTypeId());
// added for defect 1587 [start]
LegacyAcceptedPaymentTypeDao persistence = legacyAcceptedPaymentTypeDao;
if (trxnTypeId.equals(AccountActionTypes.SAVINGS_DEPOSIT.getValue())) {
if (StringUtils.isNotBlank(actionForm.getCustomerId())) {
actionForm.setAmount(depositWithdrawalReferenceDto.getDepositDue());
}
List<PaymentTypeEntity> depositPaymentTypes = persistence.getAcceptedPaymentTypesForATransaction(uc.getLocaleId(), TrxnTypes.savings_deposit.getValue());
SessionUtils.setCollectionAttribute(MasterConstants.PAYMENT_TYPE, depositPaymentTypes, request);
} else {
actionForm.setAmount(depositWithdrawalReferenceDto.getWithdrawalDue());
List<PaymentTypeEntity> withdrawalPaymentTypes = persistence.getAcceptedPaymentTypesForATransaction(uc.getLocaleId(), TrxnTypes.savings_withdrawal.getValue());
SessionUtils.setCollectionAttribute(MasterConstants.PAYMENT_TYPE, withdrawalPaymentTypes, request);
}
}
return mapping.findForward(ActionForwards.load_success.toString());
}
use of org.mifos.accounts.savings.business.SavingsBO in project head by mifos.
the class SavingsApplyAdjustmentActionForm method validate.
@Override
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
String method = request.getParameter("method");
ActionErrors errors = new ActionErrors();
if (null == request.getAttribute(Constants.CURRENTFLOWKEY)) {
request.setAttribute(Constants.CURRENTFLOWKEY, request.getParameter(Constants.CURRENTFLOWKEY));
}
try {
if (method != null && method.equals("preview")) {
SavingsBO savings = (SavingsBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
AccountPaymentEntity payment = savings.findPaymentById(this.paymentId);
if (payment == null || savings.getLastPmntAmnt() == 0 || !(new SavingsHelper().getPaymentActionType(payment).equals(AccountActionTypes.SAVINGS_WITHDRAWAL.getValue()) || new SavingsHelper().getPaymentActionType(payment).equals(AccountActionTypes.SAVINGS_DEPOSIT.getValue()))) {
errors.add(SavingsConstants.INVALID_LAST_PAYMENT, new ActionMessage(SavingsConstants.INVALID_LAST_PAYMENT));
} else {
if (StringUtils.isBlank(getLastPaymentAmount())) {
errors.add(SavingsConstants.INVALID_ADJUSTMENT_AMOUNT, new ActionMessage(SavingsConstants.INVALID_ADJUSTMENT_AMOUNT));
}
if (StringUtils.isNotBlank(getLastPaymentAmount())) {
Locale locale = getUserContext(request).getPreferredLocale();
validateAmount(errors, locale);
}
if (StringUtils.isNotBlank(getNote()) && getNote().length() > CustomerConstants.COMMENT_LENGTH) {
errors.add(AccountConstants.MAX_NOTE_LENGTH, new ActionMessage(AccountConstants.MAX_NOTE_LENGTH, AccountConstants.COMMENT_LENGTH));
}
validateDate(errors);
errors.add(super.validate(mapping, request));
}
}
} catch (ApplicationException ae) {
errors.add(ae.getKey(), new ActionMessage(ae.getKey(), ae.getValues()));
}
if (!errors.isEmpty()) {
request.setAttribute(Globals.ERROR_KEY, errors);
request.setAttribute("methodCalled", method);
}
return errors;
}
use of org.mifos.accounts.savings.business.SavingsBO in project head by mifos.
the class SavingsAction method getRecentActivity.
@TransactionDemarcate(joinToken = true)
public ActionForward getRecentActivity(ActionMapping mapping, @SuppressWarnings("unused") ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
logger.debug("In SavingsAction::getRecentActivity()");
SavingsBO savings = (SavingsBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
Long savingsId = savings.getAccountId().longValue();
List<SavingsRecentActivityDto> recentActivity = this.savingsServiceFacade.retrieveRecentSavingsActivities(savingsId);
SessionUtils.setCollectionAttribute(SavingsConstants.RECENTY_ACTIVITY_LIST, recentActivity, request);
return mapping.findForward("getRecentActivity_success");
}
use of org.mifos.accounts.savings.business.SavingsBO in project head by mifos.
the class SavingsAction method edit.
@TransactionDemarcate(joinToken = true)
public ActionForward edit(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
logger.debug("In SavingsAction::edit()");
SavingsBO savings = (SavingsBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
SavingsActionForm actionForm = (SavingsActionForm) form;
List<CustomFieldDto> customFields = new ArrayList<CustomFieldDto>();
actionForm.setRecommendedAmount(savings.getRecommendedAmount().toString());
actionForm.setAccountCustomFieldSet(customFields);
List<CustomFieldDefinitionEntity> customFieldDefinitions = new ArrayList<CustomFieldDefinitionEntity>();
SessionUtils.setCollectionAttribute(SavingsConstants.CUSTOM_FIELDS, customFieldDefinitions, request);
return mapping.findForward("edit_success");
}
use of org.mifos.accounts.savings.business.SavingsBO in project head by mifos.
the class SavingsAction method waiveAmountOverDue.
@TransactionDemarcate(joinToken = true)
public ActionForward waiveAmountOverDue(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
logger.debug("In SavingsAction::waiveAmountOverDue()");
UserContext uc = (UserContext) SessionUtils.getAttribute(Constants.USER_CONTEXT_KEY, request.getSession());
SavingsBO savings = (SavingsBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
Integer versionNum = savings.getVersionNo();
savings = this.savingsDao.findBySystemId(((SavingsActionForm) form).getGlobalAccountNum());
checkVersionMismatch(versionNum, savings.getVersionNo());
savings.setUserContext(uc);
Long savingsId = savings.getAccountId().longValue();
this.savingsServiceFacade.waiveDepositAmountOverDue(savingsId);
return mapping.findForward("waiveAmount_success");
}
Aggregations