public decimal CalculateTax(string country)
        {
            decimal taxAmount = -1;

            // Get the subtotal
            ISubtotal subtotal = _accessorFactory.CreateAccessor <ISubtotal>();

            // Get the right tax rate accessor
            ITaxRate tax = _accessorFactory.CreateAccessor <ITaxRate>(country);

            // Check to see if a tax rate accessor was created
            if (tax != null)
            {
                // Have the tax rate accessor calculate the tax amount
                tax.RequestTaxCalculation(subtotal.GetSubtotal());

                // Check to see if accessor was able to calculate the tax
                bool taxResult = tax.CheckTaxResult();

                // Get the tax amount if accessor was able to calculate taxes
                if (taxResult == true)
                {
                    taxAmount = tax.GetTaxAmount();
                }
            }

            return(taxAmount);
        }
Exemple #2
0
        public decimal CalculateTax(string country, decimal amount)
        {
            var taxService = accessorFactory.CreateAccessor <ITaxService>(country);

            if (taxService != null && amount > 0)
            {
                taxService.RequestTaxCalculation(amount);

                return((taxService.CheckTaxResult()) ? taxService.GetTaxAmount() : -1);
            }
            else
            {
                return(-1);
            }
        }