use of org.mifos.dto.domain.AccountFeeScheduleDto in project head by mifos.
the class CenterServiceFacadeWebTier method retrieveChargesDetails.
@Override
public CustomerChargesDetailsDto retrieveChargesDetails(Integer customerId) {
MifosUser mifosUser = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = new UserContextFactory().create(mifosUser);
CustomerBO customerBO = this.customerDao.findCustomerById(customerId);
CustomerAccountBO customerAccount = customerBO.getCustomerAccount();
try {
personnelDao.checkAccessPermission(userContext, customerBO.getOfficeId(), customerBO.getLoanOfficerId());
} catch (AccountException e) {
throw new MifosRuntimeException("Access denied!", e);
}
List<AccountFeesDto> accountFeesDtos = new ArrayList<AccountFeesDto>();
if (!customerAccount.getAccountFees().isEmpty()) {
for (AccountFeesEntity accountFeesEntity : customerAccount.getAccountFees()) {
AccountFeesDto accountFeesDto = new AccountFeesDto(accountFeesEntity.getFees().getFeeFrequency().getFeeFrequencyType().getId(), (accountFeesEntity.getFees().getFeeFrequency().getFeePayment() != null ? accountFeesEntity.getFees().getFeeFrequency().getFeePayment().getId() : null), accountFeesEntity.getFeeStatus(), accountFeesEntity.getFees().getFeeName(), accountFeesEntity.getAccountFeeAmount().toString(), getMeetingRecurrence(accountFeesEntity.getFees().getFeeFrequency().getFeeMeetingFrequency(), userContext), accountFeesEntity.getFees().getFeeId());
accountFeesDtos.add(accountFeesDto);
}
}
CustomerScheduleDto customerSchedule = null;
CustomerScheduleEntity scheduleEntity = (CustomerScheduleEntity) customerAccount.getUpcomingInstallment();
if (scheduleEntity != null) {
Set<AccountFeesActionDetailEntity> feeEntities = scheduleEntity.getAccountFeesActionDetails();
List<AccountFeeScheduleDto> feeDtos = new ArrayList<AccountFeeScheduleDto>();
for (AccountFeesActionDetailEntity feeEntity : feeEntities) {
feeDtos.add(convertToDto(feeEntity));
}
customerSchedule = new CustomerScheduleDto(scheduleEntity.getMiscFee().toString(), scheduleEntity.getMiscFeePaid().toString(), scheduleEntity.getMiscPenalty().toString(), scheduleEntity.getMiscPenaltyPaid().toString(), feeDtos);
}
return new CustomerChargesDetailsDto(customerAccount.getNextDueAmount().toString(), customerAccount.getTotalAmountInArrears().toString(), customerAccount.getTotalAmountDue().toString(), customerAccount.getUpcomingChargesDate(), customerSchedule, accountFeesDtos);
}
use of org.mifos.dto.domain.AccountFeeScheduleDto in project head by mifos.
the class LoanAccountServiceFacadeWebTier method retrieveLoanRepaymentSchedule.
@Override
public List<LoanRepaymentScheduleItemDto> retrieveLoanRepaymentSchedule(String globalAccountNum, Date viewDate) {
MifosUser mifosUser = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
UserContext userContext = new UserContextFactory().create(mifosUser);
LoanBO loanBO = this.loanDao.findByGlobalAccountNum(globalAccountNum);
try {
personnelDao.checkAccessPermission(userContext, loanBO.getOfficeId(), loanBO.getCustomer().getLoanOfficerId());
} catch (AccountException e) {
throw new MifosRuntimeException(e.getMessage(), e);
}
Errors errors = loanBusinessService.computeExtraInterest(loanBO, viewDate);
if (errors.hasErrors()) {
throw new MifosRuntimeException(errors.getErrorEntries().get(0).getDefaultMessage());
}
List<LoanRepaymentScheduleItemDto> loanSchedule = new ArrayList<LoanRepaymentScheduleItemDto>();
for (AccountActionDateEntity accountAction : loanBO.getAccountActionDates()) {
LoanScheduleEntity loanAccountAction = (LoanScheduleEntity) accountAction;
Set<AccountFeesActionDetailEntity> feeEntities = loanAccountAction.getAccountFeesActionDetails();
List<AccountFeeScheduleDto> feeDtos = new ArrayList<AccountFeeScheduleDto>();
for (AccountFeesActionDetailEntity feeEntity : feeEntities) {
feeDtos.add(convertToDto(feeEntity));
}
loanSchedule.add(new LoanRepaymentScheduleItemDto(loanAccountAction.getInstallmentId(), loanAccountAction.getActionDate(), loanAccountAction.getPaymentStatus(), loanAccountAction.getPaymentDate(), loanAccountAction.getPrincipal().toString(), loanAccountAction.getPrincipalPaid().toString(), loanAccountAction.getInterest().toString(), loanAccountAction.getInterestPaid().toString(), loanAccountAction.getPenalty().toString(), loanAccountAction.getPenaltyPaid().toString(), loanAccountAction.getExtraInterest().toString(), loanAccountAction.getExtraInterestPaid().toString(), loanAccountAction.getMiscFee().toString(), loanAccountAction.getMiscFeePaid().toString(), loanAccountAction.getMiscPenalty().toString(), loanAccountAction.getMiscPenaltyPaid().toString(), feeDtos));
}
return loanSchedule;
}
Aggregations