Пример #1
0
        protected IList <OrderItem> GetItems(object dataItem)
        {
            Order             order = (Order)dataItem;
            IList <OrderItem> items = new List <OrderItem>();

            foreach (OrderItem item in order.Items)
            {
                if (Array.IndexOf(displayItemTypes, item.OrderItemType) > -1 && (item.OrderItemType != OrderItemType.Tax))
                {
                    if (item.OrderItemType == OrderItemType.Product && item.IsChildItem)
                    {
                        // WHETHER THE CHILD ITEM DISPLAYS DEPENDS ON THE ROOT
                        OrderItem rootItem = item.GetParentItem(true);
                        if (rootItem != null && rootItem.Product != null && rootItem.ItemizeChildProducts)
                        {
                            // ITEMIZED DISPLAY ENABLED, SHOW THIS CHILD ITEM
                            items.Add(item);
                        }
                    }
                    else
                    {
                        items.Add(item);
                    }
                }
            }
            //ADD IN TAX ITEMS IF SPECIFIED FOR DISPLAY
            TaxInvoiceDisplay displayMode = TaxHelper.InvoiceDisplay;

            if (displayMode == TaxInvoiceDisplay.LineItem || displayMode == TaxInvoiceDisplay.LineItemRegistered)
            {
                foreach (OrderItem item in order.Items)
                {
                    //IS THIS A TAX ITEM?
                    if (item.OrderItemType == OrderItemType.Tax)
                    {
                        //IS THE TAX ITEM A PARENT ITEM OR A CHILD OF A DISPLAYED ITEM?
                        if (!item.IsChildItem || (items.IndexOf(AlwaysConvert.ToInt(item.ParentItemId)) > -1))
                        {
                            //TAX SHOULD BE SHOWN
                            items.Add(item);
                        }
                    }
                }
            }

            // SORT ITEMS AND COMBINE ORDER COUPONS TO COMPLETE INTITIALIZATION
            items.Sort(new OrderItemComparer());
            items = items.CombineOrderCoupons();
            return(items);
        }
Пример #2
0
        protected void BindOrderItemGrid()
        {
            IList <OrderItem> itemList = new List <OrderItem>();

            foreach (OrderItem item in _order.Items)
            {
                switch (item.OrderItemType)
                {
                case OrderItemType.Tax:
                case OrderItemType.GiftCertificatePayment:
                    break;

                default:
                    itemList.Add(item);
                    break;
                }
            }

            // SHOW TAXES IF SPECIFIED
            TaxInvoiceDisplay displayMode = TaxHelper.InvoiceDisplay;

            if (displayMode == TaxInvoiceDisplay.LineItem || displayMode == TaxInvoiceDisplay.LineItemRegistered)
            {
                foreach (OrderItem item in _order.Items)
                {
                    if ((item.OrderItemType == OrderItemType.Tax))
                    {
                        itemList.Add(item);
                    }
                }
            }

            // SORT AND COMBINE ORDER COUPONS FOR DISPLAY
            itemList.Sort(new OrderItemComparer());
            itemList = itemList.CombineOrderCoupons();
            OrderItemGrid.DataSource = itemList;
            OrderItemGrid.DataBind();
        }
Пример #3
0
        public static IList <OrderItem> GetShipmentItems(OrderShipment shipment)
        {
            Order             order            = shipment.Order;
            IList <OrderItem> shipmentProducts = new List <OrderItem>();

            foreach (OrderItem item in order.Items)
            {
                if (DisplayItemForShipment(item, shipment.Id))
                {
                    shipmentProducts.Add(item);
                }
            }

            //SHOW TAXES IF SPECIFIED FOR LINE ITEM DISPLAY
            TaxInvoiceDisplay displayMode = TaxHelper.InvoiceDisplay;

            if (displayMode == TaxInvoiceDisplay.LineItem || displayMode == TaxInvoiceDisplay.LineItemRegistered)
            {
                // LOOP ALL BASKET ITEMS
                foreach (OrderItem item in order.Items)
                {
                    // ONLY EXAMINE TAX ITEMS
                    if (item.OrderItemType == OrderItemType.Tax)
                    {
                        // DETERMINE THE PARENT ITEM
                        OrderItem parentItem = GetTaxParentItemForShipping(item);
                        // DISPLAY TAX IF PARENT IS DISPLAYED OR IF THIS IS NOT A CHILD ITEM AND IS PART OF THE SHIPMENT
                        if (shipmentProducts.IndexOf(parentItem.Id) > -1 ||
                            (!item.IsChildItem && item.OrderShipmentId == shipment.Id))
                        {
                            shipmentProducts.Add(item);
                        }
                    }
                }
            }
            shipmentProducts.Sort(new OrderItemComparer());
            return(shipmentProducts);
        }
Пример #4
0
        private void InitializeBasketContents()
        {
            decimal productsTotal = 0;
            decimal subtotal      = 0;
            decimal shipping      = 0;
            decimal handling      = 0;
            Dictionary <string, decimal> taxes = new Dictionary <string, decimal>();
            decimal totalTaxAmount             = 0;
            decimal total            = 0;
            int     numberOfProducts = 0;
            decimal giftCodes        = 0;
            Basket  basket           = AbleContext.Current.User.Basket;

            if (!_Recalculated)
            {
                IBasketService preCheckoutService = AbleContext.Resolve <IBasketService>();
                preCheckoutService.Recalculate(basket);
                preCheckoutService.Combine(basket);
                _Recalculated = true;
            }
            foreach (BasketItem item in basket.Items)
            {
                decimal extendedPrice = AbleCommerce.Code.InvoiceHelper.GetInvoiceExtendedPrice(item);
                switch (item.OrderItemType)
                {
                case OrderItemType.Product:
                    bool countItem = !item.IsChildItem;
                    if (!countItem)
                    {
                        BasketItem parentItem = item.GetParentItem(false);
                        if (parentItem != null)
                        {
                            countItem = parentItem.Product.IsKit && parentItem.Product.Kit.ItemizeDisplay;
                        }
                    }
                    if (countItem)
                    {
                        productsTotal    += extendedPrice;
                        subtotal         += extendedPrice;
                        numberOfProducts += item.Quantity;
                    }
                    else
                    {
                        // zero out the ext price - it is included with the parent
                        extendedPrice = 0;
                    }
                    break;

                case OrderItemType.Shipping:
                    shipping += extendedPrice;
                    break;

                case OrderItemType.Handling:
                    BasketShipment shipment = item.Shipment;
                    if (shipment != null && shipment.ShipMethod != null && shipment.ShipMethod.SurchargeIsVisible)
                    {
                        handling += extendedPrice;
                    }
                    else
                    {
                        shipping += extendedPrice;
                    }
                    break;

                case OrderItemType.Tax:
                    TaxInvoiceDisplay taxDisplay = TaxHelper.GetEffectiveInvoiceDisplay(AbleContext.Current.User);
                    if (taxDisplay == TaxInvoiceDisplay.Summary)
                    {
                        if (taxes.ContainsKey(item.Name))
                        {
                            taxes[item.Name] += extendedPrice;
                        }
                        else
                        {
                            taxes[item.Name] = extendedPrice;
                        }
                    }
                    else if (taxDisplay != TaxInvoiceDisplay.Included)
                    {
                        subtotal += extendedPrice;
                    }
                    totalTaxAmount += extendedPrice;
                    break;

                case OrderItemType.GiftCertificatePayment:
                    giftCodes += extendedPrice;
                    break;

                default:
                    subtotal += extendedPrice;
                    break;
                }
                total += extendedPrice;
            }

            Subtotal.Text = subtotal.LSCurrencyFormat("ulc");

            TaxInvoiceDisplay taxInvoiceDisplay = TaxHelper.GetEffectiveInvoiceDisplay(AbleContext.Current.User);

            if (AbleContext.Current.User.PrimaryAddress.IsValid &&
                taxInvoiceDisplay == TaxInvoiceDisplay.Summary)
            {
                TaxesBreakdownRepeater.DataSource = taxes;
                TaxesBreakdownRepeater.DataBind();
                if (ShowTaxBreakdown)
                {
                    TaxesBreakdownRepeater.Visible = true;
                    trTax.Visible = false;
                }
                else
                {
                    TaxesLabel.Text = totalTaxAmount.LSCurrencyFormat("ulc");
                    TaxesBreakdownRepeater.Visible = false;
                    trTax.Visible = true;
                }
            }
            else
            {
                // TAXES ARE NOT DISPLAYED, REMOVE ANY TAX FROM THE TOTAL
                if (taxInvoiceDisplay == TaxInvoiceDisplay.Included)
                {
                    total -= totalTaxAmount;
                }
                TaxesBreakdownRepeater.Visible = false;
                trTax.Visible = false;
            }

            // SHIPPING SHOULD NOT BE VISIBLE WHEN USER BILLING ADDRESS IS NOT SELECTED
            Shipping.Text = shipping.LSCurrencyFormat("ulc");
            if (!basket.User.PrimaryAddress.IsValid)
            {
                trShipping.Visible = false;
            }
            else if (shipping > 0)
            {
                trShipping.Visible = true;
            }
            else
            {
                trShipping.Visible = ShowShipping;
            }

            if (handling > 0)
            {
                trHandling.Visible = trShipping.Visible;
                Handling.Text      = handling.LSCurrencyFormat("ulc");
            }
            else
            {
                trHandling.Visible = false;
            }

            if (giftCodes != 0)
            {
                trGifCodes.Visible = true;
                GifCodes.Text      = giftCodes.LSCurrencyFormat("ulc");
            }
            else
            {
                trGifCodes.Visible = false;
            }

            trCouponsDivider.Visible = trGifCodes.Visible;

            Total.Text = total.LSCurrencyFormat("ulc");
            TotalPendingMessagePanel.Visible = this.ShowMessage;


            // ENABLE THE TAXCLOUD Exemption link only if taxcloud is configured and there are tax line items
            TaxGateway       taxGateway  = null;
            TaxCloudProvider taxProvider = null;
            int taxGatewayId             = TaxGatewayDataSource.GetTaxGatewayIdByClassId(Misc.GetClassId(typeof(TaxCloudProvider)));

            if (taxGatewayId > 0)
            {
                taxGateway = TaxGatewayDataSource.Load(taxGatewayId);
            }
            if (taxGateway != null)
            {
                taxProvider = taxGateway.GetProviderInstance() as TaxCloudProvider;
            }

            if (taxProvider == null || !taxProvider.EnableTaxCloud || taxes.Count == 0)
            {
                TaxCloudTaxExemptionCert1.Visible = false;
            }
        }