public async Task free_shipping_for_no_rates()
        {
            var shipItem1 = new ShipEstimateItem
            {
                LineItemID = "Line1"
            };
            var line1 = new HSLineItem
            {
                ID           = "Line1",
                LineSubtotal = 370,
                SupplierID   = "010"
            };
            var method1 = new HSShipMethod
            {
                ID = "NO_SHIPPING_RATES",
                xp = new ShipMethodXP()
            };
            var worksheet = BuildOrderWorksheet(new HSLineItem[] { line1 });
            var estimates = BuildEstimates(new[] { method1 }, new[] { shipItem1 });
            var result    = await estimates.ApplyShippingLogic(worksheet, _oc, FREE_SHIPPING_DAYS);

            var methods = result[0].ShipMethods;

            Assert.AreEqual(1, methods.Count());
            Assert.AreEqual(0, methods[0].Cost);
            Assert.AreEqual(method1.Name, methods[0].Name);
            Assert.IsTrue(methods[0].xp.FreeShippingApplied);
        }
        public async Task shipping_ignore_zerocostAsync()
        {
            // don't transform methods if they are zero cost
            var shipItem1 = new ShipEstimateItem
            {
                LineItemID = "Line1"
            };
            var line1 = new HSLineItem
            {
                ID           = "Line1",
                LineSubtotal = 0,
                SupplierID   = "027"
            };
            var method1 = new HSShipMethod
            {
                Name = "FEDEX_GROUND",
                EstimatedTransitDays = 3,
                Cost = 60,
                xp   = new ShipMethodXP {
                }
            };
            var worksheet = BuildOrderWorksheet(new HSLineItem[] { line1 });
            var estimates = BuildEstimates(new[] { method1 }, new[] { shipItem1 });
            var result    = await estimates.ApplyShippingLogic(worksheet, _oc, FREE_SHIPPING_DAYS);

            var methods = result[0].ShipMethods;

            Assert.AreEqual(1, methods.Count());
            Assert.AreEqual(method1.Cost, methods[0].Cost);
            Assert.AreEqual(method1.Name, methods[0].Name);
        }
        public void flatrateshipping_handle_second_tier()
        {
            // set shipping cost to $0 if line item cost is greater than $499.99
            var shipItem1 = new ShipEstimateItem
            {
                LineItemID = "Line1"
            };
            var line1 = new HSLineItem
            {
                ID           = "Line1",
                LineSubtotal = 602,
                SupplierID   = "027"
            };
            var method1 = new HSShipMethod
            {
                Name = "FEDEX_GROUND",
                EstimatedTransitDays = 3,
                Cost = 60,
                xp   = new ShipMethodXP {
                }
            };
            var worksheet = BuildOrderWorksheet(line1);
            var estimates = BuildEstimates(new[] { method1 }, new[] { shipItem1 });
            var result    = ApplyFlatRateShipping(worksheet, estimates, "027", null);
            var methods   = result[0].ShipMethods;

            Assert.AreEqual(1, methods.Count());
            Assert.AreEqual(FLAT_RATE_SECOND_TIER, methods[0].Cost);
            Assert.AreEqual(method1.Name, methods[0].Name);
        }
        public void flatrateshipping_ignore_zerocost()
        {
            // don't transform methods if they are zero cost
            var shipItem1 = new ShipEstimateItem
            {
                LineItemID = "Line1"
            };
            var line1 = new HSLineItem
            {
                ID           = "Line1",
                LineSubtotal = 0,
                SupplierID   = "027"
            };
            var method1 = new HSShipMethod
            {
                Name = "FEDEX_GROUND",
                EstimatedTransitDays = 3,
                Cost = 60,
                xp   = new ShipMethodXP {
                }
            };
            var worksheet = BuildOrderWorksheet(line1);
            var estimates = BuildEstimates(new[] { method1 }, new[] { shipItem1 });
            var result    = ApplyFlatRateShipping(worksheet, estimates, "027", null);
            var methods   = result[0].ShipMethods;

            Assert.AreEqual(1, methods.Count());
            Assert.AreEqual(method1.Cost, methods[0].Cost);
            Assert.AreEqual(method1.Name, methods[0].Name);
        }
        public void flatrateshipping_multiple_methods_with_nonqualifyingflatrate()
        {
            // If DOESNT qualify for flat rate shipping then dont modify the rates
            var shipItem1 = new ShipEstimateItem
            {
                LineItemID = "Line1"
            };
            var shipItem2 = new ShipEstimateItem
            {
                LineItemID = "Line2"
            };
            var line1 = new HSLineItem
            {
                ID           = "Line1",
                LineSubtotal = 250,
                SupplierID   = "027"
            };
            var line2 = new HSLineItem
            {
                ID           = "Line2",
                LineSubtotal = 130,
                SupplierID   = "027"
            };
            var method1 = new HSShipMethod
            {
                Name = "SOMETHING_ELSE",
                EstimatedTransitDays = 3,
                Cost = 60,
                xp   = new ShipMethodXP {
                }
            };
            var method2 = new HSShipMethod
            {
                Name = "PRIORITY_OVERNIGHT",
                EstimatedTransitDays = 1,
                Cost = 120,
                xp   = new ShipMethodXP {
                }
            };
            var worksheet = BuildOrderWorksheet(line1, line2);
            var estimates = BuildEstimates(new[] { method1, method2 }, new[] { shipItem1, shipItem2 });
            var result    = ApplyFlatRateShipping(worksheet, estimates, "027", null);
            var methods   = result[0].ShipMethods;

            Assert.AreEqual(2, methods.Count());
            Assert.AreEqual(method1.Cost, methods[0].Cost);
            Assert.AreEqual(method1.Name, methods[0].Name);
            Assert.AreEqual(method2.Cost, methods[1].Cost);
            Assert.AreEqual(method2.Name, methods[1].Name);
        }
        public void flatrateshipping_multiple_methods_with_qualifyingflatrate()
        {
            // If qualifies for flat rate shipping then the only rate that should be returned is the modified ground option
            // this test ensures the non-ground option is stripped out
            var shipItem1 = new ShipEstimateItem
            {
                LineItemID = "Line1"
            };
            var shipItem2 = new ShipEstimateItem
            {
                LineItemID = "Line2"
            };
            var line1 = new HSLineItem
            {
                ID           = "Line1",
                LineSubtotal = 250,
                SupplierID   = "027"
            };
            var line2 = new HSLineItem
            {
                ID           = "Line2",
                LineSubtotal = 130,
                SupplierID   = "027"
            };
            var method1 = new HSShipMethod
            {
                Name = "FEDEX_GROUND",
                EstimatedTransitDays = 3,
                Cost = 60,
                xp   = new ShipMethodXP {
                }
            };
            var method2 = new HSShipMethod
            {
                Name = "PRIORITY_OVERNIGHT",
                EstimatedTransitDays = 1,
                Cost = 120,
                xp   = new ShipMethodXP {
                }
            };
            var worksheet = BuildOrderWorksheet(line1, line2);
            var estimates = BuildEstimates(new[] { method1, method2 }, new[] { shipItem1, shipItem2 });
            var result    = ApplyFlatRateShipping(worksheet, estimates, "027", null);
            var methods   = result[0].ShipMethods;

            Assert.AreEqual(1, methods.Count());
            Assert.AreEqual(FLAT_RATE_FIRST_TIER, methods[0].Cost);
            Assert.AreEqual(method1.Name, methods[0].Name);
        }
Exemplo n.º 7
0
        public async Task default_shipping_for_no_rates()
        {
            var shipItem1 = new ShipEstimateItem
            {
                LineItemID = "Line1"
            };
            var line1 = new HSLineItem
            {
                ID           = "Line1",
                LineSubtotal = 370,
                SupplierID   = "010"
            };
            var worksheet = BuildOrderWorksheet(new HSLineItem[] { line1 });
            var estimates = BuildEstimates(new HSShipMethod[] { }, new[] { shipItem1 });
            var result    = await estimates.CheckForEmptyRates(20, 5).ApplyShippingLogic(worksheet, _oc, FREE_SHIPPING_DAYS);

            var methods = result[0].ShipMethods;

            Assert.AreEqual(1, methods.Count());
            Assert.AreEqual(20, methods[0].Cost);
        }
        public void flatrateshipping_handle_first_tier_multiple_lines()
        {
            // set shipping cost to $29.99 if line item cost is between 0.01$ and $499.99
            var shipItem1 = new ShipEstimateItem
            {
                LineItemID = "Line1"
            };
            var shipItem2 = new ShipEstimateItem
            {
                LineItemID = "Line2"
            };
            var line1 = new HSLineItem
            {
                ID           = "Line1",
                LineSubtotal = 200,
                SupplierID   = "027"
            };
            var line2 = new HSLineItem
            {
                ID           = "Line2",
                LineSubtotal = 250,
                SupplierID   = "027"
            };
            var method1 = new HSShipMethod
            {
                Name = "FEDEX_GROUND",
                EstimatedTransitDays = 3,
                Cost = 60,
                xp   = new ShipMethodXP {
                }
            };
            var worksheet = BuildOrderWorksheet(line1, line2);
            var estimates = BuildEstimates(new[] { method1 }, new[] { shipItem1, shipItem2 });
            var result    = ApplyFlatRateShipping(worksheet, estimates, "027", null);
            var methods   = result[0].ShipMethods;

            Assert.AreEqual(1, methods.Count());
            Assert.AreEqual(FLAT_RATE_FIRST_TIER, methods[0].Cost);
            Assert.AreEqual(method1.Name, methods[0].Name);
        }
        public void flatrateshipping_handle_multiple_estimates()
        {
            // set shipping cost to $0 if line item cost is greater than $499.99
            var shipItem1 = new ShipEstimateItem
            {
                LineItemID = "Supplier1Line1"
            };
            var shipitem2 = new ShipEstimateItem
            {
                LineItemID = "Supplier2Line1"
            };
            var line1 = new HSLineItem
            {
                ID           = "Supplier1Line1",
                LineSubtotal = 110,
                SupplierID   = "010"
            };
            var line2 = new HSLineItem
            {
                ID           = "Supplier1Line2",
                LineSubtotal = 125,
                SupplierID   = "010"
            };
            var line3 = new HSLineItem
            {
                ID           = "Supplier2Line1",
                LineSubtotal = 130,
                SupplierID   = "027"
            };
            var line4 = new HSLineItem
            {
                ID           = "Supplier2Line2",
                LineSubtotal = 180,
                SupplierID   = "027"
            };
            var method1 = new HSShipMethod
            {
                Name = "FEDEX_GROUND",
                EstimatedTransitDays = 1,
                Cost = 80,
                xp   = new ShipMethodXP {
                }
            };
            var method2 = new HSShipMethod
            {
                Name = "FEDEX_GROUND",
                EstimatedTransitDays = 3,
                Cost = 60,
                xp   = new ShipMethodXP {
                }
            };
            var worksheet = BuildOrderWorksheet(line1, line2, line3, line4);
            var estimates = BuildEstimates(new[] { method1 }, new[] { shipItem1 });

            estimates.AddRange(BuildEstimates(new[] { method2 }, new[] { shipitem2 }));
            var result = ApplyFlatRateShipping(worksheet, estimates, "027", null);

            Assert.AreEqual(2, result.Count());
            // compare first shipment item from first estimate (no changes because its not medline supplier)
            Assert.AreEqual(1, result[0].ShipMethods.Count());
            Assert.AreEqual(method1.Name, result[0].ShipMethods[0].Name);
            Assert.AreEqual(method1.Cost, result[0].ShipMethods[0].Cost);

            // compare first shipment item from second estimate (cost falls in first tier between $0.01 and $499.9)
            Assert.AreEqual(1, result[0].ShipMethods.Count());
            Assert.AreEqual(method2.Name, result[1].ShipMethods[0].Name);
            Assert.AreEqual(29.99M, result[1].ShipMethods[0].Cost);
        }