/// <summary> /// /// Overloaded: Calculate the greenzorro & Fund fees on any amount that greenzorro offered an investment service. /// Returns the individual fees as out parameters. /// /// </summary> /// <param name="vintageYearMonthStr"></param> /// <param name="liquidationAmount"></param> /// <param name="vintageCashInvestment"></param> /// <returns>Total greenzorro + Fund fees on a investment amount.</returns> public FeesDto GetWithdrawnFees(decimal vintageCashInvestment, string vintageYearMonthStr, decimal liquidationAmount) { var confRow = confRepo.GetConfRow(); var isAnEarlyWithdrawal = IsAnEarlyWithdrawal(vintageYearMonthStr, confRow); // beyond the unleash day? (early withdrawal fee) decimal earlyCashoutFee = GetEarlyCashoutFee(liquidationAmount, isAnEarlyWithdrawal, (decimal)confRow.EARLY_WITHDRAWAL_FEE_PCNT); var gzFeesAmount = GetGzFeesAmount(liquidationAmount, isAnEarlyWithdrawal, (decimal)confRow.COMMISSION_PCNT); var fundsFeesAmount = GetFundsFeesAmount(liquidationAmount, isAnEarlyWithdrawal, (decimal)confRow.FUND_FEE_PCNT); // hurdle fee var hurdleFee = GetHurdleFee( vintageCashInvestment, liquidationAmount, isAnEarlyWithdrawal, (decimal)confRow.HURDLE_TRIGGER_GAIN_PCNT, (decimal)confRow.EARLY_WITHDRAWAL_FEE_PCNT); // Return all fees var fees = new FeesDto() { EarlyCashoutFee = earlyCashoutFee, FundFee = fundsFeesAmount, GzFee = gzFeesAmount, HurdleFee = hurdleFee, Total = gzFeesAmount + fundsFeesAmount + earlyCashoutFee + hurdleFee }; return(fees); }
/// <summary> /// /// Calculate the vintage in latest portfolio market value /// /// </summary> /// <param name="customerId"></param> /// <param name="vintageToBeLiquidated"></param> /// <param name="portfolioPrices"></param> /// <param name="vintageSharesDto"></param> /// <param name="fees"></param> /// <returns></returns> private decimal GetVintageValuePricedNow( int customerId, VintageDto vintageToBeLiquidated, PortfolioPricesDto portfolioPrices, out VintageSharesDto vintageSharesDto, out FeesDto fees) { var presentMonth = DateTime.UtcNow.ToStringYearMonth(); // Sales after the completion of one month only, have earned no interest var sellingInFollowingMonth = DbExpressions.AddMonth(vintageToBeLiquidated.YearMonthStr); if (sellingInFollowingMonth == presentMonth) { vintageSharesDto = new VintageSharesDto() { HighRiskShares = 0m, MediumRiskShares = 0m, LowRiskShares = 0m, PresentMarketPrice = vintageToBeLiquidated.MarketPrice = vintageToBeLiquidated.InvestmentAmount }; } // Sales post 2 or more months else { vintageSharesDto = userPortfolioSharesRepo.GetVintageSharesMarketValue( customerId, vintageToBeLiquidated.YearMonthStr, portfolioPrices); } // Obsolete Special case: SALE within same month (ref alaa) // if vintageToBeSold month = current month (early cashout in same month) // value of vintage is what's not withdrawn from the month's investment cash if (vintageToBeLiquidated.YearMonthStr == DateTime.UtcNow.ToStringYearMonth()) { vintageSharesDto.PresentMarketPrice = vintageToBeLiquidated.InvestmentAmount - vintageToBeLiquidated.SellingValue - vintageToBeLiquidated.SoldFees; } fees = gzTransactionRepo.GetWithdrawnFees( vintageToBeLiquidated.InvestmentAmount, vintageToBeLiquidated.YearMonthStr, vintageSharesDto.PresentMarketPrice); return(vintageSharesDto.PresentMarketPrice); }
/// <summary> /// /// Unit Test Supporting verson /// /// Calculate the vintage in portfolio market value for a given month. /// /// </summary> /// <param name="customerId"></param> /// <param name="vintageCashInvestment"></param> /// <param name="vintageYearMonthStr"></param> /// <param name="sellOnThisYearMonth"></param> /// <param name="vintageSharesDto"></param> /// <param name="fees"></param> /// <returns></returns> private decimal GetVintageValuePricedOn( int customerId, decimal vintageCashInvestment, string vintageYearMonthStr, string sellOnThisYearMonth, out VintageSharesDto vintageSharesDto, out FeesDto fees) { vintageSharesDto = userPortfolioSharesRepo.GetVintageSharesMarketValueOn( customerId, vintageYearMonthStr, sellOnThisYearMonth); fees = gzTransactionRepo.GetWithdrawnFees(vintageCashInvestment, vintageYearMonthStr, vintageSharesDto.PresentMarketPrice); return(vintageSharesDto.PresentMarketPrice); }