Search in sources :

Example 1 with CashFlowDataDto

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;
}
Also used : MonthlyCashFlowDto(org.mifos.dto.domain.MonthlyCashFlowDto) CashFlowDataDto(org.mifos.dto.screen.CashFlowDataDto) ArrayList(java.util.ArrayList)

Example 2 with CashFlowDataDto

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;
}
Also used : Errors(org.mifos.platform.validations.Errors) CashFlowDetail(org.mifos.accounts.productdefinition.business.CashFlowDetail) MonthlyCashFlowDetail(org.mifos.platform.cashflow.service.MonthlyCashFlowDetail) CashFlowDataDto(org.mifos.dto.screen.CashFlowDataDto) LoanOfferingBO(org.mifos.accounts.productdefinition.business.LoanOfferingBO)

Example 3 with CashFlowDataDto

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;
}
Also used : MonthlyCashFlowDto(org.mifos.dto.domain.MonthlyCashFlowDto) CashFlowDataDto(org.mifos.dto.screen.CashFlowDataDto) ArrayList(java.util.ArrayList) LoanCreationInstallmentDto(org.mifos.dto.domain.LoanCreationInstallmentDto) LoanInstallmentsDto(org.mifos.dto.screen.LoanInstallmentsDto) LocalDate(org.joda.time.LocalDate) BigDecimal(java.math.BigDecimal) DateTime(org.joda.time.DateTime)

Example 4 with CashFlowDataDto

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;
}
Also used : MonthlyCashFlowDto(org.mifos.dto.domain.MonthlyCashFlowDto) CashFlowDataDto(org.mifos.dto.screen.CashFlowDataDto) BigDecimal(java.math.BigDecimal)

Aggregations

CashFlowDataDto (org.mifos.dto.screen.CashFlowDataDto)4 MonthlyCashFlowDto (org.mifos.dto.domain.MonthlyCashFlowDto)3 BigDecimal (java.math.BigDecimal)2 ArrayList (java.util.ArrayList)2 DateTime (org.joda.time.DateTime)1 LocalDate (org.joda.time.LocalDate)1 CashFlowDetail (org.mifos.accounts.productdefinition.business.CashFlowDetail)1 LoanOfferingBO (org.mifos.accounts.productdefinition.business.LoanOfferingBO)1 LoanCreationInstallmentDto (org.mifos.dto.domain.LoanCreationInstallmentDto)1 LoanInstallmentsDto (org.mifos.dto.screen.LoanInstallmentsDto)1 MonthlyCashFlowDetail (org.mifos.platform.cashflow.service.MonthlyCashFlowDetail)1 Errors (org.mifos.platform.validations.Errors)1