public CalculateTaxResult GetTaxRate(CalculateTaxRequest calculateTaxRequest)
 {
     var result = new CalculateTaxResult()
     {
         TaxRate = GetTaxRate(calculateTaxRequest.TaxCategoryId)
     };
     return result;
 }
 /// <summary>
 /// Gets tax rate
 /// </summary>
 /// <param name="calculateTaxRequest">Tax calculation request</param>
 /// <returns>Tax</returns>
 public CalculateTaxResult GetTaxRate(CalculateTaxRequest calculateTaxRequest)
 {
     var result = new CalculateTaxResult()
     {
          TaxRate = decimal.Zero
     };
     return result;
 }
        public CalculateTaxResult GetTaxRate(CalculateTaxRequest calculateTaxRequest)
        {
            var result = new CalculateTaxResult()
            {
                TaxRate = decimal.Zero
            };

            return(result);
        }
        /// <summary>
        /// Gets tax rate
        /// </summary>
        /// <param name="calculateTaxRequest">Tax calculation request</param>
        /// <returns>Tax</returns>
        public CalculateTaxResult GetTaxRate(CalculateTaxRequest calculateTaxRequest)
        {
            var result = new CalculateTaxResult();

            if (calculateTaxRequest.Address == null)
            {
                result.Errors.Add("Address is not set");
                return result;
            }

            var taxRates = _taxRateService.GetAllTaxRates(calculateTaxRequest.TaxCategoryId,
                calculateTaxRequest.Address.Country != null ? calculateTaxRequest.Address.Country.Id: 0,
                calculateTaxRequest.Address.StateProvince != null ? calculateTaxRequest.Address.StateProvince.Id : 0, 
                calculateTaxRequest.Address.ZipPostalCode);
            if (taxRates.Count > 0)
                result.TaxRate = taxRates[0].Percentage;

            return result;
        }
Exemple #5
0
        /// <summary>
        /// Create request for tax calculation
        /// </summary>
        /// <param name="product">Product</param>
        /// <param name="taxCategoryId">Tax category identifier</param>
        /// <param name="customer">Customer</param>
        /// <returns>Package for tax calculation</returns>
        protected CalculateTaxRequest CreateCalculateTaxRequest(Product product, int taxCategoryId, Customer customer)
        {
            var calculateTaxRequest = new CalculateTaxRequest();

            calculateTaxRequest.Customer = customer;
            if (taxCategoryId > 0)
            {
                calculateTaxRequest.TaxCategoryId = taxCategoryId;
            }
            else
            {
                if (product != null)
                {
                    calculateTaxRequest.TaxCategoryId = product.TaxCategoryId;
                }
            }

            calculateTaxRequest.Address = this.GetTaxAddress(customer, product);
            return(calculateTaxRequest);
        }