Search in sources :

Example 1 with SavingsAccountDepositDueDto

use of org.mifos.dto.screen.SavingsAccountDepositDueDto 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");
}
Also used : SavingsActionForm(org.mifos.accounts.savings.struts.actionforms.SavingsActionForm) AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) AccountFlagMapping(org.mifos.accounts.business.AccountFlagMapping) UserContext(org.mifos.security.util.UserContext) SavingsBO(org.mifos.accounts.savings.business.SavingsBO) SavingsAccountDepositDueDto(org.mifos.dto.screen.SavingsAccountDepositDueDto) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Example 2 with SavingsAccountDepositDueDto

use of org.mifos.dto.screen.SavingsAccountDepositDueDto in project head by mifos.

the class SavingsServiceFacadeWebTier method retrieveDepositDueDetails.

@Override
public SavingsAccountDepositDueDto retrieveDepositDueDetails(String globalAccountNum) {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = toUserContext(user);
    SavingsBO savingsAccount = this.savingsDao.findBySystemId(globalAccountNum);
    try {
        personnelDao.checkAccessPermission(userContext, savingsAccount.getOfficeId(), savingsAccount.getCustomer().getLoanOfficerId());
    } catch (AccountException e) {
        throw new MifosRuntimeException(e.getMessage(), e);
    }
    List<DueOnDateDto> previousDueDates = new ArrayList<DueOnDateDto>();
    SavingsScheduleEntity nextInstallment = (SavingsScheduleEntity) savingsAccount.getDetailsOfNextInstallment();
    Money totalDepositDue = Money.zero(savingsAccount.getCurrency());
    LocalDate nextDueDate = new LocalDate();
    if (nextInstallment != null) {
        nextDueDate = new LocalDate(nextInstallment.getActionDate());
        totalDepositDue = nextInstallment.getTotalDepositDue();
    }
    List<AccountActionDateEntity> scheduledDeposits = savingsAccount.getAccountActionDatesSortedByInstallmentId();
    for (AccountActionDateEntity scheduledDeposit : scheduledDeposits) {
        if (!scheduledDeposit.isPaid() && scheduledDeposit.isBefore(nextDueDate)) {
            SavingsScheduleEntity savingsScheduledDeposit = (SavingsScheduleEntity) scheduledDeposit;
            previousDueDates.add(new DueOnDateDto(scheduledDeposit.getActionDate(), MoneyUtils.currencyRound(savingsScheduledDeposit.getTotalDepositDue()).toString()));
        }
    }
    DueOnDateDto nextDueDetail = new DueOnDateDto(new java.sql.Date(nextDueDate.toDateMidnight().toDate().getTime()), MoneyUtils.currencyRound(totalDepositDue).toString());
    AccountStateEntity accountStateEntity = savingsAccount.getAccountState();
    return new SavingsAccountDepositDueDto(nextDueDetail, previousDueDates, accountStateEntity.getId(), accountStateEntity.getName());
}
Also used : UserContext(org.mifos.security.util.UserContext) ArrayList(java.util.ArrayList) MifosUser(org.mifos.security.MifosUser) SavingsBO(org.mifos.accounts.savings.business.SavingsBO) AccountStateEntity(org.mifos.accounts.business.AccountStateEntity) LocalDate(org.joda.time.LocalDate) SavingsAccountDepositDueDto(org.mifos.dto.screen.SavingsAccountDepositDueDto) DueOnDateDto(org.mifos.dto.domain.DueOnDateDto) Money(org.mifos.framework.util.helpers.Money) AccountActionDateEntity(org.mifos.accounts.business.AccountActionDateEntity) AccountException(org.mifos.accounts.exceptions.AccountException) SavingsScheduleEntity(org.mifos.accounts.savings.business.SavingsScheduleEntity) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Aggregations

AccountActionDateEntity (org.mifos.accounts.business.AccountActionDateEntity)2 SavingsBO (org.mifos.accounts.savings.business.SavingsBO)2 SavingsAccountDepositDueDto (org.mifos.dto.screen.SavingsAccountDepositDueDto)2 UserContext (org.mifos.security.util.UserContext)2 ArrayList (java.util.ArrayList)1 LocalDate (org.joda.time.LocalDate)1 AccountFlagMapping (org.mifos.accounts.business.AccountFlagMapping)1 AccountStateEntity (org.mifos.accounts.business.AccountStateEntity)1 AccountException (org.mifos.accounts.exceptions.AccountException)1 SavingsScheduleEntity (org.mifos.accounts.savings.business.SavingsScheduleEntity)1 SavingsActionForm (org.mifos.accounts.savings.struts.actionforms.SavingsActionForm)1 MifosRuntimeException (org.mifos.core.MifosRuntimeException)1 DueOnDateDto (org.mifos.dto.domain.DueOnDateDto)1 Money (org.mifos.framework.util.helpers.Money)1 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)1 MifosUser (org.mifos.security.MifosUser)1