use of org.mifos.dto.domain.SavingsAccountDetailDto in project head by mifos.
the class StandardAccountService method makePaymentFromSavings.
@Override
public void makePaymentFromSavings(AccountPaymentParametersDto accountPaymentParametersDto, String savingsGlobalAccNum) {
transactionHelper.flushAndClearSession();
SavingsAccountDetailDto savingsAcc = savingsServiceFacade.retrieveSavingsAccountDetails(savingsGlobalAccNum);
MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
Long savingsId = savingsAcc.getAccountId().longValue();
Long customerId = accountPaymentParametersDto.getCustomer().getCustomerId().longValue();
LocalDate dateOfWithdrawal = accountPaymentParametersDto.getPaymentDate();
Double amount = accountPaymentParametersDto.getPaymentAmount().doubleValue();
Integer modeOfPayment = accountPaymentParametersDto.getPaymentType().getValue().intValue();
String receiptId = accountPaymentParametersDto.getReceiptId();
LocalDate dateOfReceipt = accountPaymentParametersDto.getReceiptDate();
Locale preferredLocale = Localization.getInstance().getLocaleById(user.getPreferredLocaleId());
SavingsWithdrawalDto savingsWithdrawalDto = new SavingsWithdrawalDto(savingsId, customerId, dateOfWithdrawal, amount, modeOfPayment, receiptId, dateOfReceipt, preferredLocale);
try {
transactionHelper.startTransaction();
PaymentDto withdrawal = this.savingsServiceFacade.withdraw(savingsWithdrawalDto, true);
makePaymentNoCommit(accountPaymentParametersDto, withdrawal.getPaymentId(), null);
transactionHelper.commitTransaction();
} catch (AccountException e) {
transactionHelper.rollbackTransaction();
throw new BusinessRuleException(e.getKey(), e);
} catch (BusinessRuleException e) {
transactionHelper.rollbackTransaction();
throw new BusinessRuleException(e.getMessageKey(), e);
} catch (Exception e) {
transactionHelper.rollbackTransaction();
throw new MifosRuntimeException(e);
}
}
use of org.mifos.dto.domain.SavingsAccountDetailDto in project head by mifos.
the class SavingsBO method toDto.
public SavingsAccountDetailDto toDto() {
List<SavingsRecentActivityDto> recentActivity = this.getRecentAccountActivity(3);
List<CustomerNoteDto> recentNoteDtos = new ArrayList<CustomerNoteDto>();
List<AccountNotesEntity> recentNotes = this.getRecentAccountNotes();
for (AccountNotesEntity accountNotesEntity : recentNotes) {
recentNoteDtos.add(new CustomerNoteDto(accountNotesEntity.getCommentDate(), accountNotesEntity.getComment(), accountNotesEntity.getPersonnelName()));
}
SavingsPerformanceHistoryDto savingsPerformanceHistoryDto = new SavingsPerformanceHistoryDto(getActivationDate(), savingsPerformance.getTotalDeposits().toString(), savingsPerformance.getTotalWithdrawals().toString(), savingsPerformance.getTotalInterestEarned().toString(), savingsPerformance.getMissedDeposits() != null ? savingsPerformance.getMissedDeposits().toString() : "0");
AccountActionDateEntity nextInstallment = getDetailsOfNextInstallment();
return new SavingsAccountDetailDto(this.savingsOffering.toFullDto(), recentActivity, recentNoteDtos, this.recommendedAmount.toString(), this.globalAccountNum, getAccountId(), getState().getValue(), getState().name(), getSavingsBalance().toString(), nextInstallment != null ? nextInstallment.getActionDate() : null, getTotalAmountDue().toString(), getTotalAmountDueForNextInstallment().toString(), getTotalAmountInArrears().toString(), savingsPerformanceHistoryDto, this.savingsOffering.getSavingsTypeAsEnum().name(), this.customer.getCustomerId());
}
use of org.mifos.dto.domain.SavingsAccountDetailDto in project head by mifos.
the class SavingsAction method get.
@TransactionDemarcate(saveToken = true)
public ActionForward get(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
UserContext uc = (UserContext) SessionUtils.getAttribute(Constants.USER_CONTEXT_KEY, request.getSession());
SavingsActionForm actionForm = (SavingsActionForm) form;
actionForm.setInput(null);
String globalAccountNum = actionForm.getGlobalAccountNum();
if (StringUtils.isBlank(actionForm.getGlobalAccountNum())) {
SavingsBO savings = (SavingsBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, request);
globalAccountNum = savings.getGlobalAccountNum();
}
logger.debug(" Retrieving for globalAccountNum: " + globalAccountNum);
SavingsBO savings = this.savingsDao.findBySystemId(globalAccountNum);
savings.setUserContext(uc);
SavingsAccountDetailDto savingsAccountDto;
try {
savingsAccountDto = this.savingsServiceFacade.retrieveSavingsAccountDetails(savings.getAccountId().longValue());
} catch (MifosRuntimeException e) {
if (e.getCause() instanceof ApplicationException) {
throw (ApplicationException) e.getCause();
}
throw e;
}
List<AdminDocumentBO> allAdminDocuments = legacyAdminDocumentDao.getAllActiveAdminDocuments();
List<AdminDocumentBO> savingsAdminDocuments = new ArrayList();
for (AdminDocumentBO adminDocumentBO : allAdminDocuments) {
List<AdminDocAccStateMixBO> admindoclist = legacyAdminDocAccStateMixDao.getMixByAdminDocuments(adminDocumentBO.getAdmindocId());
if (!savingsAdminDocuments.contains(adminDocumentBO) && admindoclist.size() > 0 && admindoclist.get(0).getAccountStateID().getPrdType().getProductTypeID().equals(Short.valueOf("2"))) {
savingsAdminDocuments.add(adminDocumentBO);
}
}
SessionUtils.setCollectionAttribute("administrativeDocumentsList", savingsAdminDocuments, request);
SessionUtils.setAttribute(Constants.BUSINESS_KEY, savings, request);
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);
SessionUtils.setAttribute(SavingsConstants.PRDOFFERING, savings.getSavingsOffering(), request);
actionForm.setRecommendedAmount(savingsAccountDto.getRecommendedOrMandatoryAmount());
actionForm.clear();
SessionUtils.setCollectionAttribute(SavingsConstants.RECENTY_ACTIVITY_DETAIL_PAGE, savingsAccountDto.getRecentActivity(), request);
SessionUtils.setCollectionAttribute(SavingsConstants.NOTES, savings.getRecentAccountNotes(), request);
logger.info(" Savings object retrieved successfully");
setCurrentPageUrl(request, savings);
setQuestionGroupInstances(request, savings);
request.getSession().setAttribute("backPageUrl", request.getAttribute("currentPageUrl"));
return mapping.findForward("get_success");
}
use of org.mifos.dto.domain.SavingsAccountDetailDto in project head by mifos.
the class SavingsAccountController method showSavingsAccountDepositDueDetails.
@RequestMapping(value = "/viewSavingsAccountDepositDueDetails", method = RequestMethod.GET)
public ModelAndView showSavingsAccountDepositDueDetails(HttpServletRequest request, HttpServletResponse response) {
ModelAndView modelAndView = new ModelAndView();
sitePreferenceHelper.resolveSiteType(modelAndView, "viewSavingsAccountDepositDueDetails", request);
modelAndView.addObject("include_page", new IncludePage(request, response));
String globalAccountNum = request.getParameter("globalAccountNum");
SavingsAccountDetailDto savingsAccountDetailDto = savingsServiceFacade.retrieveSavingsAccountDetails(globalAccountNum);
modelAndView.addObject("savingsAccountDetailDto", savingsAccountDetailDto);
savingsServiceFacade.putSavingsBusinessKeyInSession(globalAccountNum, request);
return modelAndView;
}
use of org.mifos.dto.domain.SavingsAccountDetailDto in project head by mifos.
the class SavingsAccountController method showSavingsAccountTransactionHistory.
@RequestMapping(value = "/viewSavingsAccountTransactionHistory", method = RequestMethod.GET)
public ModelAndView showSavingsAccountTransactionHistory(HttpServletRequest request, HttpServletResponse response) {
ModelAndView modelAndView = new ModelAndView();
sitePreferenceHelper.resolveSiteType(modelAndView, "viewSavingsAccountTransactionHistory", request);
modelAndView.addObject("include_page", new IncludePage(request, response));
String globalAccountNum = request.getParameter("globalAccountNum");
SavingsAccountDetailDto savingsAccountDetailDto = savingsServiceFacade.retrieveSavingsAccountDetails(globalAccountNum);
modelAndView.addObject("savingsAccountDetailDto", savingsAccountDetailDto);
List<SavingsTransactionHistoryDto> savingsTransactionHistoryViewList = this.savingsServiceFacade.retrieveTransactionHistory(globalAccountNum);
request.setAttribute("trxnHistoryList", savingsTransactionHistoryViewList);
savingsServiceFacade.putSavingsBusinessKeyInSession(globalAccountNum, request);
return modelAndView;
}
Aggregations