Search in sources :

Example 1 with SavingsAccountDetailDto

use of org.mifos.dto.domain.SavingsAccountDetailDto in project head by mifos.

the class NotesAction method load.

@TransactionDemarcate(joinToken = true)
public ActionForward load(ActionMapping mapping, ActionForm form, @SuppressWarnings("unused") HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
    clearActionForm(form);
    NotesActionForm notesActionForm = (NotesActionForm) form;
    Integer accountId = Integer.valueOf(notesActionForm.getAccountId());
    AccountBO account = new AccountBusinessService().getAccount(accountId);
    if (account.isLoanAccount() || account.isGroupLoanAccount()) {
        LoanAccountDetailDto loanAccountDto = this.loanAccountServiceFacade.retrieveLoanAccountNotes(accountId.longValue());
        if (account.isLoanAccount()) {
            notesActionForm.setAccountTypeId(AccountTypes.LOAN_ACCOUNT.getValue().toString());
        } else {
            notesActionForm.setAccountTypeId(AccountTypes.GROUP_LOAN_ACCOUNT.getValue().toString());
        }
        notesActionForm.setGlobalAccountNum(loanAccountDto.getGlobalAccountNum());
        notesActionForm.setPrdOfferingName(loanAccountDto.getProductDetails().getPrdOfferingName());
    } else if (account.isSavingsAccount()) {
        SavingsAccountDetailDto savingsAccountDto = this.savingsServiceFacade.retrieveSavingsAccountNotes(accountId.longValue());
        notesActionForm.setPrdOfferingName(savingsAccountDto.getProductDetails().getProductDetails().getName());
        notesActionForm.setAccountTypeId(AccountTypes.SAVINGS_ACCOUNT.getValue().toString());
        notesActionForm.setGlobalAccountNum(savingsAccountDto.getGlobalAccountNum());
    }
    return mapping.findForward(ActionForwards.load_success.toString());
}
Also used : AccountBO(org.mifos.accounts.business.AccountBO) AccountBusinessService(org.mifos.accounts.business.service.AccountBusinessService) NotesActionForm(org.mifos.accounts.struts.actionforms.NotesActionForm) LoanAccountDetailDto(org.mifos.dto.screen.LoanAccountDetailDto) SavingsAccountDetailDto(org.mifos.dto.domain.SavingsAccountDetailDto) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 2 with SavingsAccountDetailDto

use of org.mifos.dto.domain.SavingsAccountDetailDto in project head by mifos.

the class LoanAccountServiceFacadeWebTier method makeEarlyRepaymentFromSavings.

public void makeEarlyRepaymentFromSavings(RepayLoanInfoDto repayLoanInfoDto, String savingsAccGlobalNum) {
    MifosUser mifosUser = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = new UserContextFactory().create(mifosUser);
    SavingsAccountDetailDto savingsAcc = savingsServiceFacade.retrieveSavingsAccountDetails(savingsAccGlobalNum);
    Long savingsId = savingsAcc.getAccountId().longValue();
    Long customerId = savingsAcc.getCustomerId().longValue();
    LocalDate trxnDate = new LocalDate(repayLoanInfoDto.getDateOfPayment());
    Double amount = Double.parseDouble(repayLoanInfoDto.getEarlyRepayAmount());
    Integer paymentTypeId = Integer.parseInt(repayLoanInfoDto.getPaymentTypeId());
    String receiptId = repayLoanInfoDto.getReceiptNumber();
    LocalDate receiptDate = new LocalDate(repayLoanInfoDto.getReceiptDate());
    Locale preferredLocale = userContext.getPreferredLocale();
    SavingsWithdrawalDto savingsWithdrawalDto = new SavingsWithdrawalDto(savingsId, customerId, trxnDate, amount, paymentTypeId, receiptId, receiptDate, preferredLocale);
    try {
        transactionHelper.startTransaction();
        PaymentDto withdrawal = savingsServiceFacade.withdraw(savingsWithdrawalDto, true);
        repayLoanInfoDto.setSavingsPaymentId(withdrawal.getPaymentId());
        makeEarlyRepayment(repayLoanInfoDto);
        transactionHelper.commitTransaction();
    } 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) UserContext(org.mifos.security.util.UserContext) MifosUser(org.mifos.security.MifosUser) UserContextFactory(org.mifos.accounts.servicefacade.UserContextFactory) SavingsWithdrawalDto(org.mifos.dto.domain.SavingsWithdrawalDto) LocalDate(org.joda.time.LocalDate) PaymentDto(org.mifos.dto.domain.PaymentDto) AccountPaymentDto(org.mifos.dto.screen.AccountPaymentDto) LoanPaymentDto(org.mifos.dto.domain.LoanPaymentDto) ExpectedPaymentDto(org.mifos.dto.screen.ExpectedPaymentDto) StatesInitializationException(org.mifos.framework.exceptions.StatesInitializationException) BusinessRuleException(org.mifos.service.BusinessRuleException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) ServiceException(org.mifos.framework.exceptions.ServiceException) HibernateSearchException(org.mifos.framework.exceptions.HibernateSearchException) PageExpiredException(org.mifos.framework.exceptions.PageExpiredException) SystemException(org.mifos.framework.exceptions.SystemException) MifosRuntimeException(org.mifos.core.MifosRuntimeException) AccountException(org.mifos.accounts.exceptions.AccountException) PropertyNotFoundException(org.mifos.framework.exceptions.PropertyNotFoundException) ConfigurationException(org.mifos.config.exceptions.ConfigurationException) MeetingException(org.mifos.application.meeting.exceptions.MeetingException) BusinessRuleException(org.mifos.service.BusinessRuleException) SavingsAccountDetailDto(org.mifos.dto.domain.SavingsAccountDetailDto) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 3 with SavingsAccountDetailDto

use of org.mifos.dto.domain.SavingsAccountDetailDto in project head by mifos.

the class SavingsAccountController method showSavingsAccountDetails.

@RequestMapping(value = "/viewSavingsAccountDetails", method = RequestMethod.GET)
public ModelAndView showSavingsAccountDetails(HttpServletRequest request, HttpServletResponse response) {
    ModelAndView modelAndView = new ModelAndView();
    sitePreferenceHelper.resolveSiteType(modelAndView, "viewSavingsAccountDetails", request);
    modelAndView.addObject("include_page", new IncludePage(request, response));
    String globalAccountNum = request.getParameter("globalAccountNum");
    SavingsAccountDetailDto savingsAccountDetailDto = savingsServiceFacade.retrieveSavingsAccountDetails(globalAccountNum);
    modelAndView.addObject("savingsAccountDetailDto", savingsAccountDetailDto);
    boolean containsQGForCloseSavings = false;
    containsQGForCloseSavings = questionnaireServiceFacade.getQuestionGroupInstances(savingsAccountDetailDto.getAccountId(), "Close", "Savings").size() > 0;
    modelAndView.addObject("containsQGForCloseSavings", containsQGForCloseSavings);
    modelAndView.addObject("backPageUrl", UrlHelper.constructCurrentPageUrl(request));
    savingsServiceFacade.putSavingsBusinessKeyInSession(globalAccountNum, request);
    // for mifostabletag
    request.getSession().setAttribute("recentActivityForDetailPage", savingsAccountDetailDto.getRecentActivity());
    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 4 with SavingsAccountDetailDto

use of org.mifos.dto.domain.SavingsAccountDetailDto in project head by mifos.

the class SavingsAccountController method showSavingsAccountRecentActivity.

@RequestMapping(value = "/viewSavingsAccountRecentActivity", method = RequestMethod.GET)
public ModelAndView showSavingsAccountRecentActivity(HttpServletRequest request, HttpServletResponse response) {
    ModelAndView modelAndView = new ModelAndView();
    sitePreferenceHelper.resolveSiteType(modelAndView, "viewSavingsAccountRecentActivity", request);
    modelAndView.addObject("include_page", new IncludePage(request, response));
    String globalAccountNum = request.getParameter("globalAccountNum");
    SavingsAccountDetailDto savingsAccountDetailDto = savingsServiceFacade.retrieveSavingsAccountDetails(globalAccountNum);
    modelAndView.addObject("savingsAccountDetailDto", savingsAccountDetailDto);
    modelAndView.addObject("currentDate", new Date());
    List<SavingsRecentActivityDto> recentActivity = this.savingsServiceFacade.retrieveRecentSavingsActivities(savingsAccountDetailDto.getAccountId().longValue());
    request.setAttribute("recentActivityList", recentActivity);
    savingsServiceFacade.putSavingsBusinessKeyInSession(globalAccountNum, request);
    return modelAndView;
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) IncludePage(freemarker.ext.servlet.IncludePage) SavingsRecentActivityDto(org.mifos.dto.screen.SavingsRecentActivityDto) SavingsAccountDetailDto(org.mifos.dto.domain.SavingsAccountDetailDto) Date(java.util.Date) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 5 with SavingsAccountDetailDto

use of org.mifos.dto.domain.SavingsAccountDetailDto in project head by mifos.

the class CreateSavingsAccountController method createAccount.

private SavingsAccountDetailDto createAccount(CreateSavingsAccountFormBean formBean, Short accountState) {
    SavingsProductReferenceDto productReference = formBean.getProduct();
    SavingsProductDto savingsProduct = productReference.getSavingsProductDetails();
    Integer productId = savingsProduct.getProductDetails().getId();
    Integer customerId = formBean.getCustomer().getCustomerId();
    // TODO - deposit amount should be validated before reaching here...
    String recommendedOrMandatoryAmount = formBean.getMandatoryDepositAmount();
    SavingsAccountCreationDto savingsAccountCreation = new SavingsAccountCreationDto(productId, customerId, accountState, recommendedOrMandatoryAmount);
    Long savingsId = savingsServiceFacade.createSavingsAccount(savingsAccountCreation, formBean.getQuestionGroups());
    SavingsAccountDetailDto savingsAccountDetailDto = savingsServiceFacade.retrieveSavingsAccountDetails(savingsId);
    return savingsAccountDetailDto;
}
Also used : SavingsProductReferenceDto(org.mifos.dto.screen.SavingsProductReferenceDto) SavingsProductDto(org.mifos.dto.domain.SavingsProductDto) SavingsAccountCreationDto(org.mifos.dto.domain.SavingsAccountCreationDto) SavingsAccountDetailDto(org.mifos.dto.domain.SavingsAccountDetailDto)

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