From 45cb3a12396a3441b3c6bcf80ea4b8ba6876a00e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=96=B9=E6=B5=B7?= Date: Mon, 11 May 2026 18:59:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=88=90=E4=BA=A4=E6=97=A5?= =?UTF-8?q?=E7=AE=97=E4=BA=86=E5=88=A9=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Modules/SwapModule/GetInterestsUnitTest.cs | 3 --- YLErpDAL/Modules/SwapModule/SwapDealService.cs | 12 +++++++----- YLErpDAL/Modules/SwapModule/SwapTradeBaseService.cs | 4 ++-- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/UnitTestProject/Modules/SwapModule/GetInterestsUnitTest.cs b/UnitTestProject/Modules/SwapModule/GetInterestsUnitTest.cs index 33ecef94..30c02dde 100644 --- a/UnitTestProject/Modules/SwapModule/GetInterestsUnitTest.cs +++ b/UnitTestProject/Modules/SwapModule/GetInterestsUnitTest.cs @@ -238,7 +238,6 @@ namespace YLErp.Modules.SwapModule (int)SwapEventTypeEnum.平仓, false, false, 0, Principal, false, - interestCalcMode.EndsWith("1", StringComparison.Ordinal), false); Assert.AreEqual(1, interests.Count); @@ -265,7 +264,6 @@ namespace YLErp.Modules.SwapModule (int)SwapEventTypeEnum.平仓, false, false, 0, Principal, false, - interestCalcMode.EndsWith("1", StringComparison.Ordinal), true); // settment=true 表示收盘 Assert.AreEqual(1, interests.Count); @@ -292,7 +290,6 @@ namespace YLErp.Modules.SwapModule (int)SwapEventTypeEnum.自动互换, false, false, 0, Principal, false, - interestCalcMode.EndsWith("1", StringComparison.Ordinal), false); Assert.AreEqual(1, interests.Count); diff --git a/YLErpDAL/Modules/SwapModule/SwapDealService.cs b/YLErpDAL/Modules/SwapModule/SwapDealService.cs index 43d0eef3..aa83751c 100644 --- a/YLErpDAL/Modules/SwapModule/SwapDealService.cs +++ b/YLErpDAL/Modules/SwapModule/SwapDealService.cs @@ -331,8 +331,7 @@ namespace YLErp.Modules.SwapModule var orginPv = lastEod != null ? lastEod.NotionalValue : stockEqvNotional; var grossPrice = realPostitions.Where(x => x.PosiDirection > 0).FirstOrDefault()?.PosiGrossPrice; bool tdClose = DbContext.swap_flow_event.Any(x => x.SwapTradeId == tradeId && x.UnwindDate == unwindDate && eventTypes.Contains(x.EventType) && x.DataState == (int)SwapFlowDateStateEnum.完成); - var calcLastNew = tradeExtend?.ExtendObj?.InterestCalcMode?.EndsWith("1") ?? true; - interests = GetInterests(td, tradeExtend, valueDate, unwindDate, lastEodPositions, positions, stockEqvNotional, posiLongNotionalValue, posiShortNotionalValue, posiNotionalValue, closePercent, eventType, tdClose, false, grossPrice ?? 0, orginPv, true, calcLastNew, false); + interests = GetInterests(td, tradeExtend, valueDate, unwindDate, lastEodPositions, positions, stockEqvNotional, posiLongNotionalValue, posiShortNotionalValue, posiNotionalValue, closePercent, eventType, tdClose, false, grossPrice ?? 0, orginPv, true, false); return interests; } /// @@ -370,13 +369,12 @@ namespace YLErp.Modules.SwapModule decimal grossPrice, decimal orginPv, bool add = false, - bool calcLast = true, bool settment = true) { List interests = new List(); var annualDays = tradeExtend == null ? 365 : tradeExtend.ExtendObj.AnnualDays; bool calcFirst = tradeExtend?.ExtendObj.InterestCalcMode?.StartsWith("1") ?? true; - + bool calcLast = tradeExtend?.ExtendObj.InterestCalcMode.EndsWith("1") ?? true; foreach (var position in positions) { // 初始化持仓信息 @@ -386,7 +384,7 @@ namespace YLErp.Modules.SwapModule // 计算计息区间 int interestPeriod = position.interest_rest_days ?? 1; - bool swap = InitInterestDate(unwindDate, preDealDate, td, tdClose, calcLast, out DateTime startDate, out DateTime endDate); + bool swap = InitInterestDate(unwindDate, preDealDate, td, tdClose, out DateTime startDate, out DateTime endDate); // 计算名义本金 var (closePrincipal, posiPrincipal, newClosePercent) = CalcNotionalByMode(position, closePrecent, posiNotionalValue, posiLongNotionalValue, posiShortNotionalValue); @@ -496,6 +494,10 @@ namespace YLErp.Modules.SwapModule bool calcToday = true; if (calcFirst == false && valueDate == td.StartDate.Value) calcToday = false; // 首日不算头 if (calcLast == false && valueDate == td.ExerciseDate.Value) calcToday = false; // 到期日不算尾 + if (valueDate < position.PosiStartDate) + { + calcToday = false; + } // 初始化EOD持仓信息 if (preEod.id == 0) { diff --git a/YLErpDAL/Modules/SwapModule/SwapTradeBaseService.cs b/YLErpDAL/Modules/SwapModule/SwapTradeBaseService.cs index 219ee1c1..5c8b2bb1 100644 --- a/YLErpDAL/Modules/SwapModule/SwapTradeBaseService.cs +++ b/YLErpDAL/Modules/SwapModule/SwapTradeBaseService.cs @@ -325,7 +325,7 @@ namespace YLErp.Modules.SwapModule /// 计息方式 /// 计息开始日期 /// 计息结束日期 - public bool InitInterestDate(DateTime valueDate, DateTime? preSettleDate, trade td, bool tdClose,bool calcLastNew, out DateTime interestStart, out DateTime interestEnd) + public bool InitInterestDate(DateTime valueDate, DateTime? preSettleDate, trade td, bool tdClose, out DateTime interestStart, out DateTime interestEnd) { interestStart = td.StartDate.Value; var exerciseDate = td.ExerciseDate.Value; @@ -343,7 +343,7 @@ namespace YLErp.Modules.SwapModule { interestStart = preSettleDate.Value; } - if ((interestEnd == exerciseDate && !calcLast)|| !calcLastNew) + if ((interestEnd == exerciseDate && !calcLast)) { interestEnd = interestEnd.AddDays(-1); }