Merge branch 'glms/feature/1.4.2-0806' into glms/feature/1.4.2

This commit is contained in:
马冰冰
2026-08-06 14:45:37 +08:00
3 changed files with 64 additions and 1 deletions
@@ -63,5 +63,35 @@ namespace YLErp.Modules.SwapModule
Assert.AreEqual(ClientCashInCashOut._预付金返息, service.ClientCashCalls[1].action);
Console.WriteLine($"SI_002: 互换={service.ClientCashCalls[0].amount}, 预付金返息={service.ClientCashCalls[1].amount} ✅");
}
[TestMethod]
public void SI_003_SwapIncome_含预付金腿_不返还预付金本金()
{
var td = SwapDealTestFactory.CreateTrade();
td.ExerciseDate = new DateTime(2026, 12, 31);
var service = new TestableSwapDealService(td);
var unwindData = SwapDealTestFactory.CreateUnwindData(swapRealizedPnL: 0m);
unwindData.FlowEvents.Add(new swap_flow_event
{
UnderlyingCode = "UT-FLOAT",
MarkClosePnl = 100m,
PayDirection = 1
});
unwindData.FlowEvents.Add(new swap_flow_event
{
InterestMode = (int)InterestModeEnum.,
InterestDirection = 1,
InterestPrincipal = 10000m,
InterestClosePnL = 2m
});
service.SwapIncome(unwindData);
Assert.AreEqual(0m, unwindData.SwapMarginAmount, "手动互换不应返还预付金本金");
Assert.IsFalse(service.ClientCashCalls.Any(x => x.action == ClientCashInCashOut._应付预付金),
"手动互换不应生成应付预付金流水");
Assert.IsTrue(service.ClientCashCalls.Any(x => x.action == ClientCashInCashOut._预付金返息),
"手动互换仍应结算预付金返息");
}
}
}
@@ -166,6 +166,35 @@ namespace YLErp.Modules.SwapModule
Console.WriteLine($"UW_005: 反序列化SwapRealizedPnL=8000, 资金流水={service.ClientCashCalls[0].amount}, TradeStatus={td.TradeStatus} ✅");
}
[TestMethod]
public void UW_005A_ApproveSwapTrade_互换审核_不返还预付金本金()
{
var td = SwapDealTestFactory.CreateTrade();
td.ExerciseDate = new DateTime(2026, 12, 31);
var unwindData = SwapDealTestFactory.CreateUnwindData(
swapRealizedPnL: 100m, swapMarginAmount: -10000m);
var swapEvent = new swap_event
{
id = 2,
SwapTradeId = SwapDealTestFactory.SwapTradeId,
EventType = (int)SwapEventTypeEnum.,
Invalid = false,
EventData = JsonConvert.SerializeObject(unwindData)
};
var service = new TestableSwapDealService(td,
swapEvents: new Dictionary<int, swap_event>
{
[(int)SwapEventTypeEnum.互换] = swapEvent
});
service.ApproveSwapTrade(td, (int)SwapEventTypeEnum.);
Assert.AreEqual(1, service.ClientCashCalls.Count, "互换审批只应生成互换结算流水");
Assert.AreEqual(ClientCashInCashOut._互换, service.ClientCashCalls[0].action);
Assert.IsFalse(service.ClientCashCalls.Any(x => x.action == ClientCashInCashOut._应付预付金),
"互换审批不应生成应付预付金流水");
}
// ================================================================
// 场景6ApplySwapTrade 提交审核 —— 前置校验与保存事件
// ================================================================
@@ -144,6 +144,10 @@ namespace YLErp.Modules.SwapModule
if (unwindData.FlowEvents.Any(x => !string.IsNullOrEmpty(x.UnderlyingCode)))
{
CalcCloseAmount(unwindData);
if (eventType == (int)SwapEventTypeEnum.)
{
unwindData.SwapMarginAmount = 0;
}
return;
}
@@ -2013,7 +2017,7 @@ namespace YLErp.Modules.SwapModule
}
string action = eventType == (int)SwapEventTypeEnum. ? ClientCashInCashOut._互换 : ClientCashInCashOut._平仓费;
int clientCashId = AddClientCash(td, Convert.ToDouble(-swapEvent.unwindData.SwapRealizedPnL), action, swapEvent.unwindData.ValueDate);
if (swapEvent.unwindData.SwapMarginAmount != 0)
if (eventType == (int)SwapEventTypeEnum. && swapEvent.unwindData.SwapMarginAmount != 0)
{
AddClientCash(td, Convert.ToDouble(swapEvent.unwindData.SwapMarginAmount), ClientCashInCashOut._应付预付金, swapEvent.unwindData.ValueDate);
}