From c425594833b9bc4f552668049e4fc153e75890a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=90=8D=E9=94=90?= <1565842059@qq.com> Date: Thu, 6 Aug 2026 18:39:20 +0800 Subject: [PATCH] =?UTF-8?q?feat(swap):=20=E5=AE=9E=E7=8E=B0=E9=A2=84?= =?UTF-8?q?=E4=BB=98=E9=87=91=E6=A8=A1=E5=BC=8F=E4=B8=8B=E9=83=A8=E5=88=86?= =?UTF-8?q?=E5=B9=B3=E4=BB=93=E7=9A=84=E5=BE=85=E5=AE=9E=E7=8E=B0=E6=94=B6?= =?UTF-8?q?=E7=9B=8A=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加DI_MANUAL_PREPAY_PARTIAL_CLOSE_UsesHistoryPlusRemainingDailyInterest测试方法 - 验证预付金部分平仓待实现收益为历史待实现加平仓后当日新增减平仓实现 - 修改ExecuteSaveAutoEodWithCloseInterestPosition方法中待实现收益计算逻辑 - 新增useAccrualBalance标识判断是否使用应计余额计算方式 - 对于预付金模式使用历史待实现收益加当日新增减平仓实现的方式计算 --- .../SwapModule/DealInterestsScenarioTest.cs | 25 +++++++++++++++++++ .../SwapModule/SwapEodPositionService.cs | 8 +++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/UnitTestProject/Modules/SwapModule/DealInterestsScenarioTest.cs b/UnitTestProject/Modules/SwapModule/DealInterestsScenarioTest.cs index ba6f8790..b4b11f31 100644 --- a/UnitTestProject/Modules/SwapModule/DealInterestsScenarioTest.cs +++ b/UnitTestProject/Modules/SwapModule/DealInterestsScenarioTest.cs @@ -782,6 +782,31 @@ namespace YLErp.Modules.SwapModule "The previous EOD identity must not be reset to a new position"); } + [TestMethod] + public void DI_MANUAL_PREPAY_PARTIAL_CLOSE_UsesHistoryPlusRemainingDailyInterest() + { + var service = new StubEodPositionService(); + var td = CreateTrade(); + var position = CreateInterestPosition(); + position.InterestMode = (int)InterestModeEnum.初始预付金; + position.InterestPrincipalFix = Principal; + var previousEod = CreatePreEod(StartDate.AddDays(2), 100m); + previousEod.InterestMode = position.InterestMode; + previousEod.TdInterestPrincipal = Principal; + var closeFlow = CreateSwapFlowEvent(StartDate.AddDays(3), 50m); + closeFlow.EventType = (int)SwapFlowEventTypeEnum.平仓; + closeFlow.InterestPrincipal = 500m; + + var result = service.ExecuteSaveAutoEodWithCloseInterestPosition( + previousEod, position, td, StartDate.AddDays(3), null, + 500m, 0m, new List { closeFlow }, 500m, false); + + var expected = previousEod.InterestIncomeSum + + result.TdInterestIncome - result.TdCloseInterest; + AssertDecimal(expected, result.InterestIncomeSum, + "预付金部分平仓待实现收益应为历史待实现+平仓后当日新增-平仓实现"); + } + [TestMethod] public void DI_AUTO_SETTLEMENT_005_AutoSettlementKeepsRemainingPrincipal() { diff --git a/YLErpDAL/Modules/SwapModule/SwapEodPositionService.cs b/YLErpDAL/Modules/SwapModule/SwapEodPositionService.cs index ce7e3807..5987acef 100644 --- a/YLErpDAL/Modules/SwapModule/SwapEodPositionService.cs +++ b/YLErpDAL/Modules/SwapModule/SwapEodPositionService.cs @@ -1412,8 +1412,14 @@ namespace YLErp.Modules.SwapModule } else { + var useAccrualBalance = !autoSwap + && (position.InterestMode == (int)InterestModeEnum.初始预付金 + || position.InterestMode == (int)InterestModeEnum.追加预付金); + var pendingInterestBeforeSettlement = useAccrualBalance + ? lastInterestIncomeSum + newEodPayPosition.TdInterestIncome + : interestAmountBeforeSettlement; newEodPayPosition.InterestIncomeSum = RoundEodInterest( - interestAmountBeforeSettlement - newEodPayPosition.TdCloseInterest); + pendingInterestBeforeSettlement - newEodPayPosition.TdCloseInterest); newEodPayPosition.InterestFeeSum = eodPayPosition.InterestFeeSum + newEodPayPosition.TdInterestFee - newEodPayPosition.TdCloseInterestFee; } //持仓内容-利息腿-损益统计(本方视角)