Merge remote-tracking branch 'origin/glms/feature/1.4.2' into glms/feature/1.4.2
This commit is contained in:
@@ -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{
|
||||
<link rel="stylesheet" href="~/Style/Css/SwapCloseDetail.css?v=@(HtmlUtil.JsVersion)" />
|
||||
@@ -69,7 +79,10 @@
|
||||
<table class="table table-bordered">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>收支方向</td>
|
||||
@if (!hideFloatingIncomeDirection)
|
||||
{
|
||||
<td>收支方向</td>
|
||||
}
|
||||
<td>多空方向</td>
|
||||
<td>标的代码</td>
|
||||
<td>期初标的价格</td>
|
||||
@@ -84,8 +97,11 @@
|
||||
{
|
||||
var fbgclass = item.PosiDirection == (int)SwapDirectionEnum.收取 ? "swapget" : "swappay";
|
||||
<tr class="color-bule">
|
||||
<td class="@fbgclass">@((SwapDirectionEnum)item.PosiDirection)</td>
|
||||
<td>@(item.PositionType == (int)PositionTypeFlag.Long ? "多头" : "空头")</td>
|
||||
@if (!hideFloatingIncomeDirection)
|
||||
{
|
||||
<td class="@fbgclass">@((SwapDirectionEnum)item.PosiDirection)</td>
|
||||
}
|
||||
<td>@FloatingPositionTypeText(item.PosiDirection, item.PositionType)</td>
|
||||
<td>@item.UnderlyingCode</td>
|
||||
<td>@(item.PosiNetPrice.OtcFormatMoney(true, 4))</td>
|
||||
<td>@(item.PosiGrossPrice.OtcFormatMoney(true, 4))</td>
|
||||
|
||||
@@ -163,7 +163,14 @@
|
||||
<td :class="floatPosition.PayDirection==1?'swapget':'swappay'">{{floatPosition.PayDirection==1?"收取":"支付"}}</td>
|
||||
}
|
||||
<td>
|
||||
{{floatPosition.PositionType==1?"多头":"空头"}}
|
||||
@if (hideFloatingIncomeDirection)
|
||||
{
|
||||
<text>{{floatPosition.PayDirection==floatPosition.PositionType?"多头":"空头"}}</text>
|
||||
}
|
||||
else
|
||||
{
|
||||
<text>{{floatPosition.PositionType==1?"多头":"空头"}}</text>
|
||||
}
|
||||
</td>
|
||||
<td>
|
||||
{{floatPosition.UnderlyingCode}}
|
||||
|
||||
@@ -202,7 +202,14 @@
|
||||
<td :class="floatPosition.PayDirection==1?'swapget':'swappay'">{{floatPosition.PayDirection==1?"收取":"支付"}}</td>
|
||||
}
|
||||
<td>
|
||||
{{floatPosition.PositionType==1?"多头":"空头"}}
|
||||
@if (hideFloatingIncomeDirection)
|
||||
{
|
||||
<text>{{floatPosition.PayDirection==floatPosition.PositionType?"多头":"空头"}}</text>
|
||||
}
|
||||
else
|
||||
{
|
||||
<text>{{floatPosition.PositionType==1?"多头":"空头"}}</text>
|
||||
}
|
||||
</td>
|
||||
<td>
|
||||
{{floatPosition.UnderlyingCode}}
|
||||
|
||||
@@ -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 @@
|
||||
{
|
||||
<td class="@bgclass" style="width:116px !important;">@((SwapDirectionEnum)item.PosiDirection)</td>
|
||||
}
|
||||
<td>@(item.PositionType == (int)PositionTypeFlag.Long ? "多头" : "空头")</td>
|
||||
<td>@FloatingPositionTypeText(item.PosiDirection, item.PositionType)</td>
|
||||
<td>@item.UnderlyingCode</td>
|
||||
<td>
|
||||
<span class="js-swap-price" data-value="@SwapPriceData(item.PosiGrossPrice * multiplier)" data-instrument-type="@item.UnderlyingInstrumentType" data-field="grossPrice"></span>
|
||||
@@ -633,7 +642,7 @@
|
||||
</td>
|
||||
}
|
||||
<td>
|
||||
@(item.PositionType == (int)PositionTypeFlag.Long ? "多头" : "空头")
|
||||
@FloatingPositionTypeText(item.PosiDirection, item.PositionType)
|
||||
</td>
|
||||
<td>@item.UnderlyingCode</td>
|
||||
<td>
|
||||
@@ -844,7 +853,7 @@
|
||||
{
|
||||
<td class="@fbgclass" style="width:116px !important;">@((SwapDirectionEnum)closeFloat.PayDirection)</td>
|
||||
}
|
||||
<td>@(closeFloat.PositionType == (int)PositionTypeFlag.Long ? "多头" : "空头")</td>
|
||||
<td>@FloatingPositionTypeText(closeFloat.PayDirection, closeFloat.PositionType)</td>
|
||||
<td>@closeFloat.UnderlyingCode</td>
|
||||
@if (isBond)
|
||||
{
|
||||
@@ -1046,7 +1055,7 @@
|
||||
{
|
||||
<td class="@fbgclass" style="width:116px !important;">@((SwapDirectionEnum)closeFloat.PayDirection)</td>
|
||||
}
|
||||
<td>@(closeFloat.PositionType == (int)PositionTypeFlag.Long ? "多头" : "空头")</td>
|
||||
<td>@FloatingPositionTypeText(closeFloat.PayDirection, closeFloat.PositionType)</td>
|
||||
<td>@closeFloat.UnderlyingCode</td>
|
||||
@if (isBond)
|
||||
{
|
||||
|
||||
@@ -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>收支方向<\/td>/);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user