public MLFSSale(DataRow row, List <MLFSAdvisor> advisors, MLFSReportingPeriod period, bool isCommission = false) { Adjustments = new HashSet <MLFSDebtorAdjustment>(); ReportingPeriod = period; ReportingPeriodId = period.Id; EstimatedOtherIncome = 0; MLFSAdvisor adv = MLFSAdvisor.Assign(row["Selling Adviser.Id"].ToString(), advisors); AdvisorId = adv.Id; Advisor = adv; IsNew = false; if (isCommission) { PlanReference = "IOB" + row["Id"].ToString(); IOReference = ""; ClientName = row["Owner 1.Full Name"].ToString(); ClientId = row["Owner 1.Id"].ToString(); JointClientName = row["Owner 2.Full Name"].ToString(); JointClientId = row["Owner 2.Id"].ToString(); PlanType = row["Plan Type"].ToString(); ProviderName = row["Provider.Name"].ToString(); RelevantDate = DateTime.Parse(row["Submitted Date"].ToString()); if (string.IsNullOrEmpty(row["Expected Commission - Non-Indemnity"].ToString())) { NetAmount = Tools.HandleNull(row["Expected Commission - Total Initial"].ToString()); } else { NetAmount = Tools.HandleNull(row["Expected Commission - Non-Indemnity"].ToString()); } VAT = 0; DateTime creationDate = DateTime.Parse(row["Owner 1.Creation Date"].ToString()); if (creationDate > ReportingPeriod.StartDate.AddMonths(-6)) { IsNew = true; } Investment = Tools.HandleNull(row["Total Premiums to Date"].ToString()); OnGoingPercentage = Tools.HandleNull(row["On-going Fee Percentage"].ToString()); Organisation = row["Selling Adviser.Group.Name"].ToString(); } else { IOId = row["Id"].ToString(); IOReference = row["Reference Number"].ToString(); ClientName = row["Fee Owner.Full Name"].ToString(); ClientId = row["Fee Owner.Id"].ToString(); JointClientName = row["Fee Owner 2.Full Name"].ToString(); JointClientId = row["Fee Owner 2.Id"].ToString(); PlanType = row["Related Plan Type"].ToString(); RelevantDate = DateTime.Parse(row["Invoice Date"].ToString()); NetAmount = Tools.HandleNull(row["Net Amount"].ToString()); VAT = Tools.HandleNull(row["VAT"].ToString()); PlanReference = row["Related Plan Reference"].ToString(); Investment = 0; OnGoingPercentage = 0; } RelatedClients = new string[] {}; }
/// <summary> /// matches the income to the sale/debtor /// </summary> /// <param name="sale"></param> /// <param name="income"></param> public MLFSDebtorAdjustment(MLFSSale sale, MLFSIncome income) { MLFSReportingPeriod period = income.ReportingPeriod; ReportingPeriodId = period.Id; ReportingPeriod = period; DebtorId = (int)sale.Id; Debtor = sale; ReceiptId = income.Id; Amount = income.Amount * -1; IsVariance = false; NotTakenUp = false; }
/// <summary> /// "writes off" anyoutstanding balance as a variance /// </summary> public MLFSDebtorAdjustment ClearToVariance(MLFSReportingPeriod period) { MLFSDebtorAdjustment variance = new MLFSDebtorAdjustment() { ReportingPeriodId = period.Id, ReportingPeriod = period, Debtor = this, DebtorId = (int)Id, Amount = Outstanding * -1, IsVariance = true, NotTakenUp = false }; Adjustments.Add(variance); return(variance); }
/// <summary> /// Creates an NTU adjustment to reverse out a debtor when the transaction never happens /// </summary> /// <param name="period">the period in which the plan is marked as NTU</param> /// <returns></returns> public MLFSDebtorAdjustment CreateNTU(MLFSReportingPeriod period) { MLFSDebtorAdjustment adj = new MLFSDebtorAdjustment { DebtorId = (int)Id, Amount = GrossAmount * -1, Debtor = this, IsVariance = false, NotTakenUp = true, ReportingPeriod = period, ReportingPeriodId = period.Id }; Adjustments.Add(adj); return(adj); }
public static List <MLFSSale> ConvertFromDataTable(DataTable sales, DataTable plans, DataTable commissions, List <MLFSAdvisor> advisors, MLFSReportingPeriod period) { List <MLFSSale> returnedSales = new List <MLFSSale>(); foreach (DataRow row in sales.Rows) { if (!row["Advise Fee Type"].ToString().Contains("Ongoing")) { MLFSSale sale = new MLFSSale(row, advisors, period); returnedSales.Add(sale); } } foreach (DataRow row in commissions.Rows) { MLFSSale sale = new MLFSSale(row, advisors, period, true); returnedSales.Add(sale); } for (int i = 0; i < returnedSales.Count; i++) { returnedSales[i].MatchPlan(plans); } return(returnedSales); }
/// <summary> /// Converts a datatable row into our domain object /// </summary> /// <param name="income">the datatable</param> /// <param name="advisors">the advisors to match</param> /// <param name="period">the period it relates to</param> /// <returns>List or MLFSIncome</returns> public static List <MLFSIncome> CreateFromDataTable(DataTable income, List <MLFSAdvisor> advisors, MLFSReportingPeriod period) { List <MLFSIncome> returnedTrans = new List <MLFSIncome>(); foreach (DataRow row in income.Rows) { MLFSIncome tran = new MLFSIncome(row, advisors) { ReportingPeriodId = period.Id, ReportingPeriod = period }; returnedTrans.Add(tran); } return(returnedTrans); }