/// <summary> /// 返回结算策略对象 <see cref="IDateTypeStrategy"/> /// </summary> /// <value> /// The <see cref="IDateTypeStrategy"/>. /// </value> /// <param name="type">结算方式</param> /// <returns></returns> public IDateTypeStrategy this[RepaymentTimeUnitType type] { get { return(dict.ContainsKey(type) ? dict[type] : null); } }
/// <summary> /// 获取 <see cref="IRepaymentCalc"/> 还款计算器. /// </summary> /// <value> /// 还款计算器 <see cref="IRepaymentCalc"/>. /// </value> /// <param name="dtype">结算方式</param> /// <param name="reType">还款模型</param> /// <param name="startDate">开始结算时间</param> /// <returns></returns> public IRepaymentCalc this[RepaymentTimeUnitType dtype, RepaymentType reType, DateTime startDate] { get { if (reType == RepaymentType.期付息N期还本) { throw new ArgumentException("该方法不能创建按期付息N期还本之本金固定"); } if (reType == RepaymentType.期付息L期还本) { throw new ArgumentException("该方法不能创建按期付息N期还本之本金缩小"); } switch (reType) { case RepaymentType.等额本息: return(new 等额本息(dtype, startDate)); case RepaymentType.等额本金: return(new 等额本金(dtype, startDate)); default: case RepaymentType.一次性还本付息: return(new 一次性还本付息(dtype, startDate)); case RepaymentType.期付息到期还本: return(new 期付息到期还本(dtype, startDate)); case RepaymentType.等本等息: return(new 等本等息(dtype, startDate)); } } }
/// <summary> /// 获取 <see cref="IRepaymentCalc"/> 还款计算器. /// </summary> /// <value> /// 还款计算器 <see cref="IRepaymentCalc"/>. /// </value> /// <param name="dtype">结算方式</param> /// <param name="reType">还款模型</param> /// <returns></returns> public IRepaymentCalc this[RepaymentTimeUnitType dtype, RepaymentType reType] { get { return(this[dtype, reType, DateTime.Now]); } }
/// <summary> /// 获取 <see cref="IRepaymentCalc"/> 还款计算器. /// </summary> /// <value> /// 还款计算器 <see cref="IRepaymentCalc"/>. /// </value> /// <param name="dtype">结算方式</param> /// <param name="reType">还款模型</param> /// <param name="principalPeriods">本金的还款信息</param> /// <returns></returns> public IRepaymentCalc this[RepaymentTimeUnitType dtype, RepaymentType reType, IEnumerable <PrincipalRepayPercent> principalPeriods] { get { return(this[dtype, reType, principalPeriods, DateTime.Now]); } }
/// <summary> /// Initializes a new instance of the <see cref="等额本息"/> class. /// </summary> /// <param name="dateType">结算类型</param> /// <param name="startDate">开始结算日期</param> public 等额本息(RepaymentTimeUnitType dateType, DateTime startDate) : base(dateType, startDate) { if (dateType != RepaymentTimeUnitType.月) { throw new DomainException("等额本息只能以月单位结算"); } }
/// <summary> /// Initializes a new instance of the <see cref="按期付息L期还本"/> class. /// </summary> /// <param name="dateType">结算类型</param> /// <param name="startDate">开始结算日期</param> /// <param name="principalPeriods">本金的还款信息</param> public 期付息L期还本(RepaymentTimeUnitType dateType, DateTime startDate, IEnumerable <PrincipalRepayType> principalPeriods) : base(dateType, startDate) { this.principalPeriods = principalPeriods ?? Enumerable.Empty <PrincipalRepayType>(); if (!this.principalPeriods.LastOrDefault().PayPrincipal) { throw new ArgumentException("最后一期一定是还款本金"); } }
/// <summary> /// Initializes a new instance of the <see cref="本金按百分比还"/> class. /// </summary> /// <param name="dateType">结算类型</param> /// <param name="startDate">开始结算日期</param> /// <param name="principalPeriods">本金的还款信息</param> public 本金按百分比还(RepaymentTimeUnitType dateType, DateTime startDate, IEnumerable <PrincipalRepayPercent> principalPeriods) : base(dateType, startDate) { this.principalPeriods = principalPeriods ?? Enumerable.Empty <PrincipalRepayPercent>(); if (this.principalPeriods.Sum(t => t.Percent) != 100) { throw new ArgumentException("所有还款期数总和不等于100%"); } }
/// <summary> /// Initializes a new instance of the <see cref="RepaymentCalc"/> class. /// </summary> /// <param name="dateType">结算类型</param> /// <param name="startDate">开始结算日期</param> protected RepaymentCalc(RepaymentTimeUnitType dateType, DateTime startDate) { this.StartDate = startDate; this.DateType = dateType; this.Strategy = Singleton <StrategyFactory> .Instance[dateType]; if (this.Strategy == null) { throw new ArgumentNullException("结算方式不在定义内"); } }
/// <summary> /// 获取 <see cref="IRepaymentCalc"/> 还款计算器. /// </summary> /// <value> /// 还款计算器 <see cref="IRepaymentCalc"/>. /// </value> /// <param name="dtype">结算方式</param> /// <param name="principalPeriods">本金的还款信息</param> /// <param name="reType">还款模型</param> /// <param name="startDate">开始结算时间</param> /// <returns></returns> public IRepaymentCalc this[RepaymentTimeUnitType dtype, RepaymentType reType, IEnumerable <PrincipalRepayPercent> principalPeriods, DateTime startDate] { get { switch (reType) { case RepaymentType.本金按百分比还: return(new 本金按百分比还(dtype, startDate, principalPeriods)); } return(this[dtype, reType, startDate]); } }
/// <summary> /// 获取 <see cref="IRepaymentCalc"/> 还款计算器. /// </summary> /// <value> /// 还款计算器 <see cref="IRepaymentCalc"/>. /// </value> /// <param name="dtype">结算方式</param> /// <param name="principalPeriods">本金的还款信息</param> /// <param name="reType">还款模型</param> /// <param name="startDate">开始结算时间</param> /// <returns></returns> public IRepaymentCalc this[RepaymentTimeUnitType dtype, RepaymentType reType, IEnumerable <PrincipalRepayType> principalPeriods, DateTime startDate] { get { switch (reType) { case RepaymentType.期付息L期还本: return(new 期付息L期还本(dtype, startDate, principalPeriods)); case RepaymentType.期付息N期还本: return(new 期付息N期还本(dtype, startDate, principalPeriods)); } return(this[dtype, reType, startDate]); } }
/// <summary> /// Initializes a new instance of the <see cref="等本等息"/> class. /// </summary> /// <param name="dateType">结算类型</param> /// <param name="startDate">开始结算日期</param> public 等本等息(RepaymentTimeUnitType dateType, DateTime startDate) : base(dateType, startDate) { }
/// <summary> /// Initializes a new instance of the <see cref="按期付息到期还本"/> class. /// </summary> /// <param name="dateType">结算类型</param> /// <param name="startDate">开始结算日期</param> public 期付息到期还本(RepaymentTimeUnitType dateType, DateTime startDate) : base(dateType, startDate) { }