diff --git a/YLErpWeb/Views/SwapTrade2/CloseDetial.cshtml b/YLErpWeb/Views/SwapTrade2/CloseDetial.cshtml index 3a641898..0283ee83 100644 --- a/YLErpWeb/Views/SwapTrade2/CloseDetial.cshtml +++ b/YLErpWeb/Views/SwapTrade2/CloseDetial.cshtml @@ -2,6 +2,16 @@ @{ ViewBag.Title = "交易 | 提前终止详情"; Layout = "~/Views/Shared/_InfoLayout.cshtml"; + bool hideFloatingIncomeDirection = PS.Config.ErpElement.SwapFloatingIncomeReceiveOnlyMode; + string FloatingPositionTypeText(int posiDirection, int positionType) + { + if (hideFloatingIncomeDirection) + { + return posiDirection == positionType ? "多头" : "空头"; + } + + return positionType == (int)PositionTypeFlag.Long ? "多头" : "空头"; + } } @section CSS{ @@ -69,7 +79,10 @@
| 收支方向 | + @if (!hideFloatingIncomeDirection) + { +收支方向 | + }多空方向 | 标的代码 | 期初标的价格 | @@ -84,8 +97,11 @@ { var fbgclass = item.PosiDirection == (int)SwapDirectionEnum.收取 ? "swapget" : "swappay";|||||||||||||||||||||||||
| @((SwapDirectionEnum)item.PosiDirection) | -@(item.PositionType == (int)PositionTypeFlag.Long ? "多头" : "空头") | + @if (!hideFloatingIncomeDirection) + { +@((SwapDirectionEnum)item.PosiDirection) | + } +@FloatingPositionTypeText(item.PosiDirection, item.PositionType) | @item.UnderlyingCode | @(item.PosiNetPrice.OtcFormatMoney(true, 4)) | @(item.PosiGrossPrice.OtcFormatMoney(true, 4)) | diff --git a/YLErpWeb/Views/SwapTrade2/SwapIncome.cshtml b/YLErpWeb/Views/SwapTrade2/SwapIncome.cshtml index c6e7df28..2eedf7ce 100644 --- a/YLErpWeb/Views/SwapTrade2/SwapIncome.cshtml +++ b/YLErpWeb/Views/SwapTrade2/SwapIncome.cshtml @@ -163,7 +163,14 @@{{floatPosition.PayDirection==1?"收取":"支付"}} | }
- {{floatPosition.PositionType==1?"多头":"空头"}}
+ @if (hideFloatingIncomeDirection)
+ {
+ |
{{floatPosition.UnderlyingCode}} diff --git a/YLErpWeb/Views/SwapTrade2/SwapUnwind.cshtml b/YLErpWeb/Views/SwapTrade2/SwapUnwind.cshtml index 26a8f625..3ef08042 100644 --- a/YLErpWeb/Views/SwapTrade2/SwapUnwind.cshtml +++ b/YLErpWeb/Views/SwapTrade2/SwapUnwind.cshtml @@ -202,7 +202,14 @@ | {{floatPosition.PayDirection==1?"收取":"支付"}} | }
- {{floatPosition.PositionType==1?"多头":"空头"}}
+ @if (hideFloatingIncomeDirection)
+ {
+ |
{{floatPosition.UnderlyingCode}} diff --git a/YLErpWeb/Views/SwapTrade2/TradeView.cshtml b/YLErpWeb/Views/SwapTrade2/TradeView.cshtml index 24f94de3..1f3efd57 100644 --- a/YLErpWeb/Views/SwapTrade2/TradeView.cshtml +++ b/YLErpWeb/Views/SwapTrade2/TradeView.cshtml @@ -31,6 +31,15 @@ var realPositions = trade.swap_positions.Where(x => x.PosiDirection > 0 && !x.IsInitial).ToList(); var sr = trade.trade_extend.ExtendObj.SettlementRules; bool hideFloatingIncomeDirection = PS.Config.ErpElement.SwapFloatingIncomeReceiveOnlyMode; + string FloatingPositionTypeText(int posiDirection, int positionType) + { + if (hideFloatingIncomeDirection) + { + return posiDirection == positionType ? "多头" : "空头"; + } + + return positionType == (int)PositionTypeFlag.Long ? "多头" : "空头"; + } string SwapPriceData(decimal? value) => value?.ToString(CultureInfo.InvariantCulture) ?? string.Empty; string SwapCommonData(object value) => value == null ? string.Empty : Convert.ToString(value, CultureInfo.InvariantCulture); } @@ -408,7 +417,7 @@ { | @((SwapDirectionEnum)item.PosiDirection) | } -@(item.PositionType == (int)PositionTypeFlag.Long ? "多头" : "空头") | +@FloatingPositionTypeText(item.PosiDirection, item.PositionType) | @item.UnderlyingCode | @@ -633,7 +642,7 @@ | }- @(item.PositionType == (int)PositionTypeFlag.Long ? "多头" : "空头") + @FloatingPositionTypeText(item.PosiDirection, item.PositionType) | @item.UnderlyingCode | @@ -844,7 +853,7 @@ { | @((SwapDirectionEnum)closeFloat.PayDirection) | } -@(closeFloat.PositionType == (int)PositionTypeFlag.Long ? "多头" : "空头") | +@FloatingPositionTypeText(closeFloat.PayDirection, closeFloat.PositionType) | @closeFloat.UnderlyingCode | @if (isBond) { @@ -1046,7 +1055,7 @@ {@((SwapDirectionEnum)closeFloat.PayDirection) | } -@(closeFloat.PositionType == (int)PositionTypeFlag.Long ? "多头" : "空头") | +@FloatingPositionTypeText(closeFloat.PayDirection, closeFloat.PositionType) | @closeFloat.UnderlyingCode | @if (isBond) { diff --git a/YLErpWeb/fe-tests/floatingIncomeDirectionDisplay.test.js b/YLErpWeb/fe-tests/floatingIncomeDirectionDisplay.test.js new file mode 100644 index 00000000..187daf64 --- /dev/null +++ b/YLErpWeb/fe-tests/floatingIncomeDirectionDisplay.test.js @@ -0,0 +1,47 @@ +const fs = require('fs'); +const path = require('path'); + +function read(relativePath) { + return fs.readFileSync(path.join(__dirname, '..', relativePath), 'utf8'); +} + +function floatingPositionTypeText(posiDirection, positionType) { + return posiDirection === positionType ? '多头' : '空头'; +} + +describe('收益互换浮动端多空方向展示', () => { + test.each([ + [1, 1, '多头'], + [1, 2, '空头'], + [2, 1, '空头'], + [2, 2, '多头'] + ])('收支方向=%i,多空方向=%i时展示%s', (posiDirection, positionType, expected) => { + expect(floatingPositionTypeText(posiDirection, positionType)).toBe(expected); + }); + + test('查看交易的初始持仓、实时持仓、平仓和互换记录均使用计算后的方向', () => { + const source = read('Views/SwapTrade2/TradeView.cshtml'); + + expect(source).toContain('FloatingPositionTypeText(item.PosiDirection, item.PositionType)'); + expect(source.match(/FloatingPositionTypeText\(item\.PosiDirection, item\.PositionType\)/g)).toHaveLength(2); + expect(source.match(/FloatingPositionTypeText\(closeFloat\.PayDirection, closeFloat\.PositionType\)/g)).toHaveLength(2); + }); + + test.each([ + 'Views/SwapTrade2/SwapUnwind.cshtml', + 'Views/SwapTrade2/SwapIncome.cshtml' + ])('%s按收支方向和多空方向计算展示值', relativePath => { + const source = read(relativePath); + + expect(source).toContain('floatPosition.PayDirection==floatPosition.PositionType?"多头":"空头"'); + expect(source).toContain('floatPosition.PositionType==1?"多头":"空头"'); + }); + + test('平仓详情隐藏浮动收支方向并计算多空展示值', () => { + const source = read('Views/SwapTrade2/CloseDetial.cshtml'); + + expect(source).toContain('bool hideFloatingIncomeDirection = PS.Config.ErpElement.SwapFloatingIncomeReceiveOnlyMode;'); + expect(source).toContain('FloatingPositionTypeText(item.PosiDirection, item.PositionType)'); + expect(source).toMatch(/@if \(!hideFloatingIncomeDirection\)[\s\S]*收支方向<\/td>/); + }); +}); |