Class: Workarea::Listrak::Models::OrderItem
- Inherits:
-
Object
- Object
- Workarea::Listrak::Models::OrderItem
- Defined in:
- app/services/workarea/listrak/models/order_item.rb
Instance Attribute Summary collapse
-
#order ⇒ Object
readonly
Returns the value of attribute order.
-
#order_item ⇒ Object
readonly
Returns the value of attribute order_item.
Instance Method Summary collapse
- #as_json ⇒ Object
-
#discount_description ⇒ String
Description of the discount for the line item.
-
#discount_price ⇒ Float
Total discounted cost of product.
-
#discount_type ⇒ String
Type of discount for the line item.
-
#initialize(order, order_item) ⇒ OrderItem
constructor
A new instance of OrderItem.
-
#item_discount_total ⇒ Float
Total amount of the discount for the line item.
-
#item_total ⇒ Float
Total line item cost (quantity times price).
-
#meta1 ⇒ String
Additional Optional Information.
-
#meta2 ⇒ String
Additional Optional Information.
-
#meta3 ⇒ String
Additional Optional Information.
-
#meta4 ⇒ String
Additional Optional Information.
-
#meta5 ⇒ String
Additional Optional Information.
-
#order_number ⇒ String
Order number.
-
#price ⇒ Float
Price of one unit purchased.
-
#quantity ⇒ Object
Total number of units purchased.
-
#ship_date ⇒ String
Timestamp when item shipped (ET).
-
#shipping_method ⇒ String
Shipping method (e.g. UPS Ground).
-
#sku ⇒ String
Unique stock number of product.
-
#status ⇒ String
Status indicator.
-
#tracking_number ⇒ Object
Shipment tracking number.
Constructor Details
#initialize(order, order_item) ⇒ OrderItem
Returns a new instance of OrderItem.
8 9 10 11 |
# File 'app/services/workarea/listrak/models/order_item.rb', line 8 def initialize(order, order_item) @order = order @order_item = order_item end |
Instance Attribute Details
#order ⇒ Object (readonly)
Returns the value of attribute order.
6 7 8 |
# File 'app/services/workarea/listrak/models/order_item.rb', line 6 def order @order end |
#order_item ⇒ Object (readonly)
Returns the value of attribute order_item.
6 7 8 |
# File 'app/services/workarea/listrak/models/order_item.rb', line 6 def order_item @order_item end |
Instance Method Details
#as_json ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/services/workarea/listrak/models/order_item.rb', line 13 def as_json { discountDescription: discount_description, discountType: discount_type, discountedPrice: discount_price, itemTotal: item_total, itemDiscountTotal: item_discount_total, meta1: , meta2: , meta3: , meta4: , meta5: , orderNumber: order_number, price: price, quantity: quantity, shipDate: ship_date, shippingMethod: shipping_method, sku: sku, status: status, trackingNumber: tracking_number } end |
#discount_description ⇒ String
Description of the discount for the line item
40 41 |
# File 'app/services/workarea/listrak/models/order_item.rb', line 40 def discount_description end |
#discount_price ⇒ Float
Total discounted cost of product
56 57 58 59 60 61 |
# File 'app/services/workarea/listrak/models/order_item.rb', line 56 def discount_price order_item.price_adjustments .select { |pa| pa.data['discount_value'].present? && pa.price == 'item' } .sum { |d| d.data['discount_value'] } .abs end |
#discount_type ⇒ String
Type of discount for the line item
“NotSet” “PriceOverride” “PriceRule” “Promotion” “SeniorCitizen” “Markdown” “Coupon” “QuantityDiscount” “Rebate” “CashDiscount” “TradeDiscount” “TradeInKind” “PromptPaymentDiscount” “GeneralDiscount” “GiftVoucher” “FlexibleDiscount” “RewardProgram” “ManufacturerReward” “CreditCardReward”
49 50 |
# File 'app/services/workarea/listrak/models/order_item.rb', line 49 def discount_type end |
#item_discount_total ⇒ Float
Total amount of the discount for the line item
75 76 77 78 79 80 |
# File 'app/services/workarea/listrak/models/order_item.rb', line 75 def item_discount_total order_item.price_adjustments .select { |pa| pa.data['discount_value'].present? && pa.price == 'item' } .sum { |d| d.data['discount_value'] } .abs end |
#item_total ⇒ Float
Total line item cost (quantity times price)
67 68 69 |
# File 'app/services/workarea/listrak/models/order_item.rb', line 67 def item_total order_item.total_value.to_f end |
#meta1 ⇒ String
Additional Optional Information
limited to 500 characters
88 89 |
# File 'app/services/workarea/listrak/models/order_item.rb', line 88 def end |
#meta2 ⇒ String
Additional Optional Information
limited to 500 characters
97 98 |
# File 'app/services/workarea/listrak/models/order_item.rb', line 97 def end |
#meta3 ⇒ String
Additional Optional Information
limited to 500 characters
106 107 |
# File 'app/services/workarea/listrak/models/order_item.rb', line 106 def end |
#meta4 ⇒ String
Additional Optional Information
limited to 500 characters
115 116 |
# File 'app/services/workarea/listrak/models/order_item.rb', line 115 def end |
#meta5 ⇒ String
Additional Optional Information
limited to 500 characters
124 125 |
# File 'app/services/workarea/listrak/models/order_item.rb', line 124 def end |
#order_number ⇒ String
Order number
limited to 50 characters
133 134 135 |
# File 'app/services/workarea/listrak/models/order_item.rb', line 133 def order_number order.id.to_s end |
#price ⇒ Float
Price of one unit purchased
141 142 143 |
# File 'app/services/workarea/listrak/models/order_item.rb', line 141 def price order_item.original_unit_price.to_f end |
#quantity ⇒ Object
Total number of units purchased
return [Integer]
149 150 151 |
# File 'app/services/workarea/listrak/models/order_item.rb', line 149 def quantity order_item.quantity end |
#ship_date ⇒ String
Timestamp when item shipped (ET)
157 158 |
# File 'app/services/workarea/listrak/models/order_item.rb', line 157 def ship_date end |
#shipping_method ⇒ String
Shipping method (e.g. UPS Ground)
limited to 32 characters
166 167 |
# File 'app/services/workarea/listrak/models/order_item.rb', line 166 def shipping_method end |
#sku ⇒ String
Unique stock number of product
limited to 100 characters
175 176 177 |
# File 'app/services/workarea/listrak/models/order_item.rb', line 175 def sku order_item.sku end |
#status ⇒ String
Status indicator
“NotSet” “Misc” “PreOrder” “BackOrder” “Pending” “Hold” “Processing” “Shipped” “Completed” “Returned” “Canceled” “Unknown” “Closed”
185 186 |
# File 'app/services/workarea/listrak/models/order_item.rb', line 185 def status end |
#tracking_number ⇒ Object
Shipment tracking number
limited to 32 characters
192 193 |
# File 'app/services/workarea/listrak/models/order_item.rb', line 192 def tracking_number end |