Changes续作功能的实现
This commit is contained in:
@@ -45,49 +45,26 @@ namespace YLErp.Web.Controllers
|
||||
ViewBag.observationDate = observationDate;
|
||||
return View();
|
||||
}
|
||||
public ActionResult TradeEdit(string enid, bool isUseApproval = false)
|
||||
public ActionResult TradeEdit(string enid, string renewEnid = null, bool isUseApproval = false)
|
||||
{
|
||||
ViewBag.isUseApproval = isUseApproval;
|
||||
var intid = DecryptInt(enid);
|
||||
// The new/renew flow uses the literal "0" to indicate that no trade exists yet.
|
||||
var intid = enid == "0" ? 0 : DecryptInt(enid);
|
||||
trade r = null;
|
||||
if (intid == 0)
|
||||
{
|
||||
var defaultMarginTemplateName = SwapMarginTemplateConfigService.GetConfig().defaultValue;
|
||||
TradeExtendJson tradeExtendJson = new TradeExtendJson()
|
||||
r = CreateNewTrade();
|
||||
var renewTradeId = DecryptInt(renewEnid);
|
||||
if (renewTradeId > 0)
|
||||
{
|
||||
FlowBookMode = (int)FlowBookModeEnum.否,
|
||||
FloatingPnlAnnualized = false,
|
||||
NeedOpenFee = false,
|
||||
OpenFeeType = 0,
|
||||
InterestCalcMode = "10",
|
||||
SettlementRules=0,
|
||||
DividendPayDate=0
|
||||
};
|
||||
var tradeDateCountry = GetBestCountry(valuedateBLL.ValueDate.Year);
|
||||
r = new trade()
|
||||
{
|
||||
TradeType = "收益互换",
|
||||
UnderlyingInstrumentType = "Stock",
|
||||
StartDate = valuedateBLL.ValueDate,
|
||||
TradeDate = QdpCalendarHelper.GetNonHolidayDefore(valuedateBLL.ValueDate.AddDays(-1), tradeDateCountry),
|
||||
TraderId = CurUser.UserId,
|
||||
TraderName = CurUser.UserName,
|
||||
MarginTemplateName = defaultMarginTemplateName,
|
||||
OpponentRole = "乙方",
|
||||
OriginalStockEqvNotional = 0,
|
||||
StructureType = "普通收益互换",
|
||||
InitialMargin = 0
|
||||
};
|
||||
r.StructureType = "普通债券类收益互换";
|
||||
tradeExtendJson.FlowBookMode = (int)FlowBookModeEnum.先进先出;
|
||||
r.trade_extend = new trade_extend()
|
||||
{
|
||||
ExtendJson = JsonHelper.Serialize(tradeExtendJson)
|
||||
};
|
||||
r.MetaDic = new Dictionary<string, string>
|
||||
{
|
||||
{ "清算机构", "甲方" }
|
||||
};
|
||||
var sourceTrade = new SwapTradeService(CurUser).GetSwapTrade(renewTradeId);
|
||||
if (sourceTrade == null)
|
||||
{
|
||||
return ShowError("没有找到交易数据");
|
||||
}
|
||||
|
||||
r = CreateRenewTrade(sourceTrade, r);
|
||||
}
|
||||
return View(r);
|
||||
}
|
||||
SwapTradeService swapTradeService = new SwapTradeService(CurUser);
|
||||
@@ -99,6 +76,92 @@ namespace YLErp.Web.Controllers
|
||||
|
||||
return View(r);
|
||||
}
|
||||
|
||||
private trade CreateNewTrade()
|
||||
{
|
||||
var defaultMarginTemplateName = SwapMarginTemplateConfigService.GetConfig().defaultValue;
|
||||
var tradeExtendJson = new TradeExtendJson()
|
||||
{
|
||||
FlowBookMode = (int)FlowBookModeEnum.先进先出,
|
||||
FloatingPnlAnnualized = false,
|
||||
NeedOpenFee = false,
|
||||
OpenFeeType = 0,
|
||||
InterestCalcMode = "10",
|
||||
SettlementRules = 0,
|
||||
DividendPayDate = 0
|
||||
};
|
||||
var tradeDateCountry = GetBestCountry(valuedateBLL.ValueDate.Year);
|
||||
return new trade()
|
||||
{
|
||||
TradeType = "收益互换",
|
||||
UnderlyingInstrumentType = "Stock",
|
||||
StartDate = valuedateBLL.ValueDate,
|
||||
TradeDate = QdpCalendarHelper.GetNonHolidayDefore(valuedateBLL.ValueDate.AddDays(-1), tradeDateCountry),
|
||||
TraderId = CurUser.UserId,
|
||||
TraderName = CurUser.UserName,
|
||||
MarginTemplateName = defaultMarginTemplateName,
|
||||
OpponentRole = "乙方",
|
||||
OriginalStockEqvNotional = 0,
|
||||
StructureType = "普通债券类收益互换",
|
||||
InitialMargin = 0,
|
||||
trade_extend = new trade_extend()
|
||||
{
|
||||
ExtendJson = JsonHelper.Serialize(tradeExtendJson)
|
||||
},
|
||||
MetaDic = new Dictionary<string, string>
|
||||
{
|
||||
{ "清算机构", "甲方" }
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private trade CreateRenewTrade(trade sourceTrade, trade defaultTrade)
|
||||
{
|
||||
var renewTrade = sourceTrade.Clone();
|
||||
renewTrade.id = 0;
|
||||
renewTrade.TradeNumber = string.Empty;
|
||||
renewTrade.ParentTradeId = 0;
|
||||
renewTrade.TradeDate = defaultTrade.TradeDate;
|
||||
renewTrade.StartDate = defaultTrade.StartDate;
|
||||
renewTrade.ExerciseDate = null;
|
||||
renewTrade.MaturityDate = null;
|
||||
renewTrade.SettlementDate = null;
|
||||
renewTrade.UnWindDate = null;
|
||||
renewTrade.PremiumPayDate = null;
|
||||
renewTrade.SettlementFlagDate = null;
|
||||
renewTrade.HasPartialUnWind = null;
|
||||
renewTrade.TradeStatus = null;
|
||||
renewTrade.CheckStatus = null;
|
||||
renewTrade.ProcessStatus = null;
|
||||
renewTrade.ProcessOrderId = 0;
|
||||
renewTrade.ProcessOrderBranch = 0;
|
||||
renewTrade.ProcessOptDate = null;
|
||||
renewTrade.ValidState = null;
|
||||
renewTrade.CreateDate = null;
|
||||
renewTrade.TradeSource = null;
|
||||
renewTrade.trade_extend = sourceTrade.trade_extend?.Clone() ?? defaultTrade.trade_extend;
|
||||
renewTrade.trade_extend.TradeId = 0;
|
||||
renewTrade.trade_Initial_Margin = sourceTrade.trade_Initial_Margin?.Clone() ?? new trade_initial_margin();
|
||||
renewTrade.trade_Initial_Margin.TradeId = 0;
|
||||
renewTrade.MetaDic = sourceTrade.MetaDic == null
|
||||
? new Dictionary<string, string>()
|
||||
: new Dictionary<string, string>(sourceTrade.MetaDic);
|
||||
renewTrade.swap_positions = sourceTrade.swap_positions.Select(position =>
|
||||
{
|
||||
var renewPosition = position.Clone();
|
||||
renewPosition.id = 0;
|
||||
renewPosition.PositionId = 0;
|
||||
renewPosition.SwapTradeId = 0;
|
||||
renewPosition.PosiNumber = null;
|
||||
renewPosition.PosiStartDate = defaultTrade.StartDate.Value;
|
||||
renewPosition.PosiMatuirityDate = null;
|
||||
renewPosition.HappenDate = null;
|
||||
renewPosition.InterestSwapInterval = null;
|
||||
renewPosition.Obervation = null;
|
||||
return renewPosition;
|
||||
}).ToList();
|
||||
return renewTrade;
|
||||
}
|
||||
/// <summary>
|
||||
/// 详情
|
||||
/// </summary>
|
||||
|
||||
@@ -157,6 +157,7 @@
|
||||
{
|
||||
@MyControls.Btn("收益结算", string.Format("unWindLongShortSwap('{0}')", tradeModel.EncryptId))
|
||||
}
|
||||
@MyControls.Btn("续做", string.Format("renewTrade('{0}')", tradeModel.EncryptId))
|
||||
}
|
||||
</div>
|
||||
|
||||
|
||||
@@ -26,6 +26,10 @@ function editTrade(enid) {
|
||||
window.location.href = `/swapTrade2/tradeEdit/?enid=${enid}`;
|
||||
}
|
||||
|
||||
function renewTrade(enid) {
|
||||
window.location.href = `/swapTrade2/tradeEdit/?enid=0&renewEnid=${encodeURIComponent(enid)}`;
|
||||
}
|
||||
|
||||
function editTradeRemarkInfo(enid) {
|
||||
main.open("修改备注", "/trade/EditRemarkInfo?enid=" + enid, { area: ["700px", "500px"] });
|
||||
}
|
||||
@@ -586,4 +590,4 @@ function SubmissionFields(enid) {
|
||||
|
||||
function SubmissionFieldsHistory(enid) {
|
||||
main.open("报送相关字段填写", "/trade/submissionFieldsHistory?encryptId=" + enid);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user