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");
}
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());
}
Aggregations