| 1 | package Marketplace::Ebay::Order; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 5 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 5 | ▶ | use DateTime; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 5 | ▶ | use DateTime::Format::ISO8601; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 5 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 5 | ▶ | use Moo; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 5 | ▶ | use MooX::Types::MooseLike::Base qw(Str HashRef Int Object); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 5 | ▶ | use Marketplace::Ebay::Order::Address; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 5 | ▶ | use Marketplace::Ebay::Order::Item; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 5 | ▶ | use namespace::clean; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | =head1 NAME | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | Marketplace::Ebay::Order | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | Class to handle the xml structures found in the GetOrders call. | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | L<http://developer.ebay.com/devzone/xml/docs/Reference/ebay/GetOrders.html> | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | The aim is to have a consistent interface with | ||||||||||||||||||||||||||||
| 26 | L<Amazon::MWS::XML::Order> so importing the orders can happens almost | ||||||||||||||||||||||||||||
| 27 | transparently. | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | =cut | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | =head1 ACCESSORS/METHODS | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | =head2 order | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | The raw structure got from the XML parsing | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | =head2 shop_type | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | Always returns C<ebay> | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | =cut | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | 5 | has order => (is => 'ro', isa => HashRef, required => 1); | |||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | sub shop_type { | ||||||||||||||||||||||||||||
| 46 | 1 | ▶ | return 'ebay'; | ||||||||||||||||||||||||||
|
Subroutine
shop_type: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | =head2 order_number | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | read-write accessor for the (shop) order number so you can set this | ||||||||||||||||||||||||||||
| 52 | while importing it. | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | =head2 payment_status | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | read-write accessor for the payment status, so the shop can set it | ||||||||||||||||||||||||||||
| 57 | while importing it. | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | =cut | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 5 | has order_number => (is => 'rw', isa => Str); | |||||||||||||||||||||||||||
| 62 | 5 | has payment_status => (is => 'rw', isa => Str); | |||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | =head2 can_be_imported | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | Return true if both orderstatus and checkout status are completed | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | =cut | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | sub can_be_imported { | ||||||||||||||||||||||||||||
| 71 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
can_be_imported: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 72 | 0 | my $order = $self->order; | |||||||||||||||||||||||||||
| 73 | 0 | ▶ | if ($order->{OrderStatus} eq 'Completed' and | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$order->{"OrderStatus"} eq "Completed" and $order->{"CheckoutStatus"}{"Status"} eq "Complete"
MC/DC0%0/2
$order->{"OrderStatus"} eq "Completed" and $order->{"CheckoutStatus"}{"Status"} eq "Complete"
$order->{"OrderStatus"} eq "Completed"
$order->{"CheckoutStatus"}{"Status"} eq "Complete"
Truth table0%0/3
A and B
A= $order->{"OrderStatus"} eq "Completed"B= $order->{"CheckoutStatus"}{"Status"} eq "Complete"
| |||||||||||||||||||||||||||||
| 74 | $order->{CheckoutStatus}->{Status} eq 'Complete') { | ||||||||||||||||||||||||||||
| 75 | 0 | return 1; | |||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||
| 77 | else { | ||||||||||||||||||||||||||||
| 78 | 0 | return 0; | |||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | =head2 order_status | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | Return the order status and the payment status, separated by a colon. | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | =cut | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | sub order_status { | ||||||||||||||||||||||||||||
| 90 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
order_status: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 91 | 0 | my $order = $self->order; | |||||||||||||||||||||||||||
| 92 | 0 | ▶ | my $order_status = $order->{OrderStatus} || 'Unknown'; | ||||||||||||||||||||||||||
|
Condition0%0/2
$order->{'OrderStatus'} || 'Unknown'
MC/DC0%0/1
$order->{'OrderStatus'} || 'Unknown'
$order->{'OrderStatus'}
Truth table0%0/2
A
A= $order->{'OrderStatus'}
| |||||||||||||||||||||||||||||
| 93 | 0 | ▶ | my $payment_status = $order->{CheckoutStatus}->{Status} || 'Unknown'; | ||||||||||||||||||||||||||
|
Condition0%0/2
$order->{'CheckoutStatus'}{'Status'} || 'Unknown'
MC/DC0%0/1
$order->{'CheckoutStatus'}{'Status'} || 'Unknown'
$order->{'CheckoutStatus'}{'Status'}
Truth table0%0/2
A
A= $order->{'CheckoutStatus'}{'Status'}
| |||||||||||||||||||||||||||||
| 94 | 0 | return "$order_status: $payment_status"; | |||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | =head2 ebay_order_number | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | Ebay order id. | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | =head2 remote_shop_order_id | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | Same as C<ebay_order_number> | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | =cut | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | sub ebay_order_number { | ||||||||||||||||||||||||||||
| 109 | 0 | ▶ | return shift->order->{OrderID}; | ||||||||||||||||||||||||||
|
Subroutine
ebay_order_number: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | sub remote_shop_order_id { | ||||||||||||||||||||||||||||
| 113 | 0 | ▶ | return shift->ebay_order_number; | ||||||||||||||||||||||||||
|
Subroutine
remote_shop_order_id: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | 5 | has shipping_address => (is => 'lazy'); | |||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | sub _build_shipping_address { | ||||||||||||||||||||||||||||
| 119 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_build_shipping_address: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 120 | 1 | my $address = $self->order->{ShippingAddress}; | |||||||||||||||||||||||||||
| 121 | 1 | return Marketplace::Ebay::Order::Address->new(%$address); | |||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | 5 | has items_ref => (is => 'lazy'); | |||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | sub _build_items_ref { | ||||||||||||||||||||||||||||
| 127 | 1 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_build_items_ref: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 128 | 1 | my $orderline = $self->orderline; | |||||||||||||||||||||||||||
| 129 | 1 | my @items; | |||||||||||||||||||||||||||
| 130 | 1 | foreach my $item (@$orderline) { | |||||||||||||||||||||||||||
| 131 | # print Dumper($item); | ||||||||||||||||||||||||||||
| 132 | 1 | push @items, Marketplace::Ebay::Order::Item->new(struct => $item); | |||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||
| 134 | 1 | return \@items; | |||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | 5 | has number_of_items => (is => 'lazy', isa => Int); | |||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | sub _build_number_of_items { | ||||||||||||||||||||||||||||
| 141 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_build_number_of_items: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 142 | 1 | my @items = $self->items; | |||||||||||||||||||||||||||
| 143 | 1 | my $total = 0; | |||||||||||||||||||||||||||
| 144 | 1 | foreach my $i (@items) { | |||||||||||||||||||||||||||
| 145 | 1 | $total += $i->quantity; | |||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||
| 147 | 1 | return $total; | |||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | 5 | has first_item => (is => 'lazy', isa => Object); | |||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | sub _build_first_item { | ||||||||||||||||||||||||||||
| 153 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
_build_first_item: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||
| 154 | 1 | my ($first, @rest) = $self->items; | |||||||||||||||||||||||||||
| 155 | 1 | ▶ | die "Missing items in transaction!" unless $first; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 156 | 1 | return $first; | |||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | =head2 orderline | ||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||
| 161 | An arrayref with the TransactionArray.Transaction structure. This is | ||||||||||||||||||||||||||||
| 162 | used internally by C<items>. | ||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | =cut | ||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||
| 166 | sub orderline { | ||||||||||||||||||||||||||||
| 167 | 1 | ▶ | return shift->order->{TransactionArray}->{Transaction}; | ||||||||||||||||||||||||||
|
Subroutine
orderline: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||
| 170 | =head2 items | ||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | Return a list of L<Marketplace::Ebay::Order::Item> objects. | ||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | =cut | ||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | sub items { | ||||||||||||||||||||||||||||
| 177 | 5 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
items: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 178 | 5 | return @{ $self->items_ref }; | |||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||
| 181 | =head2 order_date | ||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | Return a DateTime object with the creation time of the order. | ||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||
| 185 | =cut | ||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||
| 187 | sub order_date { | ||||||||||||||||||||||||||||
| 188 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
order_date: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||
| 189 | 1 | ▶ | if (my $date = $self->order->{CreatedTime}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 190 | 1 | return DateTime::Format::ISO8601->parse_datetime($date); | |||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||
| 192 | 0 | return; | |||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||
| 195 | =head2 email | ||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||
| 197 | The email of the buyer. Given that this is provided per item, the | ||||||||||||||||||||||||||||
| 198 | first one is used. | ||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||
| 200 | =cut | ||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||
| 202 | sub email { | ||||||||||||||||||||||||||||
| 203 | 1 | ▶ | return shift->first_item->email; | ||||||||||||||||||||||||||
|
Subroutine
email: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||
| 206 | =head2 first_name | ||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||
| 208 | The first name of the buyer, looked up from the first item. | ||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||
| 210 | =cut | ||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||
| 212 | sub first_name { | ||||||||||||||||||||||||||||
| 213 | 1 | ▶ | return shift->first_item->first_name || ''; | ||||||||||||||||||||||||||
|
Subroutine
first_name: called CC=2 SCAR=7.6
Pod
documented
Condition50%1/2
(shift())->first_item->first_name || ''
MC/DC0%0/1
(shift())->first_item->first_name || ''
(shift())->first_item->first_name
Truth table50%1/2
A
A= (shift())->first_item->first_name
| |||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||
| 216 | =head2 last_name | ||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||
| 218 | The last name of the buyer, looked up from the first item. | ||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||
| 220 | =cut | ||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||
| 223 | sub last_name { | ||||||||||||||||||||||||||||
| 224 | 1 | ▶ | return shift->first_item->last_name || ''; | ||||||||||||||||||||||||||
|
Subroutine
last_name: called CC=2 SCAR=7.6
Pod
documented
Condition50%1/2
(shift())->first_item->last_name || ''
MC/DC0%0/1
(shift())->first_item->last_name || ''
(shift())->first_item->last_name
Truth table50%1/2
A
A= (shift())->first_item->last_name
| |||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||
| 227 | =head2 comments | ||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||
| 229 | The BuyerCheckoutMessage's field of the order. | ||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||
| 231 | =cut | ||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||
| 233 | sub comments { | ||||||||||||||||||||||||||||
| 234 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
comments: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 235 | 0 | return $self->order->{BuyerCheckoutMessage}; | |||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||
| 238 | =head2 shipping_method | ||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||
| 240 | The order's ShippingServiceSelected.ShippingService value | ||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||
| 242 | =cut | ||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||
| 244 | sub shipping_method { | ||||||||||||||||||||||||||||
| 245 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
shipping_method: called CC=3 SCAR=12.0
Pod
documented
| |||||||||||||||||||||||||||||
| 246 | 1 | ▶ | if (my $shipping = $self->order->{ShippingServiceSelected}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 247 | 1 | ▶ | if (my $service = $shipping->{ShippingService}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 248 | 1 | return $service; | |||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||
| 251 | 0 | return ''; | |||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||
| 254 | =head2 shipping_additional_costs | ||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||
| 256 | The order's ShippingServiceSelected.ShippingServiceAdditionalCost | ||||||||||||||||||||||||||||
| 257 | value. I.e., the cost of the shipping for the other items ordered. | ||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||
| 259 | =cut | ||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||
| 261 | sub shipping_additional_costs { | ||||||||||||||||||||||||||||
| 262 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
shipping_additional_costs: called CC=4 SCAR=16.4
Pod
documented
| |||||||||||||||||||||||||||||
| 263 | 1 | my $cost = 0; | |||||||||||||||||||||||||||
| 264 | 1 | ▶ | if (my $shipping = $self->order->{ShippingServiceSelected}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 265 | 1 | ▶ | if (my $num = $shipping->{ShippingServiceAdditionalCost}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 266 | 0 | ▶ | $cost = $num->{_} || 0; | ||||||||||||||||||||||||||
|
Condition0%0/2
$num->{'_'} || 0
MC/DC0%0/1
$num->{'_'} || 0
$num->{'_'}
Truth table0%0/2
A
A= $num->{'_'}
| |||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||
| 269 | 1 | return sprintf('%.2f', $cost); | |||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||
| 272 | =head2 shipping_first_unit | ||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||
| 274 | The order's ShippingServiceSelected.ShippingServiceCost value. This is | ||||||||||||||||||||||||||||
| 275 | the cost of the shipping for the first item. | ||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||
| 277 | =cut | ||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||
| 279 | sub shipping_first_unit { | ||||||||||||||||||||||||||||
| 280 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
shipping_first_unit: called CC=4 SCAR=14.5
Pod
documented
| |||||||||||||||||||||||||||||
| 281 | 1 | my $cost = 0; | |||||||||||||||||||||||||||
| 282 | 1 | ▶ | if (my $shipping = $self->order->{ShippingServiceSelected}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 283 | 1 | ▶ | if (my $num = $shipping->{ShippingServiceCost}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 284 | 1 | ▶ | $cost = $num->{_} || 0; | ||||||||||||||||||||||||||
|
Condition50%1/2
$num->{'_'} || 0
MC/DC0%0/1
$num->{'_'} || 0
$num->{'_'}
Truth table50%1/2
A
A= $num->{'_'}
| |||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||
| 287 | 1 | return sprintf('%.2f', $cost); | |||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||
| 290 | =head2 shipping_cost | ||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||
| 292 | The total cost of the shipping. It is the C<shipping_first_unit> + the | ||||||||||||||||||||||||||||
| 293 | additional costs multiplied by the number of additional items. | ||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||
| 295 | =cut | ||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||
| 297 | sub shipping_cost { | ||||||||||||||||||||||||||||
| 298 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
shipping_cost: called CC=3 SCAR=12.3
Pod
documented
| |||||||||||||||||||||||||||||
| 299 | 1 | my $item_shipping = $self->shipping_first_unit; | |||||||||||||||||||||||||||
| 300 | 1 | ▶ | if (my $additional = $self->shipping_additional_costs) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 301 | 1 | ▶ | if ($self->number_of_items > 1) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 302 | 0 | my $others = $self->number_of_items - 1; | |||||||||||||||||||||||||||
| 303 | 0 | $item_shipping = $item_shipping + ($additional * $others); | |||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||
| 306 | 1 | return sprintf('%.2f', $item_shipping); | |||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||
| 309 | =head2 total_cost | ||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||
| 311 | The total of the order, as reported by Ebay. | ||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||
| 313 | =cut | ||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||
| 315 | sub total_cost { | ||||||||||||||||||||||||||||
| 316 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
total_cost: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||||||||||||||||||||
| 317 | 1 | my $total = 0; | |||||||||||||||||||||||||||
| 318 | 1 | ▶ | if (my $amount = $self->order->{Total}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 319 | 1 | ▶ | if (my $num = $amount->{_}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 320 | 1 | $total = $num; | |||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||
| 322 | } | ||||||||||||||||||||||||||||
| 323 | 1 | return sprintf('%.2f', $total); | |||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||
| 326 | =head2 subtotal | ||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||
| 328 | Sum of the subtotal of all items. | ||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||
| 330 | =cut | ||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||
| 332 | sub subtotal { | ||||||||||||||||||||||||||||
| 333 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
subtotal: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 334 | 1 | my @items = $self->items; | |||||||||||||||||||||||||||
| 335 | 1 | my $total = 0; | |||||||||||||||||||||||||||
| 336 | 1 | foreach my $i (@items) { | |||||||||||||||||||||||||||
| 337 | 1 | $total += $i->subtotal; | |||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||
| 339 | 1 | return sprintf('%.2f', $total); | |||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||
| 342 | =head2 currency | ||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||
| 344 | The currency code of the order (looked up in the total). | ||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||
| 346 | =cut | ||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||
| 348 | sub currency { | ||||||||||||||||||||||||||||
| 349 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
currency: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||
| 350 | 1 | ▶ | if (my $currency = $self->order->{Total}->{currencyID}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 351 | 1 | return $currency; | |||||||||||||||||||||||||||
| 352 | } | ||||||||||||||||||||||||||||
| 353 | else { | ||||||||||||||||||||||||||||
| 354 | 0 | die "Can't find currency total! " . Dumper($self->order); | |||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||
| 358 | =head2 payment_method | ||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||
| 360 | The CheckoutStatus.PaymentMethod value of the order. | ||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||
| 362 | =cut | ||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||
| 364 | sub payment_method { | ||||||||||||||||||||||||||||
| 365 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
payment_method: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||
| 366 | 1 | ▶ | if (my $checkout = $self->order->{CheckoutStatus}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 367 | 1 | return $checkout->{PaymentMethod}; | |||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||
| 369 | 0 | return; | |||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||
| 372 | =head2 order_is_shipped | ||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||
| 374 | Return true if all the items are marked as shipped. | ||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||
| 376 | =cut | ||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||
| 378 | sub order_is_shipped { | ||||||||||||||||||||||||||||
| 379 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
order_is_shipped: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||||||||||||||||||||
| 380 | 1 | my $shipped; | |||||||||||||||||||||||||||
| 381 | 1 | foreach my $item ($self->items) { | |||||||||||||||||||||||||||
| 382 | 1 | ▶ | if ($item->is_shipped) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 383 | 0 | $shipped = 1; | |||||||||||||||||||||||||||
| 384 | } | ||||||||||||||||||||||||||||
| 385 | else { | ||||||||||||||||||||||||||||
| 386 | 1 | $shipped = 0; | |||||||||||||||||||||||||||
| 387 | 1 | last; | |||||||||||||||||||||||||||
| 388 | } | ||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||
| 390 | 1 | return $shipped; | |||||||||||||||||||||||||||
| 391 | } | ||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||
| 393 | =head2 ebay_site | ||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||
| 395 | Return the site where the order was placed. We have to loop over all | ||||||||||||||||||||||||||||
| 396 | the items and check if they match. If they don't, we throw an | ||||||||||||||||||||||||||||
| 397 | exception. | ||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||
| 399 | =cut | ||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||
| 401 | sub ebay_site { | ||||||||||||||||||||||||||||
| 402 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
ebay_site: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 403 | 0 | my $site; | |||||||||||||||||||||||||||
| 404 | 0 | foreach my $item ($self->items) { | |||||||||||||||||||||||||||
| 405 | 0 | my $item_site = $item->ebay_site; | |||||||||||||||||||||||||||
| 406 | 0 | ▶ | die $item->sku . " has not a Site attached!" unless $item_site; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 407 | # if defined, check, otherwise assign; | ||||||||||||||||||||||||||||
| 408 | 0 | ▶ | if (defined $site) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 409 | 0 | ▶ | if ($site ne $item_site) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 410 | 0 | die "Mismatch $site != $item_site on " . Dumper($self); | |||||||||||||||||||||||||||
| 411 | } | ||||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||
| 413 | else { | ||||||||||||||||||||||||||||
| 414 | 0 | $site = $item_site; | |||||||||||||||||||||||||||
| 415 | } | ||||||||||||||||||||||||||||
| 416 | } | ||||||||||||||||||||||||||||
| 417 | 0 | return $site; | |||||||||||||||||||||||||||
| 418 | } | ||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||
| 420 | =head2 username | ||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||
| 422 | The ebay's username of the buyer. | ||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||
| 424 | =cut | ||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||
| 426 | sub username { | ||||||||||||||||||||||||||||
| 427 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
username: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||
| 428 | 1 | ▶ | return $self->order->{BuyerUserID} || ''; | ||||||||||||||||||||||||||
|
Condition50%1/2
$self->order->{'BuyerUserID'} || ''
MC/DC0%0/1
$self->order->{'BuyerUserID'} || ''
$self->order->{'BuyerUserID'}
Truth table50%1/2
A
A= $self->order->{'BuyerUserID'}
| |||||||||||||||||||||||||||||
| 429 | } | ||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||
| 432 | 5 | 1; | |||||||||||||||||||||||||||