Требуется получить MovementData на основе Типа суммы
- , если AmountType.Reserve, тогда MovementData должен быть получен на основе LatestReserveDate
- , если AmountType.RecoveryReserve, то MovementData должен показатьданные на основе LatestRecoveryReserveDate
Примечание. На данный момент я получаю данные движения на основе LatestRecoveryreserveDate вместо LatestReserveDate, что неверно.
foreach (var keys in itemsDict)
{
CurrentFinancialMovementData movementData =
keys.OrderByDescending(s => s.LatestReserveDate ?? s.LatestRecoveryReserveDate)
.ThenByDescending(x => x.ReserveDaySequence)
.First();
CurrentFinancialMovementData movementDataReserve =
keys.Where(s => s.AmountType == (short)StaticValues.AmountType.Reserve)
.OrderByDescending(a => a.LatestReserveDate)
.ThenByDescending(x => x.ReserveDaySequence)
.FirstOrDefault();
CurrentFinancialMovementData movementDataRecoveryReserve =
keys.Where(s => s.AmountType == (short)StaticValues.AmountType.RecoveryReserve)
.OrderByDescending(a => a.LatestRecoveryReserveDate)
.ThenByDescending(x => x.ReserveDaySequence)
.FirstOrDefault();
foreach (var item in keys)
{
if (item.ClaimTransactionSourceCode == (short)StaticValues.ClaimTransactionSource.Reserve ||
item.ClaimTransactionSourceCode == (short)StaticValues.ClaimTransactionSource.Payment ||
item.ClaimTransactionSourceCode == (short)StaticValues.ClaimTransactionSource.PaymentCancellation)
{
if (item.MovementAmount.HasValue)
{
movementData.CurrentIncurred = movementData.CurrentIncurred.GetValueOrDefault()
+ item.MovementAmount.GetValueOrDefault();
}
if (item.AmountType == (short)StaticValues.AmountType.Reserve)
{
if (item.MovementAmount.HasValue)
{
movementData.CurrentReserve = movementDataReserve.CurrentReserve.GetValueOrDefault()
+ item.MovementAmount.GetValueOrDefault();
movementData.LatestReserveDate = movementDataReserve.LatestReserveDate;
}
}
else
{
if (item.TransactionAmount.HasValue)
{
movementData.CurrentPayments = movementData.CurrentPayments.GetValueOrDefault()
+ item.TransactionAmount.GetValueOrDefault();
}
}
}
if (item.ClaimTransactionSourceCode == (short)StaticValues.ClaimTransactionSource.RecoveryReserve ||
item.ClaimTransactionSourceCode == (short)StaticValues.ClaimTransactionSource.RecoveryReceipt)
{
if (item.MovementAmount.HasValue)
{
movementData.CurrentRecovery = movementData.CurrentRecovery.GetValueOrDefault()
+ item.MovementAmount.GetValueOrDefault();
}
if (item.AmountType == (short)StaticValues.AmountType.RecoveryReserve)
{
if (item.MovementAmount.HasValue)
{
movementData.CurrentRecoveryReserve = movementDataRecoveryReserve.CurrentRecoveryReserve.GetValueOrDefault()
+ item.MovementAmount.GetValueOrDefault();
movementData.LatestRecoveryReserveDate = movementDataRecoveryReserve.LatestRecoveryReserveDate;
}
}
else
{
if (item.TransactionAmount.HasValue)
{
movementData.CurrentReceipts = movementData.CurrentReceipts.GetValueOrDefault()
+ item.TransactionAmount.GetValueOrDefault();
}
}
}
}
}