diff --git a/Framework/YLErp.Core/DBModels/SwapEvent.cs b/Framework/YLErp.Core/DBModels/SwapEvent.cs index 4b0af775..311c25d1 100644 --- a/Framework/YLErp.Core/DBModels/SwapEvent.cs +++ b/Framework/YLErp.Core/DBModels/SwapEvent.cs @@ -183,5 +183,8 @@ namespace YLErp.DBModels /// 支付日 /// public DateTime? PayDate { get; set; } + + [NotMapped] + public DateTime? TradeStartDate { get; set; } } } diff --git a/Framework/YLErp.Core/DBModels/underlying_manager.cs b/Framework/YLErp.Core/DBModels/underlying_manager.cs index 5edecdac..38138af3 100644 --- a/Framework/YLErp.Core/DBModels/underlying_manager.cs +++ b/Framework/YLErp.Core/DBModels/underlying_manager.cs @@ -326,6 +326,7 @@ namespace YLErp.DBModels /// 债券增值税 /// [Column("value_added_tax")] + [DisplayName("增值税率")] public decimal? ValueAddedTax { get; set; } public override string ToString() diff --git a/YLErpDAL/Modules/EodModule/BondPaymentService.cs b/YLErpDAL/Modules/EodModule/BondPaymentService.cs index 05f5a1cf..eda780f8 100644 --- a/YLErpDAL/Modules/EodModule/BondPaymentService.cs +++ b/YLErpDAL/Modules/EodModule/BondPaymentService.cs @@ -96,11 +96,19 @@ namespace YLErp.Modules.EodModule /// /// /// - public List GetBondPayments(string underylingCode, DateTime startDate, DateTime endDate) + public List GetBondPayments(string underlyingCode, DateTime startDate, DateTime endDate) { - var result = DbContext.bondPayment.Where(x => x.underlyingCode == underylingCode && x.payment_date > startDate && x.payment_date <= endDate).AsNoTracking().ToList(); + var result = DbContext.bondPayment.Where(x => x.underlyingCode == underlyingCode && x.payment_date > startDate && x.payment_date <= endDate).AsNoTracking().ToList(); return result; } + + + public List GetTargetDatePayments(string underlyingCode, DateTime targetDate) + { + var startDate = targetDate.Date; + var endDate = startDate.AddDays(1); + return DbContext.bondPayment.AsNoTracking().Where(x => x.underlyingCode == underlyingCode && x.payment_date >= startDate && x.payment_date < endDate).ToList(); + } /// /// 计算某债券某段时间的期间付息 /// @@ -111,9 +119,9 @@ namespace YLErp.Modules.EodModule /// 多空方向 /// 收支方向 /// - public decimal CalcPayment(string underylingCode, DateTime startDate, DateTime endDate, decimal qty, decimal longRatio, decimal payDirection) + public decimal CalcPayment(string underlyingCode, DateTime startDate, DateTime endDate, decimal qty, decimal longRatio, decimal payDirection) { - var payments = GetBondPayments(underylingCode, startDate, endDate); + var payments = GetBondPayments(underlyingCode, startDate, endDate); return CalcPayment(payments, qty, longRatio, payDirection); } /// diff --git a/YLErpDAL/Modules/SwapModule/SwapDealService.cs b/YLErpDAL/Modules/SwapModule/SwapDealService.cs index 28689a31..19775965 100644 --- a/YLErpDAL/Modules/SwapModule/SwapDealService.cs +++ b/YLErpDAL/Modules/SwapModule/SwapDealService.cs @@ -71,6 +71,7 @@ namespace YLErp.Modules.SwapModule } else { + unwindData.TradeStartDate = td.StartDate; unwindData.CloseType = commodity ? 1 : 2; unwindData.StartDate = td.TradeDate.Value; if (preDealDate.HasValue) @@ -880,13 +881,15 @@ namespace YLErp.Modules.SwapModule floatEvent.TradingFeePending = position.PosiTradingFeePending * unwindData.ClosePercent; 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); - var payment = bondPaymentService.CalcPayment(payments, unwindQty, longRatio, floatRatio); - floatEvent.DividendIn = payment / (1 + tax) * (1 - tax); + // 只计算事件日期当天的分红收益 + var payments = bondPaymentService.GetTargetDatePayments(floatEvent.UnderlyingCode, floatEvent.EventDate); + floatEvent.DividendIn = bondPaymentService.CalcPayment(payments, unwindQty, longRatio, floatRatio) / (1 + tax) * (1 - tax); floatEvent.DividendIn = Math.Round(floatEvent.DividendIn, 2, MidpointRounding.AwayFromZero); - floatEvent.DividendPending = bondPaymentService.CalcPayment(payments, floatEvent.PositionQty ?? 0, longRatio, floatRatio); + floatEvent.DividendPending = bondPaymentService.CalcPayment(payments, floatEvent.PositionQty ?? 0, longRatio, floatRatio) / (1 + tax) * (1 - tax); + floatEvent.MarkClosePnl = (unwindPrice - position.PosiGrossPrice) * unwindQty * floatRatio * longRatio; floatEvent.MarkClosePnl = Math.Round(floatEvent.MarkClosePnl + ((floatEvent.TradingFeePending+ closeFee) * floatRatio * -1) + floatEvent.DividendIn, ConsGlobal.MoneyRound, MidpointRounding.AwayFromZero); diff --git a/YLErpWeb/Views/underlying_manager/underlying_managerEdit.cshtml b/YLErpWeb/Views/underlying_manager/underlying_managerEdit.cshtml index e1280475..db4e13a7 100644 --- a/YLErpWeb/Views/underlying_manager/underlying_managerEdit.cshtml +++ b/YLErpWeb/Views/underlying_manager/underlying_managerEdit.cshtml @@ -308,6 +308,10 @@ +
+ + +
diff --git a/YLErpWeb/Views/underlying_manager/underlying_managerView.cshtml b/YLErpWeb/Views/underlying_manager/underlying_managerView.cshtml index 07953c86..f22e7837 100644 --- a/YLErpWeb/Views/underlying_manager/underlying_managerView.cshtml +++ b/YLErpWeb/Views/underlying_manager/underlying_managerView.cshtml @@ -170,6 +170,11 @@ @Html.MyDisplayFor(m => m.Price) } + + + 增值税率 + @(Model.ValueAddedTax.OtcFormatPercent()) +
diff --git a/YLErpWeb/wwwroot/Scripts/app/swaptrade/unwindSwapTrade.js b/YLErpWeb/wwwroot/Scripts/app/swaptrade/unwindSwapTrade.js index 1eff09c5..fe235911 100644 --- a/YLErpWeb/wwwroot/Scripts/app/swaptrade/unwindSwapTrade.js +++ b/YLErpWeb/wwwroot/Scripts/app/swaptrade/unwindSwapTrade.js @@ -51,6 +51,7 @@ const vue = new Vue({ }); this.ratio = this.floatPosition.PayDirection == 1 ? -1 : 1; this.shortRatio = this.floatPosition.PositionType == 1 ? 1 : -1; + this.TradeStartDate = model.TradeStartDate; }, IsBond(instType) { return tradeHelper.IsBond(instType); @@ -269,7 +270,7 @@ const vue = new Vue({ var thisObj = this; let ratio = this.floatPosition.PositionType == 1 ? 1 : -1; let floatRatio = this.floatPosition.PayDirection == 1 ? 1 : -1; - var postData = { startDate: thisObj.floatPosition.PosiStartDate, endDate: thisObj.deal.UnwindDate, underlyingCode: thisObj.floatPosition.UnderlyingCode } + var postData = { startDate: thisObj.TradeStartDate, endDate: thisObj.deal.UnwindDate, underlyingCode: thisObj.floatPosition.UnderlyingCode } main.post("/BondPayment/GetBondPayMentInterest", postData, { async: false }).done(function (resp) { thisObj.floatPosition.DividendIn = parseFloat(thisObj.deal.CloseQty) * resp.obj * ratio * floatRatio; var posiQty = parseFloat(thisObj.floatPosition.Quantity) - parseFloat(thisObj.deal.CloseQty);