diff --git a/Framework/YLErp.Core/DBModels/underlying_manager.cs b/Framework/YLErp.Core/DBModels/underlying_manager.cs index 89fea84e..5edecdac 100644 --- a/Framework/YLErp.Core/DBModels/underlying_manager.cs +++ b/Framework/YLErp.Core/DBModels/underlying_manager.cs @@ -322,6 +322,12 @@ namespace YLErp.DBModels /// public long? InnerCode { get; set; } + /// + /// 债券增值税 + /// + [Column("value_added_tax")] + public decimal? ValueAddedTax { get; set; } + public override string ToString() { return $"{UnderlyingCode}--{UnderlyingName}--{id}--{UnderlyingInstrumentType}"; diff --git a/YLErpDAL/Modules/SwapModule/SwapDealService.cs b/YLErpDAL/Modules/SwapModule/SwapDealService.cs index ef693f9c..28689a31 100644 --- a/YLErpDAL/Modules/SwapModule/SwapDealService.cs +++ b/YLErpDAL/Modules/SwapModule/SwapDealService.cs @@ -881,8 +881,10 @@ namespace YLErp.Modules.SwapModule floatEvent.TradingFeePending = Math.Round(floatEvent.TradingFeePending, ConsGlobal.MoneyRound, MidpointRounding.AwayFromZero); floatEvent.TradingFee = closeFee; BondPaymentService bondPaymentService = new BondPaymentService(UserInfo); + var tax = GetUnderlyingTax(floatEvent.UnderlyingCode); var payments = bondPaymentService.GetBondPayments(floatEvent.UnderlyingCode, td.StartDate.Value, floatEvent.UnwindDate.Value); - floatEvent.DividendIn = bondPaymentService.CalcPayment(payments, unwindQty, longRatio, floatRatio); + var payment = bondPaymentService.CalcPayment(payments, unwindQty, longRatio, floatRatio); + floatEvent.DividendIn = payment / (1 + tax) * (1 - tax); floatEvent.DividendIn = Math.Round(floatEvent.DividendIn, 2, MidpointRounding.AwayFromZero); floatEvent.DividendPending = bondPaymentService.CalcPayment(payments, floatEvent.PositionQty ?? 0, longRatio, floatRatio); @@ -910,6 +912,17 @@ namespace YLErp.Modules.SwapModule CalcCloseAmount(unwindData); DealUnwind(unwindData, td); } + + public decimal GetUnderlyingTax(string code) + { + var data = DataCacheProvider.GetUnderlyingDataSource().GetData(code); + if (data == null) + { + return 0; + } + return data.ValueAddedTax ?? 0; + } + /// /// 衡泰新增平仓事件 /// diff --git a/YLErpDAL/Modules/SwapModule/SwapEodPositionService.cs b/YLErpDAL/Modules/SwapModule/SwapEodPositionService.cs index b97a1562..6e94cba2 100644 --- a/YLErpDAL/Modules/SwapModule/SwapEodPositionService.cs +++ b/YLErpDAL/Modules/SwapModule/SwapEodPositionService.cs @@ -1142,10 +1142,13 @@ namespace YLErp.Modules.SwapModule int directionRatio = eod.PosiDirection == (int)SwapDirectionEnum.收取 ? 1 : -1; curretEod.PosiStatus = curretEod.PosiQuantity == 0 ? 1 : 0; var price = UnderlyingCodePrice(eod.UnderlyingCode, dealDate, out decimal vobp); + decimal tax = um.ValueAddedTax ?? 0; BondPaymentService bondPaymentService = new BondPaymentService(UserInfo); if (valueDate > td.StartDate.Value && (curretEod.PosiQuantity > 0 || valueDate == td.UnWindDate)) { - curretEod.TdPosiDividend = bondPaymentService.CalcPayment(curretEod.UnderlyingCode, eod.ValueDate, valueDate, curretEod.PosiQuantity, shortRatio, directionRatio); + decimal payment = bondPaymentService.CalcPayment(curretEod.UnderlyingCode, eod.ValueDate, valueDate, curretEod.PosiQuantity, shortRatio, directionRatio); + // 考虑增值税 + curretEod.TdPosiDividend = payment / (1 - tax) * (1 + tax); } curretEod.PosiDividendSum = eod.PosiDividendSum + curretEod.TdPosiDividend; curretEod.PosiQuantity = eod.PosiQuantity; @@ -1162,6 +1165,7 @@ namespace YLErp.Modules.SwapModule curretEod.TdCloseFee = 0; curretEod.TdCloseQty = 0; curretEod.TdCloseMtmPnl = 0; + // 需要计算平仓盈亏分红 curretEod.TdCloseDividend = 0; curretEod.RealizedMtmPnL = eod.RealizedMtmPnL + curretEod.TdCloseMtmPnl; curretEod.RealizedDividend = eod.RealizedDividend + curretEod.TdCloseDividend; @@ -1204,6 +1208,7 @@ namespace YLErp.Modules.SwapModule if (curretEod == null) { curretEod = eod.Clone(); + curretEod.TdPosiDividend = 0; curretEod.id = 0; curretEod.ValueDate = valueDate; } @@ -1224,10 +1229,14 @@ namespace YLErp.Modules.SwapModule curretEod.PosiDividendSum = eod.PosiDividendSum + curretEod.TdPosiDividend; curretEod.PosiProfitSum = curretEod.PosiMtmPnL + curretEod.PosiDividendSum + curretEod.PosiFeePending; curretEod.RealizedMtmPnL = eod.RealizedMtmPnL + curretEod.TdCloseMtmPnl; - curretEod.RealizedDividend = eod.RealizedDividend + curretEod.TdCloseDividend; + //curretEod.RealizedDividend = eod.RealizedDividend + curretEod.TdCloseDividend; curretEod.RealizedFee = eod.RealizedFee + curretEod.TdCloseFee; curretEod.RealizedPnl = eod.RealizedPnl + curretEod.TdCloseMtmPnl; curretEod.PosiStatus = curretEod.PosiQuantity == 0 ? 1 : 0; + var closeQty = unwindEvents.Where(x => x.EventType == (int)SwapFlowEventTypeEnum.平仓).ToList().Sum(s => s.Quantity); + // 等于 平仓数量/昨天剩余平仓数量 * 昨日浮动端分红 + curretEod.TdCloseDividend = closeQty / eod.PosiQuantity * eod.TdPosiDividend; + curretEod.RealizedDividend = curretEod.RealizedDividend + curretEod.TdCloseDividend; if (curretEod.PosiStatus == 1) { curretEod.PosiNotionalValue = 0; diff --git a/YLErpWeb/wwwroot/Scripts/app/bondPayment/bondpaymentList.js b/YLErpWeb/wwwroot/Scripts/app/bondPayment/bondpaymentList.js index 2b53d3c4..e51e522b 100644 --- a/YLErpWeb/wwwroot/Scripts/app/bondPayment/bondpaymentList.js +++ b/YLErpWeb/wwwroot/Scripts/app/bondPayment/bondpaymentList.js @@ -34,7 +34,7 @@ var colModelGrid = [{ name: '', label: '操作', index: '', width: 120, formatter: showToolName }, { - name: 'payment_date', label: '支付日期', index: 'ValueDate', width: 120, formatter: 'date' + name: 'payment_date', label: '支付日期', index: 'payment_date', width: 120, formatter: 'date' }, { name: 'MarketName', label: '市场', index: 'MarketName', width: 200 }, {