diff --git a/UnitTestProject/Modules/SwapModule/DealInterestsScenarioTest.cs b/UnitTestProject/Modules/SwapModule/DealInterestsScenarioTest.cs index f75375be..907849eb 100644 --- a/UnitTestProject/Modules/SwapModule/DealInterestsScenarioTest.cs +++ b/UnitTestProject/Modules/SwapModule/DealInterestsScenarioTest.cs @@ -864,8 +864,10 @@ namespace YLErp.Modules.SwapModule "预付金部分平仓待实现收益应为历史待实现+平仓后当日新增-平仓实现"); } - [TestMethod] - public void DI_MANUAL_PARTIAL_CLOSE_CalcLastIncludesClosedPrincipalDailyInterest() + [DataTestMethod] + [DataRow((int)InterestModeEnum.合约名义本金规模)] + [DataRow((int)InterestModeEnum.标的期初全价)] + public void DI_MANUAL_PARTIAL_CLOSE_CalcLastIncludesClosedPrincipalDailyInterest(int interestMode) { var service = new StubEodPositionService(); var td = CreateTrade(); @@ -876,6 +878,7 @@ namespace YLErp.Modules.SwapModule SettlementRules = 0 }); var position = CreateInterestPosition(); + position.InterestMode = interestMode; var previousEod = CreatePreEod(StartDate.AddDays(2), 100m); previousEod.TdInterestPrincipal = Principal; var closeFlow = CreateSwapFlowEvent(StartDate.AddDays(3), 50m); @@ -887,6 +890,8 @@ namespace YLErp.Modules.SwapModule AssertDecimal(Principal * FixedRate / AnnualDays, result.TdInterestIncome, "算尾部分平仓的当日新计利息应包含已平仓部分(按全额本金计提)"); + AssertDecimal(500m, result.TdInterestPrincipal, + "算尾部分平仓后的 EOD 本金应只携带剩余持仓"); // 补充:算尾部分平仓的待实现利息总额应满足递推 // InterestIncomeSum = 前日待实现 + 当日新计(全额本金,含被平仓部分) - 当日实现 diff --git a/YLErpDAL/Modules/SwapModule/SwapEodPositionService.cs b/YLErpDAL/Modules/SwapModule/SwapEodPositionService.cs index 9eea085c..e7c07412 100644 --- a/YLErpDAL/Modules/SwapModule/SwapEodPositionService.cs +++ b/YLErpDAL/Modules/SwapModule/SwapEodPositionService.cs @@ -1453,6 +1453,16 @@ namespace YLErp.Modules.SwapModule newEodPayPosition.TdInterestIncome /= tradeExtend.AnnualDays; } } + if (!autoSwap + && closePercent > 0m && closePercent < 1m + && posiNotionalValue > 0m + && position.InterestType == (int)InterestTypeEnum.单利 + && (position.InterestMode == (int)InterestModeEnum.合约名义本金规模 + || position.InterestMode == (int)InterestModeEnum.标的期初全价)) + { + // 单利算尾当日仍按平仓前全额计提,跨日 EOD 本金只携带剩余持仓。 + newEodPayPosition.TdInterestPrincipal = posiNotionalValue; + } Log.Info($"InterestIncomeSum is {lastInterestIncomeSum},TdInterestIncome is {newEodPayPosition.TdInterestIncome}" + $",TdCloseInterest is {newEodPayPosition.TdCloseInterest}"); Log.Info($"InterestFeeSum is {eodPayPosition.InterestFeeSum},TdInterestFee is {newEodPayPosition.TdInterestFee}" +