예제 #1
0
        private PackageList PreparePackages(Warehouse origin, Address destination, BasketItemCollection contents)
        {
            PackageList plist = PackageManager.GetPackageList(contents);

            if (plist == null || plist.Count == 0)
            {
                return(null);
            }

            ProviderUnits pUnits = GetProviderUnits(origin.Country);
            //GET UNITS USED BY STORE
            Store           store = Token.Instance.Store;
            MeasurementUnit storeMeasurementUnit = store.MeasurementUnit;
            WeightUnit      storeWeightUnit      = store.WeightUnit;

            bool requireMC = storeMeasurementUnit != pUnits.MeasurementUnit;
            bool requireWC = storeWeightUnit != pUnits.WeightUnit;

            if (requireMC && requireWC)
            {
                plist.ConvertBoth(pUnits.WeightUnit, pUnits.MeasurementUnit);
            }
            else if (requireWC)
            {
                plist.ConvertWeight(pUnits.WeightUnit);
            }
            else if (requireMC)
            {
                plist.ConvertDimensions(pUnits.MeasurementUnit);
            }

            WeightUnit sourceUnit = (Token.Instance.Store.WeightUnit == WeightUnit.Grams || Token.Instance.Store.WeightUnit == WeightUnit.Kilograms) ? WeightUnit.Kilograms : WeightUnit.Pounds;
            LSDecimal  maxWeight  = LocaleHelper.ConvertWeight(sourceUnit, MaxPackageWeight, pUnits.WeightUnit);
            LSDecimal  minWeight  = LocaleHelper.ConvertWeight(sourceUnit, MinPackageWeight, pUnits.WeightUnit);

            if (EnablePackageBreakup && maxWeight > 0)
            {
                //compose packages (splits items larger than the maximum carrier weight)
                plist.Compose(maxWeight, minWeight);
            }
            else
            {
                plist.EnsureMinimumWeight(minWeight);
            }

            //convert weight and dimensions to whole numbers
            plist.ConvertDimsToWholeNumbers();
            plist.RoundWeight(1);

            return(plist);
        }
예제 #2
0
        private PackageList PreparePackages(Warehouse origin, BasketItemCollection contents)
        {
            PackageList plist = PackageManager.GetPackageList(contents);

            if (plist == null || plist.Count == 0)
            {
                return(null);
            }

            //GET UNITS USED BY STORE
            Store           store = StoreDataSource.Load(Token.Instance.StoreId);
            MeasurementUnit storeMeasurementUnit = store.MeasurementUnit;
            WeightUnit      storeWeightUnit      = store.WeightUnit;

            bool requireMC = storeMeasurementUnit != MeasurementUnit.Inches;
            bool requireWC = storeWeightUnit != WeightUnit.Ounces;

            if (requireMC && requireWC)
            {
                plist.ConvertBoth(WeightUnit.Ounces, MeasurementUnit.Inches);
            }
            else if (requireWC)
            {
                plist.ConvertWeight(WeightUnit.Ounces);
            }
            else if (requireMC)
            {
                plist.ConvertDimensions(MeasurementUnit.Inches);
            }

            LSDecimal maxWeight = LocaleHelper.ConvertWeight(WeightUnit.Pounds, MaxPackageWeight, WeightUnit.Ounces);
            LSDecimal minWeight = LocaleHelper.ConvertWeight(WeightUnit.Pounds, MinPackageWeight, WeightUnit.Ounces);

            if (EnablePackageBreakup && maxWeight > 0)
            {
                //compose packages (splits items larger than the maximum carrier weight)
                plist.Compose(maxWeight, minWeight);
            }
            else
            {
                plist.EnsureMinimumWeight(minWeight);
            }

            //convert weight to whole number
            //plist.ConvertWeightToWholeNumber();
            //plist.ConvertDimsToWholeNumbers();

            return(plist);
        }
예제 #3
0
        private PackageList PreparePackages(Warehouse origin, BasketItemCollection contents)
        {
            PackageList plist = PackageManager.GetPackageList(contents);

            if (plist == null || plist.Count == 0)
            {
                return(null);
            }

            ProviderUnits pUnits = GetProviderUnits(origin.Country);
            //GET UNITS USED BY STORE
            Store           store = StoreDataSource.Load(Token.Instance.StoreId);
            MeasurementUnit storeMeasurementUnit = store.MeasurementUnit;
            WeightUnit      storeWeightUnit      = store.WeightUnit;

            bool requireMC = storeMeasurementUnit != pUnits.MeasurementUnit;
            bool requireWC = storeWeightUnit != pUnits.WeightUnit;

            if (requireMC && requireWC)
            {
                plist.ConvertBoth(pUnits.WeightUnit, pUnits.MeasurementUnit);
            }
            else if (requireWC)
            {
                plist.ConvertWeight(pUnits.WeightUnit);
            }
            else if (requireMC)
            {
                plist.ConvertDimensions(pUnits.MeasurementUnit);
            }

            LSDecimal maxWeight = LocaleHelper.ConvertWeight(WeightUnit.Kilograms, MaxPackageWeight, pUnits.WeightUnit);
            LSDecimal minWeight = LocaleHelper.ConvertWeight(WeightUnit.Kilograms, MinPackageWeight, pUnits.WeightUnit);

            if (EnablePackageBreakup && maxWeight > 0)
            {
                //compose packages (splits items larger than the maximum carrier weight)
                plist.Compose(maxWeight, minWeight);
            }
            else
            {
                plist.EnsureMinimumWeight(minWeight);
            }

            return(plist);
        }
예제 #4
0
 /// <summary>
 /// Converts weight of this package to the given weight unit
 /// </summary>
 /// <param name="to">The weight unit to convert to</param>
 public void ConvertWeight(WeightUnit to)
 {
     Weight          = LocaleHelper.ConvertWeight(this.WeightUnit, Weight, to);
     this.WeightUnit = to;
 }