#EQD-5850 预付金返息的发生时间有问题
This commit is contained in:
@@ -390,12 +390,35 @@ namespace YLErp.Modules.SwapModule
|
||||
}
|
||||
unwindData.NotionalValue = Convert.ToDecimal(td.OriginalStockEqvNotional ?? 0);
|
||||
unwindData.PosiNotionalValue = StockEqvNotional;
|
||||
autoInterests.ForEach(x =>
|
||||
|
||||
// 预付金腿类型列表:初始预付金、追加预付金
|
||||
var premiumModes = new List<int>() {(int)InterestModeEnum.初始预付金, (int)InterestModeEnum.追加预付金 };
|
||||
|
||||
// 分别计算预付金腿和利息腿的金额
|
||||
var premiumInterests = autoInterests.Where(x => premiumModes.Contains(x.InterestMode)).ToList();
|
||||
var interestLegs = autoInterests.Where(x => !premiumModes.Contains(x.InterestMode)).ToList();
|
||||
|
||||
// 预付金腿金额
|
||||
decimal premiumTotal = 0;
|
||||
premiumInterests.ForEach(x =>
|
||||
{
|
||||
var ratio = x.InterestDirection == (int)SwapDirectionEnum.收取 ? 1 : -1;
|
||||
unwindData.SwapCloseAmount = unwindData.SwapCloseAmount + x.InterestClosePnL;
|
||||
unwindData.SwapRealizedPnL = unwindData.SwapCloseAmount;
|
||||
premiumTotal += x.InterestClosePnL * ratio;
|
||||
});
|
||||
unwindData.SwapMarginRebatePnl = premiumTotal; // 预付金腿金额
|
||||
|
||||
// 利息腿金额(总金额减去预付金腿金额)
|
||||
decimal interestTotal = 0;
|
||||
interestLegs.ForEach(x =>
|
||||
{
|
||||
var ratio = x.InterestDirection == (int)SwapDirectionEnum.收取 ? 1 : -1;
|
||||
interestTotal += x.InterestClosePnL * ratio;
|
||||
});
|
||||
unwindData.SwapCloseAmount = interestTotal; // 利息腿金额
|
||||
|
||||
// 总实现盈亏
|
||||
unwindData.SwapRealizedPnL = unwindData.SwapCloseAmount + unwindData.SwapMarginRebatePnl;
|
||||
|
||||
SaveAutoSwapDeal(td, autoInterests, unwindData, interval);
|
||||
}
|
||||
/// <summary>
|
||||
@@ -409,7 +432,20 @@ namespace YLErp.Modules.SwapModule
|
||||
//td.UnWindDate = unwindData.ValueDate;
|
||||
//优先使用 interval.SettlementDate 作为资金记录发生日期,如果没有则使用 ValueDate
|
||||
var cashHappenDate = interval?.SettlementDate ?? unwindData.ValueDate;
|
||||
int clientCashId = AddClientCashInCashOut(td, Convert.ToDouble(-unwindData.SwapCloseAmount), ClientCashInCashOut.系统操作_互换, cashHappenDate);
|
||||
|
||||
int clientCashId = 0;
|
||||
// 利息腿:插入资金记录(使用系统操作_互换)
|
||||
if (unwindData.SwapCloseAmount != 0)
|
||||
{
|
||||
clientCashId = AddClientCashInCashOut(td, Convert.ToDouble(-unwindData.SwapCloseAmount), ClientCashInCashOut.系统操作_互换, cashHappenDate);
|
||||
}
|
||||
|
||||
// 预付金腿:单独插入一条资金记录(系统操作_预付金返息)
|
||||
if (unwindData.SwapMarginRebatePnl != 0)
|
||||
{
|
||||
AddClientCashInCashOut(td, Convert.ToDouble(-unwindData.SwapMarginRebatePnl), ClientCashInCashOut.系统操作_预付金返息, unwindData.ValueDate);
|
||||
}
|
||||
|
||||
string data = JsonConvert.SerializeObject(unwindData);
|
||||
var swapEvent = new SwapEventService(this).AddSwapEventDate(unwindData.ValueDate, unwindData.SwapTradeId, (int)SwapEventTypeEnum.自动互换, data, clientCashId, true, "系统操作-自动互换");//将互换总额存入事件
|
||||
flowEvents.ForEach(x =>
|
||||
|
||||
Reference in New Issue
Block a user