use of org.mifos.framework.util.helpers.CloseSession in project head by mifos.
the class AccountAppAction method removePenalties.
@CloseSession
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward removePenalties(ActionMapping mapping, @SuppressWarnings("unused") ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
Integer accountId = getIntegerValue(request.getParameter("accountId"));
Short penaltyId = getShortValue(request.getParameter("penaltyId"));
AccountBO accountBO = getAccountBusinessService().getAccount(accountId);
SessionUtils.setAttribute(Constants.BUSINESS_KEY, accountBO, request);
if (accountBO instanceof LoanBO) {
this.loanAccountServiceFacade.removeLoanPenalty(accountId, penaltyId);
}
String fromPage = request.getParameter(CenterConstants.FROM_PAGE);
StringBuilder forward = new StringBuilder();
forward = forward.append(AccountConstants.REMOVE + "_" + fromPage + "_" + AccountConstants.CHARGES);
if (fromPage != null) {
return mapping.findForward(forward.toString());
}
return mapping.findForward(AccountConstants.REMOVE_SUCCESS);
}
use of org.mifos.framework.util.helpers.CloseSession in project head by mifos.
the class SavingsAction method update.
@CloseSession
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward update(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
logger.debug("In SavingsAction::update()");
SavingsActionForm actionForm = (SavingsActionForm) form;
SavingsBO savings = (SavingsBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
Long savingsId = savings.getAccountId().longValue();
savings = this.savingsDao.findById(savingsId);
Integer version = savings.getVersionNo();
checkVersionMismatch(version, savings.getVersionNo());
this.savingsServiceFacade.updateSavingsAccountDetails(savingsId, actionForm.getRecommendedAmount(), actionForm.getAccountCustomFieldSet());
request.setAttribute(SavingsConstants.GLOBALACCOUNTNUM, savings.getGlobalAccountNum());
logger.info("In SavingsAction::update(), Savings object updated successfully");
doCleanUp(actionForm, request);
return mapping.findForward("update_success");
}
use of org.mifos.framework.util.helpers.CloseSession in project head by mifos.
the class AccountApplyGroupPaymentAction method applyPayment.
@TransactionDemarcate(validateAndResetToken = true)
@CloseSession
public ActionForward applyPayment(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
UserContext userContext = (UserContext) SessionUtils.getAttribute(Constants.USER_CONTEXT_KEY, request.getSession());
AccountApplyPaymentActionForm actionForm = (AccountApplyPaymentActionForm) form;
String paymentType = request.getParameter(Constants.INPUT);
Integer accountId;
if (actionForm.getAccountId().isEmpty() || actionForm.getAccountId() == null) {
accountId = loanDao.findByGlobalAccountNum(actionForm.getGlobalAccountNum()).getAccountId();
} else {
accountId = Integer.valueOf(actionForm.getAccountId());
}
UserReferenceDto userReferenceDto = new UserReferenceDto(userContext.getId());
AccountPaymentDto accountPaymentDto = accountServiceFacade.getAccountPaymentInformation(accountId, paymentType, userContext.getLocaleId(), userReferenceDto, actionForm.getTrxnDate());
validateAccountPayment(accountPaymentDto, accountId, request);
validateAmount(accountPaymentDto, actionForm.getAmount());
PaymentTypeDto paymentTypeDto;
String amount = actionForm.getAmount();
if (accountPaymentDto.getAccountType().equals(AccountTypeDto.LOAN_ACCOUNT) || accountPaymentDto.getAccountType().equals(AccountTypeDto.GROUP_LOAN_ACCOUNT)) {
paymentTypeDto = getLoanPaymentTypeDtoForId(Short.valueOf(actionForm.getPaymentTypeId()));
} else {
paymentTypeDto = getFeePaymentTypeDtoForId(Short.valueOf(actionForm.getPaymentTypeId()));
}
AccountPaymentParametersDto accountPaymentParametersDto;
if (isGroupParentAccount(accountId)) {
accountPaymentParametersDto = new AccountPaymentParametersDto(userReferenceDto, new AccountReferenceDto(accountId), new BigDecimal(amount), actionForm.getTrxnDateAsLocalDate(), paymentTypeDto, AccountConstants.NO_COMMENT, actionForm.getReceiptDateAsLocalDate(), actionForm.getReceiptId(), accountPaymentDto.getCustomerDto(), actionForm.getIndividualValues());
} else if (isGroupMemberAccount(accountId)) {
accountPaymentParametersDto = preparePaymentParametersDto(accountId, userReferenceDto, amount, actionForm, paymentTypeDto, userContext, paymentType);
} else {
accountPaymentParametersDto = new AccountPaymentParametersDto(userReferenceDto, new AccountReferenceDto(accountId), new BigDecimal(amount), actionForm.getTrxnDateAsLocalDate(), paymentTypeDto, AccountConstants.NO_COMMENT, actionForm.getReceiptDateAsLocalDate(), actionForm.getReceiptId(), accountPaymentDto.getCustomerDto());
}
if (paymentTypeDto.getValue().equals(this.legacyAcceptedPaymentTypeDao.getSavingsTransferId())) {
this.accountServiceFacade.makePaymentFromSavingsAcc(accountPaymentParametersDto, actionForm.getAccountForTransfer());
} else {
this.accountServiceFacade.makePayment(accountPaymentParametersDto);
}
request.getSession().setAttribute("globalAccountNum", ((AccountApplyPaymentActionForm) form).getGlobalAccountNum());
ActionForward findForward;
if (actionForm.getPrintReceipt()) {
findForward = mapping.findForward(getForward("PRINT"));
} else {
findForward = mapping.findForward(getForward(((AccountApplyPaymentActionForm) form).getInput()));
}
return findForward;
}
use of org.mifos.framework.util.helpers.CloseSession in project head by mifos.
the class LoanDisbursementAction method update.
@TransactionDemarcate(validateAndResetToken = true)
@CloseSession
public ActionForward update(final ActionMapping mapping, final ActionForm form, final HttpServletRequest request, @SuppressWarnings("unused") final HttpServletResponse response) throws Exception {
LoanDisbursementActionForm actionForm = (LoanDisbursementActionForm) form;
UserContext uc = getUserContext(request);
Date trxnDate = getDateFromString(actionForm.getTransactionDate(), uc.getPreferredLocale());
trxnDate = DateUtils.getDateWithoutTimeStamp(trxnDate.getTime());
Date receiptDate = getDateFromString(actionForm.getReceiptDate(), uc.getPreferredLocale());
Integer loanAccountId = Integer.valueOf(actionForm.getAccountId());
Integer accountForTransferId = (StringUtils.isBlank(actionForm.getAccountForTransfer())) ? null : legacyAccountDao.getAccountIdByGlobalAccountNumber(actionForm.getAccountForTransfer());
AccountBO accountBO = new AccountBusinessService().getAccount(loanAccountId);
Date originalDisbursementDate = DateUtils.getDateWithoutTimeStamp(((LoanBO) accountBO).getDisbursementDate());
createGroupQuestionnaire.saveResponses(request, actionForm, loanAccountId);
try {
String paymentTypeIdStringForDisbursement = actionForm.getPaymentTypeId();
String paymentTypeIdStringForFees = actionForm.getPaymentModeOfPayment();
Short paymentTypeIdForDisbursement = StringUtils.isEmpty(paymentTypeIdStringForDisbursement) ? PaymentTypes.CASH.getValue() : Short.valueOf(paymentTypeIdStringForDisbursement);
Short paymentTypeIdForFees = StringUtils.isEmpty(paymentTypeIdStringForFees) ? PaymentTypes.CASH.getValue() : Short.valueOf(paymentTypeIdStringForFees);
Short paymentTypeId = Short.valueOf(paymentTypeIdForDisbursement);
final String comment = "";
final BigDecimal disbursalAmount = new BigDecimal(actionForm.getLoanAmount());
CustomerDto customerDto = null;
PaymentTypeDto paymentType = null;
AccountPaymentParametersDto loanDisbursement = new AccountPaymentParametersDto(new UserReferenceDto(uc.getId()), new AccountReferenceDto(loanAccountId), disbursalAmount, new LocalDate(trxnDate), paymentType, comment, new LocalDate(receiptDate), actionForm.getReceiptId(), customerDto);
monthClosingServiceFacade.validateTransactionDate(trxnDate);
// GLIM
List<LoanBO> individualLoans = this.loanDao.findIndividualLoans(loanAccountId);
for (LoanBO individual : individualLoans) {
if (!loanAccountServiceFacade.isTrxnDateValid(Integer.valueOf(individual.getAccountId()), trxnDate)) {
throw new BusinessRuleException("errors.invalidTxndateOfDisbursal");
}
}
this.loanAccountServiceFacade.disburseLoan(loanDisbursement, paymentTypeId, paymentTypeIdForFees, accountForTransferId);
for (LoanBO individual : individualLoans) {
loanDisbursement = new AccountPaymentParametersDto(new UserReferenceDto(uc.getId()), new AccountReferenceDto(individual.getAccountId()), individual.getLoanAmount().getAmount(), new LocalDate(trxnDate), paymentType, comment, new LocalDate(receiptDate), actionForm.getReceiptId(), customerDto);
this.loanAccountServiceFacade.disburseLoan(loanDisbursement, paymentTypeId, paymentTypeIdForFees, accountForTransferId);
}
if (!((LoanBO) accountBO).isFixedRepaymentSchedule() && !originalDisbursementDate.equals(((LoanBO) accountBO).getDisbursementDate())) {
this.loanAccountServiceFacade.updateMemberLoansFeeAmounts(loanAccountId);
}
} catch (BusinessRuleException e) {
throw new AccountException(e.getMessage());
} catch (MifosRuntimeException e) {
if (e.getCause() != null && e.getCause() instanceof AccountException) {
throw new AccountException(e.getCause().getMessage());
}
String msg = "errors.cannotDisburseLoan.because.disburseFailed";
logger.error(msg, e);
throw new AccountException(msg);
} catch (Exception e) {
String msg = "errors.cannotDisburseLoan.because.disburseFailed";
logger.error(msg, e);
throw new AccountException(msg);
}
return mapping.findForward(Constants.UPDATE_SUCCESS);
}
use of org.mifos.framework.util.helpers.CloseSession in project head by mifos.
the class PersonnelSettingsAction method update.
@CloseSession
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward update(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
PersonnelSettingsActionForm personnelSettingsActionForm = (PersonnelSettingsActionForm) form;
PersonnelBO personnel = (PersonnelBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
AddressDto address = null;
if (personnelSettingsActionForm.getAddress() != null) {
address = Address.toDto(personnelSettingsActionForm.getAddress());
}
this.personnelServiceFacade.updateUserSettings(personnel.getPersonnelId(), personnelSettingsActionForm.getEmailId(), personnelSettingsActionForm.getName(), personnelSettingsActionForm.getMaritalStatusValue(), personnelSettingsActionForm.getGenderValue(), address, personnelSettingsActionForm.getPreferredLocaleValue(), personnelSettingsActionForm.getPreferredSiteTypeId());
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
(new SitePreferenceHelper()).setSitePreferenceCookie(personnelServiceFacade.retrieveSitePreference(user.getUserId()), response);
return mapping.findForward(ActionForwards.updateSettings_success.toString());
}
Aggregations