Search in sources :

Example 6 with SavingsAccountDetailDto

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);
    }
}
Also used : Locale(java.util.Locale) MifosUser(org.mifos.security.MifosUser) SavingsWithdrawalDto(org.mifos.dto.domain.SavingsWithdrawalDto) LocalDate(org.joda.time.LocalDate) AccountPaymentDto(org.mifos.dto.domain.AccountPaymentDto) PaymentDto(org.mifos.dto.domain.PaymentDto) NonUniqueResultException(org.hibernate.NonUniqueResultException) BusinessRuleException(org.mifos.service.BusinessRuleException) MifosRuntimeException(org.mifos.core.MifosRuntimeException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) AccountException(org.mifos.accounts.exceptions.AccountException) BusinessRuleException(org.mifos.service.BusinessRuleException) AccountException(org.mifos.accounts.exceptions.AccountException) SavingsAccountDetailDto(org.mifos.dto.domain.SavingsAccountDetailDto) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 7 with SavingsAccountDetailDto

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());
}
Also used : AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) CustomerNoteDto(org.mifos.dto.domain.CustomerNoteDto) ArrayList(java.util.ArrayList) SavingsRecentActivityDto(org.mifos.dto.screen.SavingsRecentActivityDto) AccountNotesEntity(org.mifos.accounts.business.AccountNotesEntity) SavingsPerformanceHistoryDto(org.mifos.dto.domain.SavingsPerformanceHistoryDto) SavingsAccountDetailDto(org.mifos.dto.domain.SavingsAccountDetailDto)

Example 8 with SavingsAccountDetailDto

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");
}
Also used : UserContext(org.mifos.security.util.UserContext) ArrayList(java.util.ArrayList) SavingsBO(org.mifos.accounts.savings.business.SavingsBO) AdminDocAccStateMixBO(org.mifos.reports.admindocuments.business.AdminDocAccStateMixBO) RecommendedAmntUnitEntity(org.mifos.accounts.productdefinition.business.RecommendedAmntUnitEntity) CustomFieldDefinitionEntity(org.mifos.application.master.business.CustomFieldDefinitionEntity) SavingsActionForm(org.mifos.accounts.savings.struts.actionforms.SavingsActionForm) ApplicationException(org.mifos.framework.exceptions.ApplicationException) SavingsTypeEntity(org.mifos.accounts.productdefinition.business.SavingsTypeEntity) AdminDocumentBO(org.mifos.reports.admindocuments.business.AdminDocumentBO) SavingsAccountDetailDto(org.mifos.dto.domain.SavingsAccountDetailDto) MifosRuntimeException(org.mifos.core.MifosRuntimeException) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 9 with SavingsAccountDetailDto

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;
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) IncludePage(freemarker.ext.servlet.IncludePage) SavingsAccountDetailDto(org.mifos.dto.domain.SavingsAccountDetailDto) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 10 with SavingsAccountDetailDto

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;
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) IncludePage(freemarker.ext.servlet.IncludePage) SavingsTransactionHistoryDto(org.mifos.dto.screen.SavingsTransactionHistoryDto) SavingsAccountDetailDto(org.mifos.dto.domain.SavingsAccountDetailDto) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

SavingsAccountDetailDto (org.mifos.dto.domain.SavingsAccountDetailDto)11 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)5 IncludePage (freemarker.ext.servlet.IncludePage)4 ModelAndView (org.springframework.web.servlet.ModelAndView)4 MifosRuntimeException (org.mifos.core.MifosRuntimeException)3 ArrayList (java.util.ArrayList)2 Locale (java.util.Locale)2 LocalDate (org.joda.time.LocalDate)2 AccountException (org.mifos.accounts.exceptions.AccountException)2 PaymentDto (org.mifos.dto.domain.PaymentDto)2 SavingsAccountCreationDto (org.mifos.dto.domain.SavingsAccountCreationDto)2 SavingsWithdrawalDto (org.mifos.dto.domain.SavingsWithdrawalDto)2 SavingsRecentActivityDto (org.mifos.dto.screen.SavingsRecentActivityDto)2 PersistenceException (org.mifos.framework.exceptions.PersistenceException)2 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)2 MifosUser (org.mifos.security.MifosUser)2 UserContext (org.mifos.security.util.UserContext)2 BusinessRuleException (org.mifos.service.BusinessRuleException)2 Date (java.util.Date)1 HashMap (java.util.HashMap)1