public IActionResult Index()
        {
            CalculatedVM calculatedVM = new CalculatedVM();

            calculatedVM.TaxRate = int.Parse(taxRateService.GetTaxRate().ToString());
            return(View(calculatedVM));
        }
示例#2
0
        public decimal GetTotalGiftAid(decimal donationAmount)
        {
            decimal giftAid      = _giftAidService.CalculateGiftAid(donationAmount, _taxRateService.GetTaxRate());
            decimal totalGiftAid = _eventGiftAidSupplementService.AddSupplement(giftAid);

            return(totalGiftAid);
        }
        public async Task <ActionResult <decimal> > GetTaxRate(string mname, DateTime date)
        {
            decimal taxrate = 0;

            try
            {
                if (string.IsNullOrEmpty(mname) || date == null)
                {
                    return(BadRequest(new { message = "Invalid inputs" }));
                }

                taxrate = await _taxRateService.GetTaxRate(mname, date);

                if (taxrate == 0)
                {
                    return(NotFound());
                }
            }

            catch (Exception ex)
            {
                return(new ObjectResult(ex.Message));
            }

            return(taxrate);
        }
示例#4
0
        public void Should_Update_Tax_Rate()
        {
            taxRateService.SaveTaxRate(40);

            decimal rate = taxRateService.GetTaxRate();

            Assert.That(rate, Is.EqualTo(40));
        }
示例#5
0
        public float GetOrderItemTotal(OrderItem orderItem, Location storeLocation)
        {
            var price      = (orderItem.Item.Price * orderItem.Quantity);
            var salesTax   = price * _taxRateService.GetTaxRate(storeLocation);
            var totalPrice = price + salesTax;

            return(totalPrice);
        }
示例#6
0
        public void Should_Calculate_Gift_Aid_Based_On_Tax_Rate_In_DataStore()
        {
            _taxRateService.SaveTaxRate(15);
            decimal taxRate  = _taxRateService.GetTaxRate();
            decimal donation = 100;

            decimal giftAid = _giftAidService.CalculateGiftAid(donation, taxRate);

            Assert.AreEqual(17.65m, giftAid);
        }
示例#7
0
        /// <summary>
        /// Gets tax rate
        /// </summary>
        /// <param name="product">Product</param>
        /// <param name="taxCategoryId">Tax category identifier</param>
        /// <param name="customer">Customer</param>
        /// <param name="price">Price (taxable value)</param>
        /// <param name="taxRate">Calculated tax rate</param>
        /// <param name="isTaxable">A value indicating whether a request is taxable</param>
        protected virtual void GetTaxRate(Product product, int taxCategoryId, Customer customer, decimal price, out decimal taxRate, out bool isTaxable)
        {
            taxRate   = decimal.Zero;
            isTaxable = true;

            //tax provider
            var taxProvider = _taxRateService.GetAllTaxRates();

            if (taxProvider == null)
            {
                return;
            }

            //tax request
            var calculateTaxRequest = CreateCalculateTaxRequest(product, taxCategoryId, customer, price);

            //tax exempt
            if (IsTaxExempt(product, calculateTaxRequest.Customer))
            {
                isTaxable = false;
            }
            //make EU VAT exempt validation (the European Union Value Added Tax)
            if (isTaxable &&
                _taxSettings.EuVatEnabled &&
                IsVatExempt(calculateTaxRequest.Address, calculateTaxRequest.Customer))
            {
                //VAT is not chargeable
                isTaxable = false;
            }

            //get tax rate
            var calculateTaxResult = _taxRateService.GetTaxRate(calculateTaxRequest);

            if (calculateTaxResult.Success)
            {
                //ensure that tax is equal or greater than zero
                if (calculateTaxResult.TaxRate < decimal.Zero)
                {
                    calculateTaxResult.TaxRate = decimal.Zero;
                }

                taxRate = calculateTaxResult.TaxRate;
            }
            else
            if (_taxSettings.LogErrors)
            {
                foreach (var error in calculateTaxResult.Errors)
                {
                    _logger.Error(string.Format("{0} - {1}", "CountryStateZipTaxRate", error), null, customer);
                }
            }
        }