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)