diff --git a/YLErpDAL/Modules/AppModule/AppUpgrader.cs b/YLErpDAL/Modules/AppModule/AppUpgrader.cs index ead11cb0..945744b1 100644 --- a/YLErpDAL/Modules/AppModule/AppUpgrader.cs +++ b/YLErpDAL/Modules/AppModule/AppUpgrader.cs @@ -465,9 +465,7 @@ namespace YLErp.Modules.AppModule .ToHashSet(); var nextIndex = adminDb.DictionaryItems .Where(item => item.DictId == marginTemplateDictionary.Id) - .Select(item => item.IndexNum) - .DefaultIfEmpty(-1) - .Max(); + .Max(item => (int?)item.IndexNum) ?? -1; foreach (var templateName in YLErp.Modules.SwapModule.SwapMarginTemplateConfigService.InitialTemplateNames) { if (existingNames.Contains(templateName)) diff --git a/YLErpWeb/Controllers/SwapTrade2Controller.cs b/YLErpWeb/Controllers/SwapTrade2Controller.cs index 00297abc..b0115d2f 100644 --- a/YLErpWeb/Controllers/SwapTrade2Controller.cs +++ b/YLErpWeb/Controllers/SwapTrade2Controller.cs @@ -186,7 +186,6 @@ namespace YLErp.Web.Controllers renewPosition.InterestAmount = 0; renewPosition.InterestFeePending = 0; renewPosition.PosiDividendIncome = 0; - renewPosition.PosiTradingFeePending = 0; renewPosition.InterestSwapInterval = null; renewPosition.Obervation = null; return renewPosition; diff --git a/YLErpWeb/wwwroot/Scripts/app/swaptrade/swapTradeEdit.js b/YLErpWeb/wwwroot/Scripts/app/swaptrade/swapTradeEdit.js index fa6b7011..8f1b647e 100644 --- a/YLErpWeb/wwwroot/Scripts/app/swaptrade/swapTradeEdit.js +++ b/YLErpWeb/wwwroot/Scripts/app/swaptrade/swapTradeEdit.js @@ -684,13 +684,7 @@ const vue = new Vue({ } }, setUnderlyingCode(data, item) { - var underlyingCode = item.UnderlyingCode; - if (underlyingCode != data.Code) { - this.getSpotPrice(data.Code, this.trade.TradeDate, item); - } else { - item.PosiGrossPrice = item.PosiGrossPrice; - item.PosiNetNoFeePrice = item.PosiNetNoFeePrice; - } + if (!data || !data.Code) return; item.CountRatio = data.CountRatio; item.ContractSize = data.ContractSize; item.UnderlyingInstrumentType = data.InstrumentType; @@ -704,11 +698,13 @@ const vue = new Vue({ item.underlying.Price = data.Price; item.underlying.UnderlyingInstrumentType = data.InstrumentType; item.underlying.QuoteUnitString = data.QuoteUnitString; - this.trade.UnderlyingCode = underlyingCode; + this.trade.UnderlyingCode = data.Code; // 债券标的:标记该浮动腿可启用净价/全价/收益率互算 this.$set(item, 'isBond', tradeHelper.IsBond(data.InstrumentType)); // 切换标的时清空债券三字段互算的手动/源标志(D1 修复:避免旧债券手填状态污染新债券) SwapCalc.clearBondCalcFlags(item); + // Refresh the initial price even when the user re-selects the same underlying. + this.getSpotPrice(item.UnderlyingCode, this.trade.TradeDate, item); //this.initMarginRate(); }, setFloatRateUnderlyingCode(data, item) { @@ -745,8 +741,13 @@ const vue = new Vue({ }, getSpotPrice(underlyingCode, StartDate, item) { var thisObj = this; + if (!underlyingCode) return; main.post("/pricing/AjaxGetUnderlyingPrice", { underlyingCode: underlyingCode, tradeDate: StartDate }) .done(function (resp) { + if (!resp || !resp.success || !resp.obj) { + main.message("未获取到标的价格"); + return; + } // 行情接口(AjaxGetUnderlyingPrice)对债券返回的 price/netPrice 本就是【存储态小数】(1.0 代表 100 元), // 与 PosiGrossPrice/PosiNetNoFeePrice 模型字段同量纲(见 PricingController: EodPrice 直接返回、 // 非 EodPrice 分支 ×bondPriceMultiple=0.01)。故此处仅做精度格式化,**不可**再 bondCalcPriceToStorage(÷100), @@ -1465,6 +1466,16 @@ const vue = new Vue({ //} }, + // A renewal opens as a new trade, so the underlying autocomplete only restores + // its code and does not emit change. Fetch the initial price explicitly. + refreshInitialUnderlyingPrices() { + if (!page.isAdd) return; + this.paySwapList.forEach(item => { + if (item.UnderlyingCode) { + this.getSpotPrice(item.UnderlyingCode, this.trade.TradeDate, item); + } + }); + }, //利息端添加行 addGetSwapRate() { var InterestMode = 9;