use
version;
our
$VERSION
= qv(
'400'
);
has
'tier'
=> (
is
=>
'rw'
);
has
'from_state'
=> (
is
=>
'rw'
);
has
'max_weight'
=> (
is
=>
'rw'
,
default
=> 150);
has
'disable_hundredweight'
=> (
is
=>
'rw'
);
has
'hundredweight_margin'
=> (
is
=>
'rw'
,
default
=> 10);
has
'packages'
=> (
is
=>
'rw'
,
isa
=>
'ArrayRef[Business::Shipping::UPS_Offline::Package]'
,
default
=>
sub
{ [Business::Shipping::UPS_Offline::Package->new()] },
auto_deref
=> 1
);
__PACKAGE__->meta()->make_immutable();
sub
use_hundred_weight {
my
(
$self
) =
@_
;
return
if
$self
->disable_hundredweight;
if
(@{
$self
->packages } > 1) {
my
$hundred_weight_qualification
;
my
@airborn_100
=
qw/ 1da 1dasaver 2da 2dam /
;
my
@ground_200
=
qw/ gndres gndcom 3ds /
;
my
$airborn_min
= 100 + (100 *
$self
->hundredweight_margin * 0.01);
my
$ground_min
= 200 + (100 *
$self
->hundredweight_margin * 0.01);
if
((
grep
(
$_
eq
lc
$self
->service,
@airborn_100
)
and
$self
->weight >
$airborn_min
)
or (
grep
(
$_
eq
lc
$self
->service,
@ground_200
)
and
$self
->weight >
$ground_min
)
)
{
return
1;
}
}
return
;
}
sub
is_ground {
my
(
$self
) =
@_
;
my
$is_ground_svc
= 0;
my
@ground_services
= (
'Ground Commercial'
,
'Ground Residential'
,
'Ground Hundredweight Service'
,
'Standard'
,
);
my
$ups_service_name
=
$self
->service_name;
info
"ups_service_name = '$ups_service_name'"
;
$is_ground_svc
= 1
if
grep
/${ups_service_name}/i,
@ground_services
;
info
"is_ground_svc = $is_ground_svc"
;
return
$is_ground_svc
;
}
sub
get_hundredweight_table {
my
(
$self
,
$table
) =
@_
;
my
%table_map
=
qw/
gndcomm gndcwt
gndres gndcwt
1da 1dacwt
2da 2dacwt
3ds 3dscwt
/
;
my
$suffix
=
''
;
if
(
$self
->tier and
$self
->tier >= 1 and
$self
->tier <= 7) {
$suffix
=
$self
->tier;
}
return
(
$table_map
{
$table
} ||
$table
) .
$suffix
;
}
sub
cwt_is_per {
my
(
$self
) =
@_
;
my
@airborn
=
qw/ 1da 1dasaver 2da 2dam /
;
my
@ground
=
qw/ gndres gndcom 3ds /
;
return
'pound'
if
grep
(
$_
eq
lc
$self
->service,
@airborn
);
return
'hundredweight'
if
grep
(
$_
eq
lc
$self
->service,
@ground
);
error
"could not determine is_per type. service = "
.
$self
->service;
return
;
}
sub
packages_push {
my
(
$self
,
$new_package
) =
@_
;
push
@{
$self
->packages() },
$new_package
;
return
;
}
1;