Clip lowside weight at 0.1 lbs. Otherwise UPS will gripe at you.

This commit is contained in:
Colin Kuskie 2009-08-10 13:33:40 -07:00
parent 8bcacc8316
commit fe63bccea9
2 changed files with 39 additions and 6 deletions

View file

@ -129,12 +129,14 @@ sub buildXML {
$weight += $skuWeight; $weight += $skuWeight;
} }
next PACKAGE unless $weight; next PACKAGE unless $weight;
$weight = sprintf "%.1f", $weight;
$weight = '0.1' if $weight == 0;
my $options = { my $options = {
PackagingType => [ { PackagingType => [ {
Code => [ '02' ], Code => [ '02' ],
} ], } ],
PackageWeight => [ { PackageWeight => [ {
Weight => [ sprintf "%.1f", $weight ], ##Required formatting from spec Weight => [ $weight ], ##Required formatting from spec
} ], } ],
}; };
push @{ $packHash }, $options; push @{ $packHash }, $options;

View file

@ -35,7 +35,7 @@ $session->user({user => $user});
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
# Tests # Tests
my $tests = 40; my $tests = 41;
plan tests => 1 + $tests; plan tests => 1 + $tests;
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
@ -93,6 +93,20 @@ my $nivBible = $bible->setCollateral('variantsJSON', 'variantId', 'new',
} }
); );
my $feather = $home->addChild({
className => 'WebGUI::Asset::Sku::Product',
isShippingRequired => 1, title => 'Feathers',
shipsSeparately => 0,
});
my $blueFeather = $feather->setCollateral('variantsJSON', 'variantId', 'new',
{
shortdesc => 'blue feather', price => 1.00,
varSku => 'blue', weight => 0.001,
quantity => 999999,
}
);
$versionTag->commit; $versionTag->commit;
WebGUI::Test->tagsToRollback($versionTag); WebGUI::Test->tagsToRollback($versionTag);
@ -385,8 +399,6 @@ my $xmlRate = XMLin($xmlR,
KeepRoot => 1, KeepRoot => 1,
); );
diag Dumper $xmlRate;
cmp_deeply( cmp_deeply(
$xmlRate, { $xmlRate, {
RatingServiceSelectionRequest => { RatingServiceSelectionRequest => {
@ -463,6 +475,8 @@ $xmlRate = XMLin( $xmlR,
ForceArray => ['Package'], ForceArray => ['Package'],
); );
diag Dumper $xmlRate;
cmp_deeply( cmp_deeply(
$xmlRate, { $xmlRate, {
RatingServiceSelectionRequest => { RatingServiceSelectionRequest => {
@ -475,13 +489,13 @@ cmp_deeply(
Address => { PostalCode => 97123, CountryCode => 'us', }, Address => { PostalCode => 97123, CountryCode => 'us', },
}, },
ShipTo => { ShipTo => {
Address => { PostalCode => 53715, CountryCode => 'us', }, Address => { PostalCode => 53715, CountryCode => 'us', ResidentialAddressIndicator => {}, },
}, },
Service => { Code => '03', }, Service => { Code => '03', },
Package => bag( Package => bag(
{ {
PackagingType => { Code => '02', }, PackagingType => { Code => '02', },
PackageWeight => { Weight => '1.5', }, PackageWeight => { Weight => '3.0', },
}, },
{ {
PackagingType => { Code => '02', }, PackagingType => { Code => '02', },
@ -509,6 +523,23 @@ SKIP: {
ok($driver->getEditForm(), 'getEditForm'); ok($driver->getEditForm(), 'getEditForm');
$cart->empty;
$feather->addToCart($feather->getCollateral('variantsJSON', 'variantId', $blueFeather));
$xml = $driver->buildXML($cart, $driver->_getShippableUnits($cart));
($xmlA, $xmlR) = split /\n(?=<\?xml)/, $xml;
$xmlRate = XMLin( $xmlR,
KeepRoot => 1,
ForceArray => ['Package'],
);
is (
$xmlRate->{RatingServiceSelectionRequest}->{Shipment}->{Package}->[0]->{PackageWeight}->{Weight},
'0.1',
'Weight is clipped at 0.1 pounds.'
);
$cart->empty;
} }
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------