Beispiel #1
0
 public FlooringProgramManager(IClient clientRepo, IOrderRepository orderRepo, IProducts prodRepo, ITaxRate taxRepo)
 {
     _clientRepo  = clientRepo;
     _orderRepo   = orderRepo;
     _productRepo = prodRepo;
     _taxRepo     = taxRepo;
 }
        protected virtual int CalculateSavingsTaxAmount(OrderItem orderItem, ITaxRate taxRate)
        {
            int taxAmountAsInt = 0;

            long itemPrice = GetItemPrice(orderItem);

            //TODO: Do not hardcode "gate"
            var gatePrice = orderItem.AltPrices.FirstOrDefault(
                ap => ap.Key.ToLowerInvariant() == GateKeyName.Trim().ToLowerInvariant());

            if (taxRateLookup != null)
            {
                if (gatePrice != null && taxRate != null)
                {
                    var differenceInAmounts = gatePrice.PriceMinorUnits - itemPrice;

                    if (differenceInAmounts > 0)
                    {
                        taxAmountAsInt = (int)Math.Round((decimal)((differenceInAmounts * orderItem.Quantity) * (int)taxRate.Rate) / 10000, 0);
                    }
                }
            }

            return(taxAmountAsInt);
        }
        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);
        }
        protected virtual long CalculateTaxAmount(OrderItem orderItem, ITaxRate taxRate)
        {
            var taxAmountAsInt = 0L;

            long itemPrice = GetItemPrice(orderItem);

            if (taxRateLookup != null)
            {
                if (taxRate != null)
                {
                    var taxAmount = (long)taxRate.Rate;

                    taxAmountAsInt = (int)Math.Round((decimal)(itemPrice * orderItem.Quantity * taxAmount) / 10000, 0);
                }
            }

            return(taxAmountAsInt);
        }
        public TaxCalculator(IEnumerable <ITaxable> taxableItems)
        {
            BuildIndexedRates(taxableItems);

            taxRateLookup = (orderItem) =>
            {
                ITaxRate taxRate = null;

                if (orderItem != null)
                {
                    var taxRateKey = orderItem.VariantOfTicketID == -1
                        ? orderItem.TicketID
                        : orderItem.VariantOfTicketID;

                    taxRate = IndexedTaxRates != null && IndexedTaxRates.ContainsKey(taxRateKey)
                        ? IndexedTaxRates[taxRateKey]
                        : null;
                }

                return(taxRate);
            };
        }