| 1 | package Amazon::MWS::XML::OrderlineItem; | ||||||||||||
| 2 | |||||||||||||
| 3 | 7 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | 7 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | 7 | ▶ | use Moo; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | |||||||||||||
| 7 | |||||||||||||
| 8 | =head1 ACCESSORS (they map the XML data) | ||||||||||||
| 9 | |||||||||||||
| 10 | =over 4 | ||||||||||||
| 11 | |||||||||||||
| 12 | =item PromotionDiscount | ||||||||||||
| 13 | |||||||||||||
| 14 | =item Title | ||||||||||||
| 15 | |||||||||||||
| 16 | =item OrderItemId | ||||||||||||
| 17 | |||||||||||||
| 18 | =item ASIN | ||||||||||||
| 19 | |||||||||||||
| 20 | =item GiftWrapPrice | ||||||||||||
| 21 | |||||||||||||
| 22 | =item GiftWrapTax | ||||||||||||
| 23 | |||||||||||||
| 24 | =item SellerSKU | ||||||||||||
| 25 | |||||||||||||
| 26 | =item ShippingPrice | ||||||||||||
| 27 | |||||||||||||
| 28 | =item ShippingTax | ||||||||||||
| 29 | |||||||||||||
| 30 | =item ShippingDiscount | ||||||||||||
| 31 | |||||||||||||
| 32 | =item ItemTax | ||||||||||||
| 33 | |||||||||||||
| 34 | =item ConditionId | ||||||||||||
| 35 | |||||||||||||
| 36 | =item ItemPrice | ||||||||||||
| 37 | |||||||||||||
| 38 | =item ConditionSubtypeId | ||||||||||||
| 39 | |||||||||||||
| 40 | =item QuantityShipped | ||||||||||||
| 41 | |||||||||||||
| 42 | =item QuantityOrdered | ||||||||||||
| 43 | |||||||||||||
| 44 | =back | ||||||||||||
| 45 | |||||||||||||
| 46 | =cut | ||||||||||||
| 47 | |||||||||||||
| 48 | has PromotionDiscount => (is => 'ro', | ||||||||||||
| 49 | 2 | ▶ | isa => sub { die unless ref($_[0]) eq 'HASH'}); | ||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.2
Branch: 1 branch
| |||||||||||||
| 50 | |||||||||||||
| 51 | 7 | has Title => (is => 'ro'); | |||||||||||
| 52 | |||||||||||||
| 53 | 7 | has OrderItemId => (is => 'ro'); | |||||||||||
| 54 | |||||||||||||
| 55 | 7 | has ASIN => (is => 'ro'); | |||||||||||
| 56 | |||||||||||||
| 57 | has GiftWrapPrice => (is => 'ro', | ||||||||||||
| 58 | 2 | ▶ | isa => sub { die unless ref($_[0]) eq 'HASH'}); | ||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.2
Branch: 1 branch
| |||||||||||||
| 59 | |||||||||||||
| 60 | has GiftWrapTax => (is => 'ro', | ||||||||||||
| 61 | 2 | ▶ | isa => sub { die unless ref($_[0]) eq 'HASH'}); | ||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.2
Branch: 1 branch
| |||||||||||||
| 62 | |||||||||||||
| 63 | 7 | has SellerSKU => (is => 'ro'); | |||||||||||
| 64 | |||||||||||||
| 65 | has ShippingPrice => (is => 'ro', | ||||||||||||
| 66 | 2 | ▶ | isa => sub { die unless ref($_[0]) eq 'HASH'}); | ||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.2
Branch: 1 branch
| |||||||||||||
| 67 | |||||||||||||
| 68 | has ShippingTax => (is => 'ro', | ||||||||||||
| 69 | 2 | ▶ | isa => sub { die unless ref($_[0]) eq 'HASH'}); | ||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.2
Branch: 1 branch
| |||||||||||||
| 70 | |||||||||||||
| 71 | has ShippingDiscount => (is => 'ro', | ||||||||||||
| 72 | 2 | ▶ | isa => sub { die unless ref($_[0]) eq 'HASH'}); | ||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.2
Branch: 1 branch
| |||||||||||||
| 73 | |||||||||||||
| 74 | has ItemTax => (is => 'ro', | ||||||||||||
| 75 | 2 | ▶ | isa => sub { die unless ref($_[0]) eq 'HASH'}); | ||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.2
Branch: 1 branch
| |||||||||||||
| 76 | |||||||||||||
| 77 | 7 | has ConditionId => (is => 'ro'); | |||||||||||
| 78 | |||||||||||||
| 79 | has ItemPrice => (is => 'ro', | ||||||||||||
| 80 | 2 | ▶ | isa => sub { die unless ref($_[0]) eq 'HASH'}); | ||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.2
Branch: 1 branch
| |||||||||||||
| 81 | |||||||||||||
| 82 | 7 | has ConditionSubtypeId => (is => 'ro'); | |||||||||||
| 83 | |||||||||||||
| 84 | 7 | has QuantityShipped => (is => 'ro'); | |||||||||||
| 85 | 7 | has QuantityOrdered => (is => 'ro'); | |||||||||||
| 86 | |||||||||||||
| 87 | =head2 amazon_order_item | ||||||||||||
| 88 | |||||||||||||
| 89 | The amazon id for the given item (read-only) | ||||||||||||
| 90 | |||||||||||||
| 91 | =head2 remote_shop_order_item | ||||||||||||
| 92 | |||||||||||||
| 93 | Alias for C<amazon_order_item> | ||||||||||||
| 94 | |||||||||||||
| 95 | =head2 merchant_order_item | ||||||||||||
| 96 | |||||||||||||
| 97 | Our id (read-write). | ||||||||||||
| 98 | |||||||||||||
| 99 | =head2 currency | ||||||||||||
| 100 | |||||||||||||
| 101 | The currency code. | ||||||||||||
| 102 | |||||||||||||
| 103 | =cut | ||||||||||||
| 104 | |||||||||||||
| 105 | 7 | has merchant_order_item => (is => 'rw'); | |||||||||||
| 106 | |||||||||||||
| 107 | 2 | ▶ | sub amazon_order_item { | ||||||||||
|
Subroutine
amazon_order_item: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 108 | 2 | return shift->OrderItemId; | |||||||||||
| 109 | } | ||||||||||||
| 110 | |||||||||||||
| 111 | 1 | ▶ | sub remote_shop_order_item { | ||||||||||
|
Subroutine
remote_shop_order_item: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 112 | 1 | return shift->amazon_order_item; | |||||||||||
| 113 | } | ||||||||||||
| 114 | |||||||||||||
| 115 | |||||||||||||
| 116 | 0 | ▶ | sub currency { | ||||||||||
|
Subroutine
currency: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 117 | 0 | return shift->ItemPrice->{CurrencyCode}; | |||||||||||
| 118 | } | ||||||||||||
| 119 | |||||||||||||
| 120 | =head2 price | ||||||||||||
| 121 | |||||||||||||
| 122 | Amazon report the item price's as the sum of the items, not the | ||||||||||||
| 123 | individual price. So we have to do a division for what we know as the | ||||||||||||
| 124 | item's price. This looks ugly anyway. | ||||||||||||
| 125 | |||||||||||||
| 126 | From | ||||||||||||
| 127 | L<http://docs.developer.amazonservices.com/en_US/orders/2013-09-01/Orders_ListOrderItems.html>: | ||||||||||||
| 128 | |||||||||||||
| 129 | The selling price of the order item. Note that an order item is an | ||||||||||||
| 130 | item and a quantity. This means that the value of ItemPrice is equal | ||||||||||||
| 131 | to the selling price of the item multiplied by the quantity ordered. | ||||||||||||
| 132 | Note that ItemPrice excludes ShippingPrice and GiftWrapPrice. | ||||||||||||
| 133 | |||||||||||||
| 134 | =cut | ||||||||||||
| 135 | |||||||||||||
| 136 | 2 | ▶ | sub price { | ||||||||||
|
Subroutine
price: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 137 | 2 | my $self = shift; | |||||||||||
| 138 | 2 | return sprintf('%.2f', $self->subtotal / $self->quantity); | |||||||||||
| 139 | } | ||||||||||||
| 140 | |||||||||||||
| 141 | =head2 shipping | ||||||||||||
| 142 | |||||||||||||
| 143 | The ShippingPrice amount. | ||||||||||||
| 144 | |||||||||||||
| 145 | =head2 subtotal | ||||||||||||
| 146 | |||||||||||||
| 147 | The price of the items for the given quantity (see above, C<price>). | ||||||||||||
| 148 | |||||||||||||
| 149 | =cut | ||||||||||||
| 150 | |||||||||||||
| 151 | 0 | ▶ | sub shipping { | ||||||||||
|
Subroutine
shipping: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||
| 152 | 0 | my $self = shift; | |||||||||||
| 153 | 0 | my $shipping = 0; | |||||||||||
| 154 | 0 | ▶ | if (my $price = $self->ShippingPrice) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 155 | 0 | ▶ | $shipping = $price->{Amount} || 0; | ||||||||||
|
Condition0%0/2
$price->{'Amount'} || 0
MC/DC0%0/1
$price->{'Amount'} || 0
$price->{'Amount'}
Truth table0%0/2
A
A= $price->{'Amount'}
| |||||||||||||
| 156 | } | ||||||||||||
| 157 | 0 | return sprintf('%.2f', $shipping); | |||||||||||
| 158 | } | ||||||||||||
| 159 | |||||||||||||
| 160 | =head2 as_ack_orderline_item_hashref | ||||||||||||
| 161 | |||||||||||||
| 162 | Return an hashref suitable for the building of an ack order feed. | ||||||||||||
| 163 | |||||||||||||
| 164 | =cut | ||||||||||||
| 165 | |||||||||||||
| 166 | =head2 Aliases | ||||||||||||
| 167 | |||||||||||||
| 168 | =over 4 | ||||||||||||
| 169 | |||||||||||||
| 170 | =item sku (SellerSKU) | ||||||||||||
| 171 | |||||||||||||
| 172 | =item asin (ASIN) | ||||||||||||
| 173 | |||||||||||||
| 174 | =item quantity (QuantityOrdered) | ||||||||||||
| 175 | |||||||||||||
| 176 | =item name (Title) | ||||||||||||
| 177 | |||||||||||||
| 178 | =back | ||||||||||||
| 179 | |||||||||||||
| 180 | |||||||||||||
| 181 | =cut | ||||||||||||
| 182 | |||||||||||||
| 183 | 0 | ▶ | sub sku { | ||||||||||
|
Subroutine
sku: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 184 | 0 | return shift->SellerSKU; | |||||||||||
| 185 | } | ||||||||||||
| 186 | 0 | ▶ | sub asin { | ||||||||||
|
Subroutine
asin: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 187 | 0 | return shift->ASIN; | |||||||||||
| 188 | } | ||||||||||||
| 189 | |||||||||||||
| 190 | 2 | ▶ | sub quantity { | ||||||||||
|
Subroutine
quantity: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 191 | 2 | return shift->QuantityOrdered; | |||||||||||
| 192 | } | ||||||||||||
| 193 | |||||||||||||
| 194 | 0 | ▶ | sub name { | ||||||||||
|
Subroutine
name: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 195 | 0 | return shift->Title; | |||||||||||
| 196 | } | ||||||||||||
| 197 | |||||||||||||
| 198 | 3 | ▶ | sub subtotal { | ||||||||||
|
Subroutine
subtotal: called CC=3 SCAR=11.3
Pod
documented
| |||||||||||||
| 199 | 3 | my $self = shift; | |||||||||||
| 200 | 3 | my $amount = 0; | |||||||||||
| 201 | 3 | ▶ | if (my $price = $self->ItemPrice) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 202 | 3 | ▶ | $amount = $price->{Amount} || 0; | ||||||||||
|
Condition50%1/2
$price->{'Amount'} || 0
MC/DC0%0/1
$price->{'Amount'} || 0
$price->{'Amount'}
Truth table50%1/2
A
A= $price->{'Amount'}
| |||||||||||||
| 203 | } | ||||||||||||
| 204 | 3 | return sprintf('%.2f', $amount); | |||||||||||
| 205 | } | ||||||||||||
| 206 | |||||||||||||
| 207 | 0 | ▶ | sub as_ack_orderline_item_hashref { | ||||||||||
|
Subroutine
as_ack_orderline_item_hashref: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 208 | 0 | my $self = shift; | |||||||||||
| 209 | return { | ||||||||||||
| 210 | 0 | AmazonOrderItemCode => $self->amazon_order_item, | |||||||||||
| 211 | MerchantOrderItemID => $self->merchant_order_item, | ||||||||||||
| 212 | }; | ||||||||||||
| 213 | } | ||||||||||||
| 214 | |||||||||||||
| 215 | |||||||||||||
| 216 | 7 | 1; | |||||||||||