Пример #1
0
        internal void ExtractItemList(Dictionary <int, ItemComparator.ItemInfo> magentoProductInfoMap)
        {
            orderItems = new List <MyOrderItem>();

            foreach (var item in magentoOrder.items)
            {
                if (item.sku.StartsWith("TOS_", StringComparison.InvariantCultureIgnoreCase))
                {
                    tos_sku = item.sku;
                    continue;
                }

                var orderItem = new MyOrderItem();
                orderItem.sku         = item.sku;
                orderItem.internal_id = magentoProductInfoMap[item.product_id].ns_internal_id;
                orderItem.item_type   = magentoProductInfoMap[item.product_id].ns_item_type;
                orderItem.brand       = magentoProductInfoMap[item.product_id].brand;
                orderItem.weight      = item.weight;
                orderItem.salesPrice  = item.price;
                orderItem.qty         = item.qty_ordered;
                orderItem.subtotal    = item.row_total;
                orderItem.tax_amount  = item.tax_amount;
                orderItem.tax_percent = item.tax_percent;

                orderItems.Add(orderItem);
            }
        }
Пример #2
0
        public MyOrderItem deep_clone()
        {
            var itemInfo = new MyOrderItem()
            {
                sku         = sku,
                qty         = qty,
                salesPrice  = salesPrice,
                tax_amount  = tax_amount,
                internal_id = internal_id,
                item_type   = item_type
            };

            return(itemInfo);
        }
Пример #3
0
        private TaxInfo GetTaxInfo(string shippingState, OrderInfo orderInfo)
        {
            TaxInfo taxInfo = new TaxInfo();

            if (orderInfo.magentoOrder.customer_group_id == 3)
            {
                taxInfo.isTaxable          = false;
                taxInfo.isTaxableSpecified = true;

                if (orderInfo.magentoOrder.tax_amount > 0)
                {
                    MyOrderItem amazon_sales_tax = new MyOrderItem()
                    {
                        item_type   = "Service for Sale",
                        internal_id = "51845", // X3076 - Finance Fee - Amazon Sales Tax
                        qty         = 1,
                        salesPrice  = orderInfo.magentoOrder.tax_amount
                    };
                    orderInfo.orderItems.Add(amazon_sales_tax);
                }

                return(taxInfo);
            }

            double taxableItemsAmount = orderInfo.GetTaxableItemAmount();
            double calculated_taxRate = (taxableItemsAmount > 0) ? 100 * orderInfo.magentoOrder.tax_amount / taxableItemsAmount : 0;

            orderInfo.calculated_taxRate = calculated_taxRate;

            if (calculated_taxRate <= 0)
            {
                taxInfo.isTaxable          = false;
                taxInfo.isTaxableSpecified = true;
                return(taxInfo); // no tax -> return initial
            }

            RecordRef taxItem = new RecordRef()
            {
                type = RecordType.salesTaxItem
            };

            if (orderInfo.magentoOrder.customer_group_id == 2)
            {
                taxInfo.isTaxable          = true;
                taxInfo.isTaxableSpecified = true;

                if (shippingState == "CA")
                {
                    taxItem.internalId       = "-4950";
                    taxInfo.taxItem          = taxItem;
                    taxInfo.taxRate          = calculated_taxRate;
                    taxInfo.taxRateSpecified = true;
                }
                else if (shippingState == "TX")
                {
                    taxItem.internalId       = "-4577";
                    taxInfo.taxItem          = taxItem;
                    taxInfo.taxRate          = calculated_taxRate;
                    taxInfo.taxRateSpecified = true;
                }
                else if (shippingState == "NJ")
                {
                    taxItem.internalId       = "-5316";
                    taxInfo.taxItem          = taxItem;
                    taxInfo.taxRate          = calculated_taxRate;
                    taxInfo.taxRateSpecified = true;
                }
                else if (shippingState == "SC")
                {
                    taxItem.internalId       = "-679";
                    taxInfo.taxItem          = taxItem;
                    taxInfo.taxRate          = calculated_taxRate;
                    taxInfo.taxRateSpecified = true;
                }
                else if (shippingState == "WA")
                {
                    taxItem.internalId       = "-1519";
                    taxInfo.taxItem          = taxItem;
                    taxInfo.taxRate          = calculated_taxRate;
                    taxInfo.taxRateSpecified = true;
                }
                // else: let NS find the tax item
            }
            else  // Standard
            {
                if (shippingState == "CA")
                {
                    taxItem.internalId         = "-4950";
                    taxInfo.taxItem            = taxItem;
                    taxInfo.taxRate            = calculated_taxRate;
                    taxInfo.taxRateSpecified   = true;
                    taxInfo.isTaxable          = true;
                    taxInfo.isTaxableSpecified = true;
                }
                else if (shippingState == "TX")
                {
                    taxItem.internalId         = "-4577";
                    taxInfo.taxItem            = taxItem;
                    taxInfo.taxRate            = calculated_taxRate;
                    taxInfo.taxRateSpecified   = true;
                    taxInfo.isTaxable          = true;
                    taxInfo.isTaxableSpecified = true;
                }
                else if (shippingState == "NJ")
                {
                    taxItem.internalId         = "-5316";
                    taxInfo.taxItem            = taxItem;
                    taxInfo.taxRate            = calculated_taxRate;
                    taxInfo.taxRateSpecified   = true;
                    taxInfo.isTaxable          = true;
                    taxInfo.isTaxableSpecified = true;
                }
                else if (shippingState == "WA" || shippingState == "SC")
                {
                    taxInfo.taxRate            = calculated_taxRate;
                    taxInfo.taxRateSpecified   = true;
                    taxInfo.isTaxable          = true;
                    taxInfo.isTaxableSpecified = true;
                }
            }

            return(taxInfo);
        }