Skip to content

Commit

Permalink
capture list rate discount for FedEx rates
Browse files Browse the repository at this point in the history
thanks to @jdigory for the patch!!
  • Loading branch information
pullingshots committed Sep 14, 2016
1 parent fc78e0f commit f45166d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/Shipment/FedEx.pm
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ sub _build_services {
Residential => $self->residential_address,
},
},
RateRequestTypes => 'LIST',
PackageCount => $self->count_packages || 1,
PackageDetail => 'INDIVIDUAL_PACKAGES',
RequestedPackageLineItems => \@pieces,
Expand Down Expand Up @@ -403,6 +404,11 @@ sub _build_services {
$service->get_RatedShipmentDetails->[0]->get_ShipmentRateDetail->get_TotalNetCharge->get_Amount,
$service->get_RatedShipmentDetails->[0]->get_ShipmentRateDetail->get_TotalNetCharge->get_Currency
),
discount => Data::Currency->new(
$service
->get_RatedShipmentDetails->[0]
->get_EffectiveNetDiscount->get_Amount,
),
);
}
$services{ground} = $services{'FEDEX_GROUND'} || $services{'GROUND_HOME_DELIVERY'} || $services{'INTERNATIONAL_GROUND'} || Shipment::Service->new();
Expand Down Expand Up @@ -550,6 +556,7 @@ sub rate {
Residential => $self->residential_address,
},
},
RateRequestTypes => 'LIST',
PackageCount => $self->count_packages,
PackageDetail => 'INDIVIDUAL_PACKAGES',
RequestedPackageLineItems => \@pieces,
Expand All @@ -575,6 +582,11 @@ sub rate {
$response->get_RateReplyDetails()->get_RatedShipmentDetails->[0]->get_ShipmentRateDetail->get_TotalNetCharge->get_Amount,
$response->get_RateReplyDetails()->get_RatedShipmentDetails->[0]->get_ShipmentRateDetail->get_TotalNetCharge->get_Currency,
),
discount => Data::Currency->new(
$response->get_RateReplyDetails()
->get_RatedShipmentDetails->[0]
->get_EffectiveNetDiscount->get_Amount,
),
)
);
} catch {
Expand Down
5 changes: 5 additions & 0 deletions lib/Shipment/Service.pm
Original file line number Diff line number Diff line change
Expand Up @@ -248,5 +248,10 @@ under the same terms as Perl itself.
=cut

has 'discount' => (
is => 'rw',
isa => InstanceOf ['Data::Currency'],
default => sub { Data::Currency->new(0) },
);

1;

0 comments on commit f45166d

Please sign in to comment.