Esempio n. 1
0
        public void MockTaxManager_InputTest()
        {
            var taxService = new MockTaxService();
            var factory    = new MockFactory();

            factory.MockTaxService = taxService;

            var manager = new TaxManager(factory);

            var result = manager.CalculateTax("USA", 100.00m);

            taxService.RequestTaxCalculation(100.00m);

            Assert.AreEqual(5.25m, manager.CalculateTax("USA", 100.00m));

            //var test = taxService.CheckTaxResult();

            //if (test)
            //{
            //    var result = taxService.GetTaxAmount();
            //    Assert.AreEqual(5.25m, result);
            //}
            //else
            //{
            //    Assert.AreEqual(-1, -1);
            //}
        }
Esempio n. 2
0
        public void AskState(OrderLookupResponse response)
        {
            TaxManager taxManager = TaxFactory.Create();

            while (true)
            {
                Console.Clear();
                Console.Write($"Enter State ({response.Order.State}): ");
                string      state       = (Console.ReadLine()).ToUpper();
                TaxResponse taxResponse = taxManager.TaxRate(state);
                if (string.IsNullOrEmpty(state))
                {
                    ConsoleIO.DisplayOrderDetails(response.Order);
                    return;
                }
                else
                {
                    if (taxResponse.Success)
                    {
                        response.Order.State   = taxResponse.Tax.StateAbbreviation; //set state
                        response.Order.TaxRate = taxResponse.Tax.TaxRate;           //make sure the new tax goes through
                        ConsoleIO.DisplayOrderDetails(response.Order);
                        break;
                    }
                    else
                    {
                        Console.WriteLine(taxResponse.Message);
                        ConsoleIO.PressAnyKey();
                        continue;
                        //Console.Clear();
                    }
                }
            }
        }
Esempio n. 3
0
        public void TaxServiceNull()
        {
            var manager = new TaxManager(new AccessorFactory());

            Assert.AreEqual(-1, manager.CalculateTax("US", 125.00m));
            Assert.AreEqual(-1, manager.CalculateTax("", 125.00m));
        }
        /// <summary>
        /// Gets shopping cart subtotal
        /// </summary>
        /// <param name="Cart">Cart</param>
        /// <param name="customer">Customer</param>
        /// <param name="SubTotalDiscount">Subtotal discount</param>
        /// <param name="includingTax">A value indicating whether calculated price should include tax</param>
        /// <param name="Error">Error</param>
        /// <returns>Shopping cart subtotal</returns>
        public static decimal GetShoppingCartSubTotal(ShoppingCart Cart, Customer customer,
                                                      out decimal SubTotalDiscount, bool includingTax, ref string Error)
        {
            SubTotalDiscount = decimal.Zero;

            decimal subTotalWithoutDiscount = decimal.Zero;
            decimal subTotalWithDiscount    = decimal.Zero;

            foreach (ShoppingCartItem shoppingCartItem in Cart)
            {
                string  Error2     = string.Empty;
                decimal scSubTotal = PriceHelper.GetSubTotal(shoppingCartItem, customer, true);
                subTotalWithoutDiscount += TaxManager.GetPrice(shoppingCartItem.ProductVariant, scSubTotal, includingTax, customer, ref Error2);
                if (!String.IsNullOrEmpty(Error2))
                {
                    Error = Error2;
                }
            }


            SubTotalDiscount = GetOrderDiscount(customer, subTotalWithoutDiscount);

            subTotalWithDiscount = subTotalWithoutDiscount - SubTotalDiscount;
            if (subTotalWithDiscount < decimal.Zero)
            {
                subTotalWithDiscount = decimal.Zero;
            }

            subTotalWithDiscount = Math.Round(subTotalWithDiscount, 2);

            return(subTotalWithDiscount);
        }
Esempio n. 5
0
        public void InputTest()
        {
            var manager = new TaxManager(new AccessorFactory());

            Assert.AreEqual(5.25m, manager.CalculateTax("USA", 100.00m));
            Assert.AreEqual(6.25m, manager.CalculateTax("CANADA", 100.00m));
        }
Esempio n. 6
0
        public void OrderState(Order order)
        {
            bool validState = false;

            while (!validState)
            {
                Console.Write(" Enter State: ");
                string newState = (Console.ReadLine());
                if (!string.IsNullOrEmpty(newState))
                {
                    newState = newState.ToUpper();
                    TaxManager taxManager = TaxManagerFactory.Create();
                    Tax        tax        = taxManager.TaxByState(newState);
                    if (tax != null)
                    {
                        validState    = true;
                        order.State   = newState;
                        order.TaxRate = tax.TaxRate;
                    }
                    else
                    {
                        Console.WriteLine(" Please enter a VALID state. ");
                    }
                }
                else
                {
                    validState = true;
                }
            }
        }
Esempio n. 7
0
        protected void BtnExitSale_Click(object sender, EventArgs e)
        {
            //Collects current method for error tracking
            string method = "btnExitSale_Click";

            object[] objPageDetails = { Session["currPage"].ToString(), method };
            try
            {
                //TODO: btnExitSale_Click is good as it doesn't read the new values. It removes the entry
                TaxManager TM      = new TaxManager();
                Invoice    invoice = IM.CallReturnCurrentInvoice(Convert.ToInt32(Request.QueryString["invoice"].ToString()), objPageDetails)[0];
                //object[] taxText = { "Remove GST", "Remove PST" };
                //object[] results = TM.ReturnChargedTaxForSale(invoice, taxText, objPageDetails);
                invoice.intTransactionTypeID = 1;
                IM.CallUpdateCurrentInvoice(invoice, objPageDetails);
                Response.Redirect("HomePage.aspx", false);
            }
            //Exception catch
            catch (ThreadAbortException tae) { }
            catch (Exception ex)
            {
                //Log all info into error table
                ER.CallLogError(ex, CU.employee.intEmployeeID, Convert.ToString(Session["currPage"]) + "-V3.2", method, this);
                //Display message box
                MessageBoxCustom.ShowMessage("An Error has occurred and been logged. "
                                             + "If you continue to receive this message please contact "
                                             + "your system administrator.", this);
            }
        }
        public ReturnObject GetPayableTax(string postalCode, decimal anualIncome)
        {
            ReturnObject result = new ReturnObject();

            var calculationType = GetTaxCalculationType(postalCode);

            try
            {
                TaxManager taxManager = new TaxManager(calculationType, anualIncome);

                if (calculationType == TaxCalculationType.Progressive)
                {
                    taxManager.ProgressiveTaxTables = _context.ProgressiveTaxTables.ToList();
                }

                result.PayableTax = taxManager.CalculateTax();
            }
            catch (Exception ex)
            {
                result.ErrorResult = ex.Message;
            }

            Save(postalCode, anualIncome, result.PayableTax);

            return(result);
        }
Esempio n. 9
0
        public static string GetState(string prompt, string state)
        {
            while (true)
            {
                TaxManager taxManager     = TaxManagerFactory.Create();
                var        taxLookup      = taxManager.DisplayTaxes();
                var        listOfStateAbb = taxLookup.Select(p => p.StateAbbreviation.ToUpper()).ToList();

                Console.WriteLine(prompt);
                string input = Console.ReadLine().ToUpper();
                if (string.IsNullOrEmpty(input) || input == state)
                {
                    Console.Clear();
                    return(state);
                }
                if (!listOfStateAbb.Contains(input) || input.Length != 2)
                {
                    Console.WriteLine("We're sorry. We do not sell products in your region. Check your input.");
                    Console.WriteLine("Press any key to try again...");
                    Console.WriteLine();
                    Console.ReadKey();
                    Console.Clear();
                }
                else
                {
                    Console.Clear();
                    return(input);
                }
            }
        }
Esempio n. 10
0
        /*
         * public void WorkflowWait()
         * {
         *  _WorkflowWaitHandle.WaitOne();
         * }
         * */
        #endregion

        #region Tax Methods
        /// <summary>
        /// Gets the taxes.
        /// </summary>
        /// <param name="siteId">The site id.</param>
        /// <param name="taxCategory">The tax category.</param>
        /// <param name="languageCode">The language code.</param>
        /// <param name="countryCode">The country code.</param>
        /// <param name="stateProvinceCode">The state province code.</param>
        /// <param name="zipPostalCode">The zip postal code.</param>
        /// <param name="district">The district.</param>
        /// <param name="county">The county.</param>
        /// <param name="city">The city.</param>
        /// <returns></returns>
        public TaxValue[] GetTaxes(
            Guid siteId,
            string taxCategory,
            string languageCode,
            string countryCode,
            string stateProvinceCode,
            string zipPostalCode,
            string district,
            string county,
            string city)
        {
            List <TaxValue> taxes = new List <TaxValue>();

            DataTable taxTable = TaxManager.GetTaxes(siteId, taxCategory, languageCode, countryCode, stateProvinceCode, zipPostalCode, district, county, city);

            if (taxTable.Rows.Count > 0)
            {
                foreach (DataRow row in taxTable.Rows)
                {
                    TaxValue val = new TaxValue((double)row["Percentage"], (string)row["Name"], (string)row["DisplayName"], (TaxType)(int)row["TaxType"]);
                    taxes.Add(val);
                }
            }
            return(taxes.ToArray());
        }
Esempio n. 11
0
        public string GetShoppingCartItemSubTotalString(ShoppingCartItem shoppingCartItem)
        {
            var     sb = new StringBuilder();
            decimal shoppingCartItemSubTotalWithDiscountBase = TaxManager.GetPrice(shoppingCartItem.ProductVariant, PriceHelper.GetSubTotal(shoppingCartItem, true));
            decimal shoppingCartItemSubTotalWithDiscount     = CurrencyManager.ConvertCurrency(shoppingCartItemSubTotalWithDiscountBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);
            string  subTotalString = PriceHelper.FormatPrice(shoppingCartItemSubTotalWithDiscount);

            sb.Append("<span class=\"productPrice\">");
            sb.Append(subTotalString);
            sb.Append("</span>");

            decimal shoppingCartItemDiscountBase = TaxManager.GetPrice(shoppingCartItem.ProductVariant, PriceHelper.GetDiscountAmount(shoppingCartItem));

            if (shoppingCartItemDiscountBase > decimal.Zero)
            {
                decimal shoppingCartItemDiscount = CurrencyManager.ConvertCurrency(shoppingCartItemDiscountBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);
                string  discountString           = PriceHelper.FormatPrice(shoppingCartItemDiscount);

                sb.Append("<br />");
                sb.Append(GetLocaleResourceString("Wishlist.ItemYouSave"));
                sb.Append("&nbsp;&nbsp;");
                sb.Append(discountString);
            }
            return(sb.ToString());
        }
Esempio n. 12
0
        public void ChangeState(DisplaySingleOrderResponse response)
        {
            bool validState = false;

            while (!validState)
            {
                Console.Write(" Enter State (with abbreviation or full name): ");
                string newState = (Console.ReadLine().ToUpper());

                if (!string.IsNullOrEmpty(newState))
                {
                    TaxManager taxManager = TaxManagerFactory.Create();
                    Tax        tax        = taxManager.TaxByState(newState);

                    if (tax != null)
                    {
                        validState = true;
                        response.OrderDetails.State = newState;
                    }
                    else
                    {
                        Console.WriteLine(" Please enter a VALID state. ");
                    }
                }
                else
                {
                    validState = true;
                }
            }
        }
Esempio n. 13
0
        public void CanEditOrder(DateTime orderDate, int orderNumber, string newCustomerName, string newState, string newProductType, decimal newArea, bool expected)
        {
            OrderManager orderManager = OrderManagerFactory.create(orderDate);

            TaxManager         taxManager  = TaxManagerFactory.create();
            DisplayTaxResponse taxResponse = taxManager.DisplayTaxResponse(newState);

            ProductManager         productManager  = ProductManagerFactory.create();
            DisplayProductResponse productResponse = productManager.DisplayProductResponse(newProductType);

            Orders order = new Orders()
            {
                Area = newArea,
                CostPerSquareFoot      = productResponse.Products.CostPerSquareFoot,
                CustomerName           = newCustomerName,
                LaborCostPerSquareFoot = productResponse.Products.LaborCostPerSquareFoot,
                OrderNumber            = orderNumber,
                ProductType            = productResponse.Products.ProductType,
                State   = taxResponse.Tax.StateAbbreviation,
                TaxRate = taxResponse.Tax.TaxRate,
            };

            EditOrderResponse orderResponse = orderManager.EditOrder(order);

            Assert.AreEqual(orderResponse.Success, expected);
        }
        public void CanGetTax(string stateAbreviation, string state, decimal taxRate, bool expected)
        {
            TaxManager         taxManager  = TaxManagerFactory.create();
            DisplayTaxResponse taxResponse = taxManager.DisplayTaxResponse(stateAbreviation);

            Assert.AreEqual(taxResponse.Success, expected);
        }
Esempio n. 15
0
        public void TestEverything()
        {
            var innerDispatcher = new MessageDispatcher();
            var dispatcher      = new LoggingMessageDispatcher(innerDispatcher);
            var orderRepo       = new OrderRepository();

            var entryPoint = new AppEntryPoint(dispatcher);
            var order      = new Order {
                TicketCount = 4, Subtotal = 100M
            };
            var orderProcessor = new OrderProcessor(dispatcher);
            var ticketManager  = new TicketManager(dispatcher, orderRepo, 500);
            var feeManager     = new BasicFeeManager(dispatcher);
            var taxManager     = new TaxManager(dispatcher);
            var paymentManager = new PaymentManager(dispatcher);
            var storageManager = new StorageManager(dispatcher, orderRepo);

            dispatcher.Subscribe <OrderPlaced>(orderProcessor);
            dispatcher.Subscribe <TicketsReserved>(orderProcessor);
            dispatcher.Subscribe <FeesCalculated>(orderProcessor);
            dispatcher.Subscribe <TaxesCalculated>(orderProcessor);
            dispatcher.Subscribe <CreditCardCharged>(orderProcessor);
            dispatcher.Subscribe(ticketManager);
            dispatcher.Subscribe(feeManager);
            dispatcher.Subscribe(taxManager);
            dispatcher.Subscribe(paymentManager);
            dispatcher.Subscribe(storageManager);

            entryPoint.TakeOrder(4, 50M, "1234-1234-1234-1223");
        }
Esempio n. 16
0
        static void Main(string[] args)
        {
            var orderRepo       = new OrderRepository();
            var innerDispatcher = new MessageDispatcher();
            var dispatcher      = new LoggingMessageDispatcher(innerDispatcher);

            var entryPoint     = new AppEntryPoint(dispatcher);
            var orderProcessor = new OrderProcessor(dispatcher);
            var ticketManager  = new TicketManager(dispatcher, orderRepo, 500);
            var feeManager     = new BasicFeeManager(dispatcher);
            var taxManager     = new TaxManager(dispatcher);
            var paymentManager = new PaymentManager(dispatcher);
            var storageManager = new StorageManager(dispatcher, orderRepo);

            dispatcher.Subscribe <OrderPlaced>(orderProcessor);
            dispatcher.Subscribe <TicketsReserved>(orderProcessor);
            dispatcher.Subscribe <FeesCalculated>(orderProcessor);
            dispatcher.Subscribe <TaxesCalculated>(orderProcessor);
            dispatcher.Subscribe <CreditCardCharged>(orderProcessor);

            dispatcher.Subscribe(ticketManager);
            dispatcher.Subscribe(feeManager);
            dispatcher.Subscribe(taxManager);
            dispatcher.Subscribe(paymentManager);
            dispatcher.Subscribe(storageManager);
            dispatcher.Subscribe(entryPoint);

            entryPoint.TakeOrder(4, 50M, "1234-1234-1234-1223");

            System.Console.ReadKey();
        }
Esempio n. 17
0
        protected void ddlVariantPrice_ItemDataBound(object sender, DataListItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                var productVariant  = e.Item.DataItem as ProductVariant;
                var lblPriceDisplay = e.Item.FindControl("lblPriceDisplay") as Label;
                var lblPrice        = e.Item.FindControl("lblPrice") as Label;
                var imgBuyNow       = e.Item.FindControl("imgBuyNow") as ImageButton;

                if (!SettingManager.GetSettingValueBoolean("Common.HidePricesForNonRegistered") ||
                    (NopContext.Current.User != null &&
                     !NopContext.Current.User.IsGuest))
                {
                    if (productVariant.CustomerEntersPrice)
                    {
                        int minimumCustomerEnteredPrice = Convert.ToInt32(Math.Ceiling(CurrencyManager.ConvertCurrency(productVariant.MinimumCustomerEnteredPrice, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency)));
                        lblPrice.Text        = minimumCustomerEnteredPrice.ToString();
                        lblPriceDisplay.Text = PriceHelper.FormatPrice(minimumCustomerEnteredPrice);
                    }
                    else
                    {
                        decimal fromPriceBase = TaxManager.GetPrice(productVariant, PriceHelper.GetFinalPrice(productVariant, false));
                        decimal fromPrice     = CurrencyManager.ConvertCurrency(fromPriceBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);
                        lblPrice.Text        = fromPrice.ToString();
                        lblPriceDisplay.Text = PriceHelper.FormatPrice(fromPrice);
                    }
                }
                else
                {
                    lblPriceDisplay.Visible = false;
                    btnAddToCart.Visible    = false;
                }
            }
        }
Esempio n. 18
0
        public void AmountNegativeOrZero()
        {
            var manager = new TaxManager(new AccessorFactory());

            Assert.AreEqual(-1, manager.CalculateTax("CANADA", 0.00m));
            Assert.AreEqual(-1, manager.CalculateTax("USA", -125.00m));
        }
Esempio n. 19
0
        public string GetShoppingCartItemSubTotalString(ShoppingCartItem shoppingCartItem)
        {
            StringBuilder sb      = new StringBuilder();
            decimal       taxRate = decimal.Zero;
            decimal       shoppingCartItemSubTotalWithDiscountBase = TaxManager.GetPrice(shoppingCartItem.ProductVariant, PriceHelper.GetSubTotal(shoppingCartItem, customer, true), customer, out taxRate);
            decimal       shoppingCartItemSubTotalWithDiscount     = CurrencyManager.ConvertCurrency(shoppingCartItemSubTotalWithDiscountBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);
            string        subTotalString = PriceHelper.FormatPrice(shoppingCartItemSubTotalWithDiscount);

            sb.Append(subTotalString);

            decimal shoppingCartItemDiscountBase = TaxManager.GetPrice(shoppingCartItem.ProductVariant, PriceHelper.GetDiscountAmount(shoppingCartItem, customer), customer, out taxRate);

            if (shoppingCartItemDiscountBase > decimal.Zero)
            {
                decimal shoppingCartItemDiscount = CurrencyManager.ConvertCurrency(shoppingCartItemDiscountBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);
                string  discountString           = PriceHelper.FormatPrice(shoppingCartItemDiscount);

                sb.Append("<br />");
                //sb.Append(GetLocaleResourceString("ShoppingCart.ItemYouSave"));
                sb.Append("Saved:");
                sb.Append("&nbsp;&nbsp;");
                sb.Append(discountString);
            }
            return(sb.ToString());
        }
        protected void GrdInventoryTaxes_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            string method = "GrdInventoryTaxes_RowCommand";

            object[] objPageDetails = { Session["currPage"].ToString(), method };
            int      index          = ((GridViewRow)((LinkButton)e.CommandSource).NamingContainer).RowIndex;
            bool     chargeTax      = Convert.ToBoolean(((CheckBox)GrdInventoryTaxes.Rows[index].Cells[3].FindControl("chkChargeTax")).Checked);

            if (chargeTax)
            {
                chargeTax = false;
            }
            else
            {
                chargeTax = true;
            }
            TaxManager TM = new TaxManager();

            TM.UpdateTaxChargedForInventory(Convert.ToInt32(Request.QueryString["inventory"].ToString()), Convert.ToInt32(e.CommandArgument.ToString()), chargeTax, objPageDetails);
            var nameValues = HttpUtility.ParseQueryString(Request.QueryString.ToString());

            nameValues.Set("inventory", Request.QueryString["inventory"].ToString());
            //Refreshes current page
            Response.Redirect(Request.Url.AbsolutePath + "?" + nameValues, true);
        }
Esempio n. 21
0
        protected string FormatShippingOption(ShippingOption shippingOption)
        {
            decimal rateBase = TaxManager.GetShippingPrice(shippingOption.Rate, NopContext.Current.User);
            decimal rate     = CurrencyManager.ConvertCurrency(rateBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);
            string  rateStr  = PriceHelper.FormatShippingPrice(rate, true);

            return(string.Format("({0})", rateStr));
        }
Esempio n. 22
0
        /// <summary>
        /// Loads the fresh.
        /// </summary>
        /// <returns></returns>
        private TaxDto LoadFresh()
        {
            TaxDto tax = TaxManager.GetTax(TaxId);

            // persist in session
            Session[_TaxDtoEditSessionKey] = tax;

            return(tax);
        }
Esempio n. 23
0
    void Awake()
    {
        counter = 0;
        addToTax = false;
        isBuilt = false;
        taxManager = GameObject.FindGameObjectWithTag("Manager").GetComponentInChildren<TaxManager>();

        tier = 1;
    }
Esempio n. 24
0
    void Awake()
    {
        counter    = 0;
        addToTax   = false;
        isBuilt    = false;
        taxManager = GameObject.FindGameObjectWithTag("Manager").GetComponentInChildren <TaxManager>();

        tier = 1;
    }
        private static decimal GetShippingVatPercentage()
        {
            TaxDto taxDto = TaxManager.GetTaxDto(TaxType.ShippingTax);

            if (taxDto.TaxValue.Count == 0)
            {
                return(0);
            }
            return((decimal)taxDto.TaxValue[0].Percentage);
        }
        public string GetShoppingCartItemUnitPriceString(ShoppingCartItem shoppingCartItem)
        {
            StringBuilder sb = new StringBuilder();
            decimal       shoppingCartUnitPriceWithDiscountBase = TaxManager.GetPrice(shoppingCartItem.ProductVariant, PriceHelper.GetUnitPrice(shoppingCartItem, customer, true), customer);
            decimal       shoppingCartUnitPriceWithDiscount     = CurrencyManager.ConvertCurrency(shoppingCartUnitPriceWithDiscountBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);
            string        unitPriceString = PriceHelper.FormatPrice(shoppingCartUnitPriceWithDiscount);

            sb.Append(unitPriceString);
            return(sb.ToString());
        }
Esempio n. 27
0
        public void CanRestrieveTaxInformationTest()
        {
            TaxManager        manager  = TaxManagerFactory.Create();
            TaxLookUpResponse response = new TaxLookUpResponse();

            response = manager.TaxLookUp("OH");

            Assert.IsTrue(response.Success);
            Assert.AreEqual("OH", response.TaxInformation.StateAbbreviation);
        }
Esempio n. 28
0
        private void BindData()
        {
            ProductVariant productVariant = ProductManager.GetProductVariantByID(this.ProductVariantID);

            if (productVariant != null)
            {
                decimal oldPriceBase = TaxManager.GetPrice(productVariant, productVariant.OldPrice);
                decimal finalPriceWithoutDiscountBase = TaxManager.GetPrice(productVariant, PriceHelper.GetFinalPrice(productVariant, false));
                decimal finalPriceWithDiscountBase    = TaxManager.GetPrice(productVariant, PriceHelper.GetFinalPrice(productVariant, true));

                decimal oldPrice = CurrencyManager.ConvertCurrency(oldPriceBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);
                decimal finalPriceWithoutDiscount = CurrencyManager.ConvertCurrency(finalPriceWithoutDiscountBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);
                decimal finalPriceWithDiscount    = CurrencyManager.ConvertCurrency(finalPriceWithDiscountBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);

                if (finalPriceWithoutDiscountBase != oldPriceBase && oldPriceBase > decimal.Zero)
                {
                    lblOldPrice.Text   = PriceHelper.FormatPrice(oldPrice);
                    lblPriceValue.Text = PriceHelper.FormatPrice(finalPriceWithoutDiscount);
                    phOldPrice.Visible = true;
                }
                else
                {
                    lblPriceValue.Text = PriceHelper.FormatPrice(finalPriceWithoutDiscount);
                    phOldPrice.Visible = false;
                }

                if (finalPriceWithoutDiscountBase != finalPriceWithDiscountBase)
                {
                    lblFinalPriceWithDiscount.Text = PriceHelper.FormatPrice(finalPriceWithDiscount);
                    phDiscount.Visible             = true;
                }
                else
                {
                    phDiscount.Visible = false;
                }

                if (phDiscount.Visible)
                {
                    lblPriceValue.CssClass = string.Empty;
                }
                else
                {
                    lblPriceValue.CssClass = "productPrice";
                }

                if (phDiscount.Visible || phOldPrice.Visible)
                {
                    lblPrice.Text = GetLocaleResourceString("Products.FinalPriceWithoutDiscount");
                }
            }
            else
            {
                this.Visible = false;
            }
        }
Esempio n. 29
0
        static void Main(string[] args)
        {
            var taxManager = new TaxManager(new PolandTaxStrategy());

            Console.WriteLine(taxManager.Income(300));
            Console.WriteLine(taxManager.Brutto(300));

            taxManager.TaxStrategy = new USATaxStrategy();
            Console.WriteLine(taxManager.Income(300));
            Console.WriteLine(taxManager.Brutto(300));
        }
Esempio n. 30
0
        public void CalculateTax_InvalidCountry()
        {
            // Arrange
            var factory = new MockAccessorFactory();
            var manager = new TaxManager(factory);

            // Act
            var result = manager.CalculateTax("Z");

            // Assert
            Assert.AreEqual(-1.00m, result);
        }
Esempio n. 31
0
        public static string GetState()
        {
            //Get order state, do not let user pass while the stateinput is invalid
            bool       stateInputValid = false;
            string     state           = "";
            TaxManager taxmanager      = TaxManagerFactory.Create();

            do
            {
                Console.Clear();
                Console.WriteLine("*********************************");
                Console.WriteLine("Add an Order");
                Console.WriteLine("*********************************");
                Console.WriteLine("Please select the state the work is to be done in.");
                Console.WriteLine("Note that a state not on the list is ineligible for service.");

                var allStatesAvailable = taxmanager.GetAllStates();

                ConsoleIO.DisplayStates(allStatesAvailable);

                string customerStateInput = Console.ReadLine().ToUpper();

                if (string.IsNullOrEmpty(customerStateInput) == true)
                {
                    stateInputValid = true;
                    ConsoleIO.DisplayMessage("Empty input.");
                }
                else
                {
                    var selectedState = taxmanager.GetStateTaxInfo(customerStateInput);

                    if (selectedState == null)
                    {
                        ConsoleIO.DisplayMessage($"{customerStateInput} is not a state we are authorized to work in.");
                    }
                    else
                    {
                        if (taxmanager.StateExistsInFile(selectedState.StateName) == true)
                        {
                            state = customerStateInput;
                            ConsoleIO.DisplayMessage($"Work will be done in {selectedState.StateName}.");
                            stateInputValid = true;
                        }
                        else
                        {
                            ConsoleIO.DisplayMessage($"{customerStateInput} is not a state we are authorized to work in.");
                        }
                    }
                }
            } while (stateInputValid == false);
            return(state);
        }
Esempio n. 32
0
        public void SetUp()
        {
            _mocks = new MockRepository();
            _mockDisplay = _mocks.StrictMock<IDisplay>();

            _mPoducts = new List<Product>() {new Product("xyz", 12, false),
                new Product("abc", 123, false), new Product("alma", 23, true),
                new Product("apple", 34, false), new Product("orange", 36, false),
                new Product("kiwi", 19, true), new Product("grapes", 98, true)
            };

            _mBarcodeScannerDataProcessor = new BarcodeScannerDataProcessor(_mPoducts, _mockDisplay);

            _mTaxManager = new TaxManager(_mFederalTaxRate, _mProvincialTaxRate);
            _mDisplay = new Display(_mTaxManager);
        }
Esempio n. 33
0
 public Display(TaxManager iTaxManager)
 {
     _mTaxManager = iTaxManager;
 }
Esempio n. 34
0
        public void TestTaxManagerPrivincialTaxRate()
        {
            decimal lFederalTaxRate = (decimal)0.05;
            decimal lProvincialTaxRate = (decimal)0.08;

            TaxManager lMyTaxManager = new TaxManager(lFederalTaxRate, lProvincialTaxRate);
            Product lProduct = new Product("test", (decimal)245.76, true);

            Assert.AreEqual(lProduct.Price +
                (lProduct.PstExempt ? 0 : Decimal.Multiply(lProduct.Price, lProvincialTaxRate))
            ,lMyTaxManager.GetPriceWithAppliedProvincialTax(lProduct));
        }