use of org.mifos.dto.screen.CashFlowDataDto in project head by mifos.
the class LoanAccountServiceFacadeWebTier method retrieveCashFlowSummary.
@Override
public List<CashFlowDataDto> retrieveCashFlowSummary(List<MonthlyCashFlowDto> monthlyCashFlow, LoanScheduleDto loanScheduleDto) {
List<CashFlowDataDto> cashflowdetails = new ArrayList<CashFlowDataDto>();
for (MonthlyCashFlowDto monthlyCashflowform : monthlyCashFlow) {
CashFlowDataDto cashflowDataDto = new CashFlowDataDto();
cashflowDataDto.setMonth(monthlyCashflowform.getMonthDate().monthOfYear().getAsText());
cashflowDataDto.setYear(String.valueOf(monthlyCashflowform.getMonthDate().getYear()));
cashflowDataDto.setCumulativeCashFlow(String.valueOf(monthlyCashflowform.getCumulativeCashFlow().setScale(AccountingRules.getDigitsAfterDecimal(), BigDecimal.ROUND_HALF_UP)));
cashflowDataDto.setMonthYear(monthlyCashflowform.getMonthDate().toDate());
cashflowDataDto.setNotes(monthlyCashflowform.getNotes());
String cumulativeCashflowAndInstallment = computeDiffBetweenCumulativeAndInstallment(monthlyCashflowform.getMonthDate(), monthlyCashflowform.getCumulativeCashFlow(), loanScheduleDto);
cashflowDataDto.setDiffCumulativeCashflowAndInstallment(cumulativeCashflowAndInstallment);
String cashflowAndInstallmentPercent = computeDiffBetweenCumulativeAndInstallmentPercent(monthlyCashflowform.getMonthDate(), monthlyCashflowform.getCumulativeCashFlow(), loanScheduleDto);
cashflowDataDto.setDiffCumulativeCashflowAndInstallmentPercent(cashflowAndInstallmentPercent);
cashflowdetails.add(cashflowDataDto);
}
return cashflowdetails;
}
use of org.mifos.dto.screen.CashFlowDataDto in project head by mifos.
the class LoanAccountServiceFacadeWebTier method validateCashFlowForInstallmentsForWarnings.
@Override
public Errors validateCashFlowForInstallmentsForWarnings(List<CashFlowDataDto> cashFlowDataDtos, Integer productId) {
Errors errors = new Errors();
LoanOfferingBO loanOfferingBO = this.loanProductDao.findById(productId);
if (loanOfferingBO.shouldValidateCashFlowForInstallments()) {
CashFlowDetail cashFlowDetail = loanOfferingBO.getCashFlowDetail();
if (CollectionUtils.isNotEmpty(cashFlowDataDtos)) {
for (CashFlowDataDto cashflowDataDto : cashFlowDataDtos) {
validateCashFlow(errors, cashFlowDetail.getCashFlowThreshold(), cashflowDataDto);
}
}
}
return errors;
}
use of org.mifos.dto.screen.CashFlowDataDto in project head by mifos.
the class LoanAccountController method retrieveCashflowSummaryDetails.
public List<CashFlowDataDto> retrieveCashflowSummaryDetails(CashFlowSummaryFormBean formBean, CashFlowDto cashFlowDto, List<MonthlyCashFlowDto> monthlyCashFlow, LoanScheduleDto loanScheduleDto, int productId, LoanAccountFormBean loanAccountFormBean) {
List<CashFlowDataDto> cashFlowDataDtos = this.loanAccountServiceFacade.retrieveCashFlowSummary(monthlyCashFlow, loanScheduleDto);
formBean.setCashFlowDataDtos(cashFlowDataDtos);
formBean.setProductId(productId);
BigDecimal loanAmount = BigDecimal.valueOf(loanScheduleDto.getLoanAmount());
BigDecimal totalInstallmentAmount = BigDecimal.ZERO;
DateTime firstInstallmentDueDate = new DateTime();
DateTime lastInstallmentDueDate = new DateTime();
List<DateTime> installments = new ArrayList<DateTime>();
List<Number> installmentAmounts = new ArrayList<Number>();
if (!loanScheduleDto.getInstallments().isEmpty()) {
firstInstallmentDueDate = loanScheduleDto.firstInstallment();
lastInstallmentDueDate = loanScheduleDto.lastInstallment();
for (LoanCreationInstallmentDto installment : loanScheduleDto.getInstallments()) {
totalInstallmentAmount = totalInstallmentAmount.add(BigDecimal.valueOf(installment.getTotal()));
installments.add(new DateTime(installment.getDueDate()));
installmentAmounts.add(installment.getTotal());
}
}
formBean.setInstallments(installments);
formBean.setInstallmentAmounts(installmentAmounts);
formBean.setLoanPrincipal(loanAmount);
LoanInstallmentsDto loanInstallmentsDto = new LoanInstallmentsDto(loanAmount, totalInstallmentAmount, firstInstallmentDueDate.toDate(), lastInstallmentDueDate.toDate());
BigDecimal cashFlowTotalBalance = BigDecimal.ZERO;
for (MonthlyCashFlowDto monthlyCashFlowDto : monthlyCashFlow) {
cashFlowTotalBalance = cashFlowTotalBalance.add(monthlyCashFlowDto.calculateRevenueMinusExpenses());
}
formBean.setMonthlyCashFlows(monthlyCashFlow);
formBean.setLoanInstallmentsDto(loanInstallmentsDto);
formBean.setCashFlowTotalBalance(cashFlowTotalBalance);
formBean.setRepaymentCapacity(cashFlowDto.getRepaymentCapacity());
LocalDate disbursementDate = LoanCreationHelper.translateDisbursementDateToLocalDate(loanAccountFormBean);
loanControllerHelper.populateFormBeanFromDto(loanAccountFormBean.getCustomerId(), productId, loanAccountFormBean, formBean, disbursementDate, loanScheduleDto, true);
return cashFlowDataDtos;
}
use of org.mifos.dto.screen.CashFlowDataDto in project head by mifos.
the class LoanAccountController method recalculateCashflowSummaryDetails.
public List<CashFlowDataDto> recalculateCashflowSummaryDetails(CashFlowSummaryFormBean formBean, CashFlowDto cashFlowDto, List<MonthlyCashFlowDto> monthlyCashFlow, LoanScheduleDto loanScheduleDto, int productId) {
List<CashFlowDataDto> cashFlowDataDtos = this.loanAccountServiceFacade.retrieveCashFlowSummary(monthlyCashFlow, loanScheduleDto);
formBean.setCashFlowDataDtos(cashFlowDataDtos);
formBean.setProductId(productId);
BigDecimal cashFlowTotalBalance = BigDecimal.ZERO;
for (MonthlyCashFlowDto monthlyCashFlowDto : monthlyCashFlow) {
cashFlowTotalBalance = cashFlowTotalBalance.add(monthlyCashFlowDto.calculateRevenueMinusExpenses());
}
formBean.setMonthlyCashFlows(monthlyCashFlow);
formBean.setCashFlowTotalBalance(cashFlowTotalBalance);
formBean.setRepaymentCapacity(cashFlowDto.getRepaymentCapacity());
return cashFlowDataDtos;
}
Aggregations