static void Main(string[] args)
        {
            // initialize
            _investors    = new List <Investor>();
            _salesReps    = new List <SalesRep>();
            _transactions = new List <Transaction>();

            using (var reader = new StreamReader($@"{Directory.GetCurrentDirectory()}/Data.csv"))
                using (var csv = new CsvReader(reader))
                {
                    var transactionMap = new TransactionMap(_investors, _salesReps);
                    csv.Configuration.RegisterClassMap(transactionMap);
                    _transactions = csv.GetRecords <Transaction>().ToList();
                }

            // create reports
            var salesSummaryReport = new SalesSummaryReport(_transactions, _investors, _salesReps);

            salesSummaryReport.GenerateReport();

            var assetsUnderManagementReport = new AssetsUndermanagementReport(_transactions, _investors, _salesReps);

            assetsUnderManagementReport.GenerateReport();

            var breakReport = new BreakReport(_transactions, _investors, _salesReps);

            breakReport.GenerateReport();

            var investorProfitLossReport = new InvestorProfitLossReport(_transactions, _investors, _salesReps);

            investorProfitLossReport.GenerateReport();
        }
Example #2
0
        public void GenerateBreakReport()
        {
            //    3. Break Report:
            //        Assuming the information in the data provided is complete and accurate,
            //        generate a report that shows any errors (negative cash balances,
            //        negative share balance) by investor.
            this.BreakReport = new List <Exception>();
            var investors = TransactionList.Select(x => x.Investor).Distinct().Select(x => new Investor {
                Name = x
            });

            foreach (var investor in investors)
            {
                var trans = TransactionList.Where(x => x.Investor == investor.Name);
                investor.StockFundSharesHeld = trans.Where(x => x.Fund == STOCK_FUND).Sum(x => x.ShareAdjust);
                investor.BondFundSharesHeld  = trans.Where(x => x.Fund == BOND_FUND).Sum(x => x.ShareAdjust);
                if (investor.StockFundSharesHeld < 0)
                {
                    BreakReport.Add(new NegativeShareBalanceException(investor, STOCK_FUND, investor.StockFundSharesHeld));
                }

                if (investor.BondFundSharesHeld < 0)
                {
                    BreakReport.Add(new NegativeShareBalanceException(investor, BOND_FUND, investor.BondFundSharesHeld));
                }

                investor.StockCashBalance = trans.Where(x => x.Fund == STOCK_FUND).Sum(x => x.PriceAdjust);
                investor.BondCashBalance  = trans.Where(x => x.Fund == BOND_FUND).Sum(x => x.PriceAdjust);
                if (investor.StockCashBalance < 0)
                {
                    BreakReport.Add(new NegativeCashBalanceException(investor, STOCK_FUND, investor.StockCashBalance));
                }

                if (investor.BondCashBalance < 0)
                {
                    BreakReport.Add(new NegativeCashBalanceException(investor, BOND_FUND, investor.BondCashBalance));
                }

                var ls = BreakReport.ToString();
            }
        }