feat: 债券付息收盘处理

This commit is contained in:
gongpei
2025-10-21 13:43:32 +08:00
parent a4dcaf584e
commit 89df4443bd
16 changed files with 651 additions and 6 deletions
@@ -0,0 +1,108 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using YieldChain.Security;
using YLErp.DBModels.Base;
namespace YLErp.DBModels
{
/// <summary>
/// 债券期间付息表
/// </summary>
[Table("bond_payment_info")]
public class BondPayment
{
public long id { get; set; }
/// <summary>
/// 加密主键
/// </summary>
[NotMapped]
public string EncryptId
{
get { return DataProtect.Encrypt(id.ToString()); }
}
/// <summary>
/// 债券代码
/// </summary>
[Column("inner_code")]
public int inner_code { get; set; }
[Column("underlying_code")]
public string underlyingCode { get; set; }
/// <summary>
/// 债券代码
/// </summary>
[DisplayName("债券代码")]
[NotMapped]
public string security_id { get; set; }
/// <summary>
/// 债券名称
/// </summary>
[DisplayName("债券名称")]
[NotMapped]
public string symbol { get; set; }
/// <summary>
/// 利息税率(%)
/// </summary>
[DisplayName("利息税率(%)")]
[Column("interest_tax_rate")]
public decimal? coupon_rate { get; set; }
/// <summary>
/// 现金流发放日
/// </summary>
[DisplayName("理论付息(兑付)日")]
[Column("pay_date_PL")]
public DateTime? payment_date_pl { get; set; }
/// <summary>
/// 现金流发放日
/// </summary>
[DisplayName("实际付息(兑付)日")]
[Column("pay_date_act")]
public DateTime? payment_date { get; set; }
/// <summary>
/// 每张兑付利息额
/// </summary>
[DisplayName("每张兑付利息额")]
[Column("paying_interest")]
public decimal? payment_interest { get; set; }
/// <summary>
/// 每张兑付本金额
/// </summary>
[DisplayName("每张兑付本金额")]
[Column("paying_principal")]
public decimal? payment_parvalue { get; set; }
/// <summary>
/// 每张兑付本息额
/// </summary>
[DisplayName("每张兑付本息额")]
[Column("paying_price")]
public decimal? paying_price { get; set; }
/// <summary>
/// 渠道来源
/// </summary>
[Column("info_source")]
public string channel_source { get; set; }
/// <summary>
/// 聚源JSID
/// </summary>
public long jsid { get; set; }
/// <summary>
/// 发布时间
/// </summary>
[Column("insert_time")]
public DateTime create_time { get; set; }
/// <summary>
/// 更新时间
/// </summary>
[Column("update_time")]
public DateTime update_time { get; set; }
}
}
@@ -317,6 +317,11 @@ namespace YLErp.DBModels
public string UnderlyingPinYin { get; set; }
/// <summary>
/// 聚源内部id
/// </summary>
public long? InnerCode { get; set; }
public override string ToString()
{
return $"{UnderlyingCode}--{UnderlyingName}--{id}--{UnderlyingInstrumentType}";
+2
View File
@@ -406,5 +406,7 @@ namespace YLErp.BLL
public DbSet<client_margin_config> clientMarginConfig { get; set; }
public DbSet<client_margin_detail> clientMarginDetail { get; set; }
public DbSet<trade_contract_oa_result> tradeContractOaResult { get; set; }
public DbSet<BondPayment> bondPayment { get; set; }
}
}
@@ -0,0 +1,159 @@
using BaseOUDAL;
using DocumentFormat.OpenXml.Bibliography;
using ExcelDataReader.Log;
using YLErp.DBModels;
using YLErp.Helpers;
namespace YLErp.Modules.EodModule
{
/// <summary>
/// 债券期间付息服务
/// </summary>
public class BondPaymentService : YLBaseService
{
private static IYcLogger Log = LogFactory.GetLogger(nameof(BondPaymentService));
public BondPaymentService(OptUserInfo userInfo) : base(userInfo)
{
}
public SearchListResult<BondPaymentDto> SearchList(BondPaymentReq req)
{
var valueDtStart = req.ValueDateStart.Year > 2000 ? req.ValueDateStart : DateTime.Today.AddYears(-1);
var valueDtEnd = req.ValueDateEnd.Year > 2000 ? req.ValueDateEnd.AddDays(1) : DateTime.Today.AddYears(1);
var predicatUn = PredicateBuilder.Create<underlying_manager>(d => d.LaunchState == "1");
var predicatEoc = PredicateBuilder.Create<BondPayment>(source => source.payment_date >= valueDtStart && source.payment_date < valueDtEnd);
if (!string.IsNullOrEmpty(req.DataSource))
{
predicatEoc = predicatEoc.And(d => d.channel_source.Contains(req.DataSource));
}
if (!string.IsNullOrEmpty(req.MarketName))
{
predicatUn = predicatUn.And(d => d.MarketName == req.MarketName);
}
if (!string.IsNullOrEmpty(req.UnderlyingCode))
{
predicatEoc = predicatEoc.And(d => d.underlyingCode.Contains(req.UnderlyingCode));
}
if (string.IsNullOrEmpty(req.sidx))
{
req.sidx = "payment_date";
req.sord = "desc";
}
var queryUn = DbContext.underlying_manager.Where(predicatUn).Select(n => new { n.id, n.MarketName, n.UnderlyingCode, n.UnderlyingName, n.UnderlyingInstrumentType, n.InnerCode });
var query = from un in queryUn
join source in DbContext.bondPayment.Where(predicatEoc) on un.UnderlyingCode equals source.underlyingCode
select new BondPaymentDto
{
id = source.id,
channel_source = source.channel_source,
MarketName = un.MarketName,
security_id = un.UnderlyingCode,
symbol = un.UnderlyingName,
coupon_rate = source.coupon_rate,
payment_date = source.payment_date,
payment_interest = source.payment_interest,
payment_parvalue = source.payment_parvalue,
create_time = source.create_time,
update_time = source.update_time
};
var result = query.ToSearchList(req);
return result;
}
public BondPayment SaveBondPayment(BondPayment req)
{
if (req is null)
{
throw new ArgumentNullException(nameof(req));
}
BondPayment dbmodel;
if (req.id == 0)
{
DbContext.bondPayment.Add(dbmodel = req);
}
else
{
dbmodel = DbContext.bondPayment.Find(req.id);
if (dbmodel == null)
{
throw new ServiceException("数据不存在");
}
UpdateChanges(dbmodel, req);
}
dbmodel.update_time = DateTime.Now;
DbContext.SaveChanges();
return dbmodel;
}
/// <summary>
/// 获取某债券的期间付息情况集合
/// </summary>
/// <param name="underylingCode"></param>
/// <param name="startDate"></param>
/// <param name="endDate"></param>
/// <returns></returns>
public List<BondPayment> GetBondPayments(string underylingCode, DateTime startDate, DateTime endDate)
{
var result = DbContext.bondPayment.Where(x => x.underlyingCode == underylingCode && x.payment_date > startDate && x.payment_date <= endDate).AsNoTracking().ToList();
return result;
}
/// <summary>
/// 计算某债券某段时间的期间付息
/// </summary>
/// <param name="underylingCode">债券代码</param>
/// <param name="startDate">计息开始日</param>
/// <param name="endDate">计息结束日</param>
/// <param name="qty">持仓数量</param>
/// <param name="longRatio">多空方向</param>
/// <param name="payDirection">收支方向</param>
/// <returns></returns>
public decimal CalcPayment(string underylingCode, DateTime startDate, DateTime endDate, decimal qty, decimal longRatio, decimal payDirection)
{
var payments = GetBondPayments(underylingCode, startDate, endDate);
return CalcPayment(payments, qty, longRatio, payDirection);
}
/// <summary>
/// 计算某债券期间付息
/// </summary>
/// <param name="payments">期间付息集合</param>
/// <param name="qty">持仓数量</param>
/// <param name="longRatio">多空方向</param>
/// <param name="payDirection">收支方向</param>
/// <returns></returns>
public decimal CalcPayment(List<BondPayment> payments, decimal qty, decimal longRatio, decimal payDirection)
{
var interest = payments.Sum(s => s.payment_interest ?? 0);
return interest * qty * 0.01m * longRatio * payDirection;
}
}
/// <summary>
///
/// </summary>
public class BondPaymentReq : BaseSearchReq
{
/// <summary>
/// 数据来源
/// </summary>
public string DataSource { get; set; }
/// <summary>
/// 标的代码
/// </summary>
public string UnderlyingCode { get; set; }
public DateTime ValueDateStart { get; set; }
public DateTime ValueDateEnd { get; set; }
// 市场
public string MarketName { get; set; }
}
public class BondPaymentDto : BondPayment
{
public string MarketName { get; set; }
}
}
@@ -319,7 +319,7 @@ namespace YLErp.Modules.SwapModule
var posiNotionalValue = stockEqvNotional * closePercent;//剩余名义本金
var grossPrice = realPostitions.Where(x => x.PosiDirection > 0).FirstOrDefault()?.PosiGrossPrice;
bool tdClose = DbContext.swap_flow_event.Any(x => x.SwapTradeId == tradeId && x.UnwindDate == unwindDate && eventTypes.Contains(x.EventType) && x.DataState == (int)SwapFlowDateStateEnum.);
interests = GetInterests(td, tradeExtend, valueDate, unwindDate, lastEodPositions, positions, stockEqvNotional, posiLongNotionalValue, posiShortNotionalValue, posiNotionalValue, closePercent, eventType, tdClose, false, grossPrice ?? 0, orginPv, true, false, false);
interests = GetInterests(td, tradeExtend, valueDate, unwindDate, lastEodPositions, positions, stockEqvNotional, posiLongNotionalValue, posiShortNotionalValue, posiNotionalValue, closePercent, eventType, tdClose, false, grossPrice ?? 0, orginPv, true, false, false);
return interests;
}
/// <summary>
@@ -880,11 +880,17 @@ 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 payments = bondPaymentService.GetBondPayments(floatEvent.UnderlyingCode, td.StartDate.Value, floatEvent.UnwindDate.Value);
floatEvent.DividendIn = bondPaymentService.CalcPayment(payments, unwindQty, longRatio, floatRatio);
floatEvent.DividendIn = Math.Round(floatEvent.DividendIn, 2, MidpointRounding.AwayFromZero);
floatEvent.DividendPending = bondPaymentService.CalcPayment(payments, floatEvent.PositionQty ?? 0, longRatio, floatRatio);
floatEvent.MarkClosePnl = (unwindPrice - position.PosiGrossPrice) * unwindQty * floatRatio * longRatio;
floatEvent.MarkClosePnl = Math.Round(floatEvent.MarkClosePnl + ((floatEvent.TradingFeePending+ closeFee) * floatRatio * -1), ConsGlobal.MoneyRound, MidpointRounding.AwayFromZero);
floatEvent.MarkClosePnl = Math.Round(floatEvent.MarkClosePnl + ((floatEvent.TradingFeePending+ closeFee) * floatRatio * -1) + floatEvent.DividendIn, ConsGlobal.MoneyRound, MidpointRounding.AwayFromZero);
floatEvent.TradingAmount = unwindPrice * floatEvent.Quantity * floatEvent.ContractSize;
floatEvent.TradingAmount = Math.Round(floatEvent.TradingAmount, ConsGlobal.MoneyRound, MidpointRounding.AwayFromZero);
floatEvent.OptLog = "流水自动";
floatEvent.OptLog = "流水自动";
floatEvent.ClientId = td.ClientId;
floatEvent.SetOpt(UserInfo);
}
@@ -1142,6 +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);
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);
}
curretEod.PosiDividendSum = eod.PosiDividendSum + curretEod.TdPosiDividend;
curretEod.PosiQuantity = eod.PosiQuantity;
if (curretEod.PosiStatus == 1)
{
curretEod.PosiNotionalValue = 0;
@@ -1149,8 +1156,8 @@ namespace YLErp.Modules.SwapModule
curretEod.UnderlyingPrice = price;
curretEod.UnderlyingMarketValue = curretEod.UnderlyingPrice * curretEod.PosiQuantity * curretEod.ContractSize * shortRatio;
curretEod.PosiMtmPnL = (curretEod.UnderlyingPrice - curretEod.PosiGrossPrice) * curretEod.PosiQuantity * curretEod.ContractSize * shortRatio * directionRatio;
curretEod.TdPosiDividend = 0;
curretEod.PosiDividendSum = eod.PosiDividendSum + curretEod.TdPosiDividend;
//curretEod.TdPosiDividend = 0;
//curretEod.PosiDividendSum = eod.PosiDividendSum + curretEod.TdPosiDividend;
curretEod.PosiProfitSum = curretEod.PosiMtmPnL + curretEod.PosiDividendSum+ curretEod.PosiFeePending;
curretEod.TdCloseFee = 0;
curretEod.TdCloseQty = 0;
+2
View File
@@ -53,6 +53,8 @@
<FunctionSub Name="每日估值报告邮件发送" Title="每日估值报告邮件发送" Type="Operate" Note="是否有每日估值报告权限" ></FunctionSub>
<FunctionSub Name="日终价格查看" Type="Operate" Title="日终价格查看"></FunctionSub>
<FunctionSub Name="日终价格修改" Type="Operate" Title="日终价格修改"></FunctionSub>
<FunctionSub Name="债券付息数据查看" Type="Operate" Title="债券付息数据查看"></FunctionSub>
<FunctionSub Name="债券付息数据修改" Type="Operate" Title="债券付息数据修改"></FunctionSub>
<FunctionSub Name="交易确认书" Title="交易确认书"></FunctionSub>
<FunctionSub Name="交易确认书生成" Title="交易确认书生成" Type="Operate" Note="是否有交易确认书生成权限" ></FunctionSub>
<FunctionSub Name="交易确认书邮件发送" Title="交易确认书邮件发送" Type="Operate" Note="是否有交易确认书邮件发送权限" ></FunctionSub>
+2
View File
@@ -605,6 +605,8 @@ namespace YLErp.Web
public bool _日终价格查看 => HasRight("结算管理-日终价格查看");
public bool _债券付息数据查看 => HasRight("结算管理-债券付息数据查看");
public bool _日终价格修改 => HasRight("结算管理-日终价格修改");
public bool _结算汇率查看 => HasRight("结算管理-结算汇率查看");
@@ -0,0 +1,94 @@
using Org.BouncyCastle.Ocsp;
using YLErp.DBModels;
using YLErp.Modules.EodModule;
namespace YLErp.Web.Controllers
{
public class BondPaymentController : BaseController
{
readonly IViewRenderService _viewRenderer;
public BondPaymentController(IViewRenderService viewRenderer)
{
_viewRenderer = viewRenderer;
}
[MyAuthorize("结算管理-债券付息数据查看")]
public ActionResult BondPaymentList()
{
return View();
}
[HttpPost]
public JsonResult BondPaymentQuery(BondPaymentReq req)
{
var sList = new BondPaymentService(CurUser).SearchList(req);
return Json(sList);
}
public ActionResult BondPaymentView(string enid)
{
var intid = DecryptLong(enid);
var r = yldb.bondPayment.Find(intid);
var um = yldb.underlying_manager.FirstOrDefault(x => x.UnderlyingCode == r.underlyingCode);
r.symbol = um?.UnderlyingName;
r.security_id = um?.UnderlyingCode;
return View(r);
}
public ActionResult BondPaymentEdit(string enid)
{
if (string.IsNullOrEmpty(enid) || enid == "0")
{
return View(new BondPayment());
}
var intid = DecryptLong(enid);
var dbmodel = yldb.bondPayment.Find(intid);
if (dbmodel == null)
{
return ShowError("找不到数据");
}
var um = yldb.underlying_manager.FirstOrDefault(x => x.UnderlyingCode == dbmodel.security_id);
dbmodel.symbol = um?.UnderlyingName;
return View(dbmodel);
}
public JsonResult BondPaymentEditJson(BondPayment req)
{
if (!string.IsNullOrEmpty(req.EncryptId))
{
req.id = DecryptLong(req.EncryptId);
}
var r = new BondPaymentService(CurUser).SaveBondPayment(req);
return JsonSuccess("更新成功", r);
}
[HttpPost]
public JsonResult DeletBondPayment(string id)
{
var intid = DecryptLong(id);
var r = yldb.bondPayment.Find(intid);
if (r == null)
{
return JsonError("找不到债券期间付息信息");
}
yldb.bondPayment.Remove(r);
yldb.SaveChanges();
return JsonSuccess("删除成功");
}
/// <summary>
/// 获取某债券期间付息
/// </summary>
/// <param name="startDate"></param>
/// <param name="endDate"></param>
/// <param name="underlyingCode"></param>
/// <returns></returns>
public JsonResult GetBondPayMentInterest(DateTime startDate, DateTime endDate, string underlyingCode)
{
var payments = new BondPaymentService(CurUser).GetBondPayments(underlyingCode, startDate, endDate);
decimal interest = payments.Sum(s => s.payment_interest ?? 0) * 0.01m;
return JsonSuccess("", interest);
}
}
}
@@ -0,0 +1,57 @@
@model BondPayment
@{
ViewBag.Title = "丹환퍅쇌마口 | 긍서";
Layout = "~/Views/Shared/_InfoLayout.cshtml";
}
@section JS
{
<script type="text/javascript">
$(function () {
$(".datepicker").datepicker({ changeMonth: true, changeYear: true, showButtonPanel: true, showOtherMonths: true, selectOtherMonths: true });
$(".form-group").addClass("col-md-6");
});
function checkSubmitData() {
var pass = $('#form1').valid();
return pass;
}
function saveeod_bond_price() {
if (!checkSubmitData()) return false;
var data = $("#form1").serialize();
main.post("/BondPayment/BondPaymentEditJson", data).done(function (res) {
window.location.href = "/BondPayment/BondPaymentView?enid=" + res.obj.EncryptId;
main.parentReloadData();
});
}
</script>
}
<form class="yc-panel" id="form1" method="post" onsubmit="return false;">
@Html.HiddenFor(model => model.id)
@Html.HiddenFor(model => model.jsid)
@Html.HiddenFor(model => model.coupon_rate)
@Html.HiddenFor(model => model.payment_parvalue)
@Html.HiddenFor(model => model.paying_price)
@Html.HiddenFor(model => model.channel_source)
<h4>丹환퍅쇌마口錦맣</h4>
<div style="margin-top:20px;">
<div class='form-group col-md-6'>
<label class='formlabel'>丹환츰냔</label>
<input class='text-box' type='text' value='@(Model.symbol)' readonly=readonly />
</div>
<div class='form-group col-md-6'>
<label class='formlabel'>丹환덜쯤</label>
<input class='text-box' type='text' value='@(Model.security_id)' readonly=readonly />
</div>
@Html.MyDateFor(model => model.payment_date)
@Html.MyTextFor(model => model.payment_interest)
</div>
<div style="padding:10px;padding-left:130px;">
<button class="btn btn-primary" type="button" onclick="saveeod_bond_price();">괏닸</button>
<button class="btn btn-primary" type="button" onclick="layer.closeMe();">밑균</button>
</div>
</form>
@@ -0,0 +1,43 @@
@{
var DataSources = new List<string> { "聚源", "人工" };
ViewBag.Title = "债券期间付息管理";
Layout = "~/Views/Shared/_InfoLayout.cshtml";
}
@section CSS {
<style>
.container {
width: 100%;
}
@@media (min-width: 1400px) {
.container {
max-width: 1400px;
}
}
.card-import-result .close {
display: none;
}
</style>
}
@section JS {
<script>
var curdate = "@valuedateBLL.ValueDate.ToString("yyyy-MM-dd")";
</script>
<script src="~/Scripts/app/bondPayment/bondpaymentList.js?v=@(HtmlUtil.JsVersion)"></script>
}
<div style="display:none;width:350px;" id="errormessage"></div>
<div class="searchdiv">
@Html.SearchDateRange("ValueDate", "支付日期")
@Html.MyAceDropdownInput2("DataSource", "数据来源", GlobalData.GetSelectItems(DataSources))
@Html.MyAceDropdownInput2("MarketName", "市场", MarketController.GetAllmarketName())
@Html.ShortInput("UnderlyingCode", "标的代码")
@MyControls.SearchBtn()
@MyControls.Btn("导出", "downloadExcel()")
</div>
@Html.Raw(JqGridSimple.OutTable())
@@ -0,0 +1,46 @@
@model BondPayment
@{
ViewBag.Title = "债券期间付息|查看";
Layout = "~/Views/Shared/_InfoLayout.cshtml";
}
@section JS {
<script type="text/javascript">
function deletBondPayment(id) {
if (confirm("确定删除吗?")) {
$.ajax({
type: "Post",
url: "/BondPayment/DeletBondPayment",
data: { id: id, d: new Date() },
success: function (data) {
alert(data.msg);
if (data.success == true) {
window.parent.location = window.parent.location;
window.close();
}
},
error: function (msg) {
alert("error:" + msg);
}
});
}
}
</script>
}
<div class="toolbarDiv">
@if (CurUser.结算管理_日终价格修改)
{
@MyControls.Btn("修改", "window.location.href=('/BondPayment/BondPaymentEdit/?enid=" + Model.EncryptId + "');")
}
@MyControls.Btn("关闭", "layer.closeMe();")
</div>
<div class="yc-panel">
<table class="table table-bordered">
<tr>@Html.MyDisplayFor(m => m.payment_date, Utilities.ShowValidDatetime(Model.payment_date))</tr>
<tr>@Html.MyDisplayFor(m => m.security_id)</tr>
<tr>@Html.MyDisplayFor(m => m.symbol)</tr>
<tr>@Html.MyDisplayFor(m => m.payment_interest)</tr>
<tr>@Html.MyDisplayFor(m => m.update_time, Utilities.ShowValidDatetime(Model.update_time))</tr>
</table>
</div>
@@ -122,6 +122,11 @@
{
<a class="btn btn-link" href="/eodPrice/eodPriceList" target="_blank">日终价格管理</a>
}
@if (CurUser.结算管理_债券付息数据查看)
{
<a class="btn btn-link" href="/BondPayment/BondPaymentList" target="_blank">债券付息数据</a>
}
@if (CurUser.结算管理_结算汇率查看)
{
<a class="btn btn-link" href="/eod_currency_rate/eod_currency_rateList" target="_blank">结算汇率设置</a>
+7 -1
View File
@@ -208,9 +208,15 @@
</ItemGroup>
<ItemGroup>
<None Include="Views\EodFile\Index.cshtml" />
<None Include="Views\BondPayment\BondPaymentEdit.cshtml" />
<None Include="Views\BondPayment\BondPaymentList.cshtml" />
<None Include="Views\BondPayment\BondPaymentView.cshtml" />
<None Include="Views\EodFile\Index.cshtml" />
<None Include="Views\EtradingRule\EtradingRuleEdit.cshtml" />
<None Include="Views\EtradingRule\Index.cshtml" />
<None Include="wwwroot\Scripts\app\bondPayment\bondpaymentList.js" />
</ItemGroup>
<ItemGroup>
@@ -0,0 +1,89 @@
$(function () {
$("#DateToValueDate").val(curdate)
$("#DateFromValueDate").val(curdate)
var PostData = { ValueDateEnd: curdate, ValueDateStart: curdate };
$(".datepicker").datepicker({ changeMonth: true, changeYear: true, showButtonPanel: true, showOtherMonths: true, selectOtherMonths: true });
var grid = jQuery('#listGrid').jqGrid({
url: '/BondPayment/BondPaymentQuery',
datatype: 'json',
height: 'auto',
width: '100%',
autowidth: false,
shrinkToFit: false,
viewrecords: true,
jsonReader: { repeatitems: false },
cmTemplate: { align: 'center', width: 120 },
mtype: 'POST',
postData: PostData,
colModel: colModelGrid,
pager: jQuery('#pagerGrid'),
pagerpos: 'left',
rowNum: 20,
rowList: [20, 30, 50, 200, 10000],
footerrow: false
});
function keyEnter(event) {
try {
var e = event ? event : (window.event ? window.event : null);
(e.keyCode == 13) && SearchClick(true);
} catch (e) { }
}
document.onkeydown = keyEnter;
});
var colModelGrid = [{
name: '', label: '操作', index: '', width: 120, formatter: showToolName
}, {
name: 'payment_date', label: '支付日期', index: 'ValueDate', width: 120, formatter: 'date'
}, {
name: 'MarketName', label: '市场', index: 'MarketName', width: 200
}, {
name: 'security_id', label: '债券代码', index: 'security_id', width: 150
}, {
name: 'symbol', label: '债券名称', index: 'symbol', width: 200
}, {
name: 'payment_interest', label: '支付利息', index: 'payment_interest', width: 100
},
{
name: 'update_time', label: '更新时间', index: 'update_time', width: 160, formatter: 'datetime'
}, {
name: 'channel_source', label: '数据来源', index: 'channel_source', sortable: false, width: 120
}];
function showToolName(cellValue, options, rowObject) {
return "<input type=\"button\" class=\"wentiEdit\" title='查看债券期间付息' onclick=\"startView('{0}')\" value=\"{1}\" />".template(rowObject.EncryptId, "查看");
}
function startView(id) {
var srcurl = "/BondPayment/BondPaymentView/?enid=" + id;
main.open("查看债券期间付息", srcurl, { area: ['800px', '600px'] });
}
function SearchClick(isSearchclick) {
var listGrid = $('#listGrid');
listGrid.appendPostData({ UnderlyingCode: $("#UnderlyingCode").val() });
listGrid.appendPostData({ MarketName: $("#MarketName").val() });
listGrid.appendPostData({ ValueDateStart: $("#DateFromValueDate").val() });
listGrid.appendPostData({ ValueDateEnd: $("#DateToValueDate").val() });
listGrid.appendPostData({ DataSource: $("#DataSource").val() });
if (isSearchclick) {
//点击搜索时默认第一页
listGrid.jqGrid('setGridParam', { page: 1 });
}
listGrid.trigger('reloadGrid');
}
function reloadData() {
SearchClick(false);
}
function downloadExcel() {
var dateTemp = new Date().Format("yyyyMMdd");
var fileName = "债券期间付息" + dateTemp;
var formatters = _.map(['市场', '债券代码', '债券名称', '支付利息']
, x => new Object({ colName: x, formatter: "text" }));
formatters.push(_.map(['支付日期', '更新时间']
, x => new Object({ colName: x, formatter: "datetime" })));
main.toExcel("listGrid", fileName, "xls", null, "操作", formatters)
}
@@ -262,6 +262,20 @@ const vue = new Vue({
});
thisObj.calcCloseAmount();
thisObj.dataFormat();
thisObj.getDivindIn();
});
},
getDivindIn() {
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 }
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);
thisObj.floatPosition.DividendPending = posiQty * resp.obj * ratio * floatRatio;
thisObj.calcFloatClosePnl();
thisObj.dataFormat();
});
},
closeTrade() {//平仓