Class: Comable::OrderItem

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Liquidable, Csvable, SkuChoice, SkuItem
Defined in:
app/models/comable/order_item.rb,
app/models/comable/order_item/csvable.rb

Defined Under Namespace

Modules: Csvable

Instance Method Summary collapse

Methods included from SkuChoice

#name_with_sku, #sku_name

Methods included from SkuItem

#sku_h?, #sku_v?

Instance Method Details

#completeObject



23
24
25
# File 'app/models/comable/order_item.rb', line 23

def complete
  unstock
end

#copy_attributesObject

TODO: カート投入時との差額表示



36
37
38
# File 'app/models/comable/order_item.rb', line 36

def copy_attributes
  self.attributes = current_attributes
end

#current_priceObject

時価を取得



41
42
43
# File 'app/models/comable/order_item.rb', line 41

def current_price
  stock.price
end

#current_subtotal_priceObject

時価小計を取得



46
47
48
# File 'app/models/comable/order_item.rb', line 46

def current_subtotal_price
  current_price * quantity
end

#restockObject



31
32
33
# File 'app/models/comable/order_item.rb', line 31

def restock
  increment_stock
end

#subtotal_priceObject

売価小計を取得



51
52
53
# File 'app/models/comable/order_item.rb', line 51

def subtotal_price
  price * quantity
end

#unstockObject



27
28
29
# File 'app/models/comable/order_item.rb', line 27

def unstock
  decrement_stock
end

#unstocked?Boolean

Returns:

  • (Boolean)


55
56
57
58
59
# File 'app/models/comable/order_item.rb', line 55

def unstocked?
  stock_with_clean_quantity do |stock|
    stock.unstocked?(quantity: quantity)
  end
end