diff --git a/Framework/YLErp.Core/DBModels/SwapPosition.cs b/Framework/YLErp.Core/DBModels/SwapPosition.cs index bcc18c36..44fb89d9 100644 --- a/Framework/YLErp.Core/DBModels/SwapPosition.cs +++ b/Framework/YLErp.Core/DBModels/SwapPosition.cs @@ -246,6 +246,10 @@ namespace YLErp.DBModels /// public int? interest_rule { get; set; } /// + /// 利息端类别 + /// + public string category_tag { get; set; } + /// /// 互换观察日集合 /// [NotMapped] diff --git a/Framework/YLErp.Resources/Dictionary/db_dictionaries.xml b/Framework/YLErp.Resources/Dictionary/db_dictionaries.xml index a0f9091e..97770296 100644 --- a/Framework/YLErp.Resources/Dictionary/db_dictionaries.xml +++ b/Framework/YLErp.Resources/Dictionary/db_dictionaries.xml @@ -30,6 +30,7 @@ + diff --git a/Plugins/YLErp.Plugins.GuoLian/App_Docs/contract_template/国联民生-收益互换交易确认书-境内模板-【客户看多】-【债券ETF】-清洁版.docx b/Plugins/YLErp.Plugins.GuoLian/App_Docs/contract_template/国联民生-收益互换交易确认书-境内模板-【客户看多】-【债券ETF】-清洁版.docx index 5347c974..a98c760b 100644 Binary files a/Plugins/YLErp.Plugins.GuoLian/App_Docs/contract_template/国联民生-收益互换交易确认书-境内模板-【客户看多】-【债券ETF】-清洁版.docx and b/Plugins/YLErp.Plugins.GuoLian/App_Docs/contract_template/国联民生-收益互换交易确认书-境内模板-【客户看多】-【债券ETF】-清洁版.docx differ diff --git a/Plugins/YLErp.Plugins.GuoLian/App_Docs/contract_template/国联民生-收益互换交易确认书-境内模板-【客户看空】-【债券ETF】-清洁版.docx b/Plugins/YLErp.Plugins.GuoLian/App_Docs/contract_template/国联民生-收益互换交易确认书-境内模板-【客户看空】-【债券ETF】-清洁版.docx index dc9710fa..465c9774 100644 Binary files a/Plugins/YLErp.Plugins.GuoLian/App_Docs/contract_template/国联民生-收益互换交易确认书-境内模板-【客户看空】-【债券ETF】-清洁版.docx and b/Plugins/YLErp.Plugins.GuoLian/App_Docs/contract_template/国联民生-收益互换交易确认书-境内模板-【客户看空】-【债券ETF】-清洁版.docx differ diff --git a/Plugins/YLErp.Plugins.GuoLian/DocumentGenerator/TradeConfirmationGenerator.cs b/Plugins/YLErp.Plugins.GuoLian/DocumentGenerator/TradeConfirmationGenerator.cs index 1aeed0a5..a926b273 100644 --- a/Plugins/YLErp.Plugins.GuoLian/DocumentGenerator/TradeConfirmationGenerator.cs +++ b/Plugins/YLErp.Plugins.GuoLian/DocumentGenerator/TradeConfirmationGenerator.cs @@ -241,11 +241,21 @@ namespace YLErp.Plugins.GuoLian.DocumentGenerator dic["参考标的期初全价%"] = ((double)swapPosition.PosiGrossPrice * 100).ToString("N4"); dic["参考标的期初净价%"] = ((double)(swapPosition.PosiNetNoFeePrice ?? 0m) * 100).ToString("N4"); - // 固定收益率(年化)- 债券期初到期收益率 - //dic["固定收益率(年化)"] = swapPosition.InitYtm.HasValue - // ? ((double)swapPosition.InitYtm.Value * 100).ToString("N4") - // : "0.0000"; - dic["固定收益率(年化)"] = "0.0000"; //需求说直接都是0 + // 固定收益率(年化)- ETF默认取"增强收益"腿的计息利率 + bool isEtf = IsBondEtf(underlying?.UnderlyingCode ?? string.Empty); + if (isEtf) + { + var enhancePosition = swapPositions + .Where(x => ConsTrade.InterestModels.Contains(x.InterestMode) && x.category_tag == "增强收益") + .FirstOrDefault(); + dic["固定收益率"] = enhancePosition != null + ? ((double)enhancePosition.InterestRateDefault * 100).ToString("N4") + : "0.0000"; + } + else + { + dic["固定收益率"] = "0.0000"; + } // 获取客户适用的保证金率 var clientMarginRate = UnderlyingHelper.GetApplicableMarginRate( @@ -405,9 +415,18 @@ namespace YLErp.Plugins.GuoLian.DocumentGenerator : "0.0000"; // 利率类型判断(固定/浮动) - var interestMargin = swapPositions - .Where(x => ConsTrade.InterestModels.Contains(x.InterestMode) && x.interest_rest_days != null) - .FirstOrDefault(); + swap_position interestMargin = null; + // ETF: 优先取"互换利率"腿 + if (isEtf) + { + interestMargin = swapPositions + .Where(x => ConsTrade.InterestModels.Contains(x.InterestMode) && x.category_tag == "互换利率") + .FirstOrDefault(); + } + if (interestMargin == null) + interestMargin = swapPositions + .Where(x => ConsTrade.InterestModels.Contains(x.InterestMode) && x.interest_rest_days != null) + .FirstOrDefault(); if (interestMargin == null) interestMargin = swapPositions .Where(x => ConsTrade.InterestModels.Contains(x.InterestMode) && string.IsNullOrWhiteSpace(x.FloatRateUnderlyingCode)) diff --git a/YLErpDAL/Modules/AppModule/AppUpgrader.cs b/YLErpDAL/Modules/AppModule/AppUpgrader.cs index 4a35b61f..ead11cb0 100644 --- a/YLErpDAL/Modules/AppModule/AppUpgrader.cs +++ b/YLErpDAL/Modules/AppModule/AppUpgrader.cs @@ -306,14 +306,13 @@ namespace YLErp.Modules.AppModule //----------------------------------------------- configService.AddDataIfNotExists("ProjectConfig", "Erp.IsAutoSealAfterGeneratedBook", "false", "bool", "确认书生成时是否自动用印(IsAutoSealAndUploadFiles勾选时生效)"); configService.AddDataIfNotExists("ProjectConfig", "Erp.ReportFileBeginNumber", "0", "int", "报送文件开始编号"); - //----------------------------------------------- - // 删除不再使用的 - //----------------------------------------------- RemoveUnUsed(configService); } private static void RemoveUnUsed(InnerAppConfigService configService) { + configService.RemoveData("ProjectConfig", "Trade.SwapMarginTemplateConfig"); + if (AppManager.Version.Major < 3) { configService.RemoveData("ProjectConfig", "Erp.TradeConfirmBookEmailTPL"); @@ -453,6 +452,38 @@ namespace YLErp.Modules.AppModule } adminDb.SaveChanges(); + + var marginTemplateDictionary = adminDb.Dictionaries.FirstOrDefault(item => item.Name == YLErp.Modules.SwapModule.SwapMarginTemplateConfigService.DictionaryName); + if (marginTemplateDictionary == null) + { + return; + } + + var existingNames = adminDb.DictionaryItems + .Where(item => item.DictId == marginTemplateDictionary.Id) + .Select(item => item.Name) + .ToHashSet(); + var nextIndex = adminDb.DictionaryItems + .Where(item => item.DictId == marginTemplateDictionary.Id) + .Select(item => item.IndexNum) + .DefaultIfEmpty(-1) + .Max(); + foreach (var templateName in YLErp.Modules.SwapModule.SwapMarginTemplateConfigService.InitialTemplateNames) + { + if (existingNames.Contains(templateName)) + { + continue; + } + + adminDb.DictionaryItems.Add(new BaseOUDAL.DictionaryItem + { + DictId = marginTemplateDictionary.Id, + Name = templateName, + ShortName = templateName, + IndexNum = ++nextIndex + }); + } + adminDb.SaveChanges(); } catch (Exception ex) { diff --git a/YLErpDAL/Modules/EodModule/SettlementModule/EodHandleSwapFlowService.cs b/YLErpDAL/Modules/EodModule/SettlementModule/EodHandleSwapFlowService.cs index 4fbe9235..44683a41 100644 --- a/YLErpDAL/Modules/EodModule/SettlementModule/EodHandleSwapFlowService.cs +++ b/YLErpDAL/Modules/EodModule/SettlementModule/EodHandleSwapFlowService.cs @@ -455,7 +455,7 @@ namespace YLErp.Modules.EodModule Lots = swapFlow.Lots, IsNight = swapFlow.IsNight, OpponentRole = "甲方", - MarginTemplateName = "系统默认", + MarginTemplateName = null, MarginType = MarginTypeEnum.DEFAULT, IsGroup = isSingleTrade ? 0 : 2 }; @@ -743,7 +743,7 @@ namespace YLErp.Modules.EodModule td.OriginalNotional = td.Notional; td.OriginalStockEqvNotional = td.StockEqvNotional; td.StockEqvNotionalReal = td.StockEqvNotionalReal; - td.MarginTemplateName = "系统默认"; + td.MarginTemplateName = null; td.MarginType = MarginTypeEnum.DEFAULT; td.IsTradePricePayType = true; td.TradeSource = TradeSourceEnum.导入交易.ToString(); diff --git a/YLErpDAL/Modules/SwapModule/SwapMarginTemplateConfigService.cs b/YLErpDAL/Modules/SwapModule/SwapMarginTemplateConfigService.cs new file mode 100644 index 00000000..667670dd --- /dev/null +++ b/YLErpDAL/Modules/SwapModule/SwapMarginTemplateConfigService.cs @@ -0,0 +1,39 @@ +using BaseOUDAL; +using YLErp.Models; + +namespace YLErp.Modules.SwapModule +{ + public static class SwapMarginTemplateConfigService + { + public const string DictionaryName = "保证金模板名称"; + + public static readonly string[] InitialTemplateNames = { "现金保证金", "授信保证金" }; + + public static SwapMarginTemplateConfig GetConfig() + { + using var db = new ErpBaseContext(); + var dictionaryId = db.Dictionaries + .Where(item => item.Name == DictionaryName) + .Select(item => item.Id) + .FirstOrDefault(); + var items = db.DictionaryItems + .Where(item => item.DictId == dictionaryId && !string.IsNullOrWhiteSpace(item.Name)) + .OrderBy(item => item.IndexNum) + .Select(item => new SelectItem { Text = item.Name, Value = item.Name }) + .ToArray(); + + return new SwapMarginTemplateConfig + { + options = items, + defaultValue = items.FirstOrDefault()?.Value + }; + } + } + + public class SwapMarginTemplateConfig + { + public IEnumerable options { get; set; } + + public string defaultValue { get; set; } + } +} diff --git a/YLErpDAL/Modules/SwapModule/SwapTradeService.cs b/YLErpDAL/Modules/SwapModule/SwapTradeService.cs index c23de7b8..ca343cbc 100644 --- a/YLErpDAL/Modules/SwapModule/SwapTradeService.cs +++ b/YLErpDAL/Modules/SwapModule/SwapTradeService.cs @@ -1,4 +1,4 @@ -using BaseOUDAL; +using BaseOUDAL; using ClosedXML.Report.Options; using Confluent.Kafka; using CsvHelper; @@ -341,7 +341,7 @@ namespace YLErp.Modules.SwapModule TradeDate = flowMerge.OccurTime, TraderId = asset.TraderIdsInt.FirstOrDefault(), TraderName = asset.TraderNamesList.FirstOrDefault(), - MarginTemplateName = "系统默认", + MarginTemplateName = null, OpponentRole = "乙方", StructureType = structureType, InitialMargin = 0, @@ -1414,6 +1414,7 @@ namespace YLErp.Modules.SwapModule position.FloatRateUnderlyingCode = swap.FloatRateUnderlyingCode; position.interest_rest_days = swap.interest_rest_days; position.interest_rule = swap.interest_rule; + position.category_tag = string.IsNullOrEmpty(swap.category_tag) ? "互换利率" : swap.category_tag; position.InitYtm = RoundSwapBondNetPriceAndYtm(swap.InitYtm); if (position.InitYtm != null && position.InitYtm > 0) { diff --git a/YLErpDAL/Modules/TradeModule/SwapModule/SwapTradeFlowImportService.cs b/YLErpDAL/Modules/TradeModule/SwapModule/SwapTradeFlowImportService.cs index efac3554..fb8d835d 100644 --- a/YLErpDAL/Modules/TradeModule/SwapModule/SwapTradeFlowImportService.cs +++ b/YLErpDAL/Modules/TradeModule/SwapModule/SwapTradeFlowImportService.cs @@ -378,7 +378,7 @@ namespace YLErp.Modules.TradeModule.SwapModule importTrade.StockEqvNotionalReal = importTrade.StockEqvNotionalReal; importTrade.trade_swap.RateCalcMode = "01"; importTrade.IsUsePremiumRate = true; - importTrade.MarginTemplateName = "系统默认"; + importTrade.MarginTemplateName = null; importTrade.MarginType = MarginTypeEnum.DEFAULT; importTrade.IsTradePricePayType = true; importTrade.TradeSource = TradeSourceEnum.导入交易.ToString(); diff --git a/YLErpDAL/Modules/TradeModule/SwapModule/SwapTradeFlowMoreImportService.cs b/YLErpDAL/Modules/TradeModule/SwapModule/SwapTradeFlowMoreImportService.cs index 64c89cae..5e0f2ee2 100644 --- a/YLErpDAL/Modules/TradeModule/SwapModule/SwapTradeFlowMoreImportService.cs +++ b/YLErpDAL/Modules/TradeModule/SwapModule/SwapTradeFlowMoreImportService.cs @@ -519,7 +519,7 @@ namespace YLErp.Modules.TradeModule.SwapModule importTrade.ParticipationRate = 1; //预付金 - importTrade.MarginTemplateName = "系统默认"; + importTrade.MarginTemplateName = null; importTrade.MarginType = MarginTypeEnum.DEFAULT; SetDBModelCreator(importTrade); diff --git a/YLErpDAL/Modules/TradeModule/SwapModule/SwapTradeImportService.cs b/YLErpDAL/Modules/TradeModule/SwapModule/SwapTradeImportService.cs index 4ae8a21b..6f985cbf 100644 --- a/YLErpDAL/Modules/TradeModule/SwapModule/SwapTradeImportService.cs +++ b/YLErpDAL/Modules/TradeModule/SwapModule/SwapTradeImportService.cs @@ -726,7 +726,7 @@ namespace YLErp.Modules.TradeModule.SwapModule td.OriginalStockEqvNotional = td.StockEqvNotional; td.StockEqvNotionalReal = td.StockEqvNotionalReal; td.IsUsePremiumRate = true; - td.MarginTemplateName = "系统默认"; + td.MarginTemplateName = null; td.MarginType = MarginTypeEnum.DEFAULT; td.IsTradePricePayType = true; td.TradeSource = TradeSourceEnum.导入交易.ToString(); @@ -2815,7 +2815,7 @@ namespace YLErp.Modules.TradeModule.SwapModule td.SettlementDate = td.ExerciseDate; td.StockEqvNotional = reader.GetDouble("名义本金(人民币)", true) ?? 0; - td.MarginTemplateName = "系统默认"; + td.MarginTemplateName = null; td.UnWindDate = reader.GetDate("提前终止日/终止日", true); td.Comments = reader.GetString("备注", false); //td.UnderlyingName = reader.GetString("标的名称", true); diff --git a/YLErpWeb/Areas/Admin/Controllers/OtcConfigController.cs b/YLErpWeb/Areas/Admin/Controllers/OtcConfigController.cs index b186e765..dd95f9a2 100644 --- a/YLErpWeb/Areas/Admin/Controllers/OtcConfigController.cs +++ b/YLErpWeb/Areas/Admin/Controllers/OtcConfigController.cs @@ -282,4 +282,4 @@ namespace YLErp.Web.Areas.Admin.Controllers #endregion } -} \ No newline at end of file +} diff --git a/YLErpWeb/Controllers/SwapTrade2Controller.cs b/YLErpWeb/Controllers/SwapTrade2Controller.cs index db1089ab..be227c9b 100644 --- a/YLErpWeb/Controllers/SwapTrade2Controller.cs +++ b/YLErpWeb/Controllers/SwapTrade2Controller.cs @@ -45,48 +45,26 @@ namespace YLErp.Web.Controllers ViewBag.observationDate = observationDate; return View(); } - public ActionResult TradeEdit(string enid, bool isUseApproval = false) + public ActionResult TradeEdit(string enid, string renewEnid = null, bool isUseApproval = false) { ViewBag.isUseApproval = isUseApproval; - var intid = DecryptInt(enid); + // The new/renew flow uses the literal "0" to indicate that no trade exists yet. + var intid = enid == "0" ? 0 : DecryptInt(enid); trade r = null; if (intid == 0) { - TradeExtendJson tradeExtendJson = new TradeExtendJson() + r = CreateNewTrade(); + var renewTradeId = DecryptInt(renewEnid); + if (renewTradeId > 0) { - FlowBookMode = (int)FlowBookModeEnum.否, - FloatingPnlAnnualized = false, - NeedOpenFee = false, - OpenFeeType = 0, - InterestCalcMode = "10", - SettlementRules=0, - DividendPayDate=0 - }; - var tradeDateCountry = GetBestCountry(valuedateBLL.ValueDate.Year); - r = new trade() - { - TradeType = "收益互换", - UnderlyingInstrumentType = "Stock", - StartDate = valuedateBLL.ValueDate, - TradeDate = QdpCalendarHelper.GetNonHolidayDefore(valuedateBLL.ValueDate.AddDays(-1), tradeDateCountry), - TraderId = CurUser.UserId, - TraderName = CurUser.UserName, - MarginTemplateName = "系统默认", - OpponentRole = "乙方", - OriginalStockEqvNotional = 0, - StructureType = "普通收益互换", - InitialMargin = 0 - }; - r.StructureType = "普通债券类收益互换"; - tradeExtendJson.FlowBookMode = (int)FlowBookModeEnum.先进先出; - r.trade_extend = new trade_extend() - { - ExtendJson = JsonHelper.Serialize(tradeExtendJson) - }; - r.MetaDic = new Dictionary - { - { "清算机构", "甲方" } - }; + var sourceTrade = new SwapTradeService(CurUser).GetSwapTrade(renewTradeId); + if (sourceTrade == null) + { + return ShowError("没有找到交易数据"); + } + + r = CreateRenewTrade(sourceTrade, r); + } return View(r); } SwapTradeService swapTradeService = new SwapTradeService(CurUser); @@ -98,6 +76,115 @@ namespace YLErp.Web.Controllers return View(r); } + + private trade CreateNewTrade() + { + var defaultMarginTemplateName = SwapMarginTemplateConfigService.GetConfig().defaultValue; + var tradeExtendJson = new TradeExtendJson() + { + FlowBookMode = (int)FlowBookModeEnum.先进先出, + FloatingPnlAnnualized = false, + NeedOpenFee = false, + OpenFeeType = 0, + InterestCalcMode = "10", + SettlementRules = 0, + DividendPayDate = 0 + }; + var tradeDateCountry = GetBestCountry(valuedateBLL.ValueDate.Year); + return new trade() + { + TradeType = "收益互换", + UnderlyingInstrumentType = "Stock", + StartDate = valuedateBLL.ValueDate, + TradeDate = QdpCalendarHelper.GetNonHolidayDefore(valuedateBLL.ValueDate.AddDays(-1), tradeDateCountry), + TraderId = CurUser.UserId, + TraderName = CurUser.UserName, + MarginTemplateName = defaultMarginTemplateName, + OpponentRole = "乙方", + OriginalStockEqvNotional = 0, + StructureType = "普通债券类收益互换", + InitialMargin = 0, + trade_extend = new trade_extend() + { + ExtendJson = JsonHelper.Serialize(tradeExtendJson) + }, + MetaDic = new Dictionary + { + { "清算机构", "甲方" } + } + }; + } + + private trade CreateRenewTrade(trade sourceTrade, trade defaultTrade) + { + var renewTrade = sourceTrade.Clone(); + renewTrade.id = 0; + renewTrade.TradeNumber = string.Empty; + renewTrade.ParentTradeId = 0; + renewTrade.TradeDate = defaultTrade.TradeDate; + renewTrade.StartDate = defaultTrade.StartDate; + renewTrade.ExerciseDate = null; + renewTrade.MaturityDate = null; + renewTrade.SettlementDate = null; + renewTrade.UnWindDate = null; + renewTrade.PremiumPayDate = null; + renewTrade.SettlementFlagDate = null; + renewTrade.HasPartialUnWind = null; + renewTrade.TradeStatus = null; + renewTrade.CheckStatus = null; + renewTrade.ProcessStatus = null; + renewTrade.ProcessOrderId = 0; + renewTrade.ProcessOrderBranch = 0; + renewTrade.ProcessOptDate = null; + renewTrade.ValidState = null; + renewTrade.CreateDate = null; + renewTrade.TradeSource = null; + // 恢复初始持仓名义本金(源交易若有过部分平仓,StockEqvNotional/TradeAmount 已递减, + // 但 OriginalStockEqvNotional 和 OriginalNotional 始终保留原始值不被递减) + if (renewTrade.OriginalStockEqvNotional != null) + { + renewTrade.StockEqvNotional = (double)renewTrade.OriginalStockEqvNotional; + } + + renewTrade.TradeAmount = renewTrade.OriginalNotional ?? renewTrade.TradeAmount; + renewTrade.trade_extend = sourceTrade.trade_extend?.Clone() ?? defaultTrade.trade_extend; + renewTrade.trade_extend.TradeId = 0; + renewTrade.trade_Initial_Margin = sourceTrade.trade_Initial_Margin?.Clone() ?? new trade_initial_margin(); + renewTrade.trade_Initial_Margin.TradeId = 0; + renewTrade.MetaDic = sourceTrade.MetaDic == null + ? new Dictionary() + : new Dictionary(sourceTrade.MetaDic); + // 只克隆初始持仓(IsInitial=true),避免将部分平仓后的实时持仓(名义本金已递减)带入续做交易 + renewTrade.swap_positions = sourceTrade.swap_positions + ?.Where(p => p.IsInitial) + .Select(position => + { + var renewPosition = position.Clone(); + renewPosition.id = 0; + renewPosition.PositionId = 0; + renewPosition.SwapTradeId = 0; + renewPosition.PosiNumber = null; + renewPosition.PosiStartDate = defaultTrade.StartDate.Value; + renewPosition.PosiMatuirityDate = null; + // 预付金腿的 HappenDate 用于后续生成资金流水(ResetMarginAmount 按 HappenDate 过滤), + // 续做时设为新交易的起始日;非预付金腿的 HappenDate 无实际用途,置 null + renewPosition.HappenDate = + position.InterestMode == (int)YLErp.DBModels.InterestModeEnum.初始预付金 + ? defaultTrade.StartDate + : null; + renewPosition.InterestSwapInterval = null; + renewPosition.Obervation = null; + return renewPosition; + }).ToList() ?? new List(); + // 清空源交易的事件/持仓快照等集合,避免与源交易共享引用 + renewTrade.swap_Events = new List(); + renewTrade.swap_Flow_Events = new List(); + renewTrade.eod_swaps = new List(); + renewTrade.inital_eod_swap_positions = new List(); + renewTrade.eod_swap_positions = new List(); + renewTrade.ClientCashInCashOutList = new List(); + return renewTrade; + } /// /// 详情 /// @@ -115,6 +202,12 @@ namespace YLErp.Web.Controllers { return ShowError("没有找到交易数据"); } + var marginTemplateConfig = SwapMarginTemplateConfigService.GetConfig(); + if (string.IsNullOrWhiteSpace(tradeObj.MarginTemplateName) + || !marginTemplateConfig.options.Any(item => item.Value == tradeObj.MarginTemplateName)) + { + tradeObj.MarginTemplateName = marginTemplateConfig.defaultValue; + } TradeViewModel model; model = new TradeViewModel(tradeObj) @@ -1111,4 +1204,4 @@ namespace YLErp.Web.Controllers } -} \ No newline at end of file +} diff --git a/YLErpWeb/Controllers/SwapTradeController.cs b/YLErpWeb/Controllers/SwapTradeController.cs index 8746b33b..ad82b7c7 100644 --- a/YLErpWeb/Controllers/SwapTradeController.cs +++ b/YLErpWeb/Controllers/SwapTradeController.cs @@ -303,7 +303,7 @@ namespace YLErp.Web.Controllers TradeDate = valuedateBLL.ValueDate, TraderId = CurUser.UserId, TraderName = CurUser.UserName, - MarginTemplateName = "系统默认", + MarginTemplateName = null, OpponentRole = "乙方", trade_swap = new trade_swap() { @@ -1196,4 +1196,4 @@ namespace YLErp.Web.Controllers return JsonSuccess("", 0); } } -} \ No newline at end of file +} diff --git a/YLErpWeb/Views/SwapTrade2/TradeEdit.cshtml b/YLErpWeb/Views/SwapTrade2/TradeEdit.cshtml index 661828bd..6409fe53 100644 --- a/YLErpWeb/Views/SwapTrade2/TradeEdit.cshtml +++ b/YLErpWeb/Views/SwapTrade2/TradeEdit.cshtml @@ -1,5 +1,6 @@ @using YLErp.Web.Models.JsModels; @using YLErp.Commons; +@using YLErp.Modules.SwapModule; @model trade @{ ViewBag.Title = "交易信息 | 编辑"; @@ -13,12 +14,14 @@ var jsClient = canChangeClient && Model.ClientId > 0 ? jsClients.FirstOrDefault(n => n.id == Model.ClientId) : null; var jsAssetUnits = JsDataModel.GetAssetUnits(CurUser); var tradeMarginTemplates = new tradeController().GetMarginTemplates(); + var swapMarginTemplateItems = SwapMarginTemplateConfigService.GetConfig().options; var tradeMarginTemplateItems = new tradeController().GetMarginTemplateItems(); var jsAssetUnit = Model.AssetId > 0 ? jsAssetUnits.FirstOrDefault(n => n.id == Model.AssetId) : null; var assetunits = JsDataModel.GetAssetUnits(CurUser); var jsTraders = canAddNewTrader ? JsDataModel.GetTraders(assetunits) : Enumerable.Empty(); var jsTrader = canAddNewTrader && Model.TraderId > 0 ? jsTraders.FirstOrDefault(n => n.id == Model.TraderId) : null; var currencys = CurrencyController.getList(); + var categoryTagOptions = DictionaryBLL.GetList("利息端类别", false, "互换利率"); List places = new List(); List agencys = new List(); var tradingPlaceMap = YLErp.DBModels.Consts.ConsReport.TradingPlaceMapDisplay; @@ -66,6 +69,7 @@ jsTrader, jsTraders, tradeMarginTemplates = tradeMarginTemplates, + swapMarginTemplateItems = swapMarginTemplateItems, tradeMarginTemplateItems = tradeMarginTemplateItems, needRemark = !isAdd && valuedateBLL.SystemDate.EditTradeNeedRemark, parentTradeId = ViewBag.ParentTradeId, @@ -266,6 +270,14 @@ +
+ + +
@@ -351,6 +363,7 @@ 计息方式 重置频率(天) 利率准则 + 类别 结算规则 @@ -401,6 +414,14 @@ + + + diff --git a/YLErpWeb/Views/SwapTrade2/TradeView.cshtml b/YLErpWeb/Views/SwapTrade2/TradeView.cshtml index 310b7897..9172e401 100644 --- a/YLErpWeb/Views/SwapTrade2/TradeView.cshtml +++ b/YLErpWeb/Views/SwapTrade2/TradeView.cshtml @@ -236,6 +236,10 @@ 派息金额支付日 @(trade.trade_extend.ExtendObj.DividendPayDate == 0 ? "到期结算日" : "派息日+" + (trade.trade_extend.ExtendObj.DividendPayDate - 1)) + + 保证金模板 + @trade.MarginTemplateName +
@@ -300,6 +304,7 @@ 计息方式 重置频率(天) 利率准则 + 类别 结算规则 @if (trade.swap_positions != null) @@ -344,6 +349,7 @@ @item.interest_rest_days @((item.interest_rule != null) ? (SwapInterestRule)item.interest_rule : "") + @(string.IsNullOrEmpty(item.category_tag) ? "互换利率" : item.category_tag) @@ -504,6 +510,7 @@ 计息方式 重置频率(天) 利率准则 + 类别 结算规则 @{ @@ -545,6 +552,7 @@ @(item.InterestType == 0 ? "单利" : "复利") @item.interest_rest_days @((item.interest_rule != null) ? (SwapInterestRule)item.interest_rule : "") + @(string.IsNullOrEmpty(item.category_tag) ? "互换利率" : item.category_tag) } diff --git a/YLErpWeb/Views/SwapTrade2/header.cshtml b/YLErpWeb/Views/SwapTrade2/header.cshtml index 1e9a93e1..d6706aff 100644 --- a/YLErpWeb/Views/SwapTrade2/header.cshtml +++ b/YLErpWeb/Views/SwapTrade2/header.cshtml @@ -157,6 +157,7 @@ { @MyControls.Btn("收益结算", string.Format("unWindLongShortSwap('{0}')", tradeModel.EncryptId)) } + @MyControls.Btn("续做", string.Format("renewTrade('{0}')", tradeModel.EncryptId)) } diff --git a/YLErpWeb/wwwroot/Scripts/app/swaptrade/swapTradeEdit.js b/YLErpWeb/wwwroot/Scripts/app/swaptrade/swapTradeEdit.js index 91b2e26a..542f2ccc 100644 --- a/YLErpWeb/wwwroot/Scripts/app/swaptrade/swapTradeEdit.js +++ b/YLErpWeb/wwwroot/Scripts/app/swaptrade/swapTradeEdit.js @@ -1414,6 +1414,7 @@ const vue = new Vue({ thisObj.getSwapList = thisObj.trade.swap_positions.filter(x => { if ((x.UnderlyingCode == null || x.UnderlyingCode.length == 0) && x.IsInitial && (x.InterestMode == 1 || x.InterestMode == 2 || x.InterestMode == 7 || x.InterestMode == 8 || x.InterestMode == 9)) return x; }); thisObj.getSwapList.forEach((val, num, arr) => { arr[num].index = num; + arr[num].category_tag = arr[num].category_tag || '互换利率'; // 解析 InterestSwapInterval 为 SwapIntervalList if (arr[num].InterestSwapInterval && !arr[num].SwapIntervalList) { try { @@ -1502,7 +1503,8 @@ const vue = new Vue({ HappenDate: null,//发生日期, Currency: 'CNY',//币种 interest_rest_days: 7,//重置频率 - interest_rule: null//利率准则 + interest_rule: null,//利率准则 + category_tag: '互换利率'//类别 } thisObj.getSwapList.push(getSwap); }, diff --git a/YLErpWeb/wwwroot/Scripts/app/swaptrade/swapTradeView.js b/YLErpWeb/wwwroot/Scripts/app/swaptrade/swapTradeView.js index d0759efc..585a37cb 100644 --- a/YLErpWeb/wwwroot/Scripts/app/swaptrade/swapTradeView.js +++ b/YLErpWeb/wwwroot/Scripts/app/swaptrade/swapTradeView.js @@ -26,6 +26,10 @@ function editTrade(enid) { window.location.href = `/swapTrade2/tradeEdit/?enid=${enid}`; } +function renewTrade(enid) { + window.location.href = `/swapTrade2/tradeEdit/?enid=0&renewEnid=${encodeURIComponent(enid)}`; +} + function editTradeRemarkInfo(enid) { main.open("修改备注", "/trade/EditRemarkInfo?enid=" + enid, { area: ["700px", "500px"] }); } @@ -586,4 +590,4 @@ function SubmissionFields(enid) { function SubmissionFieldsHistory(enid) { main.open("报送相关字段填写", "/trade/submissionFieldsHistory?encryptId=" + enid); -} \ No newline at end of file +}