From 5539bd9c9a5890076af52067e6a207ef18838cd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=90=8D=E9=94=90?= <1565842059@qq.com> Date: Fri, 7 Aug 2026 20:51:56 +0800 Subject: [PATCH] =?UTF-8?q?```=20fix(swap):=20=E4=BF=AE=E5=A4=8D=E5=A4=8D?= =?UTF-8?q?=E5=88=A9=E6=A8=A1=E5=BC=8F=E4=B8=8B=E9=83=A8=E5=88=86=E5=B9=B3?= =?UTF-8?q?=E4=BB=93=E5=90=8EEOD=E6=9C=AC=E9=87=91=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在复利模式部分平仓场景中确保使用计算得出的复利本金 - 添加了针对复利重置日期部分平仓的单元测试验证 - 修复了EOD本金重置逻辑,避免复利计算被错误覆盖 - 确保CloseInterestPosition执行后保留正确的复利本金值 ``` --- .../SwapModule/DealInterestsScenarioTest.cs | 34 +++++++++++++++++++ .../SwapModule/SwapEodPositionService.cs | 1 + 2 files changed, 35 insertions(+) diff --git a/UnitTestProject/Modules/SwapModule/DealInterestsScenarioTest.cs b/UnitTestProject/Modules/SwapModule/DealInterestsScenarioTest.cs index 14bf0381..14dbc782 100644 --- a/UnitTestProject/Modules/SwapModule/DealInterestsScenarioTest.cs +++ b/UnitTestProject/Modules/SwapModule/DealInterestsScenarioTest.cs @@ -782,6 +782,40 @@ namespace YLErp.Modules.SwapModule "The previous EOD identity must not be reset to a new position"); } + [TestMethod] + public void DI_COMPOUND_RESET_PARTIAL_CLOSE_UsesCalculatedPrincipal() + { + const decimal remainingNotional = 500m; + const decimal compoundPrincipalAfterSevenDays = 500.958904m; + var closeDate = StartDate.AddDays(7); + var service = new StubEodPositionService + { + AutoInterests = new List + { + new swap_flow_event + { + InterestPrincipal = compoundPrincipalAfterSevenDays, + InterestRate = FixedRate, + InterestAmount = 0m, + TdInterestAmount = 0m + } + } + }; + var td = CreateTrade(); + var position = CreateInterestPosition(); + position.InterestType = (int)InterestTypeEnum.复利; + position.interest_rest_days = 7; + var closeFlow = CreateSwapFlowEvent(closeDate, 0m); + closeFlow.EventType = (int)SwapFlowEventTypeEnum.平仓; + + var result = service.ExecuteSaveAutoEodWithCloseInterestPosition( + CreatePreEod(closeDate.AddDays(-1), 0m), position, td, closeDate, null, + remainingNotional, 0m, new List { closeFlow }, remainingNotional, false); + + AssertDecimal(compoundPrincipalAfterSevenDays, result.TdInterestPrincipal, + "复利重置日部分平仓后,EOD 本金必须保留 CalcSwapInterests 计算的 7 天复利本金"); + } + [TestMethod] public void DI_MANUAL_PREPAY_PARTIAL_CLOSE_UsesHistoryPlusRemainingDailyInterest() { diff --git a/YLErpDAL/Modules/SwapModule/SwapEodPositionService.cs b/YLErpDAL/Modules/SwapModule/SwapEodPositionService.cs index 41ef4f4c..c2f54d6a 100644 --- a/YLErpDAL/Modules/SwapModule/SwapEodPositionService.cs +++ b/YLErpDAL/Modules/SwapModule/SwapEodPositionService.cs @@ -1381,6 +1381,7 @@ namespace YLErp.Modules.SwapModule newEodPayPosition.TdInterestPrincipal = interestModes.Contains(position.InterestMode) ? position.InterestPrincipalFix : position.InterestMode == (int)InterestModeEnum.标的期初全价 + && position.InterestType != (int)InterestTypeEnum.复利 ? posiNotionalValue : interests.Count > 0 ? interests.First().InterestPrincipal : 0; if (interval != null)