private List <DomesticPackage> OptimizePackages(IShipment shipment) { List <DomesticPackage> result = new List <DomesticPackage>(); // Determine what service to use when processing DomesticServiceType service = DomesticServiceType.All; service = this.Settings.GetServiceForProcessing(); // Get max weight for this service decimal _maxWeight = CalculateMaxWeightPerPackage(service, this.Settings.PackageType); // Create many boxes if we exceed max weight PackageOptimizer optimizer = new PackageOptimizer(_maxWeight); List <IShippable> weightOptimizedPackages = optimizer.OptimizePackagesToMaxWeight(shipment); int counter = 0; foreach (IShippable s in weightOptimizedPackages) { DomesticPackage pak = new DomesticPackage(); pak.Id = counter.ToString(); pak.ZipDestination = MerchantTribe.Web.Text.TrimToLength(shipment.DestinationAddress.PostalCode, 5); pak.ZipOrigination = MerchantTribe.Web.Text.TrimToLength(shipment.SourceAddress.PostalCode, 5); pak.Container = this.Settings.PackageType; // If we're using first class service, make sure we have a valid package type if (service == DomesticServiceType.FirstClass) { if ((int)pak.Container < 100) { if (pak.Ounces < 3.5m) { pak.Container = DomesticPackageType.FirstClassLetter; } else { pak.Container = DomesticPackageType.FirstClassParcel; } } } pak.Ounces = MerchantTribe.Web.Conversions.DecimalPoundsToOunces(s.BoxWeight); pak.Pounds = (int)Math.Floor(s.BoxWeight); pak.Service = service; counter++; result.Add(pak); } return(result); }
private decimal CalculateMaxWeightPerPackage(DomesticServiceType s, DomesticPackageType packageType) { if (s == DomesticServiceType.FirstClass) { if (packageType == DomesticPackageType.FirstClassLetter) { return(USPostalConstants.MaxFirstClassLetterWeightInPounds); } return(USPostalConstants.MaxFirstClassWeightInPounds); } return(USPostalConstants.MaxWeightInPounds); }
public string TranslateServiceCodeToString(DomesticServiceType service) { switch (service) { case DomesticServiceType.All: return("ALL"); case DomesticServiceType.ExpressMail: return("EXPRESS"); case DomesticServiceType.ExpressMailCommerceial: return("EXPRESS COMMERCIAL"); case DomesticServiceType.ExpressMailHoldForPickup: return("EXPRESS HFP"); case DomesticServiceType.ExpressMailHoldForPickupCommercial: return("EXPRESS HFP COMMERCIAL"); case DomesticServiceType.ExpressMailSundayHoliday: return("EXPRESS SH"); case DomesticServiceType.ExpressMailSundayHolidayCommercial: return("EXPRESS SH COMMERCIAL"); case DomesticServiceType.FirstClass: return("FIRST CLASS"); case DomesticServiceType.LibraryMaterial: return("LIBRARY"); case DomesticServiceType.MediaMail: return("MEDIA"); case DomesticServiceType.Online: return("ONLINE"); case DomesticServiceType.ParcelPost: return("PARCEL"); case DomesticServiceType.PriorityMail: return("PRIORITY"); } return("ALL"); }
private decimal CalculateMaxWeightPerPackage(DomesticServiceType s, DomesticPackageType packageType) { if (s == DomesticServiceType.FirstClass) { if (packageType == DomesticPackageType.FirstClassLetter) return USPostalConstants.MaxFirstClassLetterWeightInPounds; return USPostalConstants.MaxFirstClassWeightInPounds; } return USPostalConstants.MaxWeightInPounds; }
public string TranslateServiceCodeToString(DomesticServiceType service) { switch (service) { case DomesticServiceType.All: return "ALL"; case DomesticServiceType.ExpressMail: return "EXPRESS"; case DomesticServiceType.ExpressMailCommerceial: return "EXPRESS COMMERCIAL"; case DomesticServiceType.ExpressMailHoldForPickup: return "EXPRESS HFP"; case DomesticServiceType.ExpressMailHoldForPickupCommercial: return "EXPRESS HFP COMMERCIAL"; case DomesticServiceType.ExpressMailSundayHoliday: return "EXPRESS SH"; case DomesticServiceType.ExpressMailSundayHolidayCommercial: return "EXPRESS SH COMMERCIAL"; case DomesticServiceType.FirstClass: return "FIRST CLASS"; case DomesticServiceType.LibraryMaterial: return "LIBRARY"; case DomesticServiceType.MediaMail: return "MEDIA"; case DomesticServiceType.Online: return "ONLINE"; case DomesticServiceType.ParcelPost: return "PARCEL"; case DomesticServiceType.PriorityMail: return "PRIORITY"; } return "ALL"; }
public DomesticPackageServiceResponse() { XmlName = string.Empty; XmlClassId = string.Empty; ServiceType = DomesticServiceType.All; }