Esempio n. 1
0
        public static (Address, Address) GetAddresses(this ShipEstimate estimates, IList <LineItem> allLines)
        {
            var firstItemInShipmentID = estimates.ShipEstimateItems.FirstOrDefault().LineItemID;
            var lineItem = allLines.First(item => item.ID == firstItemInShipmentID);

            return(lineItem.ShipFromAddress, lineItem.ShippingAddress);
        }
Esempio n. 2
0
        private static TaxJarOrder ToTaxJarOrders(ShipEstimate shipEstimate, OCLineItem lineItem, string orderID)
        {
            var selectedShipMethod = shipEstimate.ShipMethods.First(x => x.ID == shipEstimate.SelectedShipMethodID);

            return(new TaxJarOrder()
            {
                TransactionId = $"OrderID:|{orderID}|ShippingEstimateID:|{shipEstimate.ID}",
                Shipping = 0,                 // will create separate lines for shipping

                FromCity = lineItem.ShipFromAddress.City,
                FromZip = lineItem.ShipFromAddress.Zip,
                FromState = lineItem.ShipFromAddress.State,
                FromCountry = lineItem.ShipFromAddress.Country,
                FromStreet = lineItem.ShipFromAddress.Street1,

                ToCity = lineItem.ShippingAddress.City,
                ToZip = lineItem.ShippingAddress.Zip,
                ToState = lineItem.ShippingAddress.State,
                ToCountry = lineItem.ShippingAddress.Country,
                ToStreet = lineItem.ShippingAddress.Street1,

                LineItems = new List <TaxJarLineItem> {
                    new TaxJarLineItem()
                    {
                        Id = shipEstimate.ID,
                        Quantity = 1,
                        UnitPrice = selectedShipMethod.Cost,
                        Description = selectedShipMethod.Name,
                        ProductIdentifier = "shipping_code",
                    }
                }
            });
        }
Esempio n. 3
0
        private static LineItemModel ToLineItemModel(this ShipEstimate shipEstimate, Address shipFrom, Address shipTo)
        {
            var method = shipEstimate.GetSelectedShippingMethod();

            return(new LineItemModel()
            {
                amount = method.Cost,
                taxCode = "FR",
                itemCode = method.Name,
                customerUsageType = null,
                number = shipEstimate.ID,
                addresses = ToAddressesModel(shipFrom, shipTo)
            });
        }
Esempio n. 4
0
        public static VertexLineItem ToVertexLineItem(ShipEstimate shipEstimate, Address shipTo)
        {
            var selectedMethod = shipEstimate.ShipMethods.First(m => m.ID == shipEstimate.SelectedShipMethodID);

            return(new VertexLineItem()
            {
                customer = new VertexCustomer()
                {
                    destination = shipTo.ToVertexLocation(),
                },
                product = new VertexProduct()
                {
                    productClass = "shipping_code",
                    value = selectedMethod.Name
                },
                quantity = new VertexMeasure()
                {
                    value = 1
                },
                unitPrice = (double)selectedMethod.Cost,
                lineItemId = shipEstimate.ID,
            });
        }
Esempio n. 5
0
 public static ShipMethod GetSelectedShippingMethod(this ShipEstimate estimates)
 {
     return(estimates.ShipMethods.First(method => method.ID == estimates.SelectedShipMethodID));
 }