Business-Shipping
view release on metacpan or search on metacpan
lib/Business/Shipping/UPS_Offline/Shipment.pm view on Meta::CPAN
package Business::Shipping::UPS_Offline::Shipment;
=head1 NAME
Business::Shipping::UPS_Offline::Shipment
=head1 METHODS
=over 4
=item * disable_hundredweight( )
If true, don't estimate the hundredweight rate even if it would otherwise be possible.
=item * hundredweight_margin( $percent )
If the shipment weight is only $percent (default 10%) higher than the required amount to qualify for
hundredweight shipping, then do not calculate hundredweight. This is to guard against the chance that the
actual shipment weight turns out to be lower than what is used for estimation, resulting in failed eligibility
for hundredweight rates and a much higher rate than estimated.
=back
=cut
use Business::Shipping::Config;
use Business::Shipping::Logging;
use Any::Moose;
use version; our $VERSION = qv('400');
extends 'Business::Shipping::Shipment::UPS';
# TODO: Only allow tiers 1-8
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 %hundred_weight_info = (
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);
#info "ground minimum = $ground_min, current weight = " . $self->weight . ", service = " . $self->service;
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;
( run in 1.452 second using v1.01-cache-2.11-cpan-22024b96cdf )