还原平仓时付息记录。

This commit is contained in:
gongpei
2025-10-23 21:14:39 +08:00
parent 5ee62775b7
commit de184dfdd6
+7 -10
View File
@@ -889,7 +889,7 @@ namespace YLErp.Modules.SwapModule
floatEvent.OptLog = "流水自动";
floatEvent.ClientId = td.ClientId;
floatEvent.SetOpt(UserInfo);
EnrichDividendIn(floatEvent, unwindQty);
EnrichDividendIn(floatEvent, unwindQty, td);
}
unwindData.FlowEvents.Add(floatEvent);
var interestPositions = GetUnwindInterests(unwindData.ValueDate, unwindData.UnwindDate.Value, td.id, unwindPercent, (int)SwapEventTypeEnum.);
@@ -908,23 +908,20 @@ namespace YLErp.Modules.SwapModule
DealUnwind(unwindData, td);
}
private void EnrichDividendIn(swap_flow_event flowEvent, decimal unwindQty)
private void EnrichDividendIn(swap_flow_event flowEvent, decimal unwindQty, trade td)
{
if (flowEvent.UnwindDate == null) {
if (flowEvent.UnwindDate == null)
{
throw new ArgumentNullException("平仓日期缺失");
}
var date = flowEvent.UnwindDate.GetValueOrDefault();
var preDate = date.AddDays(-1);
// 平仓数量/平仓前的数量 * 上一自然日待实现分红收益,保留2位小数
var eod = DbContext.eod_swap_position.Where(e => e.SwapTradeId == flowEvent.SwapTradeId && !e.Invalid && e.PosiQuantity > 0 && e.ValueDate == preDate).FirstOrDefault();
var dividendIn = eod.PosiDividendSum * unwindQty / eod.PosiQuantity;
// + 付息日>上日日终且小于等于平仓日期的分红数据
BondPaymentService servie = new BondPaymentService(UserInfo);
var payments = servie.GetBondPayments(flowEvent.UnderlyingCode, preDate, date);
var payments = servie.GetBondPayments(flowEvent.UnderlyingCode, td.StartDate.Value, date);
int shortRatio = flowEvent.PositionType == (int)PositionTypeFlag.Long ? 1 : -1;
int directionRatio = flowEvent.PayDirection == (int)SwapDirectionEnum. ? 1 : -1;
dividendIn = dividendIn + servie.CalcPayment(payments, unwindQty, shortRatio, directionRatio);
// + 付息日>上日日终且小于等于平仓日期的分红数据
var dividendIn = servie.CalcPayment(payments, unwindQty, shortRatio, directionRatio);
flowEvent.DividendIn = Math.Round(dividendIn, 2, MidpointRounding.AwayFromZero);
}