margins)
+ {
+ var marginList = margins.ToList();
+ var totalWeight = marginList.Sum(x => Math.Abs(x.InterestPrincipalFix));
+ return totalWeight == 0
+ ? 0
+ : marginList.Sum(x => x.InterestIncomeSum
+ * (x.InterestDirection == (int)SwapDirectionEnum.收取 ? 1 : -1)
+ * Math.Abs(x.InterestPrincipalFix)) / totalWeight;
+ }
+ ///
+ /// 将数据库中以公司/交易簿记方向保存的日终字段转换为客户视角。
+ /// 该转换必须在拆分浮动收益、费用和期间付息/分红之前完成,
+ /// 否则页面、Excel 和净额结算金额会出现相反符号。
///
///
private void SetClientEodPosition(eod_swap_position position)
@@ -2499,10 +2558,10 @@ namespace YLErp.Modules.SwapModule
position.SwapPositionValue = -position.SwapPositionValue;
position.PosiDividendSum = -position.PosiDividendSum;
}
- private void SetPosiPrice(eod_swap_position position)
+ private void SetPosiPrice(eod_swap_position position, bool? useBondPriceScale = null)
{
var um = DataCacheProvider.GetUnderlyingDataSource().GetData(position.UnderlyingCode);
- if (um != null && um.IsBond())
+ if (useBondPriceScale ?? (um != null && um.IsBond()))
{
position.PosiNetPrice *= 100;
position.UnderlyingPrice *= 100;
diff --git a/YLErpWeb/App_Docs/导出模板/结算报告模板.xlsx b/YLErpWeb/App_Docs/导出模板/结算报告模板.xlsx
index ba6be62b..ae0f519f 100644
Binary files a/YLErpWeb/App_Docs/导出模板/结算报告模板.xlsx and b/YLErpWeb/App_Docs/导出模板/结算报告模板.xlsx differ
diff --git a/YLErpWeb/Views/SwapTrade2/TradeMarketReport_EodPosition.cshtml b/YLErpWeb/Views/SwapTrade2/TradeMarketReport_EodPosition.cshtml
index 63de082b..3516c460 100644
--- a/YLErpWeb/Views/SwapTrade2/TradeMarketReport_EodPosition.cshtml
+++ b/YLErpWeb/Views/SwapTrade2/TradeMarketReport_EodPosition.cshtml
@@ -6,9 +6,8 @@
var pageObj = new
{
EndTime = ViewBag.EndTime?.ToString(),
- StartTime = ViewBag.StartTime?.ToString(),
valueDate = valuedateBLL.ValueDate.ToString("yyyy-MM-dd"),
- configcolumn = configcolumn_data.互换估值,
+ configcolumn = configcolumn_data.互换估值V1,
StructureType = ViewBag.StructureType
};
}
@@ -23,7 +22,7 @@
width: 250px !important;
}
- #ValueDateFrom, #ValueDate {
+ #ValueDate {
width: 152px !important;
font-size: 1rem !important;
}
@@ -51,9 +50,8 @@
@Html.MyAceDropdownInput("ClientId", "客户名称", ClientDataModel.GetAllClient(), false, true, null, false)
- @Html.MyAceDropdownInput("BookId", "簿记账户", AssetunitController.GetClientassetunit(), false, true, null, false)
@Html.CheckBox("ParentFlag", false) @Html.Label(null,"包含子级", new { @style = "font-size:12px;" })
- @Html.ShortInput("ValueDateFrom", "起始日期:")
+ @Html.MyAceDropdownInput("BookId", "簿记账户", AssetunitController.GetClientassetunit(), false, true, null, false)
@Html.ShortInput("ValueDate", "结束日期:")
@MyControls.SearchBtn()
@if (CurUser.结算管理_每日估值报告邮件发送)
diff --git a/YLErpWeb/wwwroot/Scripts/app/swaptrade/TradeMarketReport_EodPosition.js b/YLErpWeb/wwwroot/Scripts/app/swaptrade/TradeMarketReport_EodPosition.js
index 20c9c1b0..1642cdaf 100644
--- a/YLErpWeb/wwwroot/Scripts/app/swaptrade/TradeMarketReport_EodPosition.js
+++ b/YLErpWeb/wwwroot/Scripts/app/swaptrade/TradeMarketReport_EodPosition.js
@@ -2,30 +2,13 @@
$(function () {
var PostData = {};
- //控件选择时的触发事件
- main.setTradeDatePicker("", "#ValueDate", page.calcDate, function (selectedDate) {
- if (selectedDate) {
- $("#ValueDateFrom").datepicker("option", "maxDate", selectedDate);
- }
- });
- main.setTradeDatePicker("", "#ValueDateFrom", page.calcDate, function (selectedDate) {
- if (selectedDate) {
- $("#ValueDate").datepicker("option", "minDate", selectedDate);
- }
- });
- //手动修改时的触发事件
- $("#ValueDate").change(function () {
- $("#ValueDateFrom").datepicker("option", "maxDate", $("#ValueDate").val());
- });
- $("#ValueDateFrom").change(function () {
- $("#ValueDate").datepicker("option", "minDate", $("#ValueDateFrom").val());
- });
+ main.setTradeDatePicker("", "#ValueDate", page.calcDate);
- //默认初始值赋值逻辑
+ // 互换估值页仅暴露一个估值日。当前后端按 ValueDate 单日查询,
+ // 因此 ValueDateFrom 传同日仅用于保持请求对象和报告参数的日期语义一致。
$("#ValueDate").val(page.EndTime || page.calcDate);
- $("#ValueDateFrom").val(page.StartTime && page.EndTime ? page.StartTime : '');
PostData.StructureType = page.StructureType;
- PostData.ValueDateFrom = $("#ValueDateFrom").val();
+ PostData.ValueDateFrom = $("#ValueDate").val();
PostData.ValueDate = $("#ValueDate").val();
PostData.ClientId = $("#ClientId").val();
PostData.BookId = $("#BookId").val();
@@ -110,11 +93,7 @@ function searchPositionDetials(isSearchclick) {
// main.message("结束日期不能大于当前系统日期!");
// return;
//}
- if ($("#ValueDate").val() < $("#ValueDateFrom").val()) {
- main.message("起始日期不能大于结束日期!");
- return;
- }
- listGrid.appendPostData({ ValueDateFrom: $("#ValueDateFrom").val() });
+ listGrid.appendPostData({ ValueDateFrom: $("#ValueDate").val() });
listGrid.appendPostData({ ValueDate: $("#ValueDate").val() });
listGrid.appendPostData({ StructureType: page.StructureType });
if (typeof (isSearchclick) != "undefined" && isSearchclick) {
@@ -156,14 +135,6 @@ var colModelGrid = [
index: 'UnwindDate',
hidden: true,
optionHide: true
- }, {
- name: 'TradeNumber',
- label: '交易编号',
- index: 'TradeNumber',
- sortIndex: i++,
- width: 180,
- align: 'center',
- sortable: false
}, {
name: 'ConfrimNo',
label: '确认书编号',
@@ -173,11 +144,11 @@ var colModelGrid = [
align: 'center',
sortable: false
}, {
- name: 'ClientName',
- label: '交易对手',
- index: 'ClientName',
+ name: 'TradeNumber',
+ label: '交易编号',
+ index: 'TradeNumber',
sortIndex: i++,
- width: 120,
+ width: 180,
align: 'center',
sortable: false
}, {
@@ -222,21 +193,6 @@ var colModelGrid = [
align: 'center',
sortable: false,
formatter: SpreadRateFormat
- }, {
- name: 'position.FloatRateUnderlyingCode',
- label: '基准利率',
- index: 'position.FloatRateUnderlyingCode',
- width: 120,
- align: 'center',
- sortable: false
- }, {
- name: 'position.FloatRate',
- label: '当日适用基准利率',
- index: 'position.FloatRate',
- width: 120,
- align: 'center',
- sortable: false,
- formatter: RateFormat
}, {
name: 'position.PosiNotionalValue',
label: '标的名义金额',
@@ -244,7 +200,7 @@ var colModelGrid = [
width: 150,
align: 'center',
sortable: false,
- formatter: StockEqvNotionalFormat,
+ formatter: AmountFormat,
}, {
name: 'position.PosiQuantity',
label: '标的数量',
@@ -253,21 +209,21 @@ var colModelGrid = [
align: 'center',
sortable: false,
formatter: StockEqvNotionalFormat,
- }, {
- name: 'DividendAmount',
- label: '期间分红',
- index: 'DividendAmount',
- width: 100,
- align: 'center',
- formatter: AmountFormat,
- sortable: false
}, {
name: 'PeriodAmount',
label: '期间付息',
index: 'PeriodAmount',
width: 100,
align: 'center',
- formatter: AmountFormat,
+ formatter: NullableAmountFormat,
+ sortable: false
+ }, {
+ name: 'DividendAmount',
+ label: '期间分红',
+ index: 'DividendAmount',
+ width: 100,
+ align: 'center',
+ formatter: NullableAmountFormat,
sortable: false
}, {
name: 'position.PosiGrossPrice',
@@ -284,12 +240,7 @@ var colModelGrid = [
width: 150,
align: 'center',
sortable: false,
- formatter: function (cellValue, options, rowObject) {
- if (cellValue == null) {
- return "";
- }
- return otcformat.trading.premiumRateP(cellValue);
- }
+ formatter: YieldRateFormat
},
{
name: 'position.UnderlyingPrice',
@@ -320,15 +271,7 @@ var colModelGrid = [
index: 'InterestAmount',
width: 120,
align: 'center',
- formatter: StockEqvNotionalFormat,
- sortable: false,
- }, {
- name: 'position.PosiFeePending',
- label: '开平仓交易费用',
- index: 'position.PosiFeePending',
- width: 120,
- align: 'center',
- formatter: StockEqvNotionalFormat,
+ formatter: FixedAmountFormat,
sortable: false,
}, {
name: 'position.PosiProfitSum',
@@ -336,7 +279,15 @@ var colModelGrid = [
index: 'position.PosiProfitSum',
width: 120,
align: 'center',
- formatter: StockEqvNotionalFormat,
+ formatter: FixedAmountFormat,
+ sortable: false,
+ }, {
+ name: 'position.PosiFeePending',
+ label: '开平仓交易费用',
+ index: 'position.PosiFeePending',
+ width: 120,
+ align: 'center',
+ formatter: FixedAmountFormat,
sortable: false,
}, {
name: 'OpenMarginRate',
@@ -344,7 +295,7 @@ var colModelGrid = [
index: 'OpenMarginRate',
width: 120,
align: 'center',
- formatter: RateFormat,
+ formatter: TrimmedRateFormat,
sortable: false,
}, {
name: 'MarginInterestAmount',
@@ -352,7 +303,7 @@ var colModelGrid = [
index: 'MarginInterestAmount',
width: 120,
align: 'center',
- formatter: AmountFormat,
+ formatter: FixedAmountFormat,
sortable: false,
}, {
name: 'OpenMarginAmount',
@@ -360,7 +311,7 @@ var colModelGrid = [
index: 'OpenMarginAmount',
width: 120,
align: 'center',
- formatter: AmountFormat,
+ formatter: FixedAmountFormat,
sortable: false,
}, {
name: 'AdditionalMarginAmount',
@@ -368,7 +319,7 @@ var colModelGrid = [
index: 'AdditionalMarginAmount',
width: 120,
align: 'center',
- formatter: AmountFormat,
+ formatter: FixedAmountFormat,
sortable: false,
}, {
name: 'NetSettmentAmount',
@@ -376,7 +327,7 @@ var colModelGrid = [
index: 'NetSettmentAmount',
width: 120,
align: 'center',
- formatter: StockEqvNotionalFormat,
+ formatter: FixedAmountFormat,
sortable: false,
}, {
name: 'TrsValue',
@@ -384,13 +335,15 @@ var colModelGrid = [
index: 'TrsValue',
width: 120,
align: 'center',
- formatter: StockEqvNotionalFormat,
+ formatter: FixedAmountFormat,
sortable: false,
}
];
+// 页面字段顺序以《估值模块V1》第二部分为准;历史个人列配置只能控制显隐,不能打乱业务列顺序。
var defaultVisibleColumnNames = colModelGrid
.filter(function (column) { return column.hidden !== true; })
.map(function (column) { return column.name; });
+var documentColumnOrder = colModelGrid.map(function (column) { return column.name; });
function formatter6(cellvalue, options, rowObject) {
return main.formatNumber(cellvalue, 6);
@@ -421,12 +374,27 @@ function gridComplete() {
}
//jgrid.sortGrid(g_sort.name, g_sort.order);
$.when(main.setcolumnChooser(jgrid, page.configcolumn)).always(function () {
+ restoreDocumentColumnOrder(jgrid);
ensureBusinessColumnsVisible(jgrid);
});
$(".selftooltip").tooltip({ html: true, show: 50000, trigger: "hover" });
$(window).off('resize.jqGrid');
}
+function restoreDocumentColumnOrder(jgrid) {
+ var colModel = jgrid.jqGrid('getGridParam', 'colModel') || [];
+ var currentNames = colModel.map(function (column) { return column.name; });
+ var targetNames = currentNames
+ .filter(function (name) { return documentColumnOrder.indexOf(name) < 0; })
+ .concat(documentColumnOrder);
+ var permutation = targetNames.map(function (name) { return currentNames.indexOf(name); });
+ if (permutation.length === currentNames.length
+ && permutation.every(function (index) { return index >= 0; })
+ && permutation.some(function (index, targetIndex) { return index !== targetIndex; })) {
+ jgrid.jqGrid('remapColumns', permutation, true);
+ }
+}
+
function ensureBusinessColumnsVisible(jgrid) {
var colModel = jgrid.jqGrid('getGridParam', 'colModel') || [];
var hasVisibleBusinessColumn = colModel.some(function (column) {
@@ -475,10 +443,6 @@ function SendReport() {
main.message("结束日期不能大于当前系统日期!");
return;
}
- if ($("#ValueDate").val() < $("#ValueDateFrom").val()) {
- main.message("起始日期不能大于结束日期!");
- return;
- }
main.open("向{0}发送报告".template(clientName), "/clientbalance/TradeMarketClientSend?clientid=" + param.ClientId + "&ParentFlag=" + param.ParentFlag);
}
function DownLoadReport() {
@@ -499,18 +463,16 @@ function DownLoadReport() {
main.message("结束日期不能大于当前系统日期!");
return;
}
- if ($("#ValueDate").val() < $("#ValueDateFrom").val()) {
- main.message("起始日期不能大于结束日期!");
- return;
- }
-
main.post("/clientbalance/ViewTradeMarketFile", screenData()).done(function (res) {
window.open(res.obj);
});
}
function screenData() {
- var data = { From: $("#ValueDateFrom").val(), To: $("#ValueDate").val() };
+ // 已移除起始日期控件,预览报告按单个估值日生成,From/To 保持同日。
+ var data = { From: $("#ValueDate").val(), To: $("#ValueDate").val() };
data.ClientId = $("#ClientId").val();
+ // 报告下载和发送弹窗均从 screenData 取参数,必须保留当前簿记账户筛选。
+ data.BookId = $("#BookId").val();
if ($("#ParentFlag").prop("checked"))
data.ParentFlag = true;
else
@@ -522,7 +484,7 @@ function showChiCang() {
main.showcolumnChooser(jQuery('#listGrid'), page.configcolumn);
}
function PriceFormat(cellValue, options, rowObject) {
- return otcformat.trading.umprice(cellValue);
+ return main.formatNumber(cellValue, 9, { grouping: true });
}
function StockEqvNotionalFormat(cellValue, options, rowObject) {
@@ -531,6 +493,26 @@ function StockEqvNotionalFormat(cellValue, options, rowObject) {
function AmountFormat(cellValue, options, rowObject) {
return main.formatNumber(cellValue, 2, { trimTailZeros: true });
}
+function NullableAmountFormat(cellValue, options, rowObject) {
+ if (cellValue === null || cellValue === undefined || cellValue === '') {
+ return '';
+ }
+ return AmountFormat(cellValue, options, rowObject);
+}
+function FixedAmountFormat(cellValue, options, rowObject) {
+ return main.formatNumber(cellValue, 2);
+}
+function YieldRateFormat(cellValue, options, rowObject) {
+ if (cellValue === null || cellValue === undefined || cellValue === '') {
+ return '';
+ }
+ // percent 格式会在数字末尾添加 %,通用 trimTailZeros 无法识别其后的 0。
+ // 先将小数收益率转为百分比数值,再格式化并追加 %,确保最多保留四位小数且去尾零。
+ return main.formatNumber(cellValue * 100, 4, { trimTailZeros: true }) + '%';
+}
+function TrimmedRateFormat(cellValue, options, rowObject) {
+ return main.formatNumber(cellValue, 4, { percent: true, trimTailZeros: true });
+}
function RateFormat(cellValue, options, rowObject) {
if (cellValue) {
var num = new Number(cellValue) * 100;
@@ -552,14 +534,10 @@ function locationChange(tab) {
main.message("结束日期不能大于当前系统日期!");
return;
}
- if ($("#ValueDate").val() < $("#ValueDateFrom").val()) {
- main.message("起始日期不能大于结束日期!");
- return;
- }
if ($("#ParentFlag").prop("checked"))
ParentFlag = true;
else
ParentFlag = false;
- window.location.href = tab + "?clientId=" + $("#ClientId").val() + "&startTime=" + $("#ValueDateFrom").val() + "&endTime=" + $("#ValueDate").val() + "&ParentFlag=" + ParentFlag;
+ window.location.href = tab + "?clientId=" + $("#ClientId").val() + "&startTime=" + $("#ValueDate").val() + "&endTime=" + $("#ValueDate").val() + "&ParentFlag=" + ParentFlag;
return;
}