Class: Workarea::Orderbot::Order::Item

Inherits:
Object
  • Object
show all
Defined in:
app/services/workarea/orderbot/order/item.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(item, options = {}) ⇒ Item

Returns a new instance of Item.



7
8
9
10
# File 'app/services/workarea/orderbot/order/item.rb', line 7

def initialize(item, options = {})
  @item = item
  @options = options
end

Instance Attribute Details

#itemObject (readonly)

Returns the value of attribute item.



5
6
7
# File 'app/services/workarea/orderbot/order/item.rb', line 5

def item
  @item
end

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'app/services/workarea/orderbot/order/item.rb', line 5

def options
  @options
end

Instance Method Details

#to_hObject



12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/services/workarea/orderbot/order/item.rb', line 12

def to_h
  {
    order_line_id: item.id.to_s,
    sku: item.sku,
    quantity: item.quantity,
    unit_price: item.original_unit_price.to_f,
    discount: item_discount,
    total: item.total_value.to_f,
    tax_total: item_tax_total,
    order_product_taxes: taxes
  }
end