private void ConvertFxFundingSourceToMatureFuturePaymentFundingSource(LineItem mfpLineItem)
        {
            if (mfpLineItem.RelatedLineItemId.HasValue == false)
            {
                throw new ArgumentException(string.Format("Can't find related future payment order for mature line item id '{0}'", mfpLineItem.Id));
            }

            mfpLineItem.FundingSource = new MatureFuturePaymentFundingSource
            {
                RelatedFuturePaymentOrders = new List <Order> {
                    orderMapper.GetOrderByLineItemId(mfpLineItem.RelatedLineItemId.Value, false)
                },
                ClientRateComponent = mfpLineItem.FundingSource.ClientRateComponent,
                QuoteId             = mfpLineItem.FundingSource.QuoteId
            };
        }
Example #2
0
        private Order GetRelatedOrderFromRelatedLineItems(Order linkedOrder)
        {
            if (linkedOrder.OrderType == OrderType.LockInDisbursalOrder)
            {
                return(null);
            }

            var relatedLineItemIds = GetRelatedLineItemIds(linkedOrder);

            if (NeedToPopulateAllLineItems(linkedOrder))
            {
                var relatedOrder = relatedLineItemIds.Any() ? orderMapper.GetOrderByLineItemId(relatedLineItemIds[0], true) : null;
                if (relatedOrder == null)
                {
                    throw new UnableToRetrieveRelatedOrderException(linkedOrder);
                }
#if DEBUG
                Console.WriteLine(" Read related OrderId from GetRelatedOrderFromRelatedLineItems {0}", (relatedOrder.Id));
#endif
                return(orderMapper.GetOrder(relatedOrder.Id));
            }

            return(relatedLineItemIds.Any() ? orderMapper.GetOrderByLineItemId(relatedLineItemIds[0], true) : null);
        }
        private LineItemFundingSource CreateDrawdownFundingSource(LineItem lineItem)
        {
            var forwardOrder = orderMapper.GetOrderByLineItemId(lineItem.ContributingItemId, false);

            if (forwardOrder == null)
            {
                throw new InvalidFundingSourceException(lineItem.Id);
            }

            var forwardLineItem = forwardOrder.LineItems.SingleOrDefault();

            if (forwardLineItem == null || forwardLineItem.FundingSource == null || forwardLineItem.FundingSource.ClientRateComponent == null)
            {
                throw new InvalidFundingSourceException(lineItem.Id);
            }

            return(IsPredelivery(lineItem, forwardLineItem.WindowStartDate)
                       ? CreatePredeliveryFundingSource(lineItem.QuoteId, forwardOrder)
                       : CreateForwardContractFundingSource(forwardOrder, forwardLineItem));
        }
        private LineItemFundingSource GetFundingSource(LineItem mfpRepoLineItem)
        {
            if (mfpRepoLineItem.RelatedLineItemId.HasValue && mfpRepoLineItem.RelatedLineItemId > 0)
            {
                var relatedOrder    = orderMapper.GetOrderByLineItemId(mfpRepoLineItem.RelatedLineItemId.Value, false);
                var relatedLineItem = relatedOrder.LineItems.FirstOrDefault(li => li.Id == mfpRepoLineItem.RelatedLineItemId.Value);

                if (relatedLineItem == null)
                {
                    throw new ArgumentNullException(string.Format("Can't find related MFP line item '{0}'", relatedLineItem.Id));
                }

                if (relatedLineItem.FundingSource != null)
                {
                    return(relatedLineItem.FundingSource);
                }
            }

            return(new NullLineItemFundingSource());
        }