| 1 | package Net::UPS::Package; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 7 | $Net::UPS::Package::VERSION = '0.16'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 7 | $Net::UPS::Package::DIST = 'Net-UPS'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 7 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 7 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 7 | ▶ | use Carp ( 'croak' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 7 | ▶ | use XML::Simple; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 7 | ▶ | use Class::Struct 0.58; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | Net::UPS::Package - Class representing a UPS Package | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | $pkg = Net::UPS::Package->new(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | $pkg->packaging_type('PACKAGE'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | $pkg->measurement_system('metric'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | $pkg->length(40); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | $pkg->width(30); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | $pkg->height(2); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | $pkg->weight(10); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | Net::UPS::Package represents a single UPS package. In addition to the above attributes, I<id> attribute will be set once package is submitted for a rate quote. I<id> starts at I<1>, and will be incremented by one for each subsequent package submitted at single request. The purpose of this attribute is still not clear. Comments are welcome. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | In addition to all the aforementioned attributes, following method(s) are supported | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 7 | struct( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | id => '$', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | packaging_type => '$', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | measurement_system => '$', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | length => '$', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | width => '$', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | height => '$', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | weight => '$' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | ▶ | sub PACKAGE_CODES() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
PACKAGE_CODES: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | LETTER => '01', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | PACKAGE => '02', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | TUBE => '03', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | UPS_PAK => '04', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | UPS_EXPRESS_BOX => '21', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | UPS_25KG_BOX => '24', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | UPS_10KG_BOX => '25' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | sub _packaging2code { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_packaging2code: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | my $label = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | unless ( defined $label ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | croak "_packaging2code(): usage error"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | $label =~ s/\s+/_/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | $label =~ s/\W+//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | my $code = PACKAGE_CODES->{$label}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | unless ( defined $code ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | croak "Nothing known about package type '$label'"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | return $code; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 11 | ▶ | sub as_hash { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_hash: called CC=13 SCAR=26.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 11 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 11 | ▶ | my $measurement_system = $self->measurement_system || 'english'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->measurement_system || 'english'
MC/DC0%0/1
$self->measurement_system || 'english'
$self->measurement_system
Truth table50%1/2
A
A= $self->measurement_system
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 11 | ▶ | my $weight_measure = ($measurement_system eq 'metric') ? 'KGS' : 'LBS'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 11 | ▶ | my $length_measure = ($measurement_system eq 'metric') ? 'CM' : 'IN'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 11 | ▶ | my %data = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | Package => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | PackagingType => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | Code => $self->packaging_type ? sprintf("%02d", $self->_packaging2code($self->packaging_type)) : '02', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | DimensionalWeight => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | UnitOfMeasurement => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | Code => $weight_measure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | PackageWeight => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | UnitOfMeasurement => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | Code => $weight_measure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 11 | ▶ | if ( $self->length || $self->width || $self->height ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$self->length or $self->width or $self->height
$self->length or $self->width
MC/DC33%1/3
$self->length or $self->width or $self->height
$self->length
$self->width
$self->height
Truth table50%2/4
A or B or C
A= $self->lengthB= $self->widthC= $self->height
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | $data{Package}->{Dimensions} = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 10 | UnitOfMeasurement => { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | Code => $length_measure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 10 | ▶ | if ( $self->length ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 10 | $data{Package}->{Dimensions}->{Length}= $self->length; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 10 | ▶ | if ( $self->width ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 9 | $data{Package}->{Dimensions}->{Width} = $self->width; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 10 | ▶ | if ( $self->height ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 8 | $data{Package}->{Dimensions}->{Height} = $self->height; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 11 | ▶ | if ( $self->weight ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 11 | $data{Package}->{PackageWeight}->{Weight} = $self->weight; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 11 | ▶ | if (my $oversized = $self->is_oversized ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 7 | $data{Package}->{OversizePackage} = $oversized; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 11 | return \%data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | =item is_oversized | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | Convenience method. Return value indicates if the package is oversized, and if so, its oversize level. Possible return values are I<0>, I<1>, I<2> and I<3>. I<0> means not oversized. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | # Scoob correction Feb 26th 2006 / cpan@pickledbrain.com | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | # Definitions of oversize categories: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | # http://www.ups.com/content/us/en/resources/prepare/oversize.html | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | # Length and Girth: Length + 2x Width + 2x Height | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | # Where Length is the longuest side of pkg rounded to nearest inch. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | # And Girth is: 2x Width + 2x Height) (round width & height to nearest inch) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | # Also as described in: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | # http://www.ups.com/content/us/en/resources/prepare/guidelines/index.html | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | # - Packages can be up to 150 lbs (70 kg) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | # - Packages can be up to 165 inches (419 cm) in length and girth combined | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | # - Packages can be up to 108 inches (270 cm) in length | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | # - Packages that weigh more than 70 lbs (31.5 kg, 25 kg within the EU) require a special heavy-package label | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | # - Oversize packages and packages with a large size-to-weight ratio require special pricing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | # and dimensional weight calculations | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | # Understand that "Oversize" OS[123] package is a rating to compensate for | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | # a package that is very large but weights very little. UPS charges for | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | # a "billing weight" that is larger than the actual weight for OS packages. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | # So for a package to be OS1 is must be 84 < size < 108 *AND* weight < 30lbs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | # If a package is size 104" and has weight: 33lbs, is is NOT OS1 (because it is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | # heavy enough that UPS will be fairly compensated by charging for weight only. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | ### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 22 | ▶ | sub is_oversized { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_oversized: called CC=15 SCAR=27.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 22 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 22 | ▶ | unless ( $self->width && $self->height && $self->length && $self->weight) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition77%7/9
$self->width and $self->height and $self->length and $self->weight
$self->width and $self->height and $self->length
$self->width and $self->height
MC/DC50%2/4
$self->width and $self->height and $self->length and $self->weight
$self->width
$self->height
$self->length
$self->weight
Truth table60%3/5
A and B and C and D
A= $self->widthB= $self->heightC= $self->lengthD= $self->weight
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 3 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 19 | my @sides = sort { $a <=> $b } ($self->length, $self->width, $self->height); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 19 | my $len = pop(@sides); # Get longest side | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 19 | my $girth = ((2 * $sides[0]) + (2 * $sides[1])); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 19 | my $size = $len + $girth; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 19 | ▶ | if (($len > 108) || ($self->weight > 150) || ($size > 165)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$len > 108 or $self->weight > 150 or $size > 165
$len > 108 or $self->weight > 150
MC/DC100%3/3
$len > 108 or $self->weight > 150 or $size > 165
$len > 108
$self->weight > 150
$size > 165
Truth table100%4/4
A or B or C
A= $len > 108B= $self->weight > 150C= $size > 165
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 3 | croak "Such package size/weight is not supported"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 16 | ▶ | return 0 if ( $size <= 84 ); # Below OS1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 15 | ▶ | if ($size <= 108) { # OS1 pgk is billed for 30lbs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 11 | ▶ | return (($self->weight < 30) ? 1 : 0); # Not OS1 if weight > 30lbs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 4 | ▶ | if ($size <= 130) { # OS2 pgk is billed for 70lbs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 2 | ▶ | return (($self->weight < 70) ? 2 : 0); # Not OS2 if weight > 70lbs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 2 | ▶ | if ($size <= 165) { # OS3 pgk is billed for 90lbs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 2 | ▶ | return (($self->weight < 90) ? 3 : 0); # Not OS3 if weight > 90lbs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | return 3; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | ▶ | sub as_XML { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_XML: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | return XMLout( $self->as_hash, NoAttr=>1, KeepRoot=>1, SuppressEmpty=>1 ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | ▶ | sub cache_id { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cache_id: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | ▶ | my $packaging_type = $self->packaging_type || 'PACKAGE'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->packaging_type || 'PACKAGE'
MC/DC0%0/1
$self->packaging_type || 'PACKAGE'
$self->packaging_type
Truth table0%0/2
A
A= $self->packaging_type
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | return $packaging_type . ':' . $self->length . ':' . $self->width .':'. $self->height . | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | ':'. $self->weight; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | ▶ | sub rate { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rate: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | my $ups = Net::UPS->instance(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | return $ups->rate( $_[0], $_[1], $self, $_[2]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 7 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||