- 在 margin_template_v2 实体中新增 BookIds 字段存储适用簿记账户ID列表 - 实现簿记账户ID的规范化、解析和范围重叠判断逻辑 - 在客户端和默认模板编辑页面添加适用簿记账户选择控件 - 修改预付金模板解析逻辑以考虑簿记账户适用性 - 更新交易绑定模板验证以检查簿记账户范围匹配 - 优化模板冲突检测算法以支持簿记账户范围重叠验证 - 添加簿记账户ID存在性校验防止无效引用 - 实现前端动态筛选适用当前资产的模板选项
48 lines
1.8 KiB
C#
48 lines
1.8 KiB
C#
using BaseOUDAL;
|
|
using YLErp.Models;
|
|
|
|
namespace YLErp.Modules.SwapModule
|
|
{
|
|
public static class SwapMarginTemplateConfigService
|
|
{
|
|
public const string DictionaryName = "保证金模板名称";
|
|
|
|
public static readonly string[] InitialTemplateNames = { "现金保证金", "授信保证金" };
|
|
|
|
public static SwapMarginTemplateConfig GetConfig(int? assetId = null)
|
|
{
|
|
//保证金模板V2迁移:交易页"保证金模板"下拉的选项改为"预付金模板V2"页面维护的模板(自定义+全局默认,存模板名称),不再使用数据字典
|
|
//互换交易只显示"适用结构"包含 收益互换 的模板
|
|
using var db = new YLErp.BLL.YLContext();
|
|
var items = db.margin_template_v2
|
|
.Where(item => !item.IsForClient && item.IsValid && item.TradeTypes.Contains("收益互换"))
|
|
.OrderBy(item => item.IsDefault).ThenBy(item => item.id)
|
|
.ToList()
|
|
.Where(item => !assetId.HasValue || assetId.Value <= 0 || item.IsApplicableToBook(assetId.Value))
|
|
.Select(item => new SwapMarginTemplateOption { Text = item.Name, Value = item.Name, BookIds = item.BookIds })
|
|
.ToArray();
|
|
|
|
return new SwapMarginTemplateConfig
|
|
{
|
|
options = items,
|
|
//不再默认选中任何模板,由用户在交易上显式选择;未选择则不绑定模板
|
|
defaultValue = null
|
|
};
|
|
}
|
|
}
|
|
|
|
public class SwapMarginTemplateConfig
|
|
{
|
|
public IEnumerable<SwapMarginTemplateOption> options { get; set; }
|
|
|
|
public string defaultValue { get; set; }
|
|
}
|
|
|
|
public class SwapMarginTemplateOption : SelectItem
|
|
{
|
|
public string BookIds { get; set; }
|
|
|
|
public bool IsLegacy { get; set; }
|
|
}
|
|
}
|