/// <summary> /// Updates the object from plan and fee data gained from IO Api /// </summary> /// <param name="plan">The plan</param> /// <param name="fee">the Fee</param> public void AddPlanData(MLFSPlan plan, MLFSFee fee) { ProviderName = plan.Provider; if (!plan.IsPreExistingClient) { IsNew = true; } Investment = plan.ContributionsToDate; if (fee != null) { OnGoingPercentage = fee.FeePercentage; Organisation = ""; } }
/// <summary> /// Creates a list of fees from a jarray of IO data /// </summary> /// <param name="jarray">the array of items from IO</param> /// <returns>a list of fees</returns> public static List <MLFSFee> CreateList(JArray jarray) { List <MLFSFee> fees = new List <MLFSFee>(); if (jarray == null) { return(fees); } foreach (JObject p in jarray) { if (p != null) { MLFSFee fee = new MLFSFee(p); fees.Add(fee); } } return(fees); }
/// <summary> /// Takes IO client data and uses it to update information about the sale entry /// </summary> /// <param name="client">the client to which the sale relates</param> public void AddClientData(MLFSClient client, List <MLFSIncome> income) { RelatedClients = client.RelatedClients.ToArray(); MLFSPlan plan = client.Plans.Where(x => x.Reference == this.PlanReference).FirstOrDefault(); if (plan != null) { ProviderName = plan.Provider; if (!plan.IsPreExistingClient) { IsNew = true; } if (plan.CurrentValuation == 0) { this.Investment = plan.ContributionsToDate; } else { this.Investment = plan.CurrentValuation; } MLFSFee fee = client.Fees.Where(x => x.Plan != null && x.Plan.PrimaryID == plan.PrimaryID && x.IsRecurring).FirstOrDefault(); if (fee != null) { if (fee.FeePercentage == 0 && fee.NetAmount != 0) { if (fee.RecurringFrequency == "Monthly") { this.TwelveMonthTrail = fee.NetAmount * 12; } else { this.TwelveMonthTrail = fee.NetAmount; } } else { OnGoingPercentage = fee.FeePercentage; TwelveMonthTrail = Investment * OnGoingPercentage / 100; } } } if (client.Plans != null && client.Plans.Count > 0) { this.EstimatedOtherIncome = 0; List <MLFSPlan> plans = client.Plans.Where(x => (plan == null || x.PrimaryID != plan.PrimaryID) && x.Status != PlanStatus.OutOfForce).Distinct().ToList(); foreach (MLFSPlan p in plans) { MLFSFee fee = client.Fees.Where(x => x.Plan != null && x.Plan.PrimaryID.Contains(p.PrimaryID) && x.IsRecurring).FirstOrDefault(); if (fee != null) { //if it is a plan older than 12 months use the last 12 months to assess income List <MLFSIncome> relatedIncome = income.Where(x => x.IOReference == p.Reference && (x.IncomeType == "Ongoing Fee" || x.IncomeType.Contains("Commission"))).ToList(); if (relatedIncome.Where(x => x.RelevantDate <= DateTime.Now.AddYears(-1)).Count() > 0) { this.EstimatedOtherIncome = relatedIncome.Where(x => x.RelevantDate > DateTime.Now.AddYears(-1)).Sum(y => y.Amount); } else { decimal value = 0; if (p.CurrentValuation == 0) { value = p.ContributionsToDate; } else { value = p.CurrentValuation; } decimal d = value * fee.FeePercentage / 100; this.EstimatedOtherIncome += d; } } } } if (client.CreatedOn < ReportingPeriod.StartDate.AddMonths(-3)) { IsNew = false; } else { IsNew = true; } }