public async Task GetTaxRate_Expect_SuccessAsync()
        {
            //arrange
            _mockApiClient.Setup(x => x.ApiCall <TaxRateResponse>(HttpMethod.Get, It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), null)).Returns(Task.FromResult(new TaxRateResponse()
            {
                Rate = new Domain.Entities.Rate()
                {
                    Zip       = "33712",
                    City      = "St Petesburg",
                    City_rate = "10",
                    County    = "US",
                    Combined_district_rate = "10",
                    Combined_rate          = "10",
                    County_rate            = "10",
                    Freight_taxable        = false,
                    State      = "FL",
                    State_rate = "7"
                }
            })).Verifiable();

            //act
            var actual = await _repository.GetTaxRate(new Domain.TaxRateApiRequest());

            //assert
            Assert.NotNull(actual);
            _mockApiClient.Verify();
            Assert.Equal("33712", actual.Rate.Zip);
        }
        public void GetStateTax(string stateAbbreviation, string expected)
        {
            Tax    tax    = _taxRepo.GetTaxRate(stateAbbreviation);
            string actual = tax.TaxRate;

            Assert.AreEqual(expected, actual);
        }
Esempio n. 3
0
        public static string GetOrderStateFromUser(string prompt)
        {
            while (true)
            {
                Header();
                Console.Write(prompt);
                string input = Console.ReadLine();

                if (TaxRepository.GetTaxRate(input.ToUpper()) == -1)
                {
                    Header();
                    Console.WriteLine("You must enter valid state initials. (MN, OH, PA, MI, IN)");
                    Console.WriteLine("Press any key to return.");
                    Console.ReadKey();
                }
                else
                {
                    if (string.IsNullOrEmpty(input) || string.IsNullOrWhiteSpace(input))
                    {
                        Header();
                        Console.WriteLine("You must enter a state.");
                        Console.WriteLine("Press any key to return.");
                        Console.ReadKey();
                    }
                    else
                    {
                        return(input);
                    }
                }
            }
        }
Esempio n. 4
0
        public static decimal JustTax(decimal taxRate, ProductType Type, int areaSqFt, string state)
        {
            decimal costBeforeTax = Calculations.CalculateCost(Type, areaSqFt);

            taxRate = TaxRepository.GetTaxRate(state);

            return(taxRate * costBeforeTax);
        }
        public void Execute()
        {
            Order newOrder      = new Order();
            bool  orderComplete = true;

            do
            {
                newOrder.Name      = ConsoleIO.GetOrderNameFromUser("Please enter a name for the order: ");
                newOrder.State     = ConsoleIO.GetOrderStateFromUser("Please enter your state initials: ");
                newOrder.TaxRate   = TaxRepository.GetTaxRate(newOrder.State);
                newOrder.OrderDate = ConsoleIO.GetOrderDateFromUser("Please enter your order date (MM/DD/YYYY): ");
                newOrder.Type      = ConsoleIO.GetProductFromUser(newOrder.Type);
                newOrder.Area      = ConsoleIO.GetAreaFromUser("Please enter the area amount you want to purchase: ");

                newOrder.CostLabor    = Math.Round(Calculations.GetLaborCost(newOrder.Type, newOrder.Area), 2, MidpointRounding.AwayFromZero);
                newOrder.CostMaterial = Math.Round(Calculations.GetProductCost(newOrder.Type, newOrder.Area), 2, MidpointRounding.AwayFromZero);
                newOrder.Tax          = Math.Round(ConsoleIO.JustTax(newOrder.TaxRate, newOrder.Type, newOrder.Area, newOrder.State), 2, MidpointRounding.AwayFromZero);
                newOrder.TotalCost    = Math.Round(ConsoleIO.GetTotal(newOrder.TaxRate, newOrder.Type, newOrder.Area, newOrder.State), 2, MidpointRounding.AwayFromZero);

                string confirmFormat = "{0, -16} {1} \n{2, -16} {3} \n{4, -16} {5:d} \n{6, -16} {7} \n{8, -16} {9} \n \n{10, -16} {11} \n{12, -16} {13} \n{14, -16} {15} \n{16, -16} {17}";

                ConsoleIO.Header();

                while (true)
                {
                    Console.WriteLine(confirmFormat, "Customer Name:", newOrder.Name, "Customer State:", newOrder.State, "Order Date:", newOrder.OrderDate, "Flooring Type:", newOrder.Type, "Area:", newOrder.Area + "(sqft)", "Product Cost:", newOrder.CostMaterial, "Labor Cost:", newOrder.CostLabor, "Tax:", newOrder.Tax, "Total:", newOrder.TotalCost);
                    Console.WriteLine(ConsoleIO.Separator);
                    Console.WriteLine();
                    Console.WriteLine("Is this information correct? Y/N or Q to return to the main menu.");

                    string finishOrder = Console.ReadLine();

                    if ((finishOrder.ToUpper() == "Y") || (finishOrder.ToUpper() == "YES"))
                    {
                        OrderManager     orderManager = OrderManagerFactory.Create();
                        OrderAddResponse response     = orderManager.AddOrder(newOrder);

                        ConsoleIO.Header();
                        Console.WriteLine("Thank you for your order.");
                        Console.WriteLine("Press any key to continue.");
                        Console.ReadKey();
                        orderComplete = true;
                        break;
                    }
                    else if ((finishOrder.ToUpper() == "N") || (finishOrder.ToUpper() == "NO"))
                    {
                        orderComplete = false;
                        break;
                    }
                    else if ((finishOrder.ToUpper() == "Q") || (finishOrder.ToUpper() == "QUIT"))
                    {
                        return;
                    }
                    else
                    {
                        orderComplete = false;
                        ConsoleIO.Header();
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("Please enter Y/N only. Or enter Q to return to the main menu.");
                        Console.ResetColor();
                        Console.WriteLine();
                    }
                }
            }while (!orderComplete);
        }
        public void Execute()
        {
            bool edited;
            int  orderNumber;

            ConsoleIO.Header();
            Console.WriteLine("Edit an Order");
            Console.WriteLine();
            do
            {
                DateTime editDate = ConsoleIO.GetOrderDateFromUser("Please enter a date for the order you wish you edit (MM/DD/YYYY): ");

                ConsoleIO.Header();
                Console.WriteLine("Edit an Order");
                Console.WriteLine();

                List <Order> orders = ConsoleIO.PrintOrderList(editDate);

                Console.WriteLine(ConsoleIO.Separator);
                Console.WriteLine();
                if (orders == null)
                {
                    Console.WriteLine("Press any key to continue.");
                    Console.ReadKey();
                    return;
                }

                Console.WriteLine("Please enter the order number you wish to edit: ");
                int.TryParse(Console.ReadLine(), out orderNumber);
                if (orderNumber <= 0)
                {
                    Console.WriteLine("Order Number is not valid.");
                    Console.WriteLine("Press any key to continue");
                    Console.ReadKey();
                    return;
                }
                for (int i = 0; i < orders.Count; i++)
                {
                    if (orderNumber == orders[i].OrderNumber)
                    {
                        break;
                    }
                    else if ((i == orders.Count - 1) && (orders[i].OrderNumber != orderNumber))
                    {
                        Console.WriteLine("Order Number {0} does not exist on {1}", orderNumber, editDate);
                        Console.WriteLine("Press any key to continue");
                        Console.ReadKey();
                        return;
                    }
                }

                Order oldOrder = orders[orderNumber - 1];

                oldOrder.Name      = ConsoleIO.GetOrderNameFromUser(String.Format("Please enter name for the order. Current name : ({0}) ", oldOrder.Name));
                oldOrder.State     = ConsoleIO.GetOrderStateFromUser(String.Format("Please enter your state initials. Current state: ({0}) ", oldOrder.State));
                oldOrder.TaxRate   = TaxRepository.GetTaxRate(oldOrder.State);
                oldOrder.OrderDate = editDate;
                oldOrder.Type      = ConsoleIO.GetProductFromUser(oldOrder.Type);
                oldOrder.Area      = ConsoleIO.GetAreaFromUser(String.Format("Please enter new area amount. Current Area: ({0}) ", oldOrder.Area));

                oldOrder.CostLabor    = Math.Round(Calculations.GetLaborCost(oldOrder.Type, oldOrder.Area), 2, MidpointRounding.AwayFromZero);
                oldOrder.CostMaterial = Math.Round(Calculations.GetProductCost(oldOrder.Type, oldOrder.Area), 2, MidpointRounding.AwayFromZero);
                oldOrder.Tax          = Math.Round(ConsoleIO.JustTax(oldOrder.TaxRate, oldOrder.Type, oldOrder.Area, oldOrder.State), 2, MidpointRounding.AwayFromZero);
                oldOrder.TotalCost    = Math.Round(ConsoleIO.GetTotal(oldOrder.TaxRate, oldOrder.Type, oldOrder.Area, oldOrder.State), 2, MidpointRounding.AwayFromZero);


                string confirmFormat = "{0, -16} {1} \n{2, -16} {3} \n{4, -16} {5:d} \n{6, -16} {7} \n{8, -16} {9} \n \n{10, -16} {11} \n{12, -16} {13} \n{14, -16} {15} \n{16, -16} {17}";

                while (true)
                {
                    string editOrder = ConsoleIO.GetYesNoAnswerFromUser($"Is this information correct? ({oldOrder.Name}, {oldOrder.State}, {oldOrder.Type}, {oldOrder.Area})");

                    if ((editOrder.ToUpper() == "Y") || (editOrder.ToUpper() == "YES"))
                    {
                        ConsoleIO.Header();
                        OrderManager      orderManager = OrderManagerFactory.Create();
                        OrderEditResponse response     = orderManager.EditOrder(oldOrder, orderNumber);

                        Console.WriteLine(confirmFormat, "Customer Name:", oldOrder.Name, "Customer State:", oldOrder.State, "Order Date:", oldOrder.OrderDate, "Flooring Type:", oldOrder.Type, "Area:", oldOrder.Area + "(sqft)", "Product Cost:", oldOrder.CostMaterial, "Labor Cost:", oldOrder.CostLabor, "Tax:", oldOrder.Tax, "Total:", oldOrder.TotalCost);
                        Console.WriteLine(ConsoleIO.Separator);
                        Console.WriteLine();

                        Console.WriteLine("Press any key to continue.");
                        Console.ReadKey();
                        edited = true;
                        break;
                    }
                    else if ((editOrder.ToUpper() == "N") || (editOrder.ToUpper() == "NO"))
                    {
                        ConsoleIO.Header();
                        Console.WriteLine("Edit cancelled.");
                        Console.WriteLine("Press any key to continue.");
                        Console.ReadKey();
                        edited = false;
                        return;
                    }
                    else
                    {
                        edited = false;
                        ConsoleIO.Header();
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("Please enter Y/N only.");
                        Console.ResetColor();
                        Console.WriteLine();
                    }
                }
            }while (!edited);
        }
Esempio n. 7
0
        public Tax StateTaxRate(string stateAbv)
        {
            TaxRepository asd = new TaxRepository();

            return(asd.GetTaxRate(stateAbv));
        }