kylewest / DotNetShipping

UPS, FedEx, USPS shipping rate calculators for .NET
MIT License
78 stars 66 forks source link

International USPS rate returns sometimes wrong because of incorrect rate return from USPS #39

Open jjohndrow opened 8 years ago

jjohndrow commented 8 years ago

I just encountered this new issue. It arises when you have several packages you are sending and USPS gives incomplete rate list. When this happens the shipping service just sums the totals and does not check to see if it got rates for each box. The example I have is that we split the order into 5 packages when giving a quote. The USPS Priority International rate was way cheaper then USPS Priority International Express. Digging into it I found that the call to the USPS specified 5 packages but only returned 2 for priority and all 5 for USPS Priority Express. This means that 3 whole packages were left out of the rate return. The issue occurs on line 136 of the USPSInternationalProvider.cs file.

var rates = document.Descendants("Service").GroupBy(item => (string) item.Element("SvcDescription")).Select(g => new {Name = g.Key, TotalCharges = g.Sum(x => Decimal.Parse((string) x.Element("Postage")))});

It assumes that you will get quotes for all or no boxes which is a pretty big issue if it only returns rates for two of them and causes the quote to be hundreds of dollars short. Looking into how to fix this one right now. Currently I'm under the gun to fix this as our management team wants to know why we underquoted a HK shipment by so much.

Attached is the Call and its return that we captured to debug the issue.

USPSRequest.txt

USPSResponse.txt

kylewest commented 8 years ago

@jjohndrow you mentioned you were working on a fix for this. were you able to find one? Is it something you'd be able to send as a pull request or point us to your changes and we'll try to merge it in on our own.