#EQD-6604 国联民生-确认书编码生成环节移到簿记(支持手工录入)
feat: 国联民生收益互换簿记后按确认书规则生成交易编号 - - 国联收益互换首次入库后复用原交易确认书编号规则生成交易编号,保留手工填写的交易编号 - 覆盖手工新增、系统流水自动簿记、普通交易导入、流水导入和日终合成今日交易流水 - 自动流水簿记增加本地事务,交易编号回写与基础簿记数据失败时统一回滚 - 交易确认书生成时直接取交易编号,不再重新生成确认书编号 - 结算管理-交易确认书页面将合约编号更名为交易确认书编号 - 上传确认书时将合约编号更名为交易确认书编号 - 历史交易编号不处理
This commit is contained in:
@@ -1356,11 +1356,7 @@ namespace YLErp.Modules.TradeModule.DocGenerateModule
|
||||
{
|
||||
return UniqueTimeId.GetStr();
|
||||
}
|
||||
if (Trade.TradeType == "收益互换")
|
||||
{
|
||||
return GuolianContractNoGenerator.Generate(DbContext, (trade)Trade, _client.Code);
|
||||
}
|
||||
return Trade.TradeNumber;
|
||||
return Trade.TradeNumber;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -2881,4 +2877,4 @@ namespace YLErp.Modules.TradeModule.DocGenerateModule
|
||||
return DbContext.swap_event.FirstOrDefault(x => x.id == eventId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -667,7 +667,9 @@ namespace YLErp.Modules.TradeModule.DocGenerateModule
|
||||
|
||||
public (bool, string, DateTime, string) UploadContractFile(string encryptId, string fileDescription, string ContractCode, bool OurpartySeal, bool CounterpartySeal, UploadFileModel uploadFileModel)
|
||||
{
|
||||
|
||||
var contractCodeName = PS.Config.Company == YLErp.Configuration.CompanyEnum.国联
|
||||
? "交易确认书编号"
|
||||
: "合约编号";
|
||||
try
|
||||
{
|
||||
var msg = "";
|
||||
@@ -707,7 +709,7 @@ namespace YLErp.Modules.TradeModule.DocGenerateModule
|
||||
{
|
||||
if (db.trade_contract_r.Where(O => O.ContractCode == ContractCode && O.IsValid).Any())
|
||||
{
|
||||
return (false, "合约编号已存在", DateTime.Now, "");
|
||||
return (false, $"{contractCodeName}已存在", DateTime.Now, "");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -854,6 +856,10 @@ namespace YLErp.Modules.TradeModule.DocGenerateModule
|
||||
UploadFileModel uploadFileModel)
|
||||
{
|
||||
var nowDate = DateTime.Now;
|
||||
var isGuolian = PS.Config.Company == YLErp.Configuration.CompanyEnum.国联;
|
||||
var contractCodeName = isGuolian
|
||||
? "交易确认书编号"
|
||||
: "合约编号";
|
||||
if (tradeId <= 0)
|
||||
{
|
||||
return new UploadContractFileNewResult { Success = false, Message = "请传入参数", OptDate = nowDate, DocumentPath = string.Empty };
|
||||
@@ -887,7 +893,7 @@ namespace YLErp.Modules.TradeModule.DocGenerateModule
|
||||
activeCode = (contractCode ?? "").Trim();
|
||||
if (string.IsNullOrWhiteSpace(activeCode))
|
||||
{
|
||||
return new UploadContractFileNewResult { Success = false, Message = "合约编号必填", OptDate = nowDate, DocumentPath = string.Empty };
|
||||
return new UploadContractFileNewResult { Success = false, Message = $"{contractCodeName}必填", OptDate = nowDate, DocumentPath = string.Empty };
|
||||
}
|
||||
|
||||
if (!string.Equals(oldCode, activeCode, StringComparison.OrdinalIgnoreCase))
|
||||
@@ -895,7 +901,7 @@ namespace YLErp.Modules.TradeModule.DocGenerateModule
|
||||
var isExists = new TradeContractGenerateService(OptUser).GetExistsContractCode(new[] { activeCode }).Any();
|
||||
if (isExists)
|
||||
{
|
||||
return new UploadContractFileNewResult { Success = false, Message = "合约编号已存在", OptDate = nowDate, DocumentPath = string.Empty };
|
||||
return new UploadContractFileNewResult { Success = false, Message = $"{contractCodeName}已存在", OptDate = nowDate, DocumentPath = string.Empty };
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -907,18 +913,25 @@ namespace YLErp.Modules.TradeModule.DocGenerateModule
|
||||
}
|
||||
else
|
||||
{
|
||||
var client = DataCacheProvider.GetClientDataSource().GetData(trade.ClientId);
|
||||
if (string.IsNullOrEmpty(client?.Code))
|
||||
if (isGuolian)
|
||||
{
|
||||
return new UploadContractFileNewResult { Success = false, Message = "对手方代码缩写缺失,请联系运营组同事维护", OptDate = nowDate, DocumentPath = string.Empty };
|
||||
activeCode = trade.TradeNumber;
|
||||
}
|
||||
else
|
||||
{
|
||||
var client = DataCacheProvider.GetClientDataSource().GetData(trade.ClientId);
|
||||
if (string.IsNullOrEmpty(client?.Code))
|
||||
{
|
||||
return new UploadContractFileNewResult { Success = false, Message = "对手方代码缩写缺失,请联系运营组同事维护", OptDate = nowDate, DocumentPath = string.Empty };
|
||||
}
|
||||
activeCode = GenerateContractCodeForTrade(db, trade, client?.Code);
|
||||
}
|
||||
activeCode = GenerateContractCodeForTrade(db, trade, client?.Code);
|
||||
}
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(activeCode))
|
||||
{
|
||||
return new UploadContractFileNewResult { Success = false, Message = "合约编号生成失败", OptDate = nowDate, DocumentPath = string.Empty };
|
||||
return new UploadContractFileNewResult { Success = false, Message = $"{contractCodeName}生成失败", OptDate = nowDate, DocumentPath = string.Empty };
|
||||
}
|
||||
|
||||
trade_contract_document oldDoc = null;
|
||||
@@ -1006,19 +1019,13 @@ namespace YLErp.Modules.TradeModule.DocGenerateModule
|
||||
return new UploadContractFileNewResult { Success = false, Message = "操作出错", OptDate = nowDate, DocumentPath = string.Empty };
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 生成合约编号逻辑:如果是收益互换交易,使用国联的生成规则;否则默认使用 TradeNumber 作为合约编号。
|
||||
/// </summary>
|
||||
/// <param name="db"></param>
|
||||
/// <param name="trade"></param>
|
||||
/// <param name="clientCode"></param>
|
||||
/// <returns></returns>
|
||||
private string GenerateContractCodeForTrade(YLContext db, trade trade,string clientCode)
|
||||
private static string GenerateContractCodeForTrade(YLContext db, trade trade, string clientCode)
|
||||
{
|
||||
if (trade.TradeType == "收益互换")
|
||||
{
|
||||
return GuolianContractNoGenerator.Generate(db, trade, clientCode ?? "");
|
||||
return GuolianContractNoGenerator.Generate(db, trade, clientCode ?? string.Empty);
|
||||
}
|
||||
|
||||
return trade.TradeNumber;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using YLErp.BLL;
|
||||
using YLErp.Configuration;
|
||||
using YLErp.DBModels;
|
||||
using YLErp.DBModels.Consts;
|
||||
using YLErp.DBModels.Enums;
|
||||
@@ -17,6 +18,38 @@ namespace YLErp.Modules.TradeModule.DocGenerateModule
|
||||
{
|
||||
private static readonly object _syncLock = new object();
|
||||
|
||||
public static bool IsGuolianSwapTrade(trade trade)
|
||||
{
|
||||
return PS.Config.Company == CompanyEnum.国联
|
||||
&& trade?.TradeType == "收益互换";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 交易首次入库后按国联交易确认书编号规则回写交易编号。
|
||||
/// </summary>
|
||||
/// <returns>是否生成了交易编号</returns>
|
||||
public static bool TryGenerateTradeNumberAfterSave(YLContext dbContext, trade trade)
|
||||
{
|
||||
if (!IsGuolianSwapTrade(trade) || !string.IsNullOrWhiteSpace(trade.TradeNumber))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (trade.id <= 0)
|
||||
{
|
||||
throw new InvalidOperationException("国联收益互换交易编号必须在交易入库后生成");
|
||||
}
|
||||
|
||||
var clientCode = DataCacheProvider.GetClientDataSource().GetData(trade.ClientId)?.Code;
|
||||
if (string.IsNullOrWhiteSpace(clientCode))
|
||||
{
|
||||
throw new ServiceException("对手方代码缩写缺失,请联系运营组同事维护");
|
||||
}
|
||||
|
||||
trade.TradeNumber = Generate(dbContext, trade, clientCode);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生成国贸交易确认书编号
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user