コード例 #1
0
        /// <summary>
        /// 某个月偿还的本金
        /// </summary>
        public double PaymentCapitalMonth(DateTime time)
        {
            if (OnDebtTime.AddMonths((int)TimeLengthMonth) < time) //如果贷款已经还完
            {
                return(0);
            }

            return(PaymentAt(time) - PaymentInterestAt(time));
        }
コード例 #2
0
        /// <summary>
        /// 剩余的利息总和
        /// </summary>
        /// <param name="time"></param>
        /// <returns></returns>
        public double LeftInterestAt(DateTime time)
        {
            if (OnDebtTime.AddMonths((int)TimeLengthMonth) < time) //如果贷款已经还完
            {
                time = OnDebtTime.AddMonths((int)TimeLengthMonth);
            }

            return(LeftDebtAt(time) - LeftCapitalAt(time));
        }
コード例 #3
0
ファイル: MEqualCaptial.cs プロジェクト: lhxon/Depositor
        /// <summary>
        /// 每月偿还的本金
        /// </summary>
        public double PaymentCapitalMonth(DateTime time)
        {
            if (OnDebtTime.AddMonths((int)TimeLengthMonth) < time) //如果贷款已经还完
            {
                return(0);
            }

            return(sumDebt / TimeLengthMonth);
        }
コード例 #4
0
        public double LeftDebtAt(DateTime time)
        {
            if (OnDebtTime.AddMonths((int)TimeLengthMonth) < time) //如果贷款已经还完
            {
                time = OnDebtTime.AddMonths((int)TimeLengthMonth);
            }

            return(GetSumPayment() - FinishedPaymentSumAt(time));
        }
コード例 #5
0
ファイル: MEqualCaptial.cs プロジェクト: lhxon/Depositor
        /// <summary>
        /// 获取等额本金需要的总还款额
        /// </summary>
        /// <returns></returns>
        public double GetSumPayment()
        {
            double sumPaymentAmount = 0.0;

            for (int i = 0; i < TimeLengthMonth; i++)
            {
                sumPaymentAmount += PaymentAt(OnDebtTime.AddMonths(i + 1));
            }
            return(sumPaymentAmount);
        }
コード例 #6
0
        public double FinishedPaymentSumAt(DateTime time)
        {
            if (OnDebtTime.AddMonths((int)TimeLengthMonth) < time) //如果贷款已经还完
            {
                time = OnDebtTime.AddMonths((int)TimeLengthMonth);
            }

            int monthIndex = GetMonthIndex(time);

            return(monthIndex * PaymentAt(time));
        }
コード例 #7
0
ファイル: MEqualCaptial.cs プロジェクト: lhxon/Depositor
        /// <summary>
        /// 在某个月(已供完本月的)还剩余要还的本金
        /// </summary>
        /// <param name="time"></param>
        /// <returns></returns>
        public double LeftCapitalAt(DateTime time)
        {
            if (OnDebtTime.AddMonths((int)TimeLengthMonth) < time) //如果贷款已经还完
            {
                return(0);
            }

            int i = GetMonthIndex(time);

            return(sumDebt - i * PaymentCapitalMonth(OnDebtTime.AddMonths(i)));
        }
コード例 #8
0
ファイル: MEqualCaptial.cs プロジェクト: lhxon/Depositor
        /// <summary>
        /// 在某个月偿还的利息
        /// </summary>
        /// <param name="monthIndex"></param>
        /// <returns></returns>
        public double PaymentInterestAt(DateTime time)
        {
            if (OnDebtTime.AddMonths((int)TimeLengthMonth) < time) //如果贷款已经还完
            {
                return(0);
            }
            int monthIndex = GetMonthIndex(time);

            if (monthIndex < 0)
            {
                throw new ArgumentException("月索引小于0");
            }
            return((sumDebt - (monthIndex - 1) * PaymentCapitalMonth(OnDebtTime.AddMonths(monthIndex))) * MonthDebtRate);
        }
コード例 #9
0
        /// <summary>
        /// 在某个月(已供完本月的)还剩余要还的本金
        /// </summary>
        /// <param name="time"></param>
        /// <returns></returns>
        public double LeftCapitalAt(DateTime time)
        {
            if (OnDebtTime.AddMonths((int)TimeLengthMonth) < time) //如果贷款已经还完
            {
                return(0);
            }
            int    mi  = GetMonthIndex(time);
            double sum = 0;

            for (int i = 1; i <= mi; i++)
            {
                sum += PaymentCapitalMonth(OnDebtTime.AddMonths(i));
            }
            return(sumDebt - sum);
        }
コード例 #10
0
        public double PaymentAt(DateTime time)
        {
            if (OnDebtTime.AddMonths((int)TimeLengthMonth) < time) //如果贷款已经还完
            {
                return(0);
            }
            var payment = sumDebt * MonthDebtRate *
                          Math.Pow((1 + MonthDebtRate), TimeLengthMonth) /
                          ((Math.Pow((1 + MonthDebtRate), TimeLengthMonth)) - 1);

            if (payment < 0)
            {
                throw new LessOrEquZeroException("还款金额");
            }
            return(payment);
        }
コード例 #11
0
        /// <summary>
        /// 已经偿还的本金总和
        /// </summary>
        /// <param name="time"></param>
        /// <returns></returns>
        public double FinishedInterestSumAt(DateTime time)
        {
            if (OnDebtTime.AddMonths((int)TimeLengthMonth) < time) //如果贷款已经还完
            {
                time = OnDebtTime.AddMonths((int)TimeLengthMonth);
            }

            int    monthIndex = GetMonthIndex(time);
            double sum        = 0;

            for (int i = 1; i <= monthIndex; i++)
            {
                sum += PaymentInterestAt(OnDebtTime.AddMonths(i));
            }
            return(sum);
        }
コード例 #12
0
ファイル: MEqualCaptial.cs プロジェクト: lhxon/Depositor
        /// <summary>
        /// 截止到某个时间,已经偿还的金额
        /// </summary>
        /// <param name="time"></param>
        /// <returns></returns>
        public double FinishedPaymentSumAt(DateTime time)
        {
            if (OnDebtTime.AddMonths((int)TimeLengthMonth) < time) //如果贷款已经还完
            {
                time = OnDebtTime.AddMonths((int)TimeLengthMonth);
            }

            time = DateTime.Parse(time.ToString("yyyy-MM-01"));
            double paymentAmount = 0.0;

            for (DateTime i = OnDebtTime; i < time; i = i.AddMonths(1))
            {
                paymentAmount += PaymentAt(i.AddMonths(1));
            }
            return(paymentAmount);
        }
コード例 #13
0
        public double PaymentInterestAt(DateTime time, DateTime bigRepayTime, double sumDebt1)
        {
            try
            {
                if (OnDebtTime.AddMonths((int)TimeLengthMonth) < time) //如果贷款已经还完
                {
                    return(0);
                }

                int    monthIndex = GetMonthIndex(bigRepayTime, time);
                double inter      = 0;
                if (monthIndex == 1)
                {
                    inter = sumDebt1 * MonthDebtRate;
                }
                else
                {
                    double beforeInterSum = 0;
                    for (int i = 1; i < monthIndex; i++)
                    {
                        if (!dictInterBefore.ContainsKey(i))
                        {
                            dictInterBefore.Add(i, PaymentInterestAt(OnDebtTime.AddMonths(i)));
                        }
                        beforeInterSum += dictInterBefore[i];
                    }
                    inter = (sumDebt1 - ((monthIndex - 1) * PaymentAt(OnDebtTime.AddMonths(monthIndex)) - beforeInterSum)) * MonthDebtRate;
                }
                if (inter < 0)
                {
                    //throw new LessOrEquZeroException("利息");
                    return(inter);
                }
                if (!dictInterBefore.ContainsKey(monthIndex))
                {
                    dictInterBefore.Add(monthIndex, inter);
                }
                return(inter);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #14
0
ファイル: MEqualCaptial.cs プロジェクト: lhxon/Depositor
        /// <summary>
        /// 显示某个月的下一个月的还款额度
        /// </summary>
        /// <param name="monthIndex"></param>
        /// <returns></returns>
        public double ShowPaymentNextTo(DateTime time)
        {
            if (OnDebtTime.AddMonths((int)TimeLengthMonth) < time) //如果贷款已经还完
            {
                return(0);
            }

            int monthIndex = GetMonthIndex(time);

            if (monthIndex < 0)
            {
                throw new ArgumentException("月索引小于0");
            }
            double capital  = sumDebt / TimeLengthMonth;//还款本金是不变的
            double interest = 0.0;

            interest = (sumDebt - monthIndex * capital) * MonthDebtRate;
            return(capital + interest);
        }
コード例 #15
0
ファイル: MEqualCaptial.cs プロジェクト: lhxon/Depositor
        /// <summary>
        /// 显示某个月的下多个月的还款额度
        /// </summary>
        /// <param name="monthIndex"></param>
        /// <param name="showMonths"></param>
        /// <returns></returns>
        public List <double> ShowPaymentNextTo(DateTime time, int showMonths)
        {
            var rtnList = new List <double>();

            if (OnDebtTime.AddMonths((int)TimeLengthMonth) < time) //如果贷款已经还完
            {
                for (int i = 0; i < showMonths; i++)
                {
                    rtnList.Add(0);
                }
                return(rtnList);
            }

            for (int i = 0; i < showMonths; i++)
            {
                rtnList.Add(ShowPaymentNextTo(time.AddMonths(i)));
            }
            return(rtnList);
        }
コード例 #16
0
 /// <summary>
 /// 获取等额本金需要的总还款额
 /// </summary>
 /// <returns></returns>
 public double GetSumPayment()
 {
     return(PaymentAt(OnDebtTime.AddMonths(-1)) * TimeLengthMonth);
 }