public override void Visit(Order order) { if (order.OrderType == OrderType.MatureFuturePaymentsOrder) { var mappings = lineItemToMatureLineItemMapper.GetLineItemMatureLineItemMappingsByMatureOrderId(order.Id); order.LineItems .Where(li => li.FundingSource == null || li.FundingSource is NullLineItemFundingSource) .ForEach(li => { var relatedLineItemQuoteId = GetRelatedLineItemQuoteId(li.RelatedLineItemId); li.FundingSource = relatedLineItemQuoteId > 0 ? GetFundingSource(li, relatedLineItemQuoteId) : GetFundingSource(li, mappings.Where(m => m.RelatedMatureOrderLineItemId == li.Id)); }); order.LineItems.Where(li => li.FundingSource is FxFundingSource).ForEach(ConvertFxFundingSourceToMatureFuturePaymentFundingSource); } else if (IsReissuedMatureFuturePaymentsOrder(order as LinkedOrder)) { var mappings = lineItemToMatureLineItemMapper.GetLineItemMatureLineItemMappingsByMatureOrderId(((LinkedOrder)order).RelatedOrder.Id); order.LineItems .Where(li => li.FundingSource == null || li.FundingSource is NullLineItemFundingSource) .ForEach(li => { var relatedLineItemQuoteId = GetRelatedLineItemQuoteId(li.RelatedLineItemId); li.FundingSource = relatedLineItemQuoteId > 0 ? GetFundingSource(li, relatedLineItemQuoteId) : GetFundingSource(li, mappings.Where(m => m.RelatedMatureOrderLineItemId == li.RelatedLineItemId.Value)); }); } }