/// <summary> /// 获取所有款项统计信息 /// isCurrent: true:当期欠费科目集合 false:逾期欠费集合 /// </summary> /// <returns></returns> public virtual List <BillItem> GetStatisticsItems(bool?isCurrent = false) { var bills = BillDAL.GetNormalBills(Business.Bills); List <BillItem> billItems = new List <BillItem>(); bills.ForEach(o => { if (o.BillItems != null) { billItems.AddRange(o.BillItems); } }); List <BillItem> tempItems = new List <BillItem>(); var pdtItems = GetProductItems(); foreach (var pdtItem in pdtItems) { BillItem item = new BillItem(); var filterItems = billItems.Where(p => p.Subject == pdtItem.Key).ToList(); if (isCurrent != null) { filterItems = filterItems.Where(p => p.IsCurrent == isCurrent.Value).ToList(); } item.Amount = filterItems.Sum(p => p.Amount); item.DueAmt = filterItems.Sum(p => p.DueAmt); item.ReceivedAmt = filterItems.Sum(p => p.ReceivedAmt); item.StrSubject = pdtItem.Value.Replace("月", string.Empty); item.Subject = pdtItem.Key; tempItems.Add(item); } return(tempItems); }
/// <summary> /// 剩余利息 /// </summary> /// <param name="business"></param> /// <returns></returns> private decimal GetInter(Business business) { //月利息 decimal monthacoumt = business.LoanCapital * business.InterestRate; //剩余期数 int hadPeriod = BillDAL.GetNormalBills(business.Bills).Count; int qs = business.LoanPeriod - hadPeriod; //剩余总利息 decimal sum = monthacoumt * qs; return(sum); }
/// <summary> /// 创建罚息科目(因逾期而产生的上期帐单罚息) /// 费用算法:一次性为上期帐单生成上月20日至今的罚息合计 /// </summary> /// <param name="business">订单对象</param> /// <returns>返回罚息款项</returns> public override BillItem CreatePunitiveInterest(DateTime limitTime, List <PenaltyInt> penaltyInts) { // 获取当期帐单,为NULL或已在第三次扣失日前全额付清则继续循环 var nbills = BillDAL.GetNormalBills(Business.Bills); var prevBill = nbills.FirstOrDefault(p => p.BillMonth == _PrevMonth); var curBill = nbills.FirstOrDefault(p => p.BillMonth == _CurMonth); // 判断是否存在原因帐单或当期帐单,不存在则返回NULL if (prevBill == null || curBill == null || Business.Bills.Count == 1 || (limitTime >= prevBill.FullPaidTime && prevBill.FullPaidTime != null)) { return(null); } // 获取本金、利息、管理费等参与科目,计算上期所欠本息或租金 var subjects = new List <byte> { (byte)EnumCostSubject.Capital, (byte)EnumCostSubject.Interest }; // 获取上期帐单的本息欠费 decimal debtsPrincipal = prevBill.BillItems.Where(p => subjects.Contains(p.Subject)) .Sum(s => s.DueAmt - s.ReceivedAmt); // 判断上期帐单是否存在未归还所欠本息或租金,无则不生成罚息 if (debtsPrincipal <= 0) { return(null); } var beginDay = DateTime.Now.AddMonths(-1).SetDay(21); // 在罚息表中计算罚息金额 CalculatPenaltyInt(penaltyInts, debtsPrincipal, prevBill.BillID, curBill.BillID, beginDay); // 当所欠本息大于零时,计算从上月21日至今天数的罚息 var totalDays = DateTime.Now - beginDay; debtsPrincipal = SubjectFormula.CalculatPunitiveInterest(debtsPrincipal, Business.PenaltyRate, totalDays.Days); // 判断欠费帐单是否存在未归还所欠本息或租金,无则不生成罚息 if (debtsPrincipal <= 0) { return(null); } // 创建罚息科目(科目名称、金额) return(CreateBillItem(EnumCostSubject.PunitiveInterest, debtsPrincipal, false, curBill.BillID)); }
/// <summary> /// 剩余本金 /// </summary> /// <param name="business"></param> /// <returns></returns> private decimal GetSum(Business business) { //未出帐本金 decimal wczlxamout = 0; //已出期数 string HadPeriod = business == null ? string.Empty : BillDAL.GetNormalBills(business.Bills).Count.ToString(); var product = ProductFactory.Instance.GetProduct(business); var subjectItems = product.GetBaseItemsByMonth(); //var dirItems = product.GetProductItems(); // 未到期的未收 var subjectItem = subjectItems.FirstOrDefault(p => p.Subject == (byte)EnumCostSubject.Capital); if (subjectItem != null && int.Parse(HadPeriod) < business.LoanPeriod && business.CLoanStatus == (byte)EnumCLoanStatus.Refunding) { wczlxamout = business.LoanCapital - (subjectItem.Amount * int.Parse(HadPeriod)); } return(wczlxamout); }
/// <summary> /// 创建扣失科目(因逾期而产生的本息扣失、服务费扣失) /// </summary> public override List <BillItem> CreateBuckleFail(DateTime limitTime) { List <BillItem> items = new List <BillItem>(); // 获取当期帐单 var curBill = BillDAL.GetNormalBills(Business.Bills).FirstOrDefault(p => p.BillMonth == _CurMonth); // 无当期帐单 或者 有全额支付时间且全额支付时间是在扣失日之前(包括当天)的则不生成扣失 if (curBill == null || (limitTime >= curBill.FullPaidTime && curBill.FullPaidTime != null)) { return(items); } // 判断当期帐单是否应生成本息扣失 List <byte> subjects = new List <byte> { (byte)EnumCostSubject.Capital, (byte)EnumCostSubject.Interest, (byte)EnumCostSubject.Manage }; if (IsCreateBuckleFail(subjects, curBill)) { items.Add(CreateBillItem(EnumCostSubject.InterestBuckleFail, Business.PrincipalPunish.Value, true, curBill.BillID)); } // 判断当期帐单是否应生成服务费担保费扣失 subjects = new List <byte> { (byte)EnumCostSubject.ServiceFee, (byte)EnumCostSubject.GuaranteeFee }; if (IsCreateBuckleFail(subjects, curBill)) { items.Add(CreateBillItem(EnumCostSubject.ServiceBuckleFail, Business.ServicePunish.Value, true, curBill.BillID)); } return(items); }
/// <summary> /// 创建罚息科目 /// </summary> public override BillItem CreatePunitiveInterest(DateTime limitTime, List <PenaltyInt> penaltyInts) { // 获取当期帐单,为NULL或已在第三次扣失日前全额付清则继续循环 var nbills = BillDAL.GetNormalBills(Business.Bills); var prevBill = nbills.FirstOrDefault(p => p.BillMonth == _PrevMonth); var curBill = nbills.FirstOrDefault(p => p.BillMonth == _CurMonth); // 判断是否存在原因帐单或当期帐单,不存在则返回NULL if (prevBill == null || curBill == null || Business.Bills.Count == 1 || (limitTime >= prevBill.FullPaidTime && prevBill.FullPaidTime != null)) { return(null); } // 获取本金、利息或租金等参与科目,计算上期所欠本息或租金 var subjects = new List <byte> { (byte)EnumCostSubject.Capital, (byte)EnumCostSubject.Interest, (byte)EnumCostSubject.Rent }; // 是否为渤海订单, 渤海订单一次性生成一个月的罚息, 其他合同都按日罚息千分之一计算 bool isBoHai = Business.LendingSideKey.EndsWith(EnumCompanyKey.BHXT_LENDING.ToEnumName()); decimal debtsPrincipal = 0; if (isBoHai) { // 获取普通帐单的所欠本息 var bills = BillDAL.GetArrearsBills(Business.Bills, true); foreach (var bill in bills) { debtsPrincipal += bill.BillItems.Where(p => subjects.Contains(p.Subject) && !p.IsCurrent) .Sum(p => p.DueAmt - p.ReceivedAmt); } // 判断欠费帐单是否存在未归还所欠本息或租金,无则不生成罚息 if (debtsPrincipal <= 0) { return(null); } debtsPrincipal = SubjectFormula.CalculatPunitiveInterest(debtsPrincipal, 0.03m); } else { // 获取上期帐单的本息欠费 debtsPrincipal = prevBill.BillItems.Where(p => subjects.Contains(p.Subject)) .Sum(s => s.DueAmt - s.ReceivedAmt); // 判断上期帐单是否存在未归还所欠本息或租金,无则不生成罚息 if (debtsPrincipal <= 0) { return(null); } var beginDay = DateTime.Now.AddMonths(-1).SetDay(21); // 在罚息表中计算罚息金额 CalculatPenaltyInt(penaltyInts, debtsPrincipal, prevBill.BillID, curBill.BillID, beginDay); // 当所欠本息大于零时,计算从上月21日至今天数的罚息 var totalDays = DateTime.Now - beginDay; debtsPrincipal = SubjectFormula.CalculatPunitiveInterest(debtsPrincipal, Business.PenaltyRate, totalDays.Days); } // 创建罚息科目(科目名称、金额) return(CreateBillItem(EnumCostSubject.PunitiveInterest, debtsPrincipal, false, curBill.BillID)); }