From 63b797c87585de5a2920ef201bfc8cf8f3786eb4 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Thu, 5 Nov 2009 12:38:56 -0800 Subject: [PATCH] Format oz in the USPS shipping driver to the nearest tenth of an oz. Change the minimum to be 0.1 oz --- docs/changelog/7.x.x.txt | 2 +- lib/WebGUI/Shop/ShipDriver/USPS.pm | 6 +++--- t/Shop/ShipDriver/USPS.t | 28 ++++++++++++++-------------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index b8a78ac09..372640c5d 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -6,7 +6,7 @@ - fixed #11197: Survey Edit Console is not i18n'ed - fixed USPS driver only works on domestic addresses. - fixed Shop is not sending notification emails to the user, or to the notification group. - - Set a minimum package weight of 1 oz for the USPS driver. + - Set a minimum package weight of 0.1 oz for the USPS driver. - Handle per package errors in USPS response data. 7.8.3 diff --git a/lib/WebGUI/Shop/ShipDriver/USPS.pm b/lib/WebGUI/Shop/ShipDriver/USPS.pm index 0d7b88cae..8ddc2bc01 100644 --- a/lib/WebGUI/Shop/ShipDriver/USPS.pm +++ b/lib/WebGUI/Shop/ShipDriver/USPS.pm @@ -73,9 +73,9 @@ sub buildXML { $weight += $itemWeight; } my $pounds = int($weight); - my $ounces = int(16 * ($weight - $pounds)); - if ($pounds == 0 && $ounces == 0 ) { - $ounces = 1; + my $ounces = sprintf '%3.1f', (16 * ($weight - $pounds)); + if ($pounds == 0 && $ounces eq '0.0' ) { + $ounces = 0.1; } my $destination = $package->[0]->getShippingAddress; my $destZipCode = $destination->get('code'); diff --git a/t/Shop/ShipDriver/USPS.t b/t/Shop/ShipDriver/USPS.t index 6b9ae8eab..01a9e6bcb 100644 --- a/t/Shop/ShipDriver/USPS.t +++ b/t/Shop/ShipDriver/USPS.t @@ -334,7 +334,7 @@ cmp_deeply( { ID => 0, ZipDestination => '53715', ZipOrigination => '97123', - Pounds => '1', Ounces => '8', + Pounds => '1', Ounces => '8.0', Size => 'REGULAR', Service => 'PARCEL', Machinable => 'true', }, @@ -414,14 +414,14 @@ cmp_deeply( { ID => 0, ZipDestination => '53715', ZipOrigination => '97123', - Pounds => '2', Ounces => '0', + Pounds => '2', Ounces => '0.0', Size => 'REGULAR', Service => 'PARCEL', Machinable => 'true', }, { ID => 1, ZipDestination => '53715', ZipOrigination => '97123', - Pounds => '1', Ounces => '8', + Pounds => '1', Ounces => '8.0', Size => 'REGULAR', Service => 'PARCEL', Machinable => 'true', }, @@ -445,7 +445,7 @@ SKIP: { { ID => 0, ZipOrigination => ignore(), ZipDestination => ignore(), - Machinable => ignore(), Ounces => 0, + Machinable => ignore(), Ounces => '0.0', Pounds => 2, Size => ignore(), Zone => ignore(), Postage => { @@ -457,7 +457,7 @@ SKIP: { { ID => 1, ZipOrigination => ignore(), ZipDestination => ignore(), - Machinable => ignore(), Ounces => 8, + Machinable => ignore(), Ounces => '8.0', Pounds => 1, Size => ignore(), Zone => ignore(), Postage => { @@ -545,21 +545,21 @@ cmp_deeply( { ID => 0, ZipDestination => '53715', ZipOrigination => '97123', - Pounds => '2', Ounces => '0', + Pounds => '2', Ounces => '0.0', Size => 'REGULAR', Service => 'PARCEL', Machinable => 'true', }, { ID => 1, ZipDestination => '53715', ZipOrigination => '97123', - Pounds => '1', Ounces => '8', + Pounds => '1', Ounces => '8.0', Size => 'REGULAR', Service => 'PARCEL', Machinable => 'true', }, { ID => 2, ZipDestination => '53703', ZipOrigination => '97123', - Pounds => '12', Ounces => '0', + Pounds => '12', Ounces => '0.0', Size => 'REGULAR', Service => 'PARCEL', Machinable => 'true', }, @@ -583,7 +583,7 @@ SKIP: { { ID => 0, ZipOrigination => ignore(), ZipDestination => ignore(), - Machinable => ignore(), Ounces => 0, + Machinable => ignore(), Ounces => '0.0', Pounds => 2, Size => ignore(), Zone => ignore(), Postage => { @@ -595,7 +595,7 @@ SKIP: { { ID => 1, ZipOrigination => ignore(), ZipDestination => ignore(), - Machinable => ignore(), Ounces => 8, + Machinable => ignore(), Ounces => '8.0', Pounds => 1, Size => ignore(), Zone => ignore(), Postage => { @@ -607,7 +607,7 @@ SKIP: { { ID => 2, ZipOrigination => ignore(), ZipDestination => 53703, - Machinable => ignore(), Ounces => 0, + Machinable => ignore(), Ounces => '0.0', Pounds => 12, Size => ignore(), Zone => ignore(), Postage => { @@ -650,7 +650,7 @@ cmp_deeply( { ID => 0, ZipDestination => '53715', ZipOrigination => '97123', - Pounds => '1', Ounces => '8', + Pounds => '1', Ounces => '8.0', Size => 'REGULAR', Service => 'PRIORITY', Machinable => 'true', Container => 'FLAT RATE BOX', }, @@ -715,7 +715,7 @@ cmp_deeply( { ID => 0, ZipDestination => '53715', ZipOrigination => '97123', - Pounds => '1', Ounces => '8', + Pounds => '1', Ounces => '8.0', Size => 'REGULAR', Service => 'EXPRESS', Machinable => 'true', }, @@ -779,7 +779,7 @@ cmp_deeply( { ID => 0, ZipDestination => '53715', ZipOrigination => '97123', - Pounds => '1', Ounces => '8', + Pounds => '1', Ounces => '8.0', Size => 'REGULAR', Service => 'PRIORITY', Machinable => 'true',# Container => 'VARIABLE', },