use of org.mifos.security.util.UserContext in project head by mifos.
the class SavingsAction method getDepositDueDetails.
@TransactionDemarcate(saveToken = true)
public ActionForward getDepositDueDetails(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
logger.debug("In SavingsAction::getDepositDueDetails()");
SavingsActionForm actionform = (SavingsActionForm) form;
UserContext uc = (UserContext) SessionUtils.getAttribute(Constants.USER_CONTEXT_KEY, request.getSession());
SessionUtils.removeAttribute(Constants.BUSINESS_KEY, request);
String savingsSystemId = actionform.getGlobalAccountNum();
SavingsBO savings = savingsDao.findBySystemId(savingsSystemId);
for (AccountActionDateEntity actionDate : savings.getAccountActionDates()) {
Hibernate.initialize(actionDate);
}
Hibernate.initialize(savings.getAccountNotes());
for (AccountFlagMapping accountFlagMapping : savings.getAccountFlags()) {
Hibernate.initialize(accountFlagMapping.getFlag());
}
Hibernate.initialize(savings.getAccountFlags());
savings.setUserContext(uc);
SessionUtils.setAttribute(Constants.BUSINESS_KEY, savings, request);
SavingsAccountDepositDueDto depositDueDetails = this.savingsServiceFacade.retrieveDepositDueDetails(savingsSystemId);
return mapping.findForward("depositduedetails_success");
}
use of org.mifos.security.util.UserContext in project head by mifos.
the class SavingsAction method load.
@TransactionDemarcate(joinToken = true)
public ActionForward load(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
SavingsActionForm savingsActionForm = ((SavingsActionForm) form);
logger.debug(" selectedPrdOfferingId: " + savingsActionForm.getSelectedPrdOfferingId());
UserContext uc = (UserContext) SessionUtils.getAttribute(Constants.USER_CONTEXT_KEY, request.getSession());
List<InterestCalcTypeEntity> interestCalculationTypes = this.savingsProductDao.retrieveInterestCalculationTypes();
SessionUtils.setCollectionAttribute(MasterConstants.INTEREST_CAL_TYPES, interestCalculationTypes, request);
Integer productId = Integer.valueOf(savingsActionForm.getSelectedPrdOfferingId());
SavingsOfferingBO savingsOfferingBO = this.savingsProductDao.findById(productId);
SessionUtils.setAttribute(SavingsConstants.PRDOFFERING, savingsOfferingBO, request);
// NOTE - these details are included in SavingsProductReferenceDto but left as is to satisfy JSP at present
SessionUtils.setCollectionAttribute(MasterConstants.SAVINGS_TYPE, legacyMasterDao.findMasterDataEntitiesWithLocale(SavingsTypeEntity.class), request);
SessionUtils.setCollectionAttribute(MasterConstants.RECOMMENDED_AMOUNT_UNIT, legacyMasterDao.findMasterDataEntitiesWithLocale(RecommendedAmntUnitEntity.class), request);
List<CustomFieldDefinitionEntity> customFieldDefinitions = new ArrayList<CustomFieldDefinitionEntity>();
SessionUtils.setCollectionAttribute(SavingsConstants.CUSTOM_FIELDS, customFieldDefinitions, request);
SavingsProductReferenceDto savingsProductReferenceDto = this.savingsServiceFacade.retrieveSavingsProductReferenceData(productId);
savingsActionForm.setRecommendedAmount(savingsProductReferenceDto.getSavingsProductDetails().getAmountForDeposit().toString());
List<CustomFieldDto> customFields = CustomFieldDefinitionEntity.toDto(customFieldDefinitions, uc.getPreferredLocale());
savingsActionForm.setAccountCustomFieldSet(customFields);
return mapping.findForward("load_success");
}
use of org.mifos.security.util.UserContext in project head by mifos.
the class SavingsApplyAdjustmentAction method adjustLastUserAction.
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward adjustLastUserAction(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
request.setAttribute("method", "adjustLastUserAction");
UserContext uc = (UserContext) SessionUtils.getAttribute(Constants.USER_CONTEXT_KEY, request.getSession());
SavingsBO savings = (SavingsBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
Integer accountId = savings.getAccountId();
Integer versionNum = savings.getVersionNo();
savings = savingsDao.findById(accountId);
// NOTE: initialise so when error occurs when apply adjustment, savings object is correctly initialised for
// use within Tag library in jsp.
new SavingsPersistence().initialize(savings);
checkVersionMismatch(versionNum, savings.getVersionNo());
savings.setUserContext(uc);
SessionUtils.setAttribute(Constants.BUSINESS_KEY, savings, request);
if (savings.getPersonnel() != null) {
getBizService().checkPermissionForAdjustment(AccountTypes.SAVINGS_ACCOUNT, null, uc, savings.getOffice().getOfficeId(), savings.getPersonnel().getPersonnelId());
} else {
getBizService().checkPermissionForAdjustment(AccountTypes.SAVINGS_ACCOUNT, null, uc, savings.getOffice().getOfficeId(), uc.getId());
}
SavingsApplyAdjustmentActionForm actionForm = (SavingsApplyAdjustmentActionForm) form;
if (actionForm.getLastPaymentAmount() == null) {
throw new MifosRuntimeException("Null payment amount is not allowed");
}
// date validation
Date meetingDate = new CustomerPersistence().getLastMeetingDateForCustomer(savings.getCustomer().getCustomerId());
boolean repaymentIndependentOfMeetingEnabled = new ConfigurationPersistence().isRepaymentIndepOfMeetingEnabled();
if (!savings.isTrxnDateValid(actionForm.getTrxnDateLocal().toDateMidnight().toDate(), meetingDate, repaymentIndependentOfMeetingEnabled)) {
throw new AccountException(AccountConstants.ERROR_INVALID_TRXN);
}
Long savingsId = Long.valueOf(accountId.toString());
Double adjustedAmount = Double.valueOf(actionForm.getLastPaymentAmount());
String note = actionForm.getNote();
AccountPaymentEntity adjustedPayment = savings.findPaymentById(actionForm.getPaymentId());
AccountPaymentEntity otherTransferPayment = adjustedPayment.getOtherTransferPayment();
try {
if (otherTransferPayment == null || otherTransferPayment.isSavingsDepositOrWithdrawal()) {
// regular savings payment adjustment or savings-savings transfer adjustment
SavingsAdjustmentDto savingsAdjustment = new SavingsAdjustmentDto(savingsId, adjustedAmount, note, actionForm.getPaymentId(), actionForm.getTrxnDateLocal());
this.savingsServiceFacade.adjustTransaction(savingsAdjustment);
} else {
// adjust repayment from savings account
AccountBO account = adjustedPayment.getOtherTransferPayment().getAccount();
AdjustedPaymentDto adjustedPaymentDto = new AdjustedPaymentDto(actionForm.getLastPaymentAmount(), actionForm.getTrxnDateLocal().toDateMidnight().toDate(), otherTransferPayment.getPaymentType().getId());
this.accountServiceFacade.applyHistoricalAdjustment(account.getGlobalAccountNum(), otherTransferPayment.getPaymentId(), note, uc.getId(), adjustedPaymentDto);
}
} catch (BusinessRuleException e) {
throw new AccountException(e.getMessageKey(), e);
} finally {
doCleanUp(request);
}
return mapping.findForward("account_detail_page");
}
use of org.mifos.security.util.UserContext in project head by mifos.
the class RepayLoanActionForm method getUserLocale.
protected Locale getUserLocale(HttpServletRequest request) {
Locale locale = null;
HttpSession session = request.getSession();
if (session != null) {
UserContext userContext = (UserContext) session.getAttribute(LoginConstants.USERCONTEXT);
if (null != userContext) {
locale = userContext.getCurrentLocale();
}
}
return locale;
}
use of org.mifos.security.util.UserContext in project head by mifos.
the class AccountApplyGroupPaymentAction method load.
@TransactionDemarcate(joinToken = true)
public ActionForward load(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
UserContext userContext = getUserContext(request);
AccountApplyPaymentActionForm actionForm = (AccountApplyPaymentActionForm) form;
actionForm.setReceiptDate(null);
actionForm.setReceiptId(null);
actionForm.setPaymentTypeId(null);
actionForm.setTransactionDate(DateUtils.makeDateAsSentFromBrowser());
actionForm.setPrintReceipt(false);
actionForm.setTruePrintReceipt(false);
final AccountReferenceDto accountReferenceDto = new AccountReferenceDto(Integer.valueOf(actionForm.getAccountId()));
AccountPaymentDto accountPaymentDto = accountServiceFacade.getAccountPaymentInformation(accountReferenceDto.getAccountId(), request.getParameter(Constants.INPUT), userContext.getLocaleId(), new UserReferenceDto(userContext.getId()), DateUtils.getCurrentJavaDateTime());
setValuesInSession(request, actionForm, accountPaymentDto);
actionForm.setLastPaymentDate(accountPaymentDto.getLastPaymentDate());
actionForm.setAmount(accountPaymentDto.getTotalPaymentDue());
actionForm.setTransferPaymentTypeId(this.legacyAcceptedPaymentTypeDao.getSavingsTransferId());
LoanBO loan = loanDao.findById(accountReferenceDto.getAccountId());
if (loan.isGroupLoanAccountParent()) {
SessionUtils.setAttribute(LOAN_TYPE, PARENT, request);
} else if (loan.isGroupLoanAccountMember()) {
SessionUtils.setAttribute(LOAN_TYPE, MEMBER, request);
}
List<LoanBO> memberInfos = getMemberAccountsInformation(actionForm.getAccountId());
SessionUtils.setCollectionAttribute("memberInfos", memberInfos, request);
if (memberInfos.size() > 0) {
actionForm.getIndividualValues().clear();
List<GroupIndividualLoanDto> memberAccounts = groupLoanService.getMemberLoansAndDefaultPayments(Integer.valueOf(actionForm.getAccountId()), new BigDecimal(actionForm.getAmount()));
for (int i = 0; i < memberAccounts.size(); i++) {
actionForm.getIndividualValues().put(memberAccounts.get(i).getAccountId(), String.valueOf(memberAccounts.get(i).getDefaultAmount().doubleValue()));
}
}
return mapping.findForward(ActionForwards.load_success.toString());
}
Aggregations