refactor(SwapModule): 简化预付金利息计算逻辑
- 移除本金绝对值加权平均的复杂计算方式 - 直接对各腿利息金额进行轧差求和 - 保留收取为正、支付为负的方向转换逻辑 - 删除不再使用的本金权重计算代码 - 简化方法实现并提高计算效率
This commit is contained in:
@@ -2611,18 +2611,13 @@ namespace YLErp.Modules.SwapModule
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算预付金利息。先按收取为正、支付为负转换为我方视角,
|
||||
/// 再按日终本金绝对值加权平均;本金合计为零时返回零。
|
||||
/// 计算预付金利息金额。InterestIncomeSum 已是各腿利息金额,
|
||||
/// 按收取为正、支付为负直接轧差求和,不做本金加权。
|
||||
/// </summary>
|
||||
private static decimal CalculateWeightedMarginInterest(IEnumerable<eod_swap_position> margins)
|
||||
{
|
||||
var marginList = margins.ToList();
|
||||
var totalWeight = marginList.Sum(x => Math.Abs(x.InterestPrincipalFix));
|
||||
return totalWeight == 0
|
||||
? 0
|
||||
: marginList.Sum(x => x.InterestIncomeSum
|
||||
* (x.InterestDirection == (int)SwapDirectionEnum.收取 ? 1 : -1)
|
||||
* Math.Abs(x.InterestPrincipalFix)) / totalWeight;
|
||||
return margins.Sum(x =>
|
||||
x.InterestIncomeSum * (x.InterestDirection == (int)SwapDirectionEnum.收取 ? 1 : -1));
|
||||
}
|
||||
/// <summary>
|
||||
/// 将数据库中以公司/交易簿记方向保存的日终字段转换为客户视角。
|
||||
|
||||
Reference in New Issue
Block a user