package com.ruoyi.dk.util;

import lombok.Getter;
import lombok.Setter;

import java.math.BigDecimal;
import java.util.List;

/**
 * Created by WangGenshen on 1/14/16.
 */
@Getter
@Setter
public class Loan {

    private BigDecimal totalLoanMoney; //贷款总额
    private int totalMonth; //还款月份
    private double loanRateYear; //贷款年利率

    private double loanRateDay; // 贷款日利率

    private double loanRateMonth; // 贷款月利率

    private BigDecimal totalInterest; // 总利息数
    private BigDecimal totalRepayment; // 还款总额
    private BigDecimal firstRepayment; // 首月还款额
    private BigDecimal avgRepayment; // 月均还款额

    private List<LoanByMonth> allLoans; // 所有月份的还款情况


    @Override
    public String toString() {
        String allLoansStr = "";
        if (allLoans != null) {
            for (LoanByMonth loanByMonth : allLoans) {
                String lbmStr = "月份: " + loanByMonth.getMonth() + "\t第" + loanByMonth.getYear() + "年\t第" +
                        loanByMonth.getMonthInYear() + "月\t" + "月供: " + loanByMonth.getRepayment() +
                        "\t本金: " + loanByMonth.getPayPrincipal() + "\t利息: " + loanByMonth.getInterest() +
                        "\t剩余贷款: " + loanByMonth.getRemainTotal();
                if (allLoansStr.equals("")) {
                    allLoansStr = lbmStr;
                } else {
                    allLoansStr += "\n" + lbmStr;
                }
            }
        }
        return "每月还款: " + getAvgRepayment() + "\t总利息: " + getTotalInterest() +
                "\t还款总额：" + getTotalRepayment() + "\t首月还款: " + getFirstRepayment() + "\n" + allLoansStr;
    }
}
