diff --git a/Framework/YLErp.Core/DBModels/ClientCashInCashOut.cs b/Framework/YLErp.Core/DBModels/ClientCashInCashOut.cs index 6e308224..93f0bc8b 100644 --- a/Framework/YLErp.Core/DBModels/ClientCashInCashOut.cs +++ b/Framework/YLErp.Core/DBModels/ClientCashInCashOut.cs @@ -199,6 +199,12 @@ namespace YLErp.DBModels /// 审批时间 /// public DateTime? ApprovalDate { get; set; } + + /// + /// 资金类型初保账户/追保账户 + /// + [DisplayName("账户类型")] + public string cash_type { get; set; } } /// /// 出入金信息 diff --git a/Framework/YLErp.Core/DBModels/Clientbalancedaily.cs b/Framework/YLErp.Core/DBModels/Clientbalancedaily.cs index e7b13242..6cb7fb61 100644 --- a/Framework/YLErp.Core/DBModels/Clientbalancedaily.cs +++ b/Framework/YLErp.Core/DBModels/Clientbalancedaily.cs @@ -530,6 +530,22 @@ namespace YLErp.DBModels /// 维保线 /// public double? MaintenanceLine { get; set; } + /// + /// 追保入金 + /// + public double? vm_in_fund { get; set; } + /// + /// 追保 入金累计 + /// + public double? vm_in_fund_sum { get; set; } + /// + /// 追保 出金 + /// + public double? vm_out_fund { get; set; } + /// + /// 追保 出金累计 + /// + public double? vm_out_fund_sum { get; set; } [NotMapped] public FundObject FundObject { get; set; } @@ -544,11 +560,13 @@ namespace YLErp.DBModels public class FundObject { public Dictionary InFund { get; set; } = new Dictionary(); + public Dictionary VmInFund { get; set; } = new Dictionary(); /// /// 出金为绝对值,不包含出金方向处理 /// public Dictionary OutFund { get; set; } = new Dictionary(); + public Dictionary VmOutFund { get; set; } = new Dictionary(); public Dictionary NetFund { get; set; } = new Dictionary(); @@ -559,8 +577,11 @@ namespace YLErp.DBModels public Dictionary OtherFund { get; set; } = new Dictionary(); public Dictionary InFundSum { get; set; } = new Dictionary(); + public Dictionary VmInFundSum { get; set; } = new Dictionary(); public Dictionary OutFundSum { get; set; } = new Dictionary(); + public Dictionary VmOutFundSum { get; set; } = new Dictionary(); + public Dictionary NetFundSum { get; set; } = new Dictionary(); diff --git a/Framework/YLErp.Core/DBModels/Enums/CashTypeEnum.cs b/Framework/YLErp.Core/DBModels/Enums/CashTypeEnum.cs new file mode 100644 index 00000000..04b3cbe7 --- /dev/null +++ b/Framework/YLErp.Core/DBModels/Enums/CashTypeEnum.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace YLErp.DBModels.Enums +{ + public enum CashTypeEnum + { + 初保账户, + 追保账户 + } +} diff --git a/Framework/YLErp.Core/DBModels/client_marginrate.cs b/Framework/YLErp.Core/DBModels/client_marginrate.cs index 4a8ecdba..586b834e 100644 --- a/Framework/YLErp.Core/DBModels/client_marginrate.cs +++ b/Framework/YLErp.Core/DBModels/client_marginrate.cs @@ -32,7 +32,7 @@ namespace YLErp.DBModels [DisplayName("生效日期")] public DateTime ValueDate { get; set; } - [DisplayName("初始预付金率")] + [DisplayName("初始保证金率")] public double InitMarginRate { get; set; } [DisplayName("平仓线")] @@ -61,6 +61,9 @@ namespace YLErp.DBModels /// 互换默认期限 /// public int? SwapEndDays { get; set; } + + [DisplayName("维持保证金率")] + public double MaintenanceRate { get; set; } public string GetDataTraceKeyInfo() { return "客户品种预付金率:" + ClientId + Type + VarietyId; diff --git a/Framework/YLErp.Core/Models/ClientSettleBalance.cs b/Framework/YLErp.Core/Models/ClientSettleBalance.cs index 079a8454..ec41df43 100644 --- a/Framework/YLErp.Core/Models/ClientSettleBalance.cs +++ b/Framework/YLErp.Core/Models/ClientSettleBalance.cs @@ -146,11 +146,39 @@ namespace YLErp.Models /// 当日入金 /// public double InFund { get; set; } + + public double VmInFund { get; set; } + /// + /// 总入金 + /// + public double InFundSum { get; set; } + + /// + /// 追保总入金 + /// + public double VmInFundSum { get; set; } + /// + ///追保账户金额 + /// + public double VmFundSum { get { return VmInFundSum-VmOutFundSum; } } + /// + /// 总出入金金额 + /// + public double NetFundAll { get { return NetFund+VmFundSum; } } /// /// 当日出金 /// 为绝对值,即不包含出金方向 /// public double OutFund { get; set; } + public double VmOutFund { get; set; } + /// + /// 总出金 + /// + public double OutFundSum { get; set; } + /// + /// 追保总出金 + /// + public double VmOutFundSum { get; set; } /// /// 票息 /// @@ -185,27 +213,6 @@ namespace YLErp.Models { get { - if (PS.Config.Is广期资本) - { - //期末结存 + 持仓盈亏-冻结+授信+质押市值 - var result = AmountFund + PositionPnl + AllFreezeBalance() + TotalCredit + GuaranteesTotalAmount; - if (SamePeer == 1) //非同业客户 -预付金占用 - { - result = result + PayableMargin; - } - return result; - } - - if (PS.Config.Is宏源) - { - var result = MarginBalance + PayableMargin - FrozenMarginMoney - GuaranteesTotalAmount; - return result; - } - if (PS.Config.Is广发商贸) - { - var result = MarginBalance + PayableMargin - FrozenMarginMoney - GuaranteesTotalAmount; - return result; - } return _AvailableAmount; } set @@ -388,7 +395,7 @@ namespace YLErp.Models public double TwoSideMargin { get; set; } /// - /// 本方角度预付金 + /// 初始保证金金额 /// public double MySideMargin { get; set; } @@ -1036,5 +1043,39 @@ namespace YLErp.Models /// 互换存续预付金 /// public double SwapMargin { get; set; } + + /// + /// 维持保证金 + /// + public double MaintenanceMargin { get; set; } + /// + /// 互换合并盯市金额B=现金结存+∑(组合待实现收益) + /// + public double SwapMarketAmount + { + get + { + return AmountFund + RoundedPositionPnl; + } + } + /// + /// 履约保证金比例:合并盯市价格/持仓名义本金 + /// + public decimal SwapMarketAmountPercent + { + get + { + if (PositionNotionalPrincipal == 0) + { + return 0; + } + var percent = (decimal)Math.Round(SwapMarketAmount / PositionNotionalPrincipal, 6, MidpointRounding.AwayFromZero); + return percent > 1 ? 1 : percent; + } + } + /// + /// 是否需要追保 + /// + public bool NeedAddMargin { get; set; } } } diff --git a/YLErpDAL/BLL/EodSettlement/ClientBalanceUtility.cs b/YLErpDAL/BLL/EodSettlement/ClientBalanceUtility.cs index c30cd72d..4e5fcd9f 100644 --- a/YLErpDAL/BLL/EodSettlement/ClientBalanceUtility.cs +++ b/YLErpDAL/BLL/EodSettlement/ClientBalanceUtility.cs @@ -1,6 +1,7 @@ using BaseOUDAL; using YLErp.BLL.Eod; using YLErp.DBModels.Enums; +using YLErp.Model; using YLErp.Models; using YLErp.Modules; using YLErp.Modules.ClientModule; @@ -110,7 +111,8 @@ namespace YLErp.BLL.EodSettlement var lastpushLog = db.push_log.Where(x => x.data_type == (int)SwapPushDataEnum.日终估值获取 && x.data_state == (int)SwapPushDataStateEnum.接收处理成功&&x.create_time> valuedate).OrderByDescending(o => o.create_time).FirstOrDefault(); //获取根据系统时间 var lastBalanceDate = EodOperationBase.GetLastSettlementDate(valuedate); - + // 获取定义文件预付金率设置 + var clientMarginTemplates = db.client_marginrate.Where(x => x.ValueDate <= endDate).OrderByDescending(o => o.ValueDate).AsNoTracking().ToList(); var lastDate = lastBalanceDate; //查询历史记录 @@ -248,6 +250,7 @@ namespace YLErp.BLL.EodSettlement TwoSideMargin = t.TwoSideMargin ?? 0.0, OtherSideMargin = t.OtherSideMargin ?? 0.0, MySideMargin = t.MySideMargin ?? 0.0, + MaintenanceMargin = cs.VariationMargin ?? 0.0, IsPayableMarginManual = t.IsPayableMarginManual, IsPayableMarginLock = cs == null ? false : cs.ModifiedFlag, FrozenMarginMoney = t.FrozenMarginMoney ?? 0.0, @@ -274,7 +277,11 @@ namespace YLErp.BLL.EodSettlement TdWinLoss = t.WinLoss, MarginJson = cs.PVJsons, MaintenanceLine = t.MaintenanceLine, - TotalNominal=t.TotalNominal + TotalNominal=t.TotalNominal, + InFundSum = t.InFundSum, + OutFundSum = t.OutFundSum, + VmInFundSum = t.vm_in_fund_sum, + VmOutFundSum = t.vm_out_fund_sum, }; var endDatas = endQuery.ToArray(); @@ -287,16 +294,12 @@ namespace YLErp.BLL.EodSettlement var lasttoDay = EodOperationBase.GetLastSettlementDate(lastDate, true); var lastClientBalanceDaily = db.ClientBalanceDaily.Where(a => a.BalanceDate == lasttoDay && a.ClientId == data.ClientId).FirstOrDefault(); - + var marginRate = GetClientMarginRate(data.ClientId, clientMarginTemplates); balance.FrozenBalance = data.FrozenBalance; balance.FreezePremium = data.FreezePremium; balance.ReceivablesPremium = data.ReceivablesPremium; balance.AmountFund = data.AmountFund; - balance.AvailableAmount = data.AvailableAmount; - //if (PS.Config.Is广期资本) - //{ - // balance.AvailableAmount = Math.Min(data.AvailableAmount1, data.AvailableAmount2); - //} + balance.TotalCredit = data.TotalCredit; balance.PayableMargin = data.PayableMargin; @@ -306,13 +309,13 @@ namespace YLErp.BLL.EodSettlement balance.RoundedDaliyPnl = data.RoundedPositionPnl - (lastClientBalanceDaily?.RoundedPositionPnl ?? 0); balance.PositionPnl = data.PositionPnl; balance.RoundedPositionPnl = data.RoundedPositionPnl; - balance.AvailableAmount = balance.AmountFund + balance.TotalCredit + balance.PayableMargin + balance.GuaranteesTotalAmount + balance.RoundedPositionPnl - balance.FrozenMarginMoney; balance.DeltaMargin = data.DeltaMargin; balance.SwapPayableMargin = data.SwapPayableMargin; balance.SwapUnMargin = data.SwapUnPayableMargin; balance.TwoSideMargin = data.TwoSideMargin; balance.OtherSideMargin = data.OtherSideMargin; balance.MySideMargin = data.MySideMargin; + balance.MaintenanceMargin=data.MaintenanceMargin; balance.IsPayableMarginManual = data.IsPayableMarginManual; balance.IsPayableMarginLock = data.IsPayableMarginLock; balance.FrozenMarginMoney = data.FrozenMarginMoney; @@ -341,8 +344,22 @@ namespace YLErp.BLL.EodSettlement balance.ClientName = client.Name; balance.MaintenanceLine = data.MaintenanceLine ?? 0; balance.PositionNotionalPrincipal = data.TotalNominal??0; - balance.DesirableFund = balance.AvailableAmount; - balance.MarginByPayableMarginTotal = 0; + + balance.OutFundSum = data.OutFundSum ?? 0; + balance.InFundSum = data.InFundSum ?? 0; + balance.VmInFundSum = data.VmInFundSum ?? 0; + balance.VmOutFundSum = data.VmOutFundSum ?? 0; + //预付金金额=期末结存-初始预付金金额 + balance.MarginBalance = balance.AmountFund - balance.MySideMargin; + // 可用资金 = 期末结存 - 追保账户余额 - 初始保证金 + balance.AvailableAmount = balance.MarginBalance - (balance.VmInFundSum - balance.VmOutFundSum); + // 是否追保=履约保证金比例<维持保证金率 + balance.NeedAddMargin = balance.SwapMarketAmountPercent < (decimal)marginRate.MaintenanceRate; + // 追保金额=初始保证金金额-盯市金额 + balance.MarginByPayableMarginTotal = balance.NeedAddMargin ? (balance.MySideMargin - balance.SwapMarketAmount):0; + // 可取资金=期末结存-min(持仓盈亏,0)-初始保证金 + balance.DesirableFund = balance.MarginBalance - Math.Min(balance.RoundedPositionPnl, 0); + } } } @@ -1391,6 +1408,29 @@ namespace YLErp.BLL.EodSettlement } return lastClientBalances; } + /// + /// 获取预付金率设置 + /// + /// + /// + /// + private static client_marginrate GetClientMarginRate(int clientId, List clientMarginTemplates) + { + var marinRate = clientMarginTemplates.Where(x => x.ClientId == clientId ).FirstOrDefault(); + if (marinRate == null) + { + marinRate = clientMarginTemplates.Where(x => x.ClientId == 0).FirstOrDefault(); + } + if (marinRate == null) + { + marinRate = new client_marginrate + { + InitMarginRate = 1, + MaintenanceRate = 1, + }; + } + return marinRate; + } class ClientBalanceEx : ClientSettleBalance { public string UnderlyingCode { get; set; } diff --git a/YLErpDAL/BLL/EodSettlement/RealTimeClientBanlanceService.cs b/YLErpDAL/BLL/EodSettlement/RealTimeClientBanlanceService.cs index fef0aa83..1ac1479b 100644 --- a/YLErpDAL/BLL/EodSettlement/RealTimeClientBanlanceService.cs +++ b/YLErpDAL/BLL/EodSettlement/RealTimeClientBanlanceService.cs @@ -11,6 +11,7 @@ using YLErp.Commons; using YLErp.DataBase; using YLErp.DBModels; using YLErp.DBModels.Enums; +using YLErp.Model; using YLErp.Model.Enum; using YLErp.Models; using YLErp.Modules; @@ -80,7 +81,7 @@ namespace YLErp.BLL.Eod var clientSpanQuery = from t in DbContext.client_span where t.ValueDate == calcDate && clientIds.Contains(t.ClientId) && t.SpanType == ClientSpan.SpanType_RealTime && t.WorstCastClientPayable != null - select new { t.ClientId, t.WorstCastClientPayable, t.DeltaMargin, t.SwapWorstCastClientPayable, t.TwoSideMargin, t.OtherSideMargin, t.MySideMargin, t.SwapUnMargin, t.PVJsons }; + select new { t.ClientId, t.WorstCastClientPayable, t.DeltaMargin, t.SwapWorstCastClientPayable, t.TwoSideMargin, t.OtherSideMargin, t.MySideMargin, t.SwapUnMargin, t.PVJsons, t.VariationMargin }; var clientSpanDic = clientSpanQuery.ToArray().Where(n => set.Add(n.ClientId)).ToDictionary(n => n.ClientId); @@ -140,6 +141,7 @@ namespace YLErp.BLL.Eod TwoSideMargin = clientSpan == null ? 0 : (clientSpan.TwoSideMargin ?? 0), OtherSideMargin = clientSpan == null ? 0 : (clientSpan.OtherSideMargin ?? 0), MySideMargin = clientSpan == null ? 0 : (clientSpan.MySideMargin ?? 0), + MaintenanceMargin = clientSpan == null ? 0 : (clientSpan.VariationMargin ?? 0), CreditCanApplySwap = client.creditCanApplySwap, TotalCreditStockEqvNotional = double.NaN, SettlementCurrency = client?.SettlementCurrency, @@ -164,7 +166,7 @@ namespace YLErp.BLL.Eod { var banlanceQuery = from t in DbContext.ClientBalanceDaily where t.BalanceDate == lastSettletDate && clientIds.Contains(t.ClientId) - select new { t.ClientId, t.ToDayRemainFund, t.TodayRemianFundProduct, t.PositionPremiumNetCash }; + select new { t.ClientId, t.ToDayRemainFund, t.TodayRemianFundProduct, t.PositionPremiumNetCash, t.RoundedPositionPnl, t.PayableMargin, t.MySideMargin, t.InFundSum, t.OutFundSum, t.vm_out_fund_sum, t.vm_in_fund_sum, t.OptionPremiumSwapSum, t.SwapBalance }; var banlanceDatas = banlanceQuery.ToArray(); foreach (var data in banlanceDatas) { @@ -176,6 +178,12 @@ namespace YLErp.BLL.Eod c.LastGuaranteesTotalAmount = data.TodayRemianFundProduct ?? 0; // 期初持仓交易净额 c.LastDayPositionPremiumNetCash = data.PositionPremiumNetCash ?? 0; + c.InFundSum = data.InFundSum ?? 0; + c.OutFundSum = data.OutFundSum ?? 0; + c.VmInFundSum = data.vm_in_fund_sum ?? 0; + c.VmOutFundSum = data.vm_out_fund_sum ?? 0; + c.OptionPremiumSwap = data.OptionPremiumSwapSum ?? 0; + c.SwapBalance = data.SwapBalance ?? 0; } } } @@ -226,7 +234,7 @@ namespace YLErp.BLL.Eod .ToDictionary(p => p.Key, p => p.OptDate); Dictionary dicCashInOut = DbContext.ClientCashInCashOut.Where(x => clientIds.Contains((int)x.ClientId)).AsEnumerable().GroupBy(p => (int)p.ClientId).Select(p => new { p.Key, OptDate = p.Max(d => d.OptDate) }).ToDictionary(p => p.Key, p => p.OptDate); - + var clientMarginTemplates = DbContext.client_marginrate.Where(x => x.ValueDate <= calcDate).OrderByDescending(o => o.ValueDate).AsNoTracking().ToList(); foreach (var item in _clientBalanceDic.Values) { #region 判断实时持仓数据是否最新(包含了最新交易操作的数据) @@ -241,25 +249,17 @@ namespace YLErp.BLL.Eod item.NetFund = item.InFund - item.OutFund; item.OtherFund = item.InFundOther + item.OutFundOther; + + item.InFundSum += item.InFund; + item.OutFundSum += item.OutFund; + item.VmInFundSum += item.VmInFund; + item.VmOutFundSum += item.VmOutFund; //上日资金余额 item.LastDayRemainFund = item.AmountFund; item.LastDayRemainFundWithProduct = item.LastDayRemainFund + item.LastGuaranteesTotalAmount; //当前账号资金 - item.AmountFund = item.AmountFund + item.NetFund + item.OtherFund + item.Coupon + item.OptionPremium + item.OptionPremiumSwap + item.SwapBalance + item.SettlementBalance; - - item.AvailableAmount = item.AmountFund + item.TotalCredit + item.PayableMargin + item.GuaranteesTotalAmount + item.RoundedPositionPnl - item.FrozenMarginMoney; - item.DesirableFund = item.AvailableAmount; - //预付金余额 - item.MarginBalance = item.AmountFund - item.FreezePremium - item.FrozenOutFund - item.FrozenRedeemFunds + - item.ReceivablesPremium + item.GuaranteesTotalAmount; - - //互换最大可用资金 - - item.CreditCanApplySwap = clientDic.ContainsKey(clientId) ? clientDic[clientId].creditCanApplySwap : false; - - //可取预付金为预付金余额 - 应缴预付金(上浮 + 0.02) - item.AdvisableMargin = Math.Max(item.MarginBalance + item.PayableMargin * marginMaxRation / marginRation, 0); + item.AmountFund = item.AmountFund + item.NetFund + item.OtherFund + item.OptionPremium + item.OptionPremiumSwap + item.SwapBalance + item.SettlementBalance; item.WinLoss += item.WinLoss2; @@ -269,19 +269,18 @@ namespace YLErp.BLL.Eod //可用名义本金规模 item.AvailableStockEqvNotional = item.TotalCreditStockEqvNotional - item.PositionNotionalPrincipal; - //客户方向取反 - item.RoundedPositionPnl *= -1; - item.PositionPnl *= -1; - item.DaliyPnl *= -1; - item.RoundedDaliyPnl *= -1; - item.RoundedPositionPv *= -1; - item.PositionPv *= -1; - item.SellPv *= -1; - item.DesirableRate = DataCacheProvider.GetClientDataSource().GetData(item.ClientId)?.DesirableRate ?? 0; - var clientAmount = item.AmountFund + item.TotalCredit + item.GuaranteesTotalAmount; - var clientSwapMarinAmount = clientAmount + item.SwapMargin; - var MaintenanceLine = clientSwapMarinAmount == 0 ? 0 : (clientAmount + item.PayableMargin) / clientSwapMarinAmount; - item.MaintenanceLine =Math.Round(MaintenanceLine, 2); + + var marginRate = GetClientMarginRate(item.ClientId, clientMarginTemplates); + //预付金金额=期末结存-初始预付金金额 + item.MarginBalance = item.AmountFund - item.MySideMargin; + // 可用资金 = 期末结存 - 追保账户余额 - 初始保证金 + item.AvailableAmount = item.MarginBalance - (item.VmInFundSum - item.VmOutFundSum) - item.FrozenMarginMoney; + // 是否追保=履约保证金比例<维持保证金率 + item.NeedAddMargin = item.SwapMarketAmountPercent < (decimal)marginRate.MaintenanceRate; + // 追保金额=初始保证金金额-盯市金额 + item.MarginByPayableMarginTotal = item.NeedAddMargin ? (item.MySideMargin - item.SwapMarketAmount) : 0; + // 可取资金=期末结存-min(持仓盈亏,0)-初始保证金 + item.DesirableFund = item.MarginBalance - Math.Min(item.RoundedPositionPnl, 0); } return _clientBalanceDic.Values; @@ -1082,18 +1081,20 @@ namespace YLErp.BLL.Eod ClientId = t.ClientId.Value, TradeId = t.TradeId ?? 0, action = t.Direction + "^" + (t.Direction == "应收" ? t.Action : ""), - money = t.Money.Value + money = t.Money.Value, + cash_type = t.cash_type }; //获取包含的所有收益互换id列表 var allTradeIds = ClientCashQuery.Select(x => x.TradeId).ToList(); var ClientCashQuerySum = from t in ClientCashQuery - group t by new { t.ClientId, t.action } into g + group t by new { t.ClientId, t.action, t.cash_type } into g select new { g.Key.ClientId, g.Key.action, + g.Key.cash_type, moneySum = g.Sum(n => n.money), swapMoneySun = 0.0 }; @@ -1127,13 +1128,28 @@ namespace YLErp.BLL.Eod balance.UnwindBalance = data.moneySum; } } - else if (data.action == "入金^") + if (data.action == "入金^") { - balance.InFund = data.moneySum; + if (data.cash_type == CashTypeEnum.初保账户.ToString()) + { + balance.InFund = data.moneySum; + } + else + { + balance.VmInFund = data.moneySum; + } + } else if (data.action == "出金^") { - balance.OutFund = data.moneySum; + if (data.cash_type == CashTypeEnum.初保账户.ToString()) + { + balance.OutFund = data.moneySum; + } + else + { + balance.VmOutFund = data.moneySum; + } } else if (data.action == "其他收入^") { @@ -1331,8 +1347,8 @@ namespace YLErp.BLL.Eod ClientId = item.client_id ?? 0, ClientName = item.client_name, TradingQty = (item.order_qty ?? 0) - (item.last_shares ?? 0), - TradingAmountAvg = item.full_price ?? 0, - TradingAmountFeeAvg = item.full_price ?? 0, + TradingAmountAvg = (item.full_price ?? 0)*0.01m, + TradingAmountFeeAvg = (item.full_price ?? 0) * 0.01m, TradingFee = 0 }; // clientOrder中数量单位为万 @@ -1457,6 +1473,30 @@ namespace YLErp.BLL.Eod return profit - releasedMargin; } + /// + /// 获取预付金率设置 + /// + /// + /// + /// + private static client_marginrate GetClientMarginRate(int clientId, List clientMarginTemplates) + { + var marinRate = clientMarginTemplates.Where(x => x.ClientId == clientId).FirstOrDefault(); + if (marinRate == null) + { + marinRate = clientMarginTemplates.Where(x => x.ClientId == 0).FirstOrDefault(); + } + if (marinRate == null) + { + marinRate = new client_marginrate + { + InitMarginRate = 1, + MaintenanceRate = 1, + }; + } + return marinRate; + } + public class ClientBalanceEx : ClientSettleBalance { public double InFundOther { get; set; } diff --git a/YLErpDAL/BLL/EodSettlement/RealtimePnlCalc.cs b/YLErpDAL/BLL/EodSettlement/RealtimePnlCalc.cs index d69b8843..887a8714 100644 --- a/YLErpDAL/BLL/EodSettlement/RealtimePnlCalc.cs +++ b/YLErpDAL/BLL/EodSettlement/RealtimePnlCalc.cs @@ -898,21 +898,21 @@ namespace YLErp.BLL.Eod /// private static void SetClientPositionPrice(ClientPosition clientPosition) { - if (clientPosition.position_qty <= 0 || _yLCache == null) + if (clientPosition.position_qty <= 0) { return; } try { //TRS-BondDepthMarket:160010.IB-0 - BondMarket bondMarket = _yLCache.StringGetWithNoPrefix("TRS-BondNowPrice:" + clientPosition.security_id + "-" + clientPosition.side); - if (bondMarket != null) + var bondPrice = EodPriceQueryService.GetChinaBondPrice(valuedateBLL.ValueDate, clientPosition.security_id); + if (bondPrice != null) { - clientPosition.price_now = bondMarket.netPrice; - clientPosition.full_price_now = bondMarket.fullPrice; - clientPosition.yield_now = bondMarket.mdEntryPx; + clientPosition.full_price_now = bondPrice.dirty_price_close; clientPosition.swap_market_value = clientPosition.full_price_now * clientPosition.position_qty * 10000 * (clientPosition.side == 0 ? 1 : -1) * ConsGlobal.bondPriceMultiple; clientPosition.position_profit_loss = (clientPosition.full_price_now - clientPosition.deal_full_price_avg) * clientPosition.position_qty * 10000 * ConsGlobal.bondPriceMultiple * (clientPosition.side == 0 ? 1 : -1); + clientPosition.price_now = bondPrice.net_price; + clientPosition.yield_now = bondPrice.yield * ConsGlobal.bondPriceMultiple; } } catch (Exception ex) diff --git a/YLErpDAL/Model/ClientCashInCashOut.cs b/YLErpDAL/Model/ClientCashInCashOut.cs index ebfb1351..5314f109 100644 --- a/YLErpDAL/Model/ClientCashInCashOut.cs +++ b/YLErpDAL/Model/ClientCashInCashOut.cs @@ -314,6 +314,11 @@ namespace YLErp.Model [DisplayName("操作来源")] public string Action { get; set; } /// + /// 账户类型初保账户/追保账户 + /// + [DisplayName("账户类型")] + public string cash_type { get; set; } + /// /// 加密主键 /// [NotMapped] diff --git a/YLErpDAL/Model/clientLinq.cs b/YLErpDAL/Model/clientLinq.cs index ed72f456..360fbf9c 100644 --- a/YLErpDAL/Model/clientLinq.cs +++ b/YLErpDAL/Model/clientLinq.cs @@ -274,7 +274,7 @@ namespace YLErp.Model [NotMapped] public double RoundedTotalAmount { - get { return AmountFundWithProduct + (RoundedPositionPv ?? 0) - (PrepaymentAmount ?? 0); } + get;set; } //账户资金(包含抵押品价值) @@ -405,6 +405,14 @@ namespace YLErp.Model /// 当日资金净出入 /// public double NetFund { get; set; } + /// + ///追保账户金额 + /// + public double VmFundSum { get; set; } + /// + /// 总出入金金额 + /// + public double NetFundAll { get; set; } /// /// 其他收支 @@ -563,5 +571,23 @@ namespace YLErp.Model public DateTime? LastSettlemetTime { get; set; } [NotMapped] public string LastHTSettlemetTime { get; set; } + + + /// + /// 维持保证金 + /// + public double MaintenanceMargin { get; set; } + /// + /// 互换合并盯市金额B=现金结存+∑(组合待实现收益) + /// + public double SwapMarketAmount { get; set; } + /// + /// 履约保证金比例:合并盯市价格/持仓名义本金 + /// + public decimal SwapMarketAmountPercent{get;set; } + /// + /// 是否需要追保 + /// + public bool NeedAddMargin { get; set; } } } diff --git a/YLErpDAL/Modules/ClientModule/ClientCashInCashOutDataService.cs b/YLErpDAL/Modules/ClientModule/ClientCashInCashOutDataService.cs index c2480c9a..e518ba56 100644 --- a/YLErpDAL/Modules/ClientModule/ClientCashInCashOutDataService.cs +++ b/YLErpDAL/Modules/ClientModule/ClientCashInCashOutDataService.cs @@ -599,6 +599,7 @@ namespace YLErp.Modules.ClientModule r.Action = req.Action; r.CashFlag = req.CashFlag; r.CurrencyCode = req.CurrencyCode; + r.cash_type = req.cash_type; } if (isARAP) @@ -659,26 +660,9 @@ namespace YLErp.Modules.ClientModule //如果出金大于可用资金(修改操作时需要算差价)则抛出错误 if (Math.Abs(r.Money ?? 0.0) > realAvailableFund) { - if ("出金".Equals(r.Direction)) - { - var msg = "添加出金失败,客户:" + r.ClientName + " 出金:" + r.Money + " 实际可取出资金:" + - (Math.Floor(realAvailableFund * 100) / 100).ToString("0.00") + ";"; - throw new ServiceException(msg); - } - else - { - var msg = "添加应付预付金失败,客户:" + r.ClientName + " 应付预付金:" + Math.Abs(r.Money ?? 0) + " 实际可取出资金:" + - (Math.Floor(realAvailableFund * 100) / 100).ToString("0.00") + ";"; - throw new ServiceException(msg); - } - } - } - - if ("出金".Equals(r.Direction) && PS.Config.Company == Configuration.CompanyEnum.中金) - { - if (!CheckClientCashOut(req.ClientId ?? 0, req.Money ?? 0, req.CurrencyCode)) - { - throw new ServiceException($"南向客户币种{req.CurrencyCode}的出金金额不能大于客户账户余额"); + var msg = "添加出金失败,客户:" + r.ClientName + " 出金:" + r.Money + " 实际可取出资金:" + + (Math.Floor(realAvailableFund * 100) / 100).ToString("0.00") + ";"; + throw new ServiceException(msg); } } @@ -934,10 +918,9 @@ namespace YLErp.Modules.ClientModule var clientbalance = ClientBalanceUtility.GetClientBanlances(new List { e.ClientId.Value }, DateTime.MinValue, DateTime.Now.Date).FirstOrDefault(); //当日可取现金 var availableFund = clientbalance == null ? 0 : clientbalance.DesirableFund; - var frozenOutFund = clientbalance == null ? 0 : clientbalance.FrozenOutFund; //对于0.999999999情况的数据做下处理 - var realAvailableFund = Math.Round((availableFund + frozenOutFund) * Math.Pow(10, 8)) / Math.Pow(10, 8); + var realAvailableFund = Math.Round((availableFund + (e.Money??0)) * Math.Pow(10, 8)) / Math.Pow(10, 8); //如果当前出金金额大于可用资金(不扣除冻结出金部分)则抛出错误 if (Math.Abs(e.Money ?? 0) > realAvailableFund) { diff --git a/YLErpDAL/Modules/ClientModule/EntryexitBLL.cs b/YLErpDAL/Modules/ClientModule/EntryexitBLL.cs index b1874873..f6cd93e1 100644 --- a/YLErpDAL/Modules/ClientModule/EntryexitBLL.cs +++ b/YLErpDAL/Modules/ClientModule/EntryexitBLL.cs @@ -469,7 +469,8 @@ namespace YLErp.BLL Action = source.Action, SerialNumber = source.SerialNumber, Comments = source.Comments, - TradeValidState=trade==null?"":trade.ValidState + TradeValidState=trade==null?"":trade.ValidState, + cash_type = source.cash_type, //TradeNumber = source.TradeNumber }; query = query.Where(x=>x.TradeValidState!=ConsGlobal.InValid); diff --git a/YLErpDAL/Modules/DataProviderModule/EodPriceQueryService.cs b/YLErpDAL/Modules/DataProviderModule/EodPriceQueryService.cs index f06a51bc..1bfd5c0d 100644 --- a/YLErpDAL/Modules/DataProviderModule/EodPriceQueryService.cs +++ b/YLErpDAL/Modules/DataProviderModule/EodPriceQueryService.cs @@ -225,6 +225,18 @@ namespace YLErp.Modules.DataProviderModule }; } /// + /// 获取中债估值最新价格 + /// + /// + /// + /// + public static ChinaBondValuation GetChinaBondPrice(DateTime valueDate, string underlyingCode) + { + using var db = DbContextFactory.GetYLDbContext(); + var bondPrice = db.china_bond_valuation.Where(x => x.bond_id == underlyingCode && x.valuation_date <= valueDate).OrderByDescending(o => o.credibility).ThenByDescending(o => o.valuation_date).FirstOrDefault(); + return bondPrice; + } + /// /// 获取标的收盘价格 /// /// 标的代码 diff --git a/YLErpDAL/Modules/EodModule/SettlementModule/EodCheckMonitoredTrade.cs b/YLErpDAL/Modules/EodModule/SettlementModule/EodCheckMonitoredTrade.cs index e5557639..3dc77b62 100644 --- a/YLErpDAL/Modules/EodModule/SettlementModule/EodCheckMonitoredTrade.cs +++ b/YLErpDAL/Modules/EodModule/SettlementModule/EodCheckMonitoredTrade.cs @@ -165,76 +165,44 @@ namespace YLErp.Modules.EodModule.SettlementModule var nextSettleDate = QdpCalendarHelper.GetNonHoliday(settleDate.AddDays(1)); var days = (nextSettleDate - settleDate).Days; logger.Info("settleDate:" + settleDate.ToString("yyyy-MM-dd") + " nextSettleDate:" + nextSettleDate + " days:" + days); - for (var i=0; i< days; i++) + for (var i = 0; i < days; i++) { - var yesterday= settleDate.AddDays(i-1); - var today= settleDate.AddDays(i); + var yesterday = settleDate.AddDays(i - 1); + var today = settleDate.AddDays(i); new SwapEodPositionService(OptUser).SwapPositionCompose(today, yesterday, clientIds); + CalculateMargin(today, yesterday, clientIds); new SwapEodPositionService(OptUser).SwapEodCompose(today, yesterday, clientIds); } - - } - /// - /// 追加预付金腿利息归档 - /// - public void ExceuteEodSwapMarginPosi() - { - var settleDate = _context.SettleDate; - var clientIds = _context.Request.ClientIds; - var nextSettleDate = QdpCalendarHelper.GetNonHoliday(settleDate.AddDays(1)); - var days = (nextSettleDate - settleDate).Days; - for (var i = 0; i < days; i++) - { - var yesterday = settleDate.AddDays(i - 1); - var today = settleDate.AddDays(i); - new SwapEodPositionService(OptUser).SwapEodCompose(today, yesterday, clientIds); - } - } - /// - /// 框架合约汇总 - /// - /// - public void ExecuteEodSwap() - { - var settleDate = _context.SettleDate; - var clientIds = _context.Request.ClientIds; - var nextSettleDate = QdpCalendarHelper.GetNonHoliday(settleDate.AddDays(1)); - var days = (nextSettleDate - settleDate).Days; - for (var i = 0; i < days; i++) - { - var yesterday = settleDate.AddDays(i - 1); - var today = settleDate.AddDays(i); - new SwapEodPositionService(OptUser).SwapEodCompose(today, yesterday, clientIds); - } - + } /// /// 计算互换预付金 /// /// - public bool CalculateMargin() + public bool CalculateMargin(DateTime settleDate, DateTime preSettleDate, IEnumerable ClientIds) { - var balanceDate = _context.SettleDate; - var preSettleDate = _context.PreSettleDate; - var reqClientIds = _context.Request.ClientIds; + // 构建请求对象 CalculateMarginRequest request = new CalculateMarginRequest() { - currentDate = balanceDate.ToString("yyyy-MM-dd"), - clientIds = reqClientIds, - preSettleDate= preSettleDate.ToString("yyyy-MM-dd") + currentDate = settleDate.ToString("yyyy-MM-dd"), + clientIds = ClientIds, + preSettleDate = preSettleDate.ToString("yyyy-MM-dd") }; var baseUrl = Environment.GetEnvironmentVariable("BondOmsInterface_BaseUrl"); var calculateMarginUrl = "/marginAlgorithm/triggerMarginCalc"; + if (!string.IsNullOrEmpty(baseUrl)) { var httpHelper = new HttpHelper(baseUrl, null); // http 请求 Web项目接口 var result = httpHelper.PostRequestNoAuth(calculateMarginUrl, request).Result; - if (result!=null&&!result.success) + + if (result != null && !result.success) { throw new ServiceException($"互换预付金计算失败:{result.message}"); } } + return true; } } diff --git a/YLErpDAL/Modules/EodModule/SettlementModule/EodCheckSwapFlow.cs b/YLErpDAL/Modules/EodModule/SettlementModule/EodCheckSwapFlow.cs new file mode 100644 index 00000000..e46b4202 --- /dev/null +++ b/YLErpDAL/Modules/EodModule/SettlementModule/EodCheckSwapFlow.cs @@ -0,0 +1,31 @@ +using Microsoft.EntityFrameworkCore; + +namespace YLErp.Modules.EodModule.SettlementModule +{ + /// + /// 检查日终流水 + /// + public class EodCheckSwapFlow : EodSettleServiceBaseV2 + { + public const string Step = "检查流水"; + + public EodCheckSwapFlow(EodSettlementContextV2 context) : base(context) + { + ResetDbContext(); + } + + /// + /// 检查结算汇率 + /// + public void Execute() + { + var settleDate = _context.SettleDate; + var swapFlowList = DbContext.swap_flow.Where(x=>x.OccurTime==settleDate&&x.DataState==(int)SwapFlowDateStateEnum.等待完成); + + if (swapFlowList.Any()) + { + _context.RaiseError(Step, $"{settleDate:yyyy-MM-dd}有未簿记的流水未处理"); + } + } + } +} diff --git a/YLErpDAL/Modules/EodModule/SettlementModule/EodClientBalanceCalc.cs b/YLErpDAL/Modules/EodModule/SettlementModule/EodClientBalanceCalc.cs index aff6b5a2..dd036bd0 100644 --- a/YLErpDAL/Modules/EodModule/SettlementModule/EodClientBalanceCalc.cs +++ b/YLErpDAL/Modules/EodModule/SettlementModule/EodClientBalanceCalc.cs @@ -5,6 +5,7 @@ using YieldChain.Helpers; using YLErp.BLL; using YLErp.BLL.MarginCalculation; using YLErp.Configuration; +using YLErp.DBModels.Enums; using YLErp.Helpers; using YLErp.Model; using YLErp.Model.Enum; @@ -202,7 +203,9 @@ namespace YLErp.Modules.EodModule.SettlementModule foreach (var currencyCode in currencyCodes) { fundObject.InFund.Add(currencyCode, 0); + fundObject.VmInFund.Add(currencyCode, 0); fundObject.OutFund.Add(currencyCode, 0); + fundObject.VmOutFund.Add(currencyCode, 0); fundObject.NetFund.Add(currencyCode, 0); fundObject.InFundOther.Add(currencyCode, 0); fundObject.OutFundOther.Add(currencyCode, 0); @@ -212,8 +215,10 @@ namespace YLErp.Modules.EodModule.SettlementModule } //入金 var inFund = 0.0; + var vmInFund = 0.0; //出金 var outFund = 0.0; + var vmOutFund = 0.0; //其他收入 var inFundOther = 0.0; //其他支出 @@ -340,9 +345,13 @@ namespace YLErp.Modules.EodModule.SettlementModule throw new Exception("客户:" + client.Name + "未配置结算币种"); } clientbalancedailyPre.FundObject.InFund.Add(client.SettlementCurrency, clientbalancedailyPre.InFund ?? 0); + clientbalancedailyPre.FundObject.VmInFund.Add(client.SettlementCurrency, clientbalancedailyPre.vm_in_fund ?? 0); clientbalancedailyPre.FundObject.InFundSum.Add(client.SettlementCurrency, clientbalancedailyPre.InFundSum ?? 0); + clientbalancedailyPre.FundObject.VmInFundSum.Add(client.SettlementCurrency, clientbalancedailyPre.vm_in_fund_sum ?? 0); clientbalancedailyPre.FundObject.OutFund.Add(client.SettlementCurrency, clientbalancedailyPre.OutFund ?? 0); + clientbalancedailyPre.FundObject.VmOutFund.Add(client.SettlementCurrency, clientbalancedailyPre.vm_out_fund ?? 0); clientbalancedailyPre.FundObject.OutFundSum.Add(client.SettlementCurrency, clientbalancedailyPre.OutFundSum ?? 0); + clientbalancedailyPre.FundObject.VmOutFundSum.Add(client.SettlementCurrency, clientbalancedailyPre.vm_out_fund_sum ?? 0); clientbalancedailyPre.FundObject.NetFund.Add(client.SettlementCurrency, clientbalancedailyPre.NetFund ?? 0); clientbalancedailyPre.FundObject.NetFundSum.Add(client.SettlementCurrency, clientbalancedailyPre.NetFundSum ?? 0); clientbalancedailyPre.FundObject.OtherFund.Add(client.SettlementCurrency, clientbalancedailyPre.OtherFund ?? 0); @@ -364,9 +373,13 @@ namespace YLErp.Modules.EodModule.SettlementModule if (currencyCodes.Count() == 1 && currencyCodes.FirstOrDefault() == string.Empty) { clientbalancedailyPre.FundObject.InFund.Add(string.Empty, clientbalancedailyPre.InFund ?? 0); + clientbalancedailyPre.FundObject.VmInFund.Add(string.Empty, clientbalancedailyPre.vm_in_fund ?? 0); clientbalancedailyPre.FundObject.InFundSum.Add(string.Empty, clientbalancedailyPre.InFundSum ?? 0); + clientbalancedailyPre.FundObject.VmInFundSum.Add(string.Empty, clientbalancedailyPre.vm_in_fund_sum ?? 0); clientbalancedailyPre.FundObject.OutFund.Add(string.Empty, clientbalancedailyPre.OutFund ?? 0); + clientbalancedailyPre.FundObject.VmOutFund.Add(string.Empty, clientbalancedailyPre.vm_out_fund ?? 0); clientbalancedailyPre.FundObject.OutFundSum.Add(string.Empty, clientbalancedailyPre.OutFundSum ?? 0); + clientbalancedailyPre.FundObject.VmOutFundSum.Add(string.Empty, clientbalancedailyPre.vm_out_fund_sum ?? 0); clientbalancedailyPre.FundObject.NetFund.Add(string.Empty, clientbalancedailyPre.NetFund ?? 0); clientbalancedailyPre.FundObject.NetFundSum.Add(string.Empty, clientbalancedailyPre.NetFundSum ?? 0); clientbalancedailyPre.FundObject.OtherFund.Add(string.Empty, clientbalancedailyPre.OtherFund ?? 0); @@ -376,9 +389,13 @@ namespace YLErp.Modules.EodModule.SettlementModule else { clientbalancedailyPre.FundObject.InFund.Add(client.SettlementCurrency, clientbalancedailyPre.InFund ?? 0); + clientbalancedailyPre.FundObject.VmInFund.Add(client.SettlementCurrency, clientbalancedailyPre.vm_in_fund ?? 0); clientbalancedailyPre.FundObject.InFundSum.Add(client.SettlementCurrency, clientbalancedailyPre.InFundSum ?? 0); + clientbalancedailyPre.FundObject.VmInFundSum.Add(client.SettlementCurrency, clientbalancedailyPre.vm_in_fund_sum ?? 0); clientbalancedailyPre.FundObject.OutFund.Add(client.SettlementCurrency, clientbalancedailyPre.OutFund ?? 0); + clientbalancedailyPre.FundObject.VmOutFund.Add(client.SettlementCurrency, clientbalancedailyPre.vm_out_fund ?? 0); clientbalancedailyPre.FundObject.OutFundSum.Add(client.SettlementCurrency, clientbalancedailyPre.OutFundSum ?? 0); + clientbalancedailyPre.FundObject.VmOutFundSum.Add(client.SettlementCurrency, clientbalancedailyPre.vm_out_fund_sum ?? 0); clientbalancedailyPre.FundObject.NetFund.Add(client.SettlementCurrency, clientbalancedailyPre.NetFund ?? 0); clientbalancedailyPre.FundObject.NetFundSum.Add(client.SettlementCurrency, clientbalancedailyPre.NetFundSum ?? 0); clientbalancedailyPre.FundObject.OtherFund.Add(client.SettlementCurrency, clientbalancedailyPre.OtherFund ?? 0); @@ -429,44 +446,35 @@ namespace YLErp.Modules.EodModule.SettlementModule if (clientEntryexit.Direction.Equals("入金")) { - if (fundObject.InFund.ContainsKey(clientEntryexit.CurrencyCode)) + // 根据 cash_type 判断资金进入哪个部分 + if (clientEntryexit.cash_type == CashTypeEnum.初保账户.ToString()) { - fundObject.InFund[clientEntryexit.CurrencyCode] += clientEntryexit.Money ?? 0; + AddToFund(fundObject.InFund, clientEntryexit.CurrencyCode, clientEntryexit.Money ?? 0); + // 更新 NetFund + AddToFund(fundObject.NetFund, clientEntryexit.CurrencyCode, clientEntryexit.Money ?? 0); } else { - fundObject.InFund.Add(clientEntryexit.CurrencyCode, clientEntryexit.Money ?? 0); + AddToFund(fundObject.VmInFund, clientEntryexit.CurrencyCode, clientEntryexit.Money ?? 0); } - if (fundObject.NetFund.ContainsKey(clientEntryexit.CurrencyCode)) - { - fundObject.NetFund[clientEntryexit.CurrencyCode] += clientEntryexit.Money ?? 0; - } - else - { - fundObject.NetFund.Add(clientEntryexit.CurrencyCode, clientEntryexit.Money ?? 0); - } + } else if (clientEntryexit.Direction.Equals("出金")) { - if (fundObject.OutFund.ContainsKey(clientEntryexit.CurrencyCode)) + // 根据 cash_type 判断资金退出到哪个部分 + if (clientEntryexit.cash_type == CashTypeEnum.初保账户.ToString()) { - fundObject.OutFund[clientEntryexit.CurrencyCode] += clientEntryexit.Money ?? 0; + AddToFund(fundObject.OutFund, clientEntryexit.CurrencyCode, clientEntryexit.Money ?? 0); + // 更新 NetFund + AddToFund(fundObject.NetFund, clientEntryexit.CurrencyCode, -(clientEntryexit.Money ?? 0)); } else { - fundObject.OutFund.Add(clientEntryexit.CurrencyCode, clientEntryexit.Money ?? 0); + AddToFund(fundObject.VmOutFund, clientEntryexit.CurrencyCode, clientEntryexit.Money ?? 0); } - if (fundObject.NetFund.ContainsKey(clientEntryexit.CurrencyCode)) - { - fundObject.NetFund[clientEntryexit.CurrencyCode] -= clientEntryexit.Money ?? 0; - } - else - { - fundObject.NetFund.Add(clientEntryexit.CurrencyCode, -clientEntryexit.Money ?? 0); - } } else if (clientEntryexit.Direction.Equals("其他收入")) { @@ -613,84 +621,15 @@ namespace YLErp.Modules.EodModule.SettlementModule }); } - - if (balanceDate >= new DateTime(2021, 6, 25) && PS.Config.Company == CompanyEnum.中金) - { - var clientCashInCashOutHistorys = DbContext.clientcashincashout_history.Where(x => x.ClientId == client.id && x.HappenDate == balanceDate).ToList(); - if (balanceDate == new DateTime(2021, 6, 25)) - { - clientCashInCashOutHistorys = DbContext.clientcashincashout_history.Where(x => x.ClientId == client.id && x.HappenDate <= new DateTime(2021, 6, 25)).ToList(); - } - - clientCashInCashOutHistorys.ForEach(item => - { - if (item.Action.Equals("入金")) - { - if (fundObject.InFund.ContainsKey("CNY")) - { - fundObject.InFund["CNY"] += item.Amount ?? 0; - } - else - { - fundObject.InFund.Add("CNY", item.Amount ?? 0); - } - - if (fundObject.NetFund.ContainsKey("CNY")) - { - fundObject.NetFund["CNY"] += item.Amount ?? 0; - } - else - { - fundObject.NetFund.Add("CNY", item.Amount ?? 0); - } - } - else if (item.Action.Equals("出金")) - { - if (fundObject.OutFund.ContainsKey("CNY")) - { - fundObject.OutFund["CNY"] += Math.Abs(item.Amount ?? 0); - } - else - { - fundObject.OutFund.Add("CNY", Math.Abs(item.Amount ?? 0)); - } - - //出金历史记录为负数,包含方向了 - if (fundObject.NetFund.ContainsKey("CNY")) - { - fundObject.NetFund["CNY"] += item.Amount ?? 0; - } - else - { - fundObject.NetFund.Add("CNY", item.Amount ?? 0); - } - } - else - { - if (item.Action.Equals("期权费")) - { - CurrChangeAmount += item.Amount ?? 0.0; - OptionPremium += item.Amount ?? 0.0; - } - else if (item.Action.Equals("结算金额")) - { - CurrChangeAmount += item.Amount ?? 0.0; - SettlementBalance += item.Amount ?? 0.0; - UnwindBalance += item.Amount ?? 0.0; - } - } - }); - } - foreach (var item in currencyCodes) { if (fundObject.TodayRemainFund.ContainsKey(item)) { - fundObject.TodayRemainFund[item] = (fundObject.LastDayRemainFund.ContainsKey(item) ? fundObject.LastDayRemainFund[item] : 0) + (fundObject.NetFund.ContainsKey(item) ? fundObject.NetFund[item] : 0) + (fundObject.OtherFund.ContainsKey(item) ? fundObject.OtherFund[item] : 0); + fundObject.TodayRemainFund[item] = (fundObject.LastDayRemainFund.ContainsKey(item) ? fundObject.LastDayRemainFund[item] : 0) + (fundObject.NetFund.ContainsKey(item) ? fundObject.NetFund[item] : 0) + (fundObject.VmInFund.ContainsKey(item) ? fundObject.VmInFund[item] : 0) - (fundObject.VmOutFund.ContainsKey(item) ? fundObject.VmOutFund[item] : 0); } else { - fundObject.TodayRemainFund.Add(item, (fundObject.LastDayRemainFund.ContainsKey(item) ? fundObject.LastDayRemainFund[item] : 0) + (fundObject.NetFund.ContainsKey(item) ? fundObject.NetFund[item] : 0) + (fundObject.OtherFund.ContainsKey(item) ? fundObject.OtherFund[item] : 0)); + fundObject.TodayRemainFund.Add(item, (fundObject.LastDayRemainFund.ContainsKey(item) ? fundObject.LastDayRemainFund[item] : 0) + (fundObject.NetFund.ContainsKey(item) ? fundObject.NetFund[item] : 0) + (fundObject.VmInFund.ContainsKey(item) ? fundObject.VmInFund[item] : 0) - (fundObject.VmOutFund.ContainsKey(item) ? fundObject.VmOutFund[item] : 0)); } if ((client.SettlementCurrency ?? "CNY") == item || item == "") @@ -719,7 +658,9 @@ namespace YLErp.Modules.EodModule.SettlementModule CurrAvailAmount += fundObject.TodayRemainFund[item] * rateObj.Rate; LastDayAvailAmount += fundObject.LastDayRemainFund[item] * rateObj.Rate; inFund += fundObject.InFund[item] * rateObj.Rate; + vmInFund += fundObject.VmInFund[item] * rateObj.Rate; outFund += fundObject.OutFund[item] * rateObj.Rate; + vmOutFund += fundObject.VmOutFund[item] * rateObj.Rate; NetFund += fundObject.NetFund[item] * rateObj.Rate; inFundOther += fundObject.InFundOther[item] * rateObj.Rate; outFundOther += fundObject.OutFundOther[item] * rateObj.Rate; @@ -1019,33 +960,6 @@ namespace YLErp.Modules.EodModule.SettlementModule } #endregion - #region 国君收益互换--导入持仓 - - //获取客户导入的所有持仓信息 -- 收益互换(国君) - var clientEodPositionSwapMannual = EodPositionSwapMannual.Where(x => x.ClientId == client.id).ToList(); - if (clientEodPositionSwapMannual.Any()) - { - double swapMargin = 0.0; - double swappv = 0.0; - double swappnl = 0.0; - clientEodPositionSwapMannual.ForEach(x => - { - var underly = underlyDataSource.GetData(x.UnderlyingCode); - var variety = varietyDataSource.GetData(underly.UnderlyingTypeId); - currencyProvider.TryGetCurrencyRate(variety.QuoteCurrency, client.SettlementCurrency, out var rateObj); - //预付金导入是客户方向,其他值是交易员方向 - swapMargin += (x.Margin) * rateObj.Rate; - swappv += (-x.PositionPnl + x.TotalFee) * rateObj.Rate; - swappnl += (-x.PositionPnl * rateObj.Rate); - }); - PayableMargin -= swapMargin; - clientPv = (clientPv ?? 0) + swappv; - roundedClientPv = (roundedClientPv ?? 0) + swappv; - PositionPnl += swappnl; - RoundedPositionPnl += swappnl; - } - - #endregion #region ClientBalacedaily ClientBalace对象赋值 if (client.BoundSide == BoundSideEnum.南向 && clientSpan != null) @@ -1091,7 +1005,9 @@ namespace YLErp.Modules.EodModule.SettlementModule clientbalancedaily.FrozenRedeemFunds = clientFrozenFund.RedeemFunds; clientbalancedaily.MarginBalance = MarginBalance; clientbalancedaily.InFund = inFund; + clientbalancedaily.vm_in_fund = vmInFund; clientbalancedaily.OutFund = outFund; + clientbalancedaily.vm_out_fund = vmOutFund; clientbalancedaily.NetFund = NetFund; clientbalancedaily.OtherFund = OtherFund; clientbalancedaily.IsTradeCredit = IsTradeCredit; @@ -1216,14 +1132,22 @@ namespace YLErp.Modules.EodModule.SettlementModule clientbalancedaily.NetFundSum += clientbalancedaily.FundObject.NetFundSum[item] * rateObj.Rate; clientbalancedailyPre.FundObject.InFundSum.TryGetValue(item, out var preInFundSum); + clientbalancedailyPre.FundObject.VmInFundSum.TryGetValue(item, out var vmpreInFundSum); clientbalancedaily.FundObject.InFund.TryGetValue(item, out var inFundToday); + clientbalancedaily.FundObject.VmInFund.TryGetValue(item, out var vminFundToday); clientbalancedaily.FundObject.InFundSum[item] = preInFundSum + inFundToday; + clientbalancedaily.FundObject.VmInFundSum[item] = vmpreInFundSum + vminFundToday; clientbalancedaily.InFundSum += clientbalancedaily.FundObject.InFundSum[item] * rateObj.Rate; + clientbalancedaily.vm_in_fund_sum += clientbalancedaily.FundObject.VmInFundSum[item] * rateObj.Rate; clientbalancedailyPre.FundObject.OutFundSum.TryGetValue(item, out var preOutFundSum); clientbalancedaily.FundObject.OutFund.TryGetValue(item, out var outFundToday); + clientbalancedailyPre.FundObject.VmOutFundSum.TryGetValue(item, out var vmpreOutFundSum); + clientbalancedaily.FundObject.VmOutFund.TryGetValue(item, out var vmoutFundToday); clientbalancedaily.FundObject.OutFundSum[item] = preOutFundSum + outFundToday; + clientbalancedaily.FundObject.VmOutFundSum[item] = vmpreOutFundSum + vmoutFundToday; clientbalancedaily.OutFundSum += clientbalancedaily.FundObject.OutFundSum[item] * rateObj.Rate; + clientbalancedaily.vm_out_fund_sum += clientbalancedaily.FundObject.VmOutFundSum[item] * rateObj.Rate; clientbalancedailyPre.FundObject.OtherFundSum.TryGetValue(item, out var preOtherFundSum); clientbalancedaily.FundObject.OtherFund.TryGetValue(item, out var otherFundToday); @@ -1246,11 +1170,15 @@ namespace YLErp.Modules.EodModule.SettlementModule clientbalancedaily.FundObject.NetFundSum = clientbalancedaily.FundObject.NetFund; clientbalancedaily.FundObject.InFundSum = clientbalancedaily.FundObject.InFund; clientbalancedaily.FundObject.OutFundSum = clientbalancedaily.FundObject.OutFund; + clientbalancedaily.FundObject.VmInFundSum = clientbalancedaily.FundObject.VmInFund; + clientbalancedaily.FundObject.VmOutFundSum = clientbalancedaily.FundObject.VmOutFund; clientbalancedaily.FundObject.OtherFundSum = clientbalancedaily.FundObject.OtherFund; clientbalancedaily.NetFundSum = clientbalancedaily.NetFund; clientbalancedaily.InFundSum = clientbalancedaily.InFund; + clientbalancedaily.vm_in_fund_sum= clientbalancedaily.vm_in_fund; clientbalancedaily.OutFundSum = clientbalancedaily.OutFund; + clientbalancedaily.vm_out_fund_sum = clientbalancedaily.vm_out_fund; clientbalancedaily.OtherFundSum = clientbalancedaily.OtherFund; } @@ -1375,5 +1303,16 @@ namespace YLErp.Modules.EodModule.SettlementModule return true; } + private void AddToFund(Dictionary fundDictionary, string currencyCode, double amount) + { + if (fundDictionary.ContainsKey(currencyCode)) + { + fundDictionary[currencyCode] += amount; + } + else + { + fundDictionary.Add(currencyCode, amount); + } + } } } \ No newline at end of file diff --git a/YLErpDAL/Modules/EodModule/SettlementModule/EodTaskRunner.cs b/YLErpDAL/Modules/EodModule/SettlementModule/EodTaskRunner.cs index d632c345..c3e49995 100644 --- a/YLErpDAL/Modules/EodModule/SettlementModule/EodTaskRunner.cs +++ b/YLErpDAL/Modules/EodModule/SettlementModule/EodTaskRunner.cs @@ -489,7 +489,8 @@ where {nameof(t.TaskStartTime)}>'{startDateStr}' and {nameof(t.TaskState)}={(int { new EodCheckCurrency(_context).Execute(); } - + SetTaskStep("检查日终流水"); + new EodCheckSwapFlow(_context).Execute(); tasks = new Task[3]; tasks[0] = Task.Run(() => @@ -497,9 +498,6 @@ where {nameof(t.TaskStartTime)}>'{startDateStr}' and {nameof(t.TaskState)}={(int SetTaskStep("检查标的到期日"); new EodCheckMaturityDate(_context).Execute();//t - SetTaskStep("合成篮子标的价格"); - new EodBasketPriceSaveService(_context).Execute();//t - if (PS.Config.ErpElement.SupportMultiCalendar) { SetTaskStep("为处于节假日的交易标的复制上日收盘价"); @@ -508,121 +506,17 @@ where {nameof(t.TaskStartTime)}>'{startDateStr}' and {nameof(t.TaskState)}={(int SetTaskStep("检查标的结算价格缺失"); new EodCheckSettlePrice(_context).Execute();//t - - if (PS.Config.Is厦门象屿) - { - SetTaskStep("检查标的参考价格缺失"); - new EodCheckReferencePrice(_context).Execute();//t - } }); - - if (_request.IsSettleOtcTrades) - { - tasks[1] = Task.Run(() => - { - //SetTaskStep("合成多空组合流水"); - //new EodHandleSwapFlowService(_context).Execute(); - - SetTaskStep("检查当日交易"); - new EodCheckNewTrade(_context).Execute();//t - - SetTaskStep("日终结算检查"); - new EodCheckVolService(_context).Execute();//t - - SetTaskStep("合成互换交易"); - new TradeSwapFlowMoreCheck(_context).Execute();//t - }); - } - - if (_request.IsSettleOtcTrades) - { - tasks[2] = Task.Run(() => - { - SetTaskStep("汇率收盘结算"); - new EodCurrencyRateService(_request.UserInfo).HandleAmountByCurrencyRate(_context.SettleDate, _context.Request.ClientIds);//t - }); - } - WaitTasks(tasks); if (_request.IsSettleOtcTrades) { - tasks = new[] - { - Task.Run(() => - { - SetTaskStep("检查期权观察状态1"); - new EodCheckMonitoredTrade(_context).ExecuteTask1(SetTaskStep);//t - }), - Task.Run(() => - { - SetTaskStep("检查期权观察状态2"); - new EodCheckMonitoredTrade(_context).ExecuteTask2(SetTaskStep);//t - }), - // Task.Run(() => - //{ - // SetTaskStep("定期结算互换收益"); - // new EodCheckMonitoredTrade(_context).ExecuteBalanceSwapProfit(SetTaskStep);//t - //}) - Task.Run(() => - { - SetTaskStep("定期归档收益互换"); - new EodCheckMonitoredTrade(_context).ExecuteEodSwapPosition(SetTaskStep);//t - }) - }; - - WaitTasks(tasks); - - SetTaskStep("自动延期结算"); - new EodDelaySettlementTrade(_context).Execute(_report.SetErrorTips);//t - + SetTaskStep("检查当日交易"); + new EodCheckNewTrade(_context).Execute();//t SetTaskStep("检查当日到期交易"); new EodCheckMaturityTrade(_context).Execute();//t + SetTaskStep("定期归档收益互换"); + new EodCheckMonitoredTrade(_context).ExecuteEodSwapPosition(SetTaskStep);//t } - new EodCheckMonitoredTrade(_context).CalculateMargin(); - new EodCheckMonitoredTrade(_context).ExecuteEodSwap(); - tasks = new Task[4]; - - if (_request.IsSettleExchangeTrades) - { - //tasks[0] = Task.Run(() => - //{ - // if (_context.Request.ClientIds == null) - // { - // SetTaskStep("场内期权结算"); - // new ExchangeOptionSettlementService(_context.UserInfo).Execute(_context.SettleDate); //t - // } - //}); - - - } - - if (_request.IsSettleOtcTrades) - { - tasks[0] = Task.Run(() => - { - SetTaskStep("备份场外交易"); - SaveEodTrade(_context, _cancellationTokenSource.Token);//t - }); - tasks[1] = Task.Run(() => - { - SetTaskStep("检查权利金应付日"); - new EodCheckPremiumPayDate(_context).Execute();//t - }); - - if (_context.SettlementConfig.CalcForwradMargin) - { - tasks[2] = Task.Run(() => - { - SetTaskStep("远期预付金成本结算"); - new EodForwardMarginSettlement(_context).Execute();//t - }); - } - } - - //敏感数据计算 - - - WaitTasks(tasks); } SetTaskStep("日终持仓结算"); @@ -648,61 +542,7 @@ where {nameof(t.TaskStartTime)}>'{startDateStr}' and {nameof(t.TaskState)}={(int SetTaskStep("结算客户资金"); new EodClientBalanceCalc(_context).ClientBalanceCalc(); - - //客户资金买卖权分开算 - if (_context.SettlementConfig.CalcBuySell) - { - new EodClientBalanceCalcBS(_context.UserInfo).ClientBalanceByDay(_context.SettleDate, null); - } _context.LogInfo("结束任务:结算客户资金"); - - if (PS.Config.ErpElement.UseSettleDataAcquisition) - { - SetTaskStep("配合数据采集,限额监控数据落地"); - var service = new QuotaMonitorService(_context.UserInfo); - if (_context.IsCurrentDay) - { - service.EodSettlementExecute(_context.SettleDate); - } - - service.EodSensitiveDataCalc(_context); - - _context.LogInfo("结束任务:限额监控数据落地"); - } - - //todo:客户日终结算完成发送行权到期邮件提醒 - - tasks = new Task[2]; - - if (_request.IsSettleExchangeTrades) - { - tasks[0] = Task.Run(() => - { - SetTaskStep("准备次日数据"); - new EodDividenService(_context).Execute(eodPositionService.EodTradePositions);//t - }); - } - - if (_request.IsSettleOtcTrades) - { - tasks[1] = Task.Run(() => - { - SetTaskStep("除权除息"); - var otcTrades = _context.OtcTrades.Where(t => !ConsTrade.TradeCompleteStatus.Contains(t.TradeStatus)).ToList(); - var tradeIds = otcTrades.Select(O => O.id); - var parentTradeIds = otcTrades.Where(O => O.ParentTradeId > 0 && !tradeIds.Contains(O.ParentTradeId)).Select(O => O.ParentTradeId).ToHashSet(); - if (parentTradeIds.Any()) - { - using var db = DbContextFactory.GetYLDbContext(); - var parentTrades = new TradeDalService(_context.UserInfo).GetTradeOrEodTrade(parentTradeIds, _context.SettleDate); - otcTrades.AddRange(parentTrades); - } - new EodDividenService(_context).Execute(otcTrades); - - }); - } - - WaitTasks(tasks); } _cancellationTokenSource.Token.ThrowIfCancellationRequested(); @@ -711,32 +551,6 @@ where {nameof(t.TaskStartTime)}>'{startDateStr}' and {nameof(t.TaskState)}={(int //{ AddOrUpdateEodStatus(_request); //} - - //兴证日终持仓数据上传数据中心的FTP服务器 - if (PS.Config.Company == CompanyEnum.兴证 && _context.IsCurrentDay) - { - Task.Run(() => XingZhengService.EodExecute(_context)); - } - - //日终数据采集 - if (PS.Config.Company == CompanyEnum.长江) - { - Task.Run(() => ChangJiangService.EodExecute(_context, _request.VolType, _request.UseClosePrice ? "收盘价" : "结算价")); - } - - //东证 - if (PS.Config.Company == CompanyEnum.润和) - { - Task.Run(() => DongZhengService.EodExecute(_context)); - } - - - //广发商贸 - if (PS.Config.Company == CompanyEnum.广发商贸 && _request.VolType == "对冲" && _request.UseClosePrice) - { - Task.Run(() => GuangFaService.EodExecute(_context)); - } - sw.Stop(); elapsedMilliseconds = sw.ElapsedMilliseconds; diff --git a/YLErpDAL/Modules/MarginModule/MarginRateSwapService.cs b/YLErpDAL/Modules/MarginModule/MarginRateSwapService.cs index f00f87cc..0681cdeb 100644 --- a/YLErpDAL/Modules/MarginModule/MarginRateSwapService.cs +++ b/YLErpDAL/Modules/MarginModule/MarginRateSwapService.cs @@ -82,10 +82,9 @@ namespace YLErp.Modules.MarginModule { ClientName = reader.GetString("客户名称", false), ValueDate = reader.GetDate("起效日期", true) ?? DateTime.Now, - InitMarginRate = reader.GetPercent("期初预付金", false) ?? 0, - InitMarginRebateRate = reader.GetDecimalPercent("期初预付金利率", false) ?? 0, - AddToMarginRebateRate= reader.GetDecimalPercent("追加预付金利率", false) ?? 0, - SwapEndDays=reader.GetInt("互换默认期限",true) + InitMarginRate = reader.GetPercent("初始保证金率", true) ?? 0, + MaintenanceRate = reader.GetPercent("维持保证金率", true) ?? 0, + SwapEndDays =reader.GetInt("互换默认期限",true) }; var client = new Client(); marginRate.Type = "普通"; @@ -133,6 +132,7 @@ namespace YLErp.Modules.MarginModule dbMarginRate.LongInitMarginRate = marginrate.LongInitMarginRate; dbMarginRate.ShortInitMarginRate = marginrate.ShortInitMarginRate; dbMarginRate.SwapEndDays = marginrate.SwapEndDays; + dbMarginRate.MaintenanceRate= marginrate.MaintenanceRate; dbMarginRate.OptId = UserId; dbMarginRate.OptName = UserName; dbMarginRate.OptDate = DateTime.Now; @@ -167,6 +167,7 @@ namespace YLErp.Modules.MarginModule dbMarginRate.LongInitMarginRate = marginrate.LongInitMarginRate; dbMarginRate.ShortInitMarginRate = marginrate.ShortInitMarginRate; dbMarginRate.SwapEndDays = marginrate.SwapEndDays; + dbMarginRate.MaintenanceRate = marginrate.MaintenanceRate; dbMarginRate.OptId = UserId; dbMarginRate.OptName = UserName; dbMarginRate.OptDate = DateTime.Now; diff --git a/YLErpDAL/Modules/ReportModule/SettlementReportModule/FundReportModel.cs b/YLErpDAL/Modules/ReportModule/SettlementReportModule/FundReportModel.cs index 5b1c8008..b5b99fee 100644 --- a/YLErpDAL/Modules/ReportModule/SettlementReportModule/FundReportModel.cs +++ b/YLErpDAL/Modules/ReportModule/SettlementReportModule/FundReportModel.cs @@ -17,7 +17,66 @@ namespace YLErp.Modules.ReportModule return ((LastDayRemainFund == null || LastDayRemainFund == -0) ? 0 : LastDayRemainFund.Value).ToString("0.00"); } } + /// + /// 初始保证金金额 + /// + public double? MySideMargin { get; set; } + public string MySideMarginString + { + get + { + return ((MySideMargin == null || MySideMargin == -0) ? 0 : MySideMargin.Value).ToString("0.00"); + } + } + /// + /// 预付金余额 + /// + public double? MarginBalance { get; set; } + + public string MarginBalanceString + { + get + { + return ((MarginBalance == null || MarginBalance == -0) ? 0 : MarginBalance.Value).ToString("0.00"); + } + } + /// + /// 初保账户 + /// + public double? NetFundAll { get; set; } + + public string NetFundAllString + { + get + { + return ((NetFundAll == null || NetFundAll == -0) ? 0 : NetFundAll.Value).ToString("0.00"); + } + } + /// + /// 盯市金额 + /// + public double? SwapMarketAmount { get; set; } + + public string SwapMarketAmountString + { + get + { + return ((SwapMarketAmount == null || SwapMarketAmount == -0) ? 0 : SwapMarketAmount.Value).ToString("0.00"); + } + } + /// + /// 追保账户 + /// + public double? VmFundSum { get; set; } + + public string VmFundSumString + { + get + { + return ((VmFundSum == null || VmFundSum == -0) ? 0 : VmFundSum.Value).ToString("0.00"); + } + } /// /// 上日资金(包含抵押金额) /// diff --git a/YLErpDAL/Modules/ReportModule/SettlementReportModule/SettlementReportFotShanXiService.cs b/YLErpDAL/Modules/ReportModule/SettlementReportModule/SettlementReportFotShanXiService.cs index 424f0777..a6411295 100644 --- a/YLErpDAL/Modules/ReportModule/SettlementReportModule/SettlementReportFotShanXiService.cs +++ b/YLErpDAL/Modules/ReportModule/SettlementReportModule/SettlementReportFotShanXiService.cs @@ -261,7 +261,7 @@ namespace YLErp.Modules.ReportModule.SettlementReportModule modelDict.Add("质押记录", report.clientcashincashout_productLinq); } var sourcePath = OtcAppContext.MapPath("~/App_Docs/导出模板"); - string sourceFileName = Path.Combine(sourcePath, $"结算报告模板_{PS.Config.Company}.xlsx"); + string sourceFileName = Path.Combine(sourcePath, $"结算报告模板.xlsx"); ExcelPackage.LicenseContext = LicenseContext.NonCommercial; var pdffile = ExcelTemplate.GeneratePDFFromExeclTemplate(sourcePath, sourceFileName, modelDict, targetPath, targetFileName , shouldDeleteSheet: true, needToPdf: false); @@ -288,7 +288,7 @@ namespace YLErp.Modules.ReportModule.SettlementReportModule { LastDayRemainFund = clientBalance?.LastDayRemainFund ?? 0, LastDayRemainFundWithProduct = clientBalance?.LastDayRemainFundWithProduct ?? 0, - CashInCashOutChange = clientBalance?.NetFund ?? 0, + CashInCashOutChange = clientBalance?.NetFundAll ?? 0, CashInChange = clientBalance?.InFund ?? 0, CashOutChange = clientBalance?.OutFund ?? 0, CashInCashOutOther = clientBalance?.OtherFund ?? 0, @@ -326,7 +326,12 @@ namespace YLErp.Modules.ReportModule.SettlementReportModule TotalNetSettlement = clientBalance?.TotalNetSettlementTotal ?? 0, ClientSellPositionPnl = clientBalance?.ClientSellPositionPnl, FreezePremium = clientBalance?.FreezePremium, - EndDesirableFund = clientBalance?.EndDesirableFund ?? 0 + EndDesirableFund = clientBalance?.EndDesirableFund ?? 0, + MySideMargin= clientBalance?.MySideMargin, + MarginBalance= clientBalance?.MarginBalance, + NetFundAll = clientBalance?.NetFundAll, + SwapMarketAmount= clientBalance?.SwapMarketAmount, + VmFundSum= clientBalance?.VmFundSum, }; return FundReportModel; } @@ -381,17 +386,12 @@ namespace YLErp.Modules.ReportModule.SettlementReportModule { return QdpCalendarHelper.GetNonHoliday(DateTime.Now < DateTime.Now.Date.AddHours(9).AddMinutes(30) ? DateTime.Now : DateTime.Now.AddDays(1)).ToString("yyyy年MM月dd日") + "上午9:30"; } - case "追保金额": return report.FundReportModel.MarginString; - case "大写追保金额": return NumberHelper.CmycurD(report.FundReportModel.Margin ?? 0); - case "应付资金总额": return report.FundReportModel.PayableFundString; - case "大写应付资金总额": return NumberHelper.CmycurD(report.FundReportModel.PayableFund ?? 0); + case "追保金额": return report.FundReportModel.PositionTradePayableFundString; + case "大写追保金额": return NumberHelper.CmycurD(report.FundReportModel.PositionTradePayableFund ?? 0); + case "预付金余额": return report.FundReportModel.MarginBalanceString; + case "初始保证金金额": return report.FundReportModel.MySideMarginString; case "发送日期": return DateTime.Now.ToString("yyyy-MM-dd"); - case "预付金占用": return report.FundReportModel.WorstCastClientPayableString; case "可用资金": return report.FundReportModel.AvailableFundString; - case "授信额度": return report.FundReportModel.CreditString; - case "应付了结交易款": return report.FundReportModel.ClosedTradePayableFundString; - case "应付存续交易款": return report.FundReportModel.PositionTradePayableFundString; - case "存续交易期权费净额": return report.FundReportModel.PositionPremiumNetCashString; case "可取资金": return report.FundReportModel.DesirableFundString; case "起始日期": return report.ReportFrom.ToString("yyyy-MM-dd"); case "结束日期": return report.ReportEnd.ToString("yyyy-MM-dd"); diff --git a/YLErpDAL/Modules/RiskModule/QuotaMonitorService.cs b/YLErpDAL/Modules/RiskModule/QuotaMonitorService.cs index c2b5f0d4..159ceb0e 100644 --- a/YLErpDAL/Modules/RiskModule/QuotaMonitorService.cs +++ b/YLErpDAL/Modules/RiskModule/QuotaMonitorService.cs @@ -4096,6 +4096,11 @@ namespace YLErp.Modules.RiskModule { throw new ServiceException("未找到客户信息"); } + var dealDate = DateTime.Parse(clientRiskCheckReq.dealDate); + if (client.EvaluateExpireDate< dealDate) + { + throw new ServiceException("适当性评估已经过期,只有在适当性有效期内才可以新开仓"); + } using var bondDb = new BondOmsDBContext(); var (clientPositions, clientOrderPositions) = GetClientPositionsAndOrders(bondDb, clientRiskCheckReq.orderId); var position = clientPositions @@ -4106,7 +4111,7 @@ namespace YLErp.Modules.RiskModule AddClientRiskCheckPosition(clientRiskCheckReq, clientPositions); var umCodes = GetUnderlyingCodes(clientPositions, clientRiskCheckReq.securityId); var ums = GetUnderlyings(umCodes); - var dealDate = DateTime.Parse(clientRiskCheckReq.dealDate); + var checkPoisiList = BuildCheckQuotaMoitorModels(clientPositions, ums, dealDate); foreach (var settingItem in precheckQuotaSettingList) { @@ -4150,15 +4155,14 @@ namespace YLErp.Modules.RiskModule } private (List, List) GetClientPositionsAndOrders(BondOmsDBContext bondDb, long orderId) { - var clientLongIds = DataCacheProvider.GetClientDataSource() - .AsQueryable() - .Where(s => s.BusinessUseType == "否") - .Select(s => (long)s.id) - .ToList(); - var clientPositions = bondDb.client_position.Where(x => clientLongIds.Contains(x.client_id ?? 0)).AsNoTracking().ToList(); + var clientPositions = bondDb.client_position.AsNoTracking().ToList(); var startDate = DateTime.Now.Date; var nextDate = startDate.AddDays(1); var clientOrderPositions = bondDb.client_order.Where(x => x.status == 0 && x.create_time > startDate && x.create_time < nextDate && x.id != orderId).AsNoTracking().ToList(); + clientPositions.ForEach(x => + { + x.position_qty *= 10000; + }); return (clientPositions, clientOrderPositions); } /// @@ -4170,29 +4174,48 @@ namespace YLErp.Modules.RiskModule /// private List FilterPrecheckQuotaSettings(List precheckQuotaSettingList, ClientRiskCheckItemParam clientRiskCheckReq) { - // 过滤出与当前客户端相关的配额设置 - var clientPrecheckQuotaSettingList = precheckQuotaSettingList - .Where(x => x.QuotaRange == clientRiskCheckReq.clientId && x.QuotaType == QuotaTypeEnum.CLIENT) - .ToList(); - - // 过滤出所有客户端通用的配额设置 - var allClientPrecheckQuotaSettingList = precheckQuotaSettingList - .Where(x => x.QuotaRange == 0 && x.QuotaType == QuotaTypeEnum.CLIENT) - .ToList(); - - // 获取底层数据源 + var clientId = clientRiskCheckReq.clientId; var um = DataCacheProvider.GetUnderlyingDataSource().GetData(clientRiskCheckReq.securityId); - var noneClientAllUnderlyingPrecheckQuotaSettingList = precheckQuotaSettingList - .Where(x => x.QuotaType == QuotaTypeEnum.UNDERLYING) - .ToList(); - // 处理客户端相关的配额设置 - if (clientPrecheckQuotaSettingList.Count > 0) - { - precheckQuotaSettingList = precheckQuotaSettingList - .Except(allClientPrecheckQuotaSettingList) - .ToList(); - } - return precheckQuotaSettingList; + var underlyingId = um?.id; + + // 分离三种类型数据 + var clientQuotas = precheckQuotaSettingList.Where(x => x.QuotaType == QuotaTypeEnum.CLIENT); + var underlyingQuotas = precheckQuotaSettingList.Where(x => x.QuotaType == QuotaTypeEnum.UNDERLYING); + var otherQuotas = precheckQuotaSettingList.Where(x => + x.QuotaType != QuotaTypeEnum.CLIENT && + x.QuotaType != QuotaTypeEnum.UNDERLYING + ); + // 1. CLIENT类型处理(按QuotaIndex分组+三层优先级) + var filteredClient = clientQuotas + .GroupBy(x => x.QuotaIndex) + .SelectMany(g => { + // 优先级1: QuotaRange=clientId + var p1 = g.Where(x => x.QuotaRange == clientId); + if (p1.Any()) return p1; + + // 优先级2: QuotaRange=0 + return g.Where(x => x.QuotaRange == 0); + }) + .ToList(); + + + // 2. UNDERLYING类型分层筛选 + var filteredUnderlying = underlyingQuotas + .GroupBy(x => x.QuotaIndex) + .SelectMany(g => { + // 优先级1: QuotaRange=underlyingId + var p1 = g.Where(x => x.QuotaRange == underlyingId); + if (p1.Any()) return p1; + + // 优先级2: QuotaRange=0 + return g.Where(x => x.QuotaRange == 0); + }).ToList(); + + // 3. 合并所有类型(保留其他类型原样) + return filteredClient + .Concat(filteredUnderlying) + .Concat(otherQuotas) + .ToList(); } /// /// 构建风控指标类 @@ -4234,8 +4257,8 @@ namespace YLErp.Modules.RiskModule full_price_now = item.full_price, deal_full_price_avg = item.full_price ?? 0, client_id = item.client_id, - position_qty = item.order_qty, - position_notional_principal = item.full_price * item.order_qty* ConsGlobal.bondPriceMultiple, + position_qty = item.order_qty*10000, + position_notional_principal = item.full_price * item.order_qty* ConsGlobal.bondPriceMultiple * 10000, direction = (int)SwapDirectionEnum.支付, id = item.id, Current = false, @@ -4259,11 +4282,11 @@ namespace YLErp.Modules.RiskModule deal_full_price_avg = clientRiskCheckReq.price * ConsGlobal.bondShowPriceMultiple, client_id = clientRiskCheckReq.clientId, position_qty = clientRiskCheckReq.qty, - position_notional_principal = clientRiskCheckReq.amount, direction = (int)SwapDirectionEnum.支付, id = clientRiskCheckReq.orderId, Current = true, }; + posi.position_notional_principal = posi.position_qty * posi.deal_full_price_avg* ConsGlobal.bondPriceMultiple; clientPositions.Add(posi); } /// @@ -5296,6 +5319,7 @@ namespace YLErp.Modules.RiskModule switch (checkItem.quotaType) { case "轧差名义本金": + currentValue = Math.Abs(Convert.ToDouble(currentPv)); if (!ValidateQuoteResult(checkItem, currentValue, posiVal)) { return checkItem; diff --git a/YLErpDAL/Modules/SwapModule/SwapEodPositionService.cs b/YLErpDAL/Modules/SwapModule/SwapEodPositionService.cs index 251d1229..6af4a5e0 100644 --- a/YLErpDAL/Modules/SwapModule/SwapEodPositionService.cs +++ b/YLErpDAL/Modules/SwapModule/SwapEodPositionService.cs @@ -100,7 +100,6 @@ namespace YLErp.Modules.SwapModule var tradePositionList = allTradePositionList.Where(t => t.IsInitial).ToList(); var tradeRealPositionList = allTradePositionList.Where(t => !t.IsInitial).ToList(); var tradeExtendList = DbContext.trade_extend.Where(x => tradeIds.Contains(x.TradeId)).ToList(); - var eodSwapPositionList = DbContext.eod_swap_position.Where(x => x.ValueDate >= preSettleDate && x.ValueDate <= settleDate && tradeIds.Contains(x.SwapTradeId) && !x.Invalid).ToList(); var eodSwapList = DbContext.eod_swap.Where(x => x.ValueDate == preSettleDate).ToList(); List eventTyps = new List() { (int)SwapEventTypeEnum.平仓, (int)SwapEventTypeEnum.互换, (int)SwapEventTypeEnum.自动互换 }; foreach (var td in tradeQueryList) @@ -123,7 +122,7 @@ namespace YLErp.Modules.SwapModule { throw new Exception($"交易{td.TradeNumber}在上一交易日【{preSettleDate:yyyy-MM-dd}】未收盘"); } - var allEodPositions = eodSwapPositionList.Where(x => x.ValueDate >= preSettleDate && x.SwapTradeId == td.id && !x.Invalid); + var allEodPositions = DbContext.eod_swap_position.Where(x => x.ValueDate >= preSettleDate && x.SwapTradeId == td.id && !x.Invalid); var eodPositions = allEodPositions.Where(x => x.ValueDate == preSettleDate).ToList();//上一日终持仓信息 @@ -828,17 +827,18 @@ namespace YLErp.Modules.SwapModule newEodPayPosition.InterestDirection = position.InterestDirection; newEodPayPosition.InterestMode = position.InterestMode; newEodPayPosition.InterestPrincipalFix = position.InterestPrincipalFix; + newEodPayPosition.InterestPrincipalFix *= (1 - closePercent); newEodPayPosition.InterestRateDefault = position.InterestRateDefault; newEodPayPosition.InterestSwapInterval = position.InterestSwapInterval; newEodPayPosition.IsAnnualized = position.IsAnnualized; newEodPayPosition.HappenDate = position.HappenDate; newEodPayPosition.Currency = position.Currency; newEodPayPosition.InterestType = position.InterestType; - newEodPayPosition.interest_rest_days = position.interest_rest_days; - newEodPayPosition.interest_rule = position.interest_rule; newEodPayPosition.FloatRate = interests.Count > 0 ? interests.First().FloatRate ?? 0 : 0; newEodPayPosition.FloatRateUnderlyingCode = position.FloatRateUnderlyingCode; newEodPayPosition.InterestFeePending = 0; + newEodPayPosition.interest_rest_days = position.interest_rest_days; + newEodPayPosition.interest_rule = position.interest_rule; //利息端估值用信息 newEodPayPosition.TdInterestPrincipal = interests.Count > 0 ? interests.First().InterestPrincipal : 0; newEodPayPosition.TdInterestPrincipal *= (1 - closePercent); @@ -850,19 +850,17 @@ namespace YLErp.Modules.SwapModule { newEodPayPosition.TdInterestRate = flowEvents.FirstOrDefault()?.InterestRate ?? 0; } - //当日已实现,平仓时已处理 newEodPayPosition.TdInterestFee = flowEvents.Sum(s => s.InterestFee); newEodPayPosition.TdCloseInterestFee = newEodPayPosition.TdInterestFee; + newEodPayPosition.TdCloseInterest = flowEvents.Sum(s => s.InterestClosePnL); if (closePercent == 1) { - newEodPayPosition.TdCloseInterest = eodPayPosition.InterestIncomeSum; newEodPayPosition.InterestIncomeSum = 0; } else { - newEodPayPosition.TdCloseInterest = (eodPayPosition.InterestIncomeSum + TdInterestAmount) * closePercent; - newEodPayPosition.InterestIncomeSum = eodPayPosition.InterestIncomeSum + TdInterestAmount - newEodPayPosition.TdCloseInterest; + newEodPayPosition.InterestIncomeSum = eodPayPosition.InterestIncomeSum + TdInterestAmount - Math.Abs(newEodPayPosition.TdCloseInterest); } //持仓内容-利息腿-损益统计(本方视角) newEodPayPosition.TdInterestIncome = TdInterestAmount * (1 - closePercent); @@ -872,7 +870,7 @@ namespace YLErp.Modules.SwapModule newEodPayPosition.SwapPositionValue = newEodPayPosition.InterestProfitSum + newEodPayPosition.PosiProfitSum; //累计已实现 - newEodPayPosition.RealizedInterest = eodPayPosition.RealizedInterest + newEodPayPosition.TdCloseInterest * ratio; + newEodPayPosition.RealizedInterest = eodPayPosition.RealizedInterest + newEodPayPosition.TdCloseInterest; newEodPayPosition.RealizedInterestFee = eodPayPosition.RealizedInterestFee + newEodPayPosition.TdCloseInterestFee; newEodPayPosition.RealizedPnl = newEodPayPosition.RealizedInterest + newEodPayPosition.RealizedInterestFee; var currencyRate = new EodCurrencyRateService(UserInfo).GetCurrencyRate(td.QuoteCurrency, td.SettlementCurrency, valueDate @@ -1461,19 +1459,9 @@ namespace YLErp.Modules.SwapModule interestPnL += x.InterestProfitSum * ratio; }); eod_Swap.InterestPnL = interestPnL; - decimal tdRealizedPnL = 0; - eodSwapPositions.ForEach(x => - { - decimal ratio = x.InterestDirection == (int)SwapDirectionEnum.收取 ? 1 : -1;//收取为正,支付为负 - if (marginTypes.Contains(x.InterestMode)) - { - ratio = -ratio; - } - tdRealizedPnL += x.TdCloseMtmPnl + x.TdCloseDividend + x.TdCloseFee + x.TdCloseInterest * ratio + x.TdCloseInterestFee; - }); - eod_Swap.TdRealizedPnL = tdRealizedPnL; eod_Swap.PostionValue = eodSwapPositions.Sum(s => s.SwapPositionValue); - eod_Swap.RealizedPnL = eodSwapPositions.Sum(s => s.RealizedMtmPnL + s.RealizedDividend + s.RealizedFee + s.RealizedInterest + s.RealizedInterestFee); + eod_Swap.RealizedPnL = eodSwapPositions.Sum(s => s.RealizedPnl); + eod_Swap.TdRealizedPnL = eod_Swap.RealizedPnL - (preEodSwap?.RealizedPnL ?? 0); eod_Swap.TdCloseQty = positions.Sum(s => s.TdCloseQty); var initMargin = Convert.ToDecimal(tradeSpan?.InitialMargin ?? 0); var maintainMargin = Convert.ToDecimal(tradeSpan?.WorstCastClientPayable ?? 0); diff --git a/YLErpDAL/Modules/SwapModule/SwapTradeAutoService.cs b/YLErpDAL/Modules/SwapModule/SwapTradeAutoService.cs index 12c6ba89..54f3a60a 100644 --- a/YLErpDAL/Modules/SwapModule/SwapTradeAutoService.cs +++ b/YLErpDAL/Modules/SwapModule/SwapTradeAutoService.cs @@ -280,7 +280,7 @@ namespace YLErp.Modules.SwapModule /// 簿记前自动校验 /// /// - public void BookingValidate(List mergeList) + public void BookingValidate(List mergeList,DateTime valueDate) { foreach (var merge in mergeList) { diff --git a/YLErpDAL/Modules/SwapModule/SwapTradeService.cs b/YLErpDAL/Modules/SwapModule/SwapTradeService.cs index ee8c8200..55124b26 100644 --- a/YLErpDAL/Modules/SwapModule/SwapTradeService.cs +++ b/YLErpDAL/Modules/SwapModule/SwapTradeService.cs @@ -253,7 +253,7 @@ namespace YLErp.Modules.SwapModule bool cashNeedAfter = false) { var td = PrepareTrade(flowMerge, client, asset, underlying, clientMarginTemplate?.SwapEndDays??14, structureType); - PrepareTradeExtend(flowMerge, td, underlying, swapFloatRate, clientMarginTemplate); + PrepareTradeExtend(flowMerge, td, underlying, swapFloatRate); td.TradeNumber = BizLogicSingleton.Instance.GenerateTradeNumberBeforeConfirm(td, DbContext); flowMerge.SwapTradeNo = td.TradeNumber; PrepareSwapTrade(td, TradeSourceEnum.系统交易, underlying); @@ -359,7 +359,7 @@ namespace YLErp.Modules.SwapModule /// /// /// - private void PrepareTradeExtend(swap_flow_merge flowMerge, trade td, underlying_manager underlying, SwapFloatRate swapFloatRate, client_marginrate clientMarginTemplate) + private void PrepareTradeExtend(swap_flow_merge flowMerge, trade td, underlying_manager underlying, SwapFloatRate swapFloatRate) { swap_position floatPosition = new swap_position() { @@ -387,53 +387,6 @@ namespace YLErp.Modules.SwapModule UnderlyingInstrumentType = underlying.UnderlyingInstrumentType }; td.swap_positions.Add(floatPosition); - if (clientMarginTemplate != null) - { - decimal initMarginRate = Convert.ToDecimal(clientMarginTemplate.InitMarginRate); - if (td.StructureType != "普通债券类收益互换") - { - if (floatPosition.PositionType == (int)PositionTypeFlag.Long) - { - initMarginRate = clientMarginTemplate.LongInitMarginRate ?? 0; - } - else - { - initMarginRate = clientMarginTemplate.ShortInitMarginRate ?? 0; - } - } - bool year20 = true; - if (underlying.MaturityDate.HasValue && underlying.MaturityDate < DateTime.Now.AddDays(20 * 365)) - { - year20 = false; - } - initMarginRate = year20 ? 0.05m : initMarginRate; - swap_position marginPosition = new swap_position() - { - InterestDirection = (int)SwapDirectionEnum.收取, - InterestRateDefault = clientMarginTemplate.InitMarginRebateRate ?? 0, - InterestMode = (int)InterestModeEnum.初始预付金, - InterestPrincipalFix = initMarginRate * Convert.ToDecimal(td.StockEqvNotional), - HappenDate = td.TradeDate.Value, - PosiMatuirityDate = td.ExerciseDate.Value, - PosiStartDate = td.StartDate.Value, - Currency = "CNY", - IsAnnualized = true, - SwapTradeId = td.id, - IsInitial = true, - OptTime = DateTime.Now, - OptId = UserInfo.UserId, - OptName = UserInfo.UserName, - }; - var marginInterval = new IntervalModel() - { - Date = td.ExerciseDate.Value, - Rate = marginPosition.InterestRateDefault, - Settlement = 0 - }; - List marginIntervalModels = new List() { marginInterval }; - marginPosition.InterestSwapInterval = JsonConvert.SerializeObject(marginIntervalModels); - td.swap_positions.Add(marginPosition); - } swap_position interestPosition = new swap_position() { InterestDirection = flowMerge.BsType == (int)PositionTypeFlag.Long ? (int)SwapDirectionEnum.收取 : (int)SwapDirectionEnum.支付, @@ -818,7 +771,10 @@ namespace YLErp.Modules.SwapModule { throw new ServiceException($"客户'{client.Name}'的'交易资产'属性不包括'权益',不能进行收益互换交易"); } - + if (client.EvaluateExpireDate < req.TradeDate) + { + throw new ServiceException("适当性评估已经过期,只有在适当性有效期内才可以新开仓"); + } req.ClientName = client.Name; req.SettlementCurrency = client.SettlementCurrency; } diff --git a/YLErpWeb/App_Data/FunctionRight.xml b/YLErpWeb/App_Data/FunctionRight.xml index c9878eb5..cdedb7d9 100644 --- a/YLErpWeb/App_Data/FunctionRight.xml +++ b/YLErpWeb/App_Data/FunctionRight.xml @@ -38,8 +38,6 @@ - - @@ -73,27 +71,19 @@ - - - - - - - - @@ -125,7 +115,6 @@ - @@ -139,8 +128,6 @@ - - @@ -160,10 +147,6 @@ - - - - diff --git a/YLErpWeb/App_Data/Menus.txt b/YLErpWeb/App_Data/Menus.txt index f564c05b..dce08627 100644 --- a/YLErpWeb/App_Data/Menus.txt +++ b/YLErpWeb/App_Data/Menus.txt @@ -13,7 +13,6 @@ {Name:"限额监控",Rights:["风险控制-限额监控"],Url:"risk/quotaMonitor"}, {Name:"白名单券池",Rights:["风险控制-白名单券池"],Url:"v3/data/underlying-pool"}, {Name:"日终持仓风险_互换",Rights:["风险控制-日终持仓风险_互换"],Url:"swaptrade2/EodPositionRisks"}, - {Name:"互换预付金监控",Rights:["风险控制-互换预付金监控"],Url:"marginRateSwap/MarginRateSwapMonitorV2"}, {Name:"监控日志",Rights:["风险控制-监控日志"],Url:"RiskCheckLog/Index"}, ] }, @@ -24,18 +23,14 @@ {Name:"收盘操作",Rights:["结算管理-收盘操作"],Url:"eod_trade_value/eodExec"}, {Name:"交易确认书",Rights:["结算管理-交易确认书"],Url:"TradeConfirmBook/Index"}, {Name:"结算确认书",Rights:["结算管理-结算确认书"],Url:"swaptrade2/tradeEndConfirmList"}, - {Name:"资金提示邮件",Rights:["结算管理-资金提示邮件"],Url:"SwapEventEmail/Index"}, {Name:"每日估值报告",Rights:["结算管理-每日估值报告"],Url:"clientbalance/TradeMarketReport"}, ] }, {Name:"客户管理",Rights:["客户管理"],Icon:"menu-icon iconeight" ,SubItems:[ - {Name:"客户等级",Rights:["客户管理-客户等级"],Url:"clientlevel/clientlevelList"}, - {Name:"资信等级",Rights:["客户管理-资信等级"],Url:"credit_rating/credit_ratingList"}, {Name:"开户管理",Rights:["客户管理-开户管理"],Url:"AccountOpeningProcess/clientList"}, {Name:"客户列表",Rights:["客户管理-客户查看"],Url:"client/ClientList"}, {Name:"客户审批",Rights:["客户管理-客户审批"],Url:"clientApproval/openingclientList"}, - {Name:"资信等级有效期",Rights:["客户管理-资信等级有效期"],Url:"client_rating/List"}, {Name:"黑名单客户",Rights:["客户管理-黑名单客户"],Url:"clientblack/clientblacklist"}, {Name:"机构账号设置",Rights:["客户管理-机构账号设置"],Url:"v3/client/account"} ] @@ -59,7 +54,6 @@ }, {Name:"系统管理",Rights:["系统管理"],Icon:"menu-icon iconten" ,SubItems:[ - {Name:"部门架构",Rights:["系统管理-部门管理"],Url:"System/DepartmentView"}, {Name:"角色权限",Rights:["系统管理-角色管理"],Url:"System/RoleIndex"}, {Name:"系统账号",Rights:["系统管理-用户管理"],Url:"System/UserIndex"}, {Name:"簿记账户",Rights:["系统管理-资产单元"],Url:"assetunit/assetunitList"}, diff --git a/YLErpWeb/App_Docs/导入模板/互换预付金率导入模板.xlsx b/YLErpWeb/App_Docs/导入模板/互换预付金率导入模板.xlsx index ca6173bf..3b3b345e 100644 Binary files a/YLErpWeb/App_Docs/导入模板/互换预付金率导入模板.xlsx and b/YLErpWeb/App_Docs/导入模板/互换预付金率导入模板.xlsx differ diff --git a/YLErpWeb/App_Docs/导出模板/结算报告模板.xlsx b/YLErpWeb/App_Docs/导出模板/结算报告模板.xlsx index 36ae26df..4c4ea2b2 100644 Binary files a/YLErpWeb/App_Docs/导出模板/结算报告模板.xlsx and b/YLErpWeb/App_Docs/导出模板/结算报告模板.xlsx differ diff --git a/YLErpWeb/App_Docs/导出模板/结算报告模板_浙商.xlsx b/YLErpWeb/App_Docs/导出模板/结算报告模板_浙商.xlsx deleted file mode 100644 index 343eccaa..00000000 Binary files a/YLErpWeb/App_Docs/导出模板/结算报告模板_浙商.xlsx and /dev/null differ diff --git a/YLErpWeb/App_Docs/导出模板/资金监控模板1.xlsx b/YLErpWeb/App_Docs/导出模板/资金监控模板1.xlsx index e2ff4377..989cc2e6 100644 Binary files a/YLErpWeb/App_Docs/导出模板/资金监控模板1.xlsx and b/YLErpWeb/App_Docs/导出模板/资金监控模板1.xlsx differ diff --git a/YLErpWeb/Controllers/MarginRateSwapController.cs b/YLErpWeb/Controllers/MarginRateSwapController.cs index bf9c1b4b..b81c5960 100644 --- a/YLErpWeb/Controllers/MarginRateSwapController.cs +++ b/YLErpWeb/Controllers/MarginRateSwapController.cs @@ -81,6 +81,7 @@ namespace YLErp.Web.Controllers MarginRateSwap.AddToMarginRebateRate /= 100; MarginRateSwap.LongInitMarginRate /= 100; MarginRateSwap.ShortInitMarginRate /= 100; + MarginRateSwap.MaintenanceRate /= 100; new MarginRateSwapService(CurUser).saveMarginRate(MarginRateSwap); return JsonSuccess("已修改"); diff --git a/YLErpWeb/Controllers/clientController.cs b/YLErpWeb/Controllers/clientController.cs index e000a5cb..90ff4066 100644 --- a/YLErpWeb/Controllers/clientController.cs +++ b/YLErpWeb/Controllers/clientController.cs @@ -625,7 +625,7 @@ namespace YLErp.Web.Controllers x.HoldingDepositB = -clientBalance.PayableMarginB; x.SwapPayableMargin = -clientBalance.SwapPayableMargin; x.AvailableAmount = clientBalance.AvailableAmount; - x.InsuredAmount = clientBalance.MarginByPayableMargin; + x.InsuredAmount = clientBalance.PositionTradePayableFundTotal; x.MarginMonitoringTime = clientBalance.UpdateDate ?? DateTime.Now; x.FreezePremium = clientBalance.FreezePremium; x.ReceivablesPremium = clientBalance.ReceivablesPremium; @@ -643,7 +643,8 @@ namespace YLErp.Web.Controllers Math.Min(Math.Abs(Math.Min((x.AvailableAmount ?? 0) - (x.GuaranteesTotalAmount ?? 0), 0)), x.GuaranteesTotalAmount ?? 0); x.AmountFund = clientBalance.AmountFund; x.AmountFundWithProduct = clientBalance.AmountFundWithProduct; - x.TotalAmount = clientBalance.TotalAmount; + x.TotalAmount = clientBalance.SwapMarketAmount; + x.RoundedTotalAmount = clientBalance.RoundedTotalAmount; x.TotalTradeCount = clientBalance.TotalTradeCount; x.BuyCount = clientBalance.BuyCount; x.SellCount = clientBalance.SellCount; @@ -661,13 +662,15 @@ namespace YLErp.Web.Controllers x.PrepaymentAmount = clientBalance.PrepaymentAmount; x.FrozenMarginMoney = clientBalance.FrozenMarginMoney; x.NetFund = clientBalance.NetFund; + x.NetFundAll = clientBalance.NetFundAll; + x.VmFundSum = clientBalance.VmFundSum; x.OtherFund = clientBalance.OtherFund; x.Coupon = clientBalance.Coupon; x.SwapBalance = clientBalance.SwapBalance; x.PayableMargin = clientBalance.PayableMargin; x.TwoSideMargin = clientBalance.TwoSideMargin; x.OtherSideMargin = -clientBalance.OtherSideMargin; - x.MySideMargin = -clientBalance.MySideMargin; + x.MySideMargin = clientBalance.MySideMargin; x.DeltaMargin = -clientBalance.DeltaMargin; x.IsPayableMarginManual = clientBalance?.IsPayableMarginManual; x.AvailableAmount = clientBalance.AvailableAmount; @@ -683,6 +686,10 @@ namespace YLErp.Web.Controllers x.AvailableStockEqvNotional = clientBalance.AvailableStockEqvNotional.Normalize(); x.PFE = clientBalance.PFE; x.EndDesirableFund = x.NetFund + x.SettlementBalance + clientBalance.EndPremiumSum; + x.SwapMarketAmount= clientBalance.SwapMarketAmount; + x.SwapMarketAmountPercent=clientBalance.SwapMarketAmountPercent; + x.MaintenanceMargin=clientBalance.MaintenanceMargin; + x.NeedAddMargin=clientBalance.NeedAddMargin; if (clientBalance.MarginOccupation == 0) { x.WorstCastClientPayableRatio = 10000; @@ -718,31 +725,6 @@ namespace YLErp.Web.Controllers x.LastHTSettlemetTime = clientBalance.LastHTSettlemetTime; x.LastSettlemetTime = clientBalance.LastSettlemetTime; - if (PS.Config.Is润和) - { - x.AvailableAmount = clientBalance.AvailableAmount + clientBalance.TotalCredit; - x.DesirableFund = Math.Max(clientBalance.AvailableAmount, 0); - - switch ((MarginOptionEnum)client.MarginOptionType) - { - case MarginOptionEnum.单向追保: - x.HoldingDeposit = Math.Max(x.HoldingDeposit ?? 0, 0); - x.OtherSideMargin = 0; - break; - case MarginOptionEnum.对手方单向追保: - x.HoldingDeposit = 0; - x.OtherSideMargin = Math.Max(x.OtherSideMargin, 0); - break; - case MarginOptionEnum.双向追保: - x.HoldingDeposit = Math.Max(x.HoldingDeposit ?? 0, 0); - x.OtherSideMargin = Math.Max(x.OtherSideMargin, 0); - break; - case MarginOptionEnum.其他: - default: - break; - } - x.SpanValue = x.HoldingDeposit; - } //拼装标签值 if (clientTagList.ContainsKey(x.id)) @@ -829,11 +811,7 @@ namespace YLErp.Web.Controllers var sourceFileName = OtcAppContext.MapPath("~/App_Docs/导出模板/"); if (req.StartDate == null || req.StartDate == req.ValueDate) { - var temp = Path.Combine(sourceFileName, $"资金监控模板1-{PS.Config.Company}.xlsx"); - if (!System.IO.File.Exists(temp)) - { - temp = Path.Combine(sourceFileName, $"资金监控模板1.xlsx"); - } + var temp = Path.Combine(sourceFileName, $"资金监控模板1.xlsx"); sourceFileName = temp; var searchList = ClientBanlanceQuery(req).Value as SearchListResult; //模板绑定值,处理四舍五入配置 @@ -853,57 +831,25 @@ namespace YLErp.Web.Controllers { TotalTradeCountSum = pairs["TotalTradeCountSum"], TotalNotionalPrincipalSum = pairs["TotalNotionalPrincipalSum"], - BuyCountSum = pairs["BuyCountSum"], - BuyNominalPrincipalOfTransactionSum = pairs["BuyNominalPrincipalOfTransactionSum"], - SellCountSum = pairs["SellCountSum"], - SellNominalPrincipalOfTransactionSum = pairs["SellNominalPrincipalOfTransactionSum"], TransactionPenNumberSum = pairs["TransactionPenNumberSum"], TodayNotionalPrincipalSum = pairs["TodayNotionalPrincipalSum"], PositionNotionalPrincipalSum = pairs["PositionNotionalPrincipalSum"], CurrentHoldingPenNumberSum = pairs["CurrentHoldingPenNumberSum"], - FreezePremiumSum = pairs["FreezePremiumSum"], - ReceivablesPremiumSum = pairs["ReceivablesPremiumSum"], - FrozenMarginMoneySum = pairs["FrozenMarginMoneySum"], WinLossSum = pairs["WinLossSum"], - PositionPremiumNetCashSum = pairs["PositionPremiumNetCashSum"], PositionPvSum = PS.Config.IsPVRounded ? pairs["RoundedPositionPvSum"] : pairs["PositionPvSum"], PositionPnlSum = PS.Config.IsPVRounded ? pairs["RoundedPositionPnlSum"] : pairs["PositionPnlSum"], TotalAmountSum = PS.Config.IsPVRounded ? pairs["RoundedTotalAmountSum"] : pairs["TotalAmountSum"], NetFundSum = pairs["NetFundSum"], - OptionPremiumSum = pairs["OptionPremiumSum"], - SettlementBalanceSum = pairs["SettlementBalanceSum"], - CouponSum = pairs["CouponSum"], - OptionPremiumSwapSum = pairs["OptionPremiumSwapSum"], - SwapBalanceSum = pairs["SwapBalanceSum"], + NetFundAllSum = pairs["NetFundAllSum"], OtherFundSum = pairs["OtherFundSum"], AmountFundSum = pairs["AmountFundSum"], - GuaranteesTotalAmountSum = pairs["GuaranteesTotalAmountSum"], - HoldingDepositSum = pairs["HoldingDepositSum"], - HoldingDepositASum = pairs["HoldingDepositASum"], - HoldingDepositBSum = pairs["HoldingDepositBSum"], AvailableAmountSum = pairs["AvailableAmountSum"], - CreditUsedSum = pairs["CreditUsedSum"], InsuredAmountSum = pairs["InsuredAmountSum"], - ClosedTradePayableFundSum = pairs["ClosedTradePayableFundSum"], - PositionTradePayableFundSum = pairs["PositionTradePayableFundSum"], - PayableFundSum = pairs["PayableFundSum"], DesirableFundSum = pairs["DesirableFundSum"], - OtherSideMarginSum = pairs["OtherSideMarginSum"], MySideMarginSum = pairs["MySideMarginSum"], - CreditRiskLossSum = pairs["CreditRiskLossSum"], - ExposureSum = pairs["ExposureSum"], - CreditUsedValueSum = pairs["CreditUsedValueSum"], - BuyerPositionMarginSum = pairs["BuyerPositionMarginSum"], - SellerPositionPremiumSum = pairs["SellerPositionPremiumSum"], - ShouldChargedSum = pairs["ShouldChargedSum"], - PFESum = pairs["PFESum"], - EndDesirableFundSum = pairs["EndDesirableFundSum"], - clientEquitySum = pairs["clientEquitySum"], - LastDayPositionPremiumNetCashsSum = pairs["LastDayPositionPremiumNetCashsSum"], - NetFundSumSum = pairs["NetFundSumSum"], - EADSum = pairs["EADSum"], - DaliyPnlSum = PS.Config.IsPVRounded ? pairs["RoundedDaliyPnlSum"] : pairs["DaliyPnlSum"], - AvailableStockEqvNotionalSum= pairs["AvailableStockEqvNotionalSum"], + VmFundSumSum = pairs["VmFundSumSum"], + MarginBalanceSum = pairs["MarginBalanceSum"], + SwapMarketAmountSum = pairs["SwapMarketAmountSum"], InfoList = searchList.rows }; diff --git a/YLErpWeb/Hubs/SwapFlowCombookingHub.cs b/YLErpWeb/Hubs/SwapFlowCombookingHub.cs index 851bd53e..c5300b24 100644 --- a/YLErpWeb/Hubs/SwapFlowCombookingHub.cs +++ b/YLErpWeb/Hubs/SwapFlowCombookingHub.cs @@ -64,7 +64,7 @@ namespace YLErp.Web.Hubs //service.CheckBookByDate(tradeDate); currentStep = "校验簿记前置条件"; await client.SendAsync("ReceiveMessage", currentStep); - service.BookingValidate(mergeList); + service.BookingValidate(mergeList, req.tradeDate); currentStep = "正在合成簿记"; await client.SendAsync("ReceiveMessage", currentStep); //var dmaFlows = swapFlows.Where(x => dmaClientIds.Contains(x.ClientId)).ToList(); diff --git a/YLErpWeb/Views/MarginRateSwap/MarginRateSwapEdit.cshtml b/YLErpWeb/Views/MarginRateSwap/MarginRateSwapEdit.cshtml index 01825430..63b89222 100644 --- a/YLErpWeb/Views/MarginRateSwap/MarginRateSwapEdit.cshtml +++ b/YLErpWeb/Views/MarginRateSwap/MarginRateSwapEdit.cshtml @@ -78,18 +78,13 @@ *
- + %
- - - % -
-
- - + + %
diff --git a/YLErpWeb/Views/WildCard/ClientBalanceReportWildcard.cshtml b/YLErpWeb/Views/WildCard/ClientBalanceReportWildcard.cshtml index 4ac5d27b..ce94d2ac 100644 --- a/YLErpWeb/Views/WildCard/ClientBalanceReportWildcard.cshtml +++ b/YLErpWeb/Views/WildCard/ClientBalanceReportWildcard.cshtml @@ -23,16 +23,7 @@ {{支付截止时间}} - @{ - if (PS.Config.Company == CompanyEnum.浙期) - { - 2020年09月15日上午11:30 - } - else - { - 2020年09月15日上午9:30 - } - } + 2020年09月15日上午11:30 @@ -46,22 +37,17 @@ - {{应付资金总额}} + {{预付金余额}} 548545.26 - - {{大写应付资金总额}} - 伍拾肆万捌仟伍佰肆拾伍元贰角陆分 - - {{发送日期}} 2020-09-14 - {{预付金占用}} + {{初始保证金金额}} 4183.00 @@ -70,33 +56,6 @@ -548545.26 - - {{授信额度}} - 50.00 - - @if (PS.Config.Company != CompanyEnum.中金) - { - - {{应付了结交易款}} - 544362.26 - - - - {{应付存续交易款}} - 0.00 - - - - {{存续交易期权费净额}} - 9557.57 - - - - {{可取资金}} - 80177.03 - - } - {{起始日期}} 2020-09-14 @@ -117,13 +76,10 @@ {{账号}} 309074058888 - @if (PS.Config.Company != CompanyEnum.中金 && !PS.Config.Is国投) - { - - {{期末结存}} + + {{期末结存}} 3622.00 - - } + diff --git a/YLErpWeb/Views/client/clientRiskMonitorBatchSend.cshtml b/YLErpWeb/Views/client/clientRiskMonitorBatchSend.cshtml index 9a442f1d..91e0fbe4 100644 --- a/YLErpWeb/Views/client/clientRiskMonitorBatchSend.cshtml +++ b/YLErpWeb/Views/client/clientRiskMonitorBatchSend.cshtml @@ -24,6 +24,12 @@ var shownType = '@Html.Raw(@ViewBag.ShownType)'; $(function () { $("#setClientBalanceType").val(shownType); + $('#CBContractor').on('changed.bs.select', function () { + changeGetInfo("CB"); + }); + $('#CBContractor').val("1");//默认估值报告接收人 + $('#CBContractor').selectpicker('refresh'); // 刷新 selectpicker,使默认值生效 + $('#CBContractor').trigger('changed.bs.select'); // 手动触发 changed.bs.select 事件 }); var vue = new Vue({ diff --git a/YLErpWeb/Views/clientbalance/TradeMarketClientSend.cshtml b/YLErpWeb/Views/clientbalance/TradeMarketClientSend.cshtml index 7b1f736a..8bbb8b4f 100644 --- a/YLErpWeb/Views/clientbalance/TradeMarketClientSend.cshtml +++ b/YLErpWeb/Views/clientbalance/TradeMarketClientSend.cshtml @@ -240,7 +240,7 @@ !sheets && (sheets = ''); $("[name=sendcontent]").each(function () { let val = $(this).val(); - val !== '账户状况' && $(this).prop('checked', sheets.indexOf(val) >= 0); + $(this).prop('checked', sheets.indexOf(val) >= 0); }); var ue = UE.getEditor('container'); var m_ue = UE.getEditor('margin_container'); diff --git a/YLErpWeb/Views/clientbalance/TradeMarketDescSet.cshtml b/YLErpWeb/Views/clientbalance/TradeMarketDescSet.cshtml index f1a82053..3c7cdba8 100644 --- a/YLErpWeb/Views/clientbalance/TradeMarketDescSet.cshtml +++ b/YLErpWeb/Views/clientbalance/TradeMarketDescSet.cshtml @@ -80,7 +80,7 @@ !sheets && (sheets = ''); $("[name=sendcontent]").each(function () { let val = $(this).val(); - val !== '账户状况' && $(this).prop('checked', sheets.indexOf(val) >= 0); + $(this).prop('checked', sheets.indexOf(val) >= 0); }); } diff --git a/YLErpWeb/Views/clientbalance/TradeMarketReport.cshtml b/YLErpWeb/Views/clientbalance/TradeMarketReport.cshtml index f4628ecf..c485199e 100644 --- a/YLErpWeb/Views/clientbalance/TradeMarketReport.cshtml +++ b/YLErpWeb/Views/clientbalance/TradeMarketReport.cshtml @@ -87,302 +87,69 @@
- @if (PS.Config.Is申万) - { -
- - - - - - - - -
期初结存空头浮动盈利
本日入金客户权益
本日出金期权市值
本日权利金收支应缴纳预付金
行权收益预付金总额
资金结存应追加预付金
可提取预付金
-
- } - else if (PS.Config.Company == CompanyEnum.润和) - { -
- - - - - - - - - -
收支与结存占用与可取盈亏与估值
期初结存预付金占用实现盈亏
出金入金可用资金持仓盈亏
成交收支授信额度持仓市值
了结收支授信占用总资产
其他收支追保金额
期末结存可取资金
质押市值
- - - - - - - -
- } - else if (PS.Config.Company == CompanyEnum.国投) - { -
- - - - - - - - - - - - - - -
收支与结存应付与可取盈亏与估值
期初余额浮动预付金已平仓盈亏
入金权利金收付持仓浮动盈亏
出金可用资金市值权益
当日终止授信额度
期末余额可提取金额
-
- } - else if (PS.Config.Company == CompanyEnum.湘财) - { -
- - - @if (PS.Config.ErpElement.SuppotSnowballSpecialist) - { - - - - - - - - - - - - - - } - else - { - - - - - - - - - - - - - - } - - - - - - - - - @if (PS.Config.Is厦门象屿) - { - - - } - - - - - - - - - - - - - @if (tradeMarketShowTotalNetSettlement) - { - - - - - } -
收支与结存应付与可取盈亏与估值
期初结存预付金占用实现盈亏
出金入金可用资金持仓盈亏
成交收支授信额度
了结收支追保金额
票息可取资金
期初结存预付金占用实现盈亏
出金入金可用资金持仓盈亏
成交收支授信额度持仓市值
了结收支追保金额
票息可取资金
互换成交收支
互换了结收支
其他收支
期末结存阈值 - -
质押市值
总盈亏
- - - - - - -
- } - else if (PS.Config.Company == CompanyEnum.浙商) - { -
- - - - - - - @if (tradeMarketShowTotalNetSettlement) - { - - - - - } -
收支与结存可用与追保盈亏与估值
期初结存保证金占用 已实现盈亏
出金入金可用资金持仓盈亏
其他收支追保金额持仓市值
期末结存可取资金总资产
总盈亏
- - - - - - -
- } - else - { -
- - - @if (PS.Config.ErpElement.SuppotSnowballSpecialist) - { - - - - - - - - - - - - - - } - else - { - - - - - - } - @if (PS.Config.Is东吴) - { - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - } - else - { - - - - - - - - - - - } - @if (tradeMarketShowTotalNetSettlement) - { - - - - - } -
收支与结存应付与可取盈亏与估值
期初结存预付金占用实现盈亏
出金入金可用资金持仓盈亏
成交收支授信额度持仓市值
了结收支应付了结交易款其中:预付金
票息应付存续交易款总资产
期初结存预付金占用实现盈亏
出金入金可用资金持仓盈亏
互换成交收支授信额度持仓市值
互换了结收支应付了结交易款总资产
其他收支应付存续交易款
互换成交收支未结算部分权利金收益
互换了结收支追保金额
其他收支应付资金总额
期末结存可取资金
质押市值期末结存_权利金后付
期末结存追保金额
质押市值应付资金总额
可取资金
总盈亏
- - - - - - -
- } +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
收支与结存可用与追保盈亏与估值
期初结存初始保证金金额已实现盈亏
出金入金预付金余额持仓盈亏
初保账户盯市金额持仓市值
追保账户可用资金总资产
其他收支追保金额
期末结存可取资金
+
- @if (PS.Config.Company == CompanyEnum.浙商) - { - -

1.【期初结存】:观察期初即上期期末的结存;

-

2.【出金入金】:观察区间内的入金(正)和出金(负)的净额;

- @*

3.  【成交收支】:观察区间内衍生品交易生命周期起点的净收入(卖出收入减去买入支出);

*@ - @*

4.  【了结收支】:观察区间内衍生品交易生命周期终点的净收入(了结收入减去了结支出);

*@ -

3.【其他收支】:观察区间内的调整项;

-

4.【期末结存】:期末结存 =  期初结存+出金入金+已实现盈亏+其他收支;

- @*

7.  【质押市值】:抵押的有价证券在观察期末的市值,只可用于抵扣保证金占用,不可抵扣交易款;

*@ -

5.【保证金占用】:根据观察期末的持仓交易按特定算法计算的盯市保证金额,即观察期末不可使用需要暂时冻结的资金;

-

6.【可用资金】:观察期末可用于达成新交易的资金规模,可用资金=期末结存-保证金占用;

- @*

10.【授信额度】:我司在观察期末根据交易对手方的资信情况审慎提供的资金支持额度;

*@ - @*

11.【应付了结交易款】:观察期末尚未结清的了结交易的成交与了结收支净额; 

12.【应付存续交易款】:观察期末尚未结清的存续交易的成交收支;

*@ -

7.【追保金额】:期末结存抵扣保证金占用后不足以抵扣的部分,追保金额=Max(0-可用资金,0);

- @*

14.【应付资金总额】:观察期末交易对手方应入金的资金总额,应付资金总额 = 应付了结交易款 + 应付存续交易款 + 追保金额;

*@ -

8.【可取资金】:扣掉持仓亏损后(持仓盈利则不计算在内),观察期末被占用的可出金取出的资金,可取资金=期末结存-持仓亏损-保证金占用;

-

9.【已实现盈亏】:观察区间内平仓了结交易的盈亏;

-

10.【持仓盈亏】:观察期末存续交易的浮动盈亏;

-

11.【持仓市值】:观察期末存续交易的估值;

-

12.【总  资  产】:观察期末归属交易对手方的资产总额,总资产=期末结存+持仓市值 ;

-
- } - else - { - - @Html.Raw(DBCacheManager.Single.GetStr(CacheTable.DingShiDesc)) - - } + + @Html.Raw(DBCacheManager.Single.GetStr(CacheTable.DingShiDesc)) +
@await Html.PartialAsync("/Views/Common/_importFiles.cshtml", new ImportFileModel() { diff --git a/YLErpWeb/Views/entryexit/entryexitEdit.cshtml b/YLErpWeb/Views/entryexit/entryexitEdit.cshtml index ef07a25d..c1b419d0 100644 --- a/YLErpWeb/Views/entryexit/entryexitEdit.cshtml +++ b/YLErpWeb/Views/entryexit/entryexitEdit.cshtml @@ -49,17 +49,6 @@ - if (PS.Config.Company == CompanyEnum.中金) - { -
- - -
-
- - -
- } if (Model.Direction != ClientCashInCashOut.应收 && !pageObj.isCompanyCash) {
@@ -114,7 +103,13 @@
} - +
+ + +
diff --git a/YLErpWeb/Views/entryexit/entryexitList.cshtml b/YLErpWeb/Views/entryexit/entryexitList.cshtml index 6ff7f3a7..1f2c7aff 100644 --- a/YLErpWeb/Views/entryexit/entryexitList.cshtml +++ b/YLErpWeb/Views/entryexit/entryexitList.cshtml @@ -137,6 +137,12 @@ width: 150, align: 'center', formatter: directionType + }, { + name: 'cash_type', + label: '账户类型', + index: 'cash_type', + width: 150, + align: 'center' }, { name: 'Money', label: '金额', diff --git a/YLErpWeb/Views/entryexit/entryexitView.cshtml b/YLErpWeb/Views/entryexit/entryexitView.cshtml index c6731b81..63e042ee 100644 --- a/YLErpWeb/Views/entryexit/entryexitView.cshtml +++ b/YLErpWeb/Views/entryexit/entryexitView.cshtml @@ -66,6 +66,7 @@ @Html.MyDisplayFor(m => m.Number) @Html.MyDisplayFor(m => m.ClientName) @Html.MyDisplayFor(m => m.DirectionType) + @Html.MyDisplayFor(m => m.cash_type) @Html.MyDisplayFor(m => m.Money, (((Model.Direction == "出金" ? (-1) : 1) * Model.Money) ?? 0).ToString("N")) @Html.MyDisplayFor(m => m.CurrencyCode) @Html.MyDisplayFor(m => m.HappenDate, Utilities.ShowValidDatetime(Model.HappenDate, "yyyy-MM-dd HH:mm:ss")) diff --git a/YLErpWeb/YLErpWeb.csproj b/YLErpWeb/YLErpWeb.csproj index c8392917..ec0d8db9 100644 --- a/YLErpWeb/YLErpWeb.csproj +++ b/YLErpWeb/YLErpWeb.csproj @@ -112,7 +112,7 @@ PreserveNewest - + PreserveNewest @@ -179,8 +179,8 @@ <_AppFiles Remove="App_Docs\导出模板\浮动利率特殊设置导出模板.xlsx" /> <_AppFiles Remove="App_Docs\导出模板\浮动利率默认设置导出模板.xlsx" /> <_AppFiles Remove="App_Docs\导出模板\结算报告标准模板_湘财.xlsx" /> + <_AppFiles Remove="App_Docs\导出模板\结算报告模板.xlsx" /> <_AppFiles Remove="App_Docs\导出模板\结算报告模板_山西固收.xlsx" /> - <_AppFiles Remove="App_Docs\导出模板\结算报告模板_浙商.xlsx" /> <_AppFiles Remove="App_Docs\导出模板\结算报告模板_湘财.xlsx" /> <_AppFiles Remove="App_Docs\导入模板\导入限额指标.xlsx" /> <_AppFiles Remove="App_Docs\导入模板\批量对冲波动率模板.xlsx" /> diff --git a/YLErpWeb/wwwroot/Scripts/app/client/clientRiskMonitor.js b/YLErpWeb/wwwroot/Scripts/app/client/clientRiskMonitor.js index fa168b7b..7e328f96 100644 --- a/YLErpWeb/wwwroot/Scripts/app/client/clientRiskMonitor.js +++ b/YLErpWeb/wwwroot/Scripts/app/client/clientRiskMonitor.js @@ -141,12 +141,6 @@ function setHoldingDepositFunc() { function getColModelGrid() { - function KeShangYuEr(cellValue, options, rowObject) { - return ((parseFloat(rowObject.NetFund) || 0) + (parseFloat(rowObject.WinLoss) || 0)).toFixed(2); - } - - var isHaiTong = page.Company === "海通"; - var colModelGrid = [ { name: 'id', label: 'id', index: 'id', width: 1, align: 'left', hidden: true, @@ -158,12 +152,6 @@ function getColModelGrid() { name: 'Number', label: '客户编号', index: 'Number', width: 100, align: 'center', frozen: true }, { name: 'Name', label: '客户名称', index: 'Name', width: 238, align: 'center', frozen: true - }, { - name: 'ProtocolSignDate', label: '商品类签署日期', index: 'ProtocolSignDate', width: 150, align: 'center', formatter: 'date', hidden: true, frozen: true - }, { - name: 'RightProtocolSignDate', label: '权益类签署日期', index: 'RightProtocolSignDate', width: 150, align: 'center', formatter: 'date', hidden: true, frozen: true - },{ - name: 'licenseCodes', label: '统一社会信用代码', index: 'licenseCodes', width: 100, align: 'right', frozen: true },{ name: 'TotalTradeCount', label: '交易总数', index: 'TotalTradeCount', width: 120, align: 'center', formatter: main.toInt, sorttype: 'number' }, { @@ -176,65 +164,42 @@ function getColModelGrid() { name: 'PositionNotionalPrincipal', label: '持仓名义本金', index: 'PositionNotionalPrincipal', width: 120, align: 'right', formatter: 'number', sorttype: 'number' }, { name: 'CurrentHoldingPenNumber', label: '持仓笔数', index: 'CurrentHoldingPenNumber', width: 80, align: 'center', formatter: main.toInt, sorttype: 'number' - }, { - name: 'FreezePremium', label: '应付冻结权利金', index: 'FreezePremium', width: 100, align: 'right', formatter: 'number', hidden: true, sorttype: 'number' - }, { - name: 'ReceivablesPremium', label: '应收冻结权利金', index: 'ReceivablesPremium', width: 100, align: 'right', formatter: 'number', hidden: true, sorttype: 'number' - }, { - name: 'FrozenMarginMoney', label: '冻结预付金', index: 'FrozenMarginMoney', width: 100, align: 'right', formatter: 'number', hidden: true, sorttype: 'number' }, { name: 'WinLoss', label: '实现盈亏', index: 'WinLoss', width: 120, align: 'right', value: '0', formatter: 'number', sorttype: 'number' }, { - name: 'PositionPv', label: '持仓市值', index: 'PositionPv', width: 120, align: 'right', value: '0', formatter: 'number', optionHide: page.isPvRounded, hidden: page.isPvRounded, sorttype: 'number' - }, { - name: 'RoundedPositionPv', label: '持仓市值', index: 'RoundedPositionPv', width: 120, align: 'right', value: '0', formatter: 'number', optionHide: !page.isPvRounded, hidden: !page.isPvRounded, sorttype: 'number' - }, { - name: 'PrepaymentAmount', label: '其中:预付金', index: 'PrepaymentAmount', width: 120, align: 'right', value: '0', formatter: 'number', optionHide: !page.SuppotSnowballSpecialist, hidden: !page.SuppotSnowballSpecialist, sorttype: 'number' + name: 'RoundedPositionPv', label: '持仓市值', index: 'RoundedPositionPv', width: 120, align: 'right', value: '0', formatter: 'number', sorttype: 'number' }, { name: 'PositionPnl', label: '持仓盈亏', index: 'PositionPnl', width: 120, align: 'right', value: '0', formatter: 'number', optionHide: page.isPvRounded, hidden: page.isPvRounded, sorttype: 'number' - }, { - name: 'DaliyPnl', label: '当日盈亏', index: 'DaliyPnl', width: 120, align: 'right', value: '0', formatter: 'number', optionHide: page.isPvRounded, hidden: page.isPvRounded, sorttype: 'number' }, { name: 'RoundedPositionPnl', label: '持仓盈亏', index: 'RoundedPositionPnl', width: 120, align: 'right', value: '0', formatter: 'number', optionHide: !page.isPvRounded, hidden: !page.isPvRounded, sorttype: 'number' }, { - name: 'RoundedDaliyPnl', label: '当日盈亏', index: 'RoundedDaliyPnl', width: 120, align: 'right', value: '0', formatter: 'number', optionHide: !page.isPvRounded, hidden: !page.isPvRounded, sorttype: 'number' + name: 'NetFundAll', label: '出金入金', index: 'NetFundAll', width: 100, align: 'right', formatter: 'number', sorttype: 'number' }, { - name: 'NetFund', label: '出金入金', index: 'NetFund', width: 100, align: 'right', formatter: 'number', sorttype: 'number' + name: 'NetFund', label: '初保账户', index: 'NetFund', width: 100, align: 'right', formatter: 'number', sorttype: 'number' }, { - name: 'OptionPremiumSwap', label: '互换成交收支', index: 'OptionPremiumSwap', width: 100, align: 'right', formatter: 'number', sorttype: 'number' - }, { - name: 'SwapBalance', label: '互换了结收支', index: 'SwapBalance', width: 100, align: 'right', formatter: 'number', sorttype: 'number' + name: 'VmFundSum', label: '追保账户', index: 'VmFundSum', width: 100, align: 'right', formatter: 'number', sorttype: 'number' }, { name: 'OtherFund', label: '其他收支', index: 'OtherFund', width: 100, align: 'right', formatter: 'number', sorttype: 'number' }, { name: 'AmountFund', label: '期末结存', index: 'AmountFund', width: 100, align: 'right', formatter: 'number', sorttype: 'number' - }, { - name: 'GuaranteesTotalAmount', label: '质押市值', index: 'GuaranteesTotalAmount', width: 100, align: 'right', formatter: 'number', sorttype: 'number' }, { name: 'TotalAmount', label: '总资产', index: 'TotalAmount', width: 100, align: 'right', formatter: 'number', optionHide: page.isPvRounded, hidden: page.isPvRounded, sorttype: 'number' }, { name: 'RoundedTotalAmount', label: '总资产', index: 'RoundedTotalAmount', width: 100, align: 'right', formatter: 'number', optionHide: !page.isPvRounded, hidden: !page.isPvRounded, sorttype: 'number' }, { - name: 'HoldingDeposit', label: '预付金占用', index: 'HoldingDeposit', width: 120, align: 'right', formatter: holdingDepositFormat, sorttype: 'number' + name: 'MySideMargin', label: '初始保证金金额', index: 'MySideMargin', width: 120, align: 'right', formatter: 'number', sorttype: 'number' + }, { + name: 'MarginBalance', label: '预付金余额', index: 'MarginBalance', width: 120, align: 'right', formatter: 'number', sorttype: 'number' + }, { + name: 'SwapMarketAmount', label: '盯市金额', index: 'SwapMarketAmount', width: 120, align: 'right', formatter: 'number', sorttype: 'number' + }, { + name: 'SwapMarketAmountPercent', label: '履约保证金比例', index: 'SwapMarketAmountPercent', width: 120, align: 'right', formatter: percentFormat, sorttype: 'number' }, { name: 'AvailableAmount', label: '可用资金', index: 'AvailableAmount', width: 120, align: 'right', formatter: 'number', sorttype: 'number' - }, { - name: 'CreditUsed', label: '授信使用率', index: 'CreditUsed', width: 120, align: 'right', formatter: percentFormat, sorttype: 'number' }, { name: 'InsuredAmount', label: '追保金额', index: 'InsuredAmount', width: 120, align: 'right', value: '0', formatter: 'number', sorttype: 'number' - }, { - name: 'ClosedTradePayableFund', label: '应付已了结交易款', index: 'ClosedTradePayableFund', width: 120, align: 'right', value: '0', formatter: 'number', sorttype: 'number' - }, { - name: 'PositionTradePayableFund', label: '应付未了结交易款', index: 'PositionTradePayableFund', width: 100, align: 'right', formatter: 'number', sorttype: 'number' - }, { - name: 'PayableFund', label: '应付资金总额', index: 'PayableFund', width: 100, align: 'right', formatter: 'number', sorttype: 'number' }, { name: 'DesirableFund', label: '可取资金', index: 'DesirableFund', width: 100, align: 'right', formatter: 'number', sorttype: 'number' - }, - { - name: 'CreditUsedValue', label: '授信使用金额', index: 'CreditUsedValue', width: 100, align: 'right', formatter: 'number', sorttype: 'number' - }, { - name: 'AvailableStockEqvNotional', label: '可用名义本金规模', index: 'AvailableStockEqvNotional', width: 180, align: 'right', formatter: 'number', hidden: !page.UseClientStockEqvNotional, optionHide: !page.UseClientStockEqvNotional, sorttype: 'number' } ]; colModelGrid.push({ @@ -300,17 +265,14 @@ function gridComplete() { var sum = arguments[0].Sum; $("#listGrid").footerData("set", { Number: "合计", TotalTradeCount: sum.TotalTradeCountSum, TotalNotionalPrincipal: sum.TotalNotionalPrincipalSum, - BuyCount: sum.BuyCountSum, BuyNominalPrincipalOfTransaction: sum.BuyNominalPrincipalOfTransactionSum, SellCount: sum.SellCountSum, - SellNominalPrincipalOfTransaction: sum.SellNominalPrincipalOfTransactionSum, TransactionPenNumber: sum.TransactionPenNumberSum, + TransactionPenNumber: sum.TransactionPenNumberSum, TodayNotionalPrincipal: sum.TodayNotionalPrincipalSum, PositionNotionalPrincipal: sum.PositionNotionalPrincipalSum, CurrentHoldingPenNumber: sum.CurrentHoldingPenNumberSum, - FreezePremium: sum.FreezePremiumSum, ReceivablesPremium: sum.ReceivablesPremiumSum, FrozenMarginMoney: sum.FrozenMarginMoneySum, - WinLoss: sum.WinLossSum, PositionPremiumNetCash: sum.PositionPremiumNetCashSum, PositionPv: sum.PositionPvSum, PositionPnl: sum.PositionPnlSum, RoundedPositionPv: sum.RoundedPositionPvSum, RoundedPositionPnl: sum.RoundedPositionPnlSum, DaliyPnl: sum.DaliyPnlSum, - NetFund: sum.NetFundSum,Coupon: sum.CouponSum, OptionPremiumSwap: sum.OptionPremiumSwapSum, SwapBalance: sum.SwapBalanceSum, OtherFund: sum.OtherFundSum, - AmountFund: sum.AmountFundSum, GuaranteesTotalAmount: sum.GuaranteesTotalAmountSum, TotalAmount: sum.TotalAmountSum, RoundedTotalAmount: sum.RoundedTotalAmountSum, HoldingDeposit: sum.HoldingDepositSum, HoldingDepositA: sum.HoldingDepositASum, HoldingDepositB: sum.HoldingDepositBSum, + WinLoss: sum.WinLossSum, PositionPv: sum.PositionPvSum, PositionPnl: sum.PositionPnlSum, RoundedPositionPv: sum.RoundedPositionPvSum, RoundedPositionPnl: sum.RoundedPositionPnlSum, + NetFund: sum.NetFundSum, OtherFund: sum.OtherFundSum, + AmountFund: sum.AmountFundSum, TotalAmount: sum.TotalAmountSum, RoundedTotalAmount: sum.RoundedTotalAmountSum, AvailableAmount: sum.AvailableAmountSum, InsuredAmount: sum.InsuredAmountSum, - ClosedTradePayableFund: sum.ClosedTradePayableFundSum, PositionTradePayableFund: sum.PositionTradePayableFundSum, PayableFund: sum.PayableFundSum, DesirableFund: sum.DesirableFundSum, - PFE: sum.PFESum, EAD: sum.EADSum, EndDesirableFund: sum.EndDesirableFundSum, LastDayPositionPremiumNetCashs: sum.LastDayPositionPremiumNetCashsSum, - NetFundSumString: sum.NetFundSumSum, clientEquity: sum.clientEquitySum + DesirableFund: sum.DesirableFundSum, NetFundAll: sum.NetFundAllSum, VmFundSum: sum.VmFundSumSum, MySideMargin: sum.MySideMarginSum, + MarginBalance: sum.MarginBalanceSum, SwapMarketAmount: sum.SwapMarketAmountSum }); } g_grid = jQuery('#listGrid'); @@ -355,9 +317,9 @@ function LoadGrid() { jQuery('#listGrid').jqGrid('setGroupHeaders', { useColSpanStyle: true, groupHeaders: [ - { startColumnName: 'Number', numberOfColumns: 17, titleText: '客户信息' }, - { startColumnName: 'TotalTradeCount', numberOfColumns: 23, titleText: '交易信息 ' }, - { startColumnName: 'NetFund', numberOfColumns: 37, titleText: '账户状况' } + { startColumnName: 'Number', numberOfColumns: 2, titleText: '客户信息' }, + { startColumnName: 'TotalTradeCount', numberOfColumns: 10, titleText: '交易信息 ' }, + { startColumnName: 'NetFundAll', numberOfColumns: 14, titleText: '账户状况' } ] }); } diff --git a/YLErpWeb/wwwroot/Scripts/app/client/entryexitEdit.js b/YLErpWeb/wwwroot/Scripts/app/client/entryexitEdit.js index 76096464..c4b260ea 100644 --- a/YLErpWeb/wwwroot/Scripts/app/client/entryexitEdit.js +++ b/YLErpWeb/wwwroot/Scripts/app/client/entryexitEdit.js @@ -203,9 +203,7 @@ function saveentryexit() { function setDirection(isInit) { !isInit && cardInputMgr.changeInputType(true); - let direction = $("#Direction").val(); - $(".changeInputBtn").toggleClass("hide", ["出金", "应付"].includes(direction)); cardInputMgr.toggle(["入金", "出金"].includes(direction)); diff --git a/YLErpWeb/wwwroot/Scripts/app/client/tradeMarketReport.js b/YLErpWeb/wwwroot/Scripts/app/client/tradeMarketReport.js index db1699ad..10f850c5 100644 --- a/YLErpWeb/wwwroot/Scripts/app/client/tradeMarketReport.js +++ b/YLErpWeb/wwwroot/Scripts/app/client/tradeMarketReport.js @@ -302,100 +302,21 @@ function SearchClientBalance() { main.post("/trade_span/GetClientLatestBalance", { clientId: $("#ClientId").val(), ValueDateFrom: param.ValueDateStart, ValueDateTo: param.ValueDateEnd, IsClientBalanceGap: param.IsClientBalanceGap, IsGetOuterMarginGap: param.IsGetOuterMarginGap, ParentFlag: param.ParentFlag }).done(function (data) { $("#LastDayRemainFund").text(numFormart(data.LastDayRemainFund)); - $("#CashInCashOutChange").text(numFormart(data.NetFund)); - $("#CashInChange").text(numFormart(data.InFund)); - $("#CashOutChange").text(numFormart(data.OutFund)); - $("#OptionPremium").text(numFormart(data.OptionPremium));//成交支出 - $("#OptionPremiumSwap").text(numFormart(data.OptionPremiumSwap)); - $("#OtherFund").text(numFormart(data.OtherFund)); - $("#SettlementBalance").text(numFormart(data.SettlementBalance));//了解支出 - $("#Coupon").text(numFormart(data.Coupon)); - $("#SwapBalance").text(numFormart(data.SwapBalance)); - $("#OptionPremiumAndUnwindBalance").text(numFormart(data.OptionPremiumAndUnwindBalanceTotal)); - $("#ExerciseBalance").text(numFormart(data.ExerciseBalance)); - $("#ToDayRemainFund").text(numFormart(data.AmountFund)); - $("#TodayRemianFundProduct").text(numFormart(data.GuaranteesTotalAmount)); - $("#WorstCastClientPayable").text(numFormart(data.MinusPayableMarginTotal)); - $("#WorstCastClientPayable").val(numFormart(data.MinusPayableMarginTotal)); - $("#PositionPremium").text(numFormart(-data.PositionPremiumNetCash)); - $("#EndDesirableFund").text(numFormart(data.EndDesirableFund)); - if (data.IsPayableMarginManual || data.ClientBalanceGap) { - $("#WorstCastClientPayable").css("border-color", "red"); - } - else { - $("#WorstCastClientPayable").css("border-color", "initial"); - } - if (data.IsPayableMarginLock && canUpdatePayableMargin) { - $("#unlock").show(); - } - else { - $("#unlock").hide(); - } - - $("#TotalMargin").text(numFormart(data.TotalMarginTotal)); - $("#Credit").text(numFormart(data.TotalCredit)); - + $("#MySideMargin").text(numFormart(data.MySideMargin)); $("#WinLoss").text(numFormart(data.WinLoss)); - $("#PositionPremiumNetCash").text(numFormart(data.PositionPremiumNetCash)); - $("#Pv").text(numFormart(isPvRounded ? data.RoundedPositionPv : data.PositionPv)); + $("#CashInCashOutChange").text(numFormart(data.NetFundAll)); + $("#MarginBalance").text(numFormart(data.MarginBalance)); $("#PositionPnl").text(numFormart(isPvRounded ? data.RoundedPositionPnl : data.PositionPnl)); - $("#PrepaymentAmount").text(numFormart(data.PrepaymentAmount)); - $("#Amount").text(numFormart(isPvRounded ? data.RoundedTotalAmountTotal : data.TotalAmountTotal)); - $("#Margin").text(numFormart(data.MarginByPayableMarginTotal)); - $("#ClosedTradePayableFund").text(numFormart(data.ClosedTradePayableFundTotal)); + $("#NetFundAll").text(numFormart(data.NetFund)); + $("#SwapMarketAmount").text(numFormart(data.SwapMarketAmount)); + $("#Pv").text(numFormart(isPvRounded ? data.RoundedPositionPv : data.PositionPv)); + $("#VmFundSum").text(numFormart(data.VmFundSum)); + $("#AvailableFund").text(numFormart(data.AvailableAmount)); + $("#OtherFund").text(numFormart(data.OtherFund)); $("#PositionTradePayableFund").text(numFormart(data.PositionTradePayableFundTotal)); - - if (isGuoTou) { - $("#ToEndBalance").text(numFormart(data.ToEndBalance)); - $("#WinLossSum").text(numFormart(data.WinLossSum)); - $("#AmountFundWithPositionPnl").text(numFormart(data.AmountFundWithPositionPnl)); - $("#OptionPremiumAndSwapSum").text(numFormart(data.OptionPremiumAndSwapSum)); - } - - if (isRunHe) { - //东证界面上没有这个,追保用追保金额计算 - $("#PayableFund").val(numFormart(data.MarginByPayableMarginTotal)); - //东证有授信占用 - $("#CreditOccupy").text(numFormart(Math.min(data.TotalCredit, Math.max(data.MinusPayableMarginTotal - data.AmountFund, 0)))); - $("#AvailableFund").text(numFormart(data.AvailableAmount + data.TotalCredit)); - $("#DesirableFund").text(numFormart(Math.max(data.AvailableAmount, 0))); - } else { - $("#PayableFund").val(numFormart(data.PayableFundTotal)); - $("#AvailableFund").text(numFormart(data.AvailableAmount)); - $("#DesirableFund").text(numFormart(data.DesirableFundTotal)); - } - $("#SellTradePrice").text(numFormart(data.SellTradePrice)); - $("#ClientSellPositionPnl").text(numFormart(data.ClientSellPositionPnl)); - - $("#TotalNetSettlement").text(numFormart(data.TotalNetSettlementTotal)); - - $("#IsTradeCredit").val(data.IsTradeCredit); - $("#TotalCredit").val(data.TotalCredit); - $("#MarginBalance").val(data.MarginBalance); - $("#FrozenMarginMoney").val(data.FrozenMarginMoney); - $("#FrozenRedeemFunds").val(numFormart(data.FrozenRedeemFunds)); - $("#FundThreshold").val(data.FundThreshold); - - if (!data.IsLatestDate) { - $("#latestDataTip").show(); - } - else { - $("#latestDataTip").hide(); - } - - //定制需求 #TRS-ZS-144 每日估值报告字段调整 - if (ylotc.Company == '浙商') { - //保证金占用- 浙商 经过沟通,取值沿用-预付金占用 - $("#NoccupyMargin").text(numFormart(data.MinusPayableMarginTotal)); - //期末结存 = 期初结存+出金入金+已实现盈亏+其他收支 (经过产品沟通,取原理的期末结存值,描述不变更) - $("#ToDayRemainFund").text(numFormart(data.AmountFund)); - //可用资金=期末结存-保证金占用; - $("#AvailableFund").text(numFormart(data.AmountFund - data.MinusPayableMarginTotal)); - //可取资金 = 期末结存 - 持仓亏损 - 保证金占用; 产品沟通调整:可取资金=期末结存-保证金占用+ Min(0,持仓盈亏) - $("#Margin").text(numFormart(data.AmountFund - data.MinusPayableMarginTotal + Math.min(0, isPvRounded ? data.RoundedPositionPnl : data.PositionPnl))); - //总资产=期末结存+持仓市值 ; - $("#Amount").text(numFormart(isPvRounded ? data.RoundedPositionPv + data.AmountFund : data.PositionPv + data.AmountFund)); - } + $("#ToDayRemainFund").text(numFormart(data.AmountFund)); + $("#DesirableFund").text(numFormart(data.DesirableFundTotal)); + $("#Amount").text(numFormart(data.SwapMarketAmount)); }); var data = { clientId: $("#ClientId").val(), ValueDateFrom: $("#ValueDateFrom").val(), ValueDateTo: $("#ValueDate").val() }; diff --git a/YLErpWeb/wwwroot/Scripts/app/marginRate/marginRateSwapList.js b/YLErpWeb/wwwroot/Scripts/app/marginRate/marginRateSwapList.js index 09ad9659..91cab8dc 100644 --- a/YLErpWeb/wwwroot/Scripts/app/marginRate/marginRateSwapList.js +++ b/YLErpWeb/wwwroot/Scripts/app/marginRate/marginRateSwapList.js @@ -158,11 +158,9 @@ const jqgrid1Mgr = (new function () { return cellValue + "天"; } }, { - name: 'InitMarginRate', label: '期初预付金', index: 'InitMarginRate', formatter: percentFormat + name: 'InitMarginRate', label: '初始保证金率', index: 'InitMarginRate', formatter: percentFormat }, { - name: 'InitMarginRebateRate', label: '期初预付金利率', index: 'InitMarginRebateRate', formatter: percentFormat, - }, { - name: 'AddToMarginRebateRate', label: '追加预付金利率', index: 'AddToMarginRebateRate', formatter: percentFormat, + name: 'MaintenanceRate', label: '维持保证金率', index: 'MaintenanceRate', formatter: percentFormat, }, { name: 'OptName', label: '操作人', index: 'OptName' }, {