Exemplo n.º 1
0
        public bool CanFundAcceptParticipationAddition(int fundId, decimal amount)
        {
            IFundRepository fundRepository = _DataRepositoryFactory.GetDataRepository <IFundRepository>();
            Fund            fund           = fundRepository.Get(fundId);

            if (fund == null)
            {
                FundFault fault = new FundFault(string.Format("Fund {0} does not exist in the system.", fundId));
                throw new FaultException <FundFault>(fault, fault.Message);
            }

            if (amount <= 0)
            {
                FundFault fault = new FundFault(string.Format("Allocation amount ${0} is invalid.", amount));
                throw new FaultException <FundFault>(fault, fault.Message);
            }
            else
            {
                decimal fundMaximumAUM = fund.Strategies.Sum(e => e.MaximumAUM);
                decimal fundCurrentAUM = fund.Strategies.Sum(e => e.CurrentAUM);

                if (amount > (fundMaximumAUM - fundCurrentAUM))
                {
                    FundFault fault = new FundFault(string.Format("Allocation amount ${0} exceeds Fund {1} available capacity.", amount, fundId));
                    throw new FaultException <FundFault>(fault, fault.Message);
                }
            }

            return(true);
        }
Exemplo n.º 2
0
        public bool CanFundAcceptNewParticipation(int fundId, decimal amount)
        {
            bool fundHasSufficientCapacity = CanFundAcceptParticipationAddition(fundId, amount);

            if (fundHasSufficientCapacity)
            {
                IFundRepository fundRepository = _DataRepositoryFactory.GetDataRepository <IFundRepository>();
                Fund            fund           = fundRepository.Get(fundId);

                if (!fund.OpenToNew || DateTime.UtcNow > fund.CloseDate)
                {
                    FundFault fault = new FundFault(string.Format("Fund {0} is closed to new participations.", fundId));
                    throw new FaultException <FundFault>(fault, fault.Message);
                }

                return(true);
            }
            else
            {
                return(fundHasSufficientCapacity);
            }
        }