Exemplo n.º 1
0
        public AnalysisWindow(InvoiceAnalysis invoiceAnalysis)
        {
            InitializeComponent();
            DataContext                     = this;
            SelectedInvoices                = new BindingList <IInvoice>();
            Analyser                        = invoiceAnalysis;
            allInvoicesGroupBox.Header      = $"All Invoices ({Analyser.Invoices.Count()})";
            analyseButton.Click            += AnalyseButton_Click;
            SelectedInvoices.ListChanged   += AnalysisWindow_SelectedInvoicesChanged;
            TabController.SelectionChanged += TabController_SelectionChanged;
            PopulateAllInvoicesContainer();

            MinHeight = Height;
            MaxHeight = Height;
            MinWidth  = Width;
            MaxWidth  = Width;

            TotalsGraphs                   = new UIElement[] { totalsGraph, ordersDeliveredGraph, dropFeesGraph, tipsGraph, hoursGraph };
            totalsGraphs.ItemsSource       = new string[] { (string)totalsGraph.Title, (string)ordersDeliveredGraph.Title, (string)dropFeesGraph.Title, (string)tipsGraph.Title, (string)hoursGraph.Title };
            totalsGraphs.SelectionChanged += TotalsGraphs_SelectionChanged;
            totalsGraphs.SelectedItem      = ((LineGraph)TotalsGraphs[0]).Title;

            SAGraphs                   = new UIElement[] { hourlyEarningsGraph, deliveryRateGraph, daysWorkedGraph, averageShiftLengthGraph, averageShiftDeliveriesGraph, averageTotalGraph };
            saGraphs.ItemsSource       = new string[] { hourlyEarningsGraph.Title, deliveryRateGraph.Title, daysWorkedGraph.Title, averageShiftLengthGraph.Title, averageShiftDeliveriesGraph.Title, averageTotalGraph.Title };
            saGraphs.SelectionChanged += SaGraphs_SelectionChanged;
            saGraphs.SelectedItem      = ((LineGraph)SAGraphs[0]).Title;
        }
Exemplo n.º 2
0
        public void CorrectTotalReturned_1920TaxYear()
        {
            InvoiceAnalysis ia       = new InvoiceAnalysis(fh.InvoiceFiles());
            decimal         expected = 199.84m;
            decimal?        actual   = ia.Total(Array.FindAll(ia.Invoices, x => (x.Date <= new DateTime(2020, 4, 5) && x.Date >= new DateTime(2019, 4, 6))));

            Assert.Equal(expected, actual);
        }
Exemplo n.º 3
0
        public void DaysWorkedReturned()
        {
            InvoiceAnalysis ia       = new InvoiceAnalysis(fh.InvoiceFiles());
            int             expected = 14;
            int             actual   = ia.DaysWorked();

            Assert.Equal(expected, actual);
        }
Exemplo n.º 4
0
        public void CorrectTotalReturned_AllInvoices()
        {
            InvoiceAnalysis ia       = new InvoiceAnalysis(fh.InvoiceFiles());
            decimal         expected = 321.90m;
            decimal?        actual   = ia.Total();

            Assert.Equal(expected, actual);
        }
Exemplo n.º 5
0
        public void AverageShiftLengthReturned()
        {
            InvoiceAnalysis ia = new InvoiceAnalysis(fh.InvoiceFiles());

            double expected = 2.69;
            double actual   = ia.AverageShiftLength();

            Assert.Equal(expected, actual);
        }
Exemplo n.º 6
0
        public void AverageOrdersDeliveredPerDayWorkedReturned()
        {
            InvoiceAnalysis ia = new InvoiceAnalysis(fh.InvoiceFiles());

            double expected = 5.29;
            double actual   = ia.AverageOrdersPerShift();

            Assert.Equal(expected, actual);
        }
Exemplo n.º 7
0
        public void InvoicesPropertyCorrectlyPopulated()
        {
            InvoiceAnalysis ia = new InvoiceAnalysis(fh.InvoiceFiles());

            int expected = 6;

            int actual = ia.Invoices.Length;

            Assert.Equal(expected, actual);
        }
Exemplo n.º 8
0
        private void AnalyseButton_Click(object sender, RoutedEventArgs e)
        {
            if (!Directory.Exists(directoryPath.Text))
            {
                errorMessage.Visibility = Visibility.Visible;
                return;
            }
            InvoiceAnalysis IA      = new InvoiceAnalysis(FileHandler.InvoiceFiles(directoryPath.Text));
            AnalysisWindow  aWindow = new AnalysisWindow(IA);

            aWindow.Show();
            this.Close();
        }
Exemplo n.º 9
0
        public void FeePerOrderReturned()
        {
            InvoiceAnalysis ia = new InvoiceAnalysis(fh.InvoiceFiles());
            // All
            decimal expected = 4.29m;
            decimal actual   = ia.AverageOrderFee();

            Assert.Equal(expected, actual, 2);

            // 18-19 Tax Year
            decimal expected1 = 4.15m;
            decimal actual1   = ia.AverageOrderFee(Array.FindAll(ia.Invoices, x => (x.Date <= new DateTime(2019, 4, 5) && x.Date >= new DateTime(2018, 4, 6))));

            Assert.Equal(expected1, actual1, 2);
        }
Exemplo n.º 10
0
        public void OrdersPerTipReturned()
        {
            InvoiceAnalysis ia = new InvoiceAnalysis(fh.InvoiceFiles());
            // All
            decimal expected = 24.7m;
            decimal actual   = ia.OrdersPerTip();

            Assert.Equal(expected, actual, 1);

            // 18-19 Tax Year
            decimal expected1 = 28;
            decimal actual1   = ia.OrdersPerTip(Array.FindAll(ia.Invoices, x => (x.Date <= new DateTime(2019, 4, 5) && x.Date >= new DateTime(2018, 4, 6))));

            Assert.Equal(expected1, actual1, 1);
        }
Exemplo n.º 11
0
        public void TipsPerOrderReturned()
        {
            InvoiceAnalysis ia = new InvoiceAnalysis(fh.InvoiceFiles());
            // All
            decimal expected = 0.04m;
            decimal actual   = ia.TipPerOrder();

            Assert.Equal(expected, actual, 2);

            // 18-19 Tax Year
            decimal expected1 = 0;
            decimal actual1   = ia.TipPerOrder(Array.FindAll(ia.Invoices, x => (x.Date <= new DateTime(2019, 4, 5) && x.Date >= new DateTime(2018, 4, 6))));

            Assert.Equal(expected1, actual1, 2);
        }
Exemplo n.º 12
0
        public void AverageOrdersDeliveredPerInvoiceReturned()
        {
            InvoiceAnalysis ia = new InvoiceAnalysis(fh.InvoiceFiles());
            // All
            double expected = 12.3;
            double actual   = ia.AverageOrdersPerInvoice();

            Assert.Equal(expected, actual, 1);

            // 18-19 Tax Year
            double expected1 = 14;
            double actual1   = ia.AverageOrdersPerInvoice(Array.FindAll(ia.Invoices, x => (x.Date <= new DateTime(2019, 4, 5) && x.Date >= new DateTime(2018, 4, 6))));

            Assert.Equal(expected1, actual1, 2);
        }
Exemplo n.º 13
0
        public void AverageDropFeesReturned()
        {
            InvoiceAnalysis ia = new InvoiceAnalysis(fh.InvoiceFiles());
            // All
            decimal expected = 52.90m;
            decimal actual   = ia.AverageDropFees();

            Assert.Equal(expected, actual, 2);

            // 18-19 Tax Year
            decimal expected1 = 58.03m;
            decimal actual1   = ia.AverageDropFees(Array.FindAll(ia.Invoices, x => (x.Date <= new DateTime(2019, 4, 5) && x.Date >= new DateTime(2018, 4, 6))));

            Assert.Equal(expected1, actual1, 2);
        }
Exemplo n.º 14
0
        public void AverageHoursWorkedReturned()
        {
            InvoiceAnalysis ia = new InvoiceAnalysis(fh.InvoiceFiles());
            // All
            double expected = 6.27;
            double actual   = ia.AverageHoursWorked();

            Assert.Equal(expected, actual, 2);

            // 18-19 Tax Year
            double expected1 = 7.2;
            double actual1   = ia.AverageHoursWorked(Array.FindAll(ia.Invoices, x => (x.Date <= new DateTime(2019, 4, 5) && x.Date >= new DateTime(2018, 4, 6))));

            Assert.Equal(expected1, actual1, 2);
        }
Exemplo n.º 15
0
        public void CorrectHoursWorkedReturned()
        {
            InvoiceAnalysis ia = new InvoiceAnalysis(fh.InvoiceFiles());
            // All
            double expected = 37.6;
            double actual   = ia.HoursWorked();

            Assert.Equal(expected, actual);

            // 18-19 Tax Year
            double expected1 = 14.4;
            double actual1   = ia.HoursWorked(Array.FindAll(ia.Invoices, x => (x.Date <= new DateTime(2019, 4, 5) && x.Date >= new DateTime(2018, 4, 6))));

            Assert.Equal(expected1, actual1, 1);
        }
Exemplo n.º 16
0
        public void CorrectAdjustmentsReturned()
        {
            InvoiceAnalysis ia = new InvoiceAnalysis(fh.InvoiceFiles());
            // All
            decimal expected = 2m;
            decimal actual   = ia.Adjustments();

            Assert.Equal(expected, actual);

            // 18-19 Tax Year
            decimal expected1 = 0m;
            decimal actual1   = ia.Adjustments(Array.FindAll(ia.Invoices, x => (x.Date <= new DateTime(2019, 4, 5) && x.Date >= new DateTime(2018, 4, 6))));

            Assert.Equal(expected1, actual1);
        }
Exemplo n.º 17
0
        public void OrdersPerHourReturned()
        {
            InvoiceAnalysis ia = new InvoiceAnalysis(fh.InvoiceFiles());
            // All
            double expected = 1.97;
            double actual   = ia.OrdersPerHour();

            Assert.Equal(expected, actual, 2);

            // 18-19 Tax Year
            double expected1 = 1.94;
            double actual1   = ia.OrdersPerHour(Array.FindAll(ia.Invoices, x => (x.Date <= new DateTime(2019, 4, 5) && x.Date >= new DateTime(2018, 4, 6))));

            Assert.Equal(expected1, actual1, 2);
        }
Exemplo n.º 18
0
        public void HourlyEarningsReturned()
        {
            InvoiceAnalysis ia = new InvoiceAnalysis(fh.InvoiceFiles());
            // All
            decimal expected = 8.44m;
            decimal actual   = ia.HourlyEarnings();

            Assert.Equal(expected, actual, 2);

            // 18-19 Tax Year
            decimal expected1 = 8.06m;
            decimal actual1   = ia.HourlyEarnings(Array.FindAll(ia.Invoices, x => (x.Date <= new DateTime(2019, 4, 5) && x.Date >= new DateTime(2018, 4, 6))));

            Assert.Equal(expected1, actual1, 2);
        }
Exemplo n.º 19
0
        public void CorrectOrdersDeliveredReturned()
        {
            InvoiceAnalysis ia = new InvoiceAnalysis(fh.InvoiceFiles());
            // All
            int expected = 74;
            int actual   = ia.OrdersDelivered();

            Assert.Equal(expected, actual);

            // 18-19 Tax Year
            int expected1 = 28;
            int actual1   = ia.OrdersDelivered(Array.FindAll(ia.Invoices, x => (x.Date <= new DateTime(2019, 4, 5) && x.Date >= new DateTime(2018, 4, 6))));

            Assert.Equal(expected1, actual1);
        }
Exemplo n.º 20
0
        private static void RunAnalytics(InvoiceAnalysis analyser, IInvoice[] invoices)
        {
            Console.WriteLine("*FIGURES*\n");
            if (invoices == null)
            {
                Console.WriteLine($"Invoices Count: {analyser.Invoices.Length}");
            }
            else
            {
                Console.WriteLine($"Invoices Count: {invoices.Length}");
            }

            Console.WriteLine($"Total: £{analyser.Total(invoices)} \nOrders Delivered: {analyser.OrdersDelivered(invoices)} \nDrop Fees: £{analyser.DropFees(invoices)} \nTips: £{analyser.Tips(invoices)} " +
                              $"\nAdjustments: £{analyser.Adjustments(invoices)} \nTransaction Fees: £{analyser.TransactionFees(invoices)} \nHours Worked: {analyser.HoursWorked(invoices)}h\n");
            WriteBar();
            Console.WriteLine("*AVERAGES*\n");
            Console.WriteLine($"Average Total: £{analyser.AverageTotal(invoices)} \nAverage Orders Delivered: {analyser.AverageOrdersPerInvoice(invoices)} " +
                              $"\nAverage Drop Fees: £{analyser.AverageDropFees(invoices)} \nAverage Tips: £{analyser.AverageTips(invoices)} \nAverage Hours Worked: {analyser.AverageHoursWorked(invoices)}h\n");
            WriteBar();
            Console.WriteLine("*STATS*\n");
            Console.WriteLine($"Hourly Earnings: £{analyser.HourlyEarnings(invoices)} p/h \nOrders per Hour: {analyser.OrdersPerHour(invoices)} p/h \nFee per Order: £{analyser.AverageOrderFee(invoices)} \n" +
                              $"Tips per Order: £{analyser.TipPerOrder(invoices)} \nOrders per £1 Tip: {analyser.OrdersPerTip(invoices)}\n");
        }
Exemplo n.º 21
0
        private static void ExecuteProgram(string[] args = null)
        {
            Console.WriteLine("Hello! \n\nBefore we begin, please make sure all invoices are downloaded and share the same root folder folder e.g. downloads.\n");
            FileHandler handler = OpenFileHandler();

            Console.Clear();
            Console.WriteLine("The application will now try to rename and organise your invoices.\nIf you have already completed this step, press y to continue to analysis.");
            ConfirmationPrompt();
            handler.OrganiseFiles();
            Console.Clear();
            Console.WriteLine("\nOrganisation successful!\n");

            Console.WriteLine("I will now attempt to analyse your invoices.");

            ConfirmationPrompt();
            InvoiceAnalysis analyser = new InvoiceAnalysis(handler.InvoiceFiles());

            do
            {
                Console.Clear();
                var dateRange = DateEnterPrompt();
                WriteBar();
                IInvoice[] targets;
                if (dateRange.Item1 == null || dateRange.Item2 == null)
                {
                    targets = null;
                }
                else
                {
                    targets = Array.FindAll(analyser.Invoices, x => (x.Date >= dateRange.Item1 && x.Date <= dateRange.Item2));
                }

                RunAnalytics(analyser, targets);
                WriteBar();
                Console.ReadKey();
            }while (AnotherDate());
        }