diff --git a/Plugins/YLErp.Plugins.ZheShang/App_Docs/交易确认书/客户多头交易确认书模板.docx b/Plugins/YLErp.Plugins.ZheShang/App_Docs/交易确认书/客户多头交易确认书模板.docx index 711f4173..94e1c504 100644 Binary files a/Plugins/YLErp.Plugins.ZheShang/App_Docs/交易确认书/客户多头交易确认书模板.docx and b/Plugins/YLErp.Plugins.ZheShang/App_Docs/交易确认书/客户多头交易确认书模板.docx differ diff --git a/Plugins/YLErp.Plugins.ZheShang/App_Docs/交易确认书/客户空头交易确认书模板.docx b/Plugins/YLErp.Plugins.ZheShang/App_Docs/交易确认书/客户空头交易确认书模板.docx index 15bbd574..9e67a9a5 100644 Binary files a/Plugins/YLErp.Plugins.ZheShang/App_Docs/交易确认书/客户空头交易确认书模板.docx and b/Plugins/YLErp.Plugins.ZheShang/App_Docs/交易确认书/客户空头交易确认书模板.docx differ diff --git a/Plugins/YLErp.Plugins.ZheShang/App_Docs/交易确认书/收益互换交易确认书(DMA)模板.docx b/Plugins/YLErp.Plugins.ZheShang/App_Docs/交易确认书/收益互换交易确认书(DMA)模板.docx deleted file mode 100644 index 88e51041..00000000 Binary files a/Plugins/YLErp.Plugins.ZheShang/App_Docs/交易确认书/收益互换交易确认书(DMA)模板.docx and /dev/null differ diff --git a/Plugins/YLErp.Plugins.ZheShang/DocumentGenerator/TradeConfirmationGenerator.cs b/Plugins/YLErp.Plugins.ZheShang/DocumentGenerator/TradeConfirmationGenerator.cs index 889b03ec..265d4a05 100644 --- a/Plugins/YLErp.Plugins.ZheShang/DocumentGenerator/TradeConfirmationGenerator.cs +++ b/Plugins/YLErp.Plugins.ZheShang/DocumentGenerator/TradeConfirmationGenerator.cs @@ -23,27 +23,21 @@ namespace YLErp.Plugins.ShanXi.DocumentGenerator var trade = Context.Trade; if (trade.TradeType == "收益互换" && trade.StructureType != null) { - if (trade.StructureType == "普通债券类收益互换"|| trade.StructureType == "普通收益互换") - { - var swapPosition = Context.GetSwapPositions(trade.id, true).Where(x => x.PositionType>0).FirstOrDefault(); + var swapPosition = Context.GetSwapPositions(trade.id, true).Where(x => x.PositionType > 0).FirstOrDefault(); - if (swapPosition != null) + if (swapPosition != null) + { + switch (swapPosition.PositionType) { - switch (swapPosition.PositionType) - { - case 1: - templatePath = MosPathHelper.Combine(GlobalConfig.PluginFolder, "App_Docs\\交易确认书\\客户多头交易确认书模板.docx"); - break; - case 2: - templatePath = MosPathHelper.Combine(GlobalConfig.PluginFolder, "App_Docs\\交易确认书\\客户空头交易确认书模板.docx"); - break; - } + case 1: + templatePath = MosPathHelper.Combine(GlobalConfig.PluginFolder, "App_Docs\\交易确认书\\客户多头交易确认书模板.docx"); + break; + case 2: + templatePath = MosPathHelper.Combine(GlobalConfig.PluginFolder, "App_Docs\\交易确认书\\客户空头交易确认书模板.docx"); + break; } } - else - { - templatePath = MosPathHelper.Combine(GlobalConfig.PluginFolder, "App_Docs\\交易确认书\\收益互换交易确认书(DMA)模板.docx"); - } + } else { @@ -78,44 +72,13 @@ namespace YLErp.Plugins.ShanXi.DocumentGenerator } - /// - /// 检查是否存在扩展模板 - /// - /// - private string CheckTemplateFilePath(string templateFilePath, OtcTradeBase t) - { - bool check(string pathStr, string tempName, string suffix, out string nPath) - { - nPath = $"{pathStr}{tempName}{suffix}"; - return File.Exists(nPath); - }; - - var fix = Path.GetExtension(templateFilePath); - var path = $"{Path.GetDirectoryName(templateFilePath)}\\{Path.GetFileNameWithoutExtension(templateFilePath)}"; - if (check(path, t.OptionType, fix, out var newPath)) - { - templateFilePath = newPath; - } - - return templateFilePath; - } /// /// 山证收益互换模板数据填充 /// /// public void SetSwapData(Dictionary dic) { - var trade = Context.Trade; - if (trade.StructureType == "普通债券类收益互换" || trade.StructureType == "普通收益互换") - { SetSingleSwap(dic); - } - else - { - SetLongShort(dic); - } - - } private void SetSingleSwap(Dictionary dic) @@ -150,7 +113,30 @@ namespace YLErp.Plugins.ShanXi.DocumentGenerator FormatToDict("期初标的交割全价", (double)((swapPosition?.PosiGrossPrice) ?? 0) * 100, dic); FormatToDict("期初标的交割净价", (double)((swapPosition?.PosiNetNoFeePrice) ?? 0) * 100, dic); - dic["利差"] = ((interestMargin?.InterestRateDefault) ?? 0) * 100; + + if (string.IsNullOrWhiteSpace(interestMargin?.FloatRateUnderlyingCode)) + { + dic["利率类型"] = "固定利率"; + dic["利差"] = ""; + dic["固定利率"] = ((interestMargin?.InterestRateDefault) ?? 0) * 100; ; + dic["参考利率"] = ""; + } + else + { + dic["利率类型"] = "浮动利率"; + dic["利差"] = ((swapPosition?.InterestRateDefault) ?? 0) * 10000; + dic["参考利率"] = interestMargin?.FloatRateUnderlyingCode; + dic["固定利率"] = ""; + } + if (initialMarginQuery.Any()) + { + dic["初始预付金支付日"] = initialMarginQuery.FirstOrDefault().HappenDate?.ToString("【yyyy】年【M】月【d】日"); + } + else + { + dic["初始预付金支付日"] = ""; + } + FormatToDict("标的期初全价", trade.StockEqvNotionalReal * (double)((swapPosition?.PosiGrossPrice) ?? 0) * 100, dic); var basicFee = trade.StockEqvNotionalReal == 0 ? 0 : ((double)((swapPosition?.PosiTradingFeePending) ?? 0) / trade.StockEqvNotionalReal) * 100; dic["基本费率"] = (basicFee * 2).ToString("f4"); var initialMarginSum = initialMarginQuery.Sum(x => @@ -185,122 +171,6 @@ namespace YLErp.Plugins.ShanXi.DocumentGenerator dic["table2"] = table2; } - private void SetLongShort(Dictionary dic) - { - var client = Context.GetClient(); - var trade = Context.Trade; - var swapPositions = Context.GetSwapPositions(trade.id, true); - var swapFlowDeals = Context.GetSwapFlowDeals(trade.id); - swapFlowDeals = swapFlowDeals.Where(x => x.OpenFlag==(int)OpenCloseEnum.开仓).ToList(); - var table1 = new JArray(); - var table2 = new JArray(); - - dic["交易编号"] = trade.TradeNumber; - dic["交易对手方全称"] = client.Name; - dic["主协议编号"] = client.MainProtocolCode; - dic["定义文件编号"] = client.SettleFileNumber; - //FormatToDict("名义本金", trade.StockEqvNotionalReal, dic); - dic["成交日期"] = trade.TradeDate?.ToString("yyyy年M月d日"); - dic["开始日期"] = trade.StartDate?.ToString("yyyy年M月d日"); - dic["到期日期"] = trade.ExerciseDate?.ToString("yyyy年M月d日"); - var count = 0; - var count2 = 0; - var interestMode = new int[] { 1, 2, 7, 8 }; - var list = swapPositions.Where(x => x.PositionType > 0 && x.PosiQuantity > 0); - - var fixLong = swapPositions.Where(x => x.InterestMode == 7).FirstOrDefault(); - var fixShort = swapPositions.Where(x => x.InterestMode == 8).FirstOrDefault(); - dic["固定多头"] = ((double)(fixLong?.InterestRateDefault * 100 ?? 0)).ToString("0.####") + "%"; - dic["浮动多头"] = !string.IsNullOrWhiteSpace(fixLong?.FloatRateUnderlyingCode) ? "适用" : "不适用"; - dic["固定空头"] = ((double)(fixShort?.InterestRateDefault * 100 ?? 0)).ToString("0.####") + "%"; - dic["浮动空头"] = !string.IsNullOrWhiteSpace(fixShort?.FloatRateUnderlyingCode) ? "适用" : "不适用"; - dic["管理人名称"] = client.Manager; - var calculationBasis = ""; - if (dic["浮动多头"].ToString() == "适用") - { - calculationBasis = fixLong?.FloatRateUnderlyingCode; - } - else if (dic["浮动空头"].ToString() == "适用") - { - calculationBasis = fixShort?.FloatRateUnderlyingCode; - } - else - { - calculationBasis = "不适用"; - } - - dic["计算基准"] = calculationBasis; - - double totalPosiQuantity = 0; - - foreach (var item in list) - { - var row = new JObject(); - - row["序号"] = ++count; - if (!string.IsNullOrWhiteSpace(item?.UnderlyingCode)) - { - var um = Context.GetTradeUnderlying(item?.UnderlyingCode); - row["标的名称"] = um.UnderlyingName; - row["标的代码"] = item?.UnderlyingCode; - decimal multiplier = um.IsBond() ? 100 : 1; - FormatToDict("期初价格", (double)((item?.PosiNetPrice * multiplier) ?? 0), row); - } - else - { - row["标的名称"] = ""; - row["标的代码"] = ""; - row["期初价格"] = ""; - } - FormatToDict("数量", (double)((item?.PosiQuantity) ?? 0), row); - totalPosiQuantity += (double)((item?.PosiQuantity) ?? 0); - FormatToDict("合约乘数", (double)((item?.ContractSize) ?? 0), row); - row["方向"] = item?.PositionType switch - { - 1 => "买入", - 2 => "卖出", - _ => "" - }; - table1.Add(row); - } - FormatToDict("名义本金", totalPosiQuantity, dic); - var underlyingCodes = swapFlowDeals.Select(r => r.UnderlyingCode).ToList(); - List underlyings = new List(); - if (underlyingCodes.Count() > 0) - { - underlyings = Context.GetUnderlyings(underlyingCodes); - } - foreach (var item in swapFlowDeals.OrderBy(o => o.UnderlyingCode).ThenBy(t => t.id)) - { - var row = new JObject(); - row["编号"] = ++count2; - row["标的代码"] = item.UnderlyingCode; - var um = underlyings.FirstOrDefault(x => x.UnderlyingCode == item.UnderlyingCode); - if (um != null) - { - row["标的名称"] = um.UnderlyingName; - if (um.IsBond()) - { - item.FullPrice *= ConsGlobal.bondShowPriceMultiple; - item.FullPriceFee *= ConsGlobal.bondShowPriceMultiple; - item.NetPrice *= ConsGlobal.bondShowPriceMultiple; - item.NetPriceFee *= ConsGlobal.bondShowPriceMultiple; - } - } - FormatToDict("成交收益率", (double)(item.Ytm), row); - FormatToDict("成交全价", (double)(item.FullPriceFee), row); - FormatToDict("成交数量", (double)(item.TradingQty), row); - row["成交方向"] = item?.BsType switch - { - 1 => "买入", - 2 => "卖出", - _ => "" - }; - row["交易日期"] = item.OccurDate.ToString("yyyy-MM-dd"); - table2.Add(row); - } - dic["table1"] = table1; - dic["flowtable"] = table2; - } + } } \ No newline at end of file diff --git a/Plugins/YLErp.Plugins.ZheShang/YLErp.Plugins.ZheShang.csproj b/Plugins/YLErp.Plugins.ZheShang/YLErp.Plugins.ZheShang.csproj index b741a64b..e2125f46 100644 --- a/Plugins/YLErp.Plugins.ZheShang/YLErp.Plugins.ZheShang.csproj +++ b/Plugins/YLErp.Plugins.ZheShang/YLErp.Plugins.ZheShang.csproj @@ -18,9 +18,6 @@ PreserveNewest - - PreserveNewest - PreserveNewest