public Order ProcessOrder(Order order)
        {
            List <Order> ord       = new List <Order>();
            Order        prc_order = new Order();
            double       _results  = 0;
            double       _price    = order.rowPrice;
            int          _quantity = order.quantity;
            double       _taxValue = 0;
            double       _sumTaxes = 0;
            double       _importedPriceBeforeTaxes = 0;
            double       _sumimportFees            = 0;
            double       _totaTaxes = 0;

            if (order.imported)
            {
                _importedPriceBeforeTaxes = _importFeeCalculator.CalculateImportFee(_price);

                if (order.taxable)
                {
                    _taxValue = _taxCalculator.CalculateSalesTax(_price);
                    _results  = ((_price + _taxValue + _importedPriceBeforeTaxes) * _quantity);
                }
                else
                {
                    _results = (_importedPriceBeforeTaxes + _price) * _quantity;
                }
            }
            else
            {
                if (order.taxable)
                {
                    _taxValue = _taxCalculator.CalculateSalesTax(_price);
                    _results  = (_taxValue + _price) * _quantity;
                }
                else
                {
                    _results = (_price * _quantity);
                }
            }
            _sumTaxes      = _sumTaxes + _taxValue;
            _sumimportFees = _sumimportFees + _importedPriceBeforeTaxes;
            _totaTaxes     = _sumimportFees + _sumTaxes;
            Convert.ToDouble(_results.ToString("0.00"));
            prc_order.orderName  = order.orderName;
            prc_order.quantity   = order.quantity;
            prc_order.rowPrice   = order.rowPrice;
            prc_order.taxes      = _totaTaxes;
            prc_order.finalPrice = _results.ToString("0.00");
            return(prc_order);
        }
Ejemplo n.º 2
0
        public int GetTransportationPrice(int warehouseId, string destination)
        {
            Console.WriteLine("[" + this.GetType().ToString() + "]" + " Looking for warehouse in repository");
            IWarehouse warehouse = warehouses.Find(warehouseId);

            if (null == warehouse)
            {
                Console.WriteLine("Warehouse is not found!");
                return(-1);
            }

            Console.WriteLine("[" + this.GetType().ToString() + "]" + " Calculating fee");
            return(importCalculator.CalculateImportFee(warehouse, destination));
        }